import os
import sys


script = __file__
scriptPath = os.path.dirname(script)
scriptFile = os.path.basename(script)[0]
files = [f for f in os.listdir(scriptPath) if scriptFile in f and '.in' in f]
if '{}-large'.format(scriptFile) in str(files):
    size = 'large'
elif '{}-small'.format(scriptFile) in str(files):
    size = 'small'
elif '{}-test'.format(scriptFile) in str(files):
    size = 'test'
else:
    print('{}-test not found'.format(scriptFile))
    sys.exit()
latest = sorted(f for f in files if size in f)[-1][:-3]
f = '{}/{}'.format(scriptPath, latest)
i = open(f + '.in', 'r')
o = open(f + '.out', 'w')
print(f)
T = int(i.readline())

# https://code.google.com/codejam/contest/4304486/dashboard#s=p0
# Problem A. The Last Word

for x in range(T):
    S = list(i.readline().rstrip())
    y = S[0]
    for s in S[1:]:
        y = max(y + s, s + y)

    o.write('{}Case #{}: {}'.format(['', '\n'][x > 0], x + 1, y))

i.close()
o.close()

@@ -45,17 +45,18 @@
 %0D%0Ascript
-P
+_p
 ath = os
@@ -80,25 +80,26 @@
 ipt)%0D%0Ascript
-F
+_f
 ile = os.pat
@@ -158,17 +158,18 @@
 r(script
-P
+_p
 ath) if 
@@ -174,17 +174,18 @@
 f script
-F
+_f
 ile in f
@@ -221,33 +221,34 @@
 e'.format(script
-F
+_f
 ile) in str(file
@@ -293,33 +293,34 @@
 l'.format(script
-F
+_f
 ile) in str(file
@@ -368,25 +368,26 @@
 ormat(script
-F
+_f
 ile) in str(
@@ -468,9 +468,10 @@
 ript
-F
+_f
 ile)
@@ -571,17 +571,18 @@
 t(script
-P
+_p
 ath, lat

Update A.py