Problem:


Score : 100 points

Problem Statement

Given is a lowercase English letter C that is not z. Print the letter that follows C in alphabetical order.

Constraints

C is a lowercase English letter that is not z.

Input

Input is given from Standard Input in the following format:

C

Output

Print the letter that follows C in alphabetical order.

Sample Input 1

a

Sample Output 1

b

a is followed by b.

Sample Input 2

y

Sample Output 2

z

y is followed by z.



Sample input:
a


Sample output:
b

Submission status: Runtime Error

Solution code:
N,K,M=map(int,input().split())
An=list(map(int,input().split()))
rest=M*N-sum(An)
if rest<=K:
        print(max(rest,0))
else:
        print(-1)

Submission status: Runtime Error

Solution code:
print(chir(ord(input())+1))

Submission status: Runtime Error

Solution code:
N,K,M=map(int,input().split())
l = input().split()
L = [int(i) for i in l]

Lsum=sum(L)

if M*N-Lsum>K:
    print(-1)
elif M*N-Lsum<0:
    print(0)
else:
    print(M*N-Lsum)

Submission status: Runtime Error

Solution code:
c=input()
print(char(ord(c)+1)

Submission status: Runtime Error

Solution code:
return 0

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline


alphabets = "abcdefghijklmnopqrstuvwxyz"

c = input()
i = alphabets.index(c)

answer = alphabets[i + 1]
print(answer)

Submission status: Runtime Error

Solution code:
C = input()
print(chr(ord(C)+1)

Submission status: Runtime Error

Solution code:
n,k,m = map(int,input().split())
a = list(map(int,input().split()))

t = n*m - sum(a)
if 0<=t<=k:
 print(t)
if  k<t:
 print(-1)
else:
 print(0

Submission status: Runtime Error

Solution code:
c=input()
c+=1
print(c)

Submission status: Runtime Error

Solution code:
c=input()
print(chr(c+1))

Submission status: Runtime Error

Solution code:
c=input()
print(str(chr(c)+1))

Submission status: Runtime Error

Solution code:
C=input()
for i in range(len(string.ascii_lowercase)):
  if(string.ascii_lowercase[i]==C):
    print(string.ascii_lowercase[i+1])

Submission status: Runtime Error

Solution code:
c = input()
abc = 'abcdefghijklmnopqrstuvwxyz'
for i in range(26) :
    if abc[i] == c
        print(abc[i+1])
        break

Submission status: Runtime Error

Solution code:
print((input().encode('ascii')+1).decode('ascii'))

Submission status: Runtime Error

Solution code:
aaa

Submission status: Runtime Error

Solution code:
a = int(input())
print(chr(ord(a)+1)

Submission status: Runtime Error

Solution code:
import math
INF = math.inf
h,w = map(int,input().split())
n = h*w

field = []
for i in range(h):
    field.append(input())

dist = [[INF] * n for _ in range(n)]

for i in range(h):
    for j in range(w):
        if field[i][j] == "#":continue
        if j + 1 < w and field[i][j+1] != "#":
            dist[i * w + j][i * w + j + 1] = 1
            dist[i * w + j + 1][i * w + j] = 1
        if i + 1 < h and field[i+1][j] != "#":
            dist[i * w + j][(i+1) * w + j] = 1
            dist[(i+1) * w + j][i * w + j] = 1

for i in range(n):
    for j in range(n):
        for k in range(n):
            dist[j][k] = min(dist[j][k],dist[j][i]+dist[i][k])

ans = 0
for i in range(n):
    for j in range(n):
        if(i==j):continue
        if(dist[i][j]==INF):continue
        ans = max(ans,dist[i][j])

print(ans)

Submission status: Runtime Error

Solution code:
K,X = map(int, input().split())
if K*500 >= X:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
K,X = map(int, input().split())
if K*500 >= X:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
n = input()

for i in alphabet:
  if n == alphabet[i]:
    print(alphabet[i+1])

Submission status: Runtime Error

Solution code:
#include<iostream>
using namespace std;

int main(){
    char C;
    cin >> C;
    C ++;
    cout << C << "\n";
    return 0;
}

Submission status: Runtime Error

Solution code:
s = input()
  print(chr(ord(s)+1))

Submission status: Runtime Error

Solution code:
from sys import stdin
lines = stdin.readlines()
 
C = str(lines[0])
 
print(chr(ord(C) + 1))

Submission status: Runtime Error

Solution code:
N, K, M = map(int,input().split())
A = list(map(int,input().split(' ')))

goal = N*M

if K < M or (sum(A)+K) < goal:
    print("-1")
elif 0 <= goal - sum(A) <= K:
    print(goal - sum(A))
elif goal - sum(A) < 0:
    print("0")

Submission status: Runtime Error

Solution code:
def prepare(n, MOD):
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return factorials, invs

def combinations_count(n, r, factorials, invs):
    return (factorials[n] * invs[n-r] * invs[r]) % (10 ** 9 + 7)
 
f = open("151_E_max01", "r")
n, k = map(int, f.readline().split())
a = sorted(list(map(int, f.readline().split())))

factorials, invs = prepare(n, 10 ** 9 + 7)

ans = 0
for i in range(n):
    if i <= n - k:
        ans -= a[i] * combinations_count(n-i-1, k-1, factorials, invs)
    
    if i >= k - 1:
        ans += a[i] * combinations_count(i, k-1, factorials, invs)
    
    ans = ans % (10 ** 9 + 7)
 
print(ans)

Submission status: Runtime Error

Solution code:
import sys

x = sys.argv[1]

y = ord(x)
y += 1
x = chr(y)
print(x)

Submission status: Runtime Error

Solution code:
c=input()

c=int(c)+1

c=str(c)

print(c)

Submission status: Runtime Error

Solution code:
print(chr(ord(C) + 1))

Submission status: Runtime Error

Solution code:
alphabet = input()
alphabet = ord(alphabet)+1
print(chr(alphabet)

Submission status: Runtime Error

Solution code:
from collections import deque

def bfs(maze, h, w, si, sj):
    q = deque([[si, sj]])
    score = [[0] * w for i in range(h)]

    pattern = [[1, 0], [-1, 0], [0, 1], [0, -1]]
    while len(q) > 0:
        i, j = q.popleft()
        for move in pattern:
            ni, nj= i + move[0], j + move[1]
            if ni < 0 or h <= ni or nj < 0 or w <= nj:
                continue
            p = maze[ni][nj]
            if p == '#':
                continue
            if p == '.' and not score[ni][nj]:
                score[ni][nj] = score[i][j] + 1
                q.append([ni, nj])
    return max(sum(score, []))
  
h, w = map(int, input().split())
maze = [input() for i in range(h)]
scores = []
for si  in range(h):
    for sj in range(w):
        memo.append((si, sj))
        if maze[si][sj] == "#":
            continue
        scores.append(bfs(maze, h, w, si, sj))
print(max(scores))

Submission status: Runtime Error

Solution code:
n, m = list(map(int, input().split()))

ac = [0] * (n+1)
wa = [0] * (n+1)
pena = 0

for i in range(m):
    question, answer = input().split()
    question = int(question)
    if (answer == "AC") and (ac[question] == 0):
        ac[question] = 1
        pena += wa[question]
    elif (answer == "WA") and (ac[question] == 0):
        wa[question] += 1

print(sum(ac), pena)

Submission status: Runtime Error

Solution code:
a,b,c=(int(x) for x in input().split())
s = list(map(int, input().split()))
t = 0
for x in s:
  t += x
l = a + 1
chk = l * c
chk -= t
if chk > b:
  print(-1)
elseif chk < 0:
  print(0)
else:
  print(chk)

Submission status: Runtime Error

Solution code:
s = input()
print chr(ord(s[0]) + 1)

Submission status: Runtime Error

Solution code:
s = input()
print chr(ord(s) + 1)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

c = input()
ans = ord(c)+1
print(chr(ans))

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

c = input()
print(chr(ord(c)+1))

Submission status: Runtime Error

Solution code:
C = input()
alpha_list = 'abcdefghijklmnopqrstuvwxyz'
if C == alpha_list[i]:
  print(alpha_list[i+1])

Submission status: Runtime Error

Solution code:
C = input()
alpha_list = [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]
i = alpha_list.index(C)
print(alpha_list[i+1])

Submission status: Runtime Error

Solution code:
c=input()
S='abcdefghijklmnopqrstuvwxyz"
for i in range(26):
  if c==S[i]:
    print(S[i+1])

Submission status: Runtime Error

Solution code:
N, K, M = map(int, input().split())
List = [int(i) for i in input().split()]

Goal = N * M

sub = Goal - sum(List)
if sub > K:
    print(-1)
else:
    print(sub)

Submission status: Runtime Error

Solution code:
lis = "abcdefghijklmnopqrstuvwxyz"

z = input()

for a in range(len(lis)-1):
  if z = lis[a]:
    print(lis[a+1])
    exit()

Submission status: Runtime Error

Solution code:
lis = "abcdefghijklmnopqrstuvwxyz"
dic = {}

z = imput()

for a in range(len(lis)-1):
  if z = lis[a]:
    print(lis[a+1])
    exit()

Submission status: Runtime Error

Solution code:
import math

n, k = map(int, input().split())
const = 1000000007

arr = list(sorted(map(int, input().split())))

def comb(n, r):
    if n < r or n < 0 or r < 0:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

result = 0
for i, e in enumerate(arr):
    result += e * (comb(i, k - 1) - comb(n - i - 1, k - 1))
    result %= const

print(result)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
l=list(input().split() for _ in range(m))
l=sorted(l,key=lambda x:x[0])
import itertools
lll=[]
for (k,g) in itertools.groupby(l,key=lambda x:x[0]):
    lll.append(list(g))
a=0
w=0
for i in range(len(lll)):
    for j in lll[i]:
        if j[1]=="AC":
            a+=1
            w+=lll[i].index(j)
            break
print(a,w)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
grid = [[c for c in input()] for _ in range(N)]
mat = [[float('inf')]*(M*N) for _ in range(N*M)]

DX = [0, 0, 1, -1]
DY = [-1, 1, 0, 0]
for row in range(N):
    for col in range(M):
        if grid[row][col] == "#":
            continue
        for dx, dy in zip(DX, DY):
            if 0 <= row+dx < N and 0 <= col+dy < M:
                if grid[row+dx][col+dy] == "#":
                    continue
                mat[(row+dx)*M+col+dy][row*M+col] = 1
                mat[row*M+col][(row+dx)*M+col+dy] = 1
for k in range(N*M):
    for i in range(N*M):
        for j in range(N*M):
            mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j])
ans = 0
for srow in range(N):
    for scol in range(M):
        if grid[srow][scol] == "#":
            continue
        for erow in range(N):
            for ecol in range(M):
                if grid[erow][ecol] == "#":
                    continue
                else:
                    ans = max(mat[srow*M+scol][erow*M+ecol], ans)
print(ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import string
print(string.ascii_lowercase[string.ascii_lowercase.index(input()+1])

Submission status: Runtime Error

Solution code:
n,k,m=(int(x) for x in input().split())
a=[int(x) for x in input().split()]

sum = 0
for ai in a:
    sum+= ai

t = m * n  - sum
if t <= 0:
    print(0)
elif t<= k:
    print(t)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
    N, M = map(int, input().split())
     
    seikai = 0
    miss = 0
     
    seikai_list = []  ##既に正解した問題番号のリスト
    input_list = [[0 for i in range(2)] for j in range(M)]  ##入力のリスト 問題番号と正誤
     
    for i in range(M):
      tmp = input().split()
      input_list[i][0] = tmp[0]
      input_list[i][1] = tmp[1]
     
    a = False
     
    for i in range(M):
      if input_list[i][1] =='AC':
          if (input_list[i][0] in seikai_list) == False:   ##正解リストの中に無ければ
            seikai += 1
            
            for k in range(i):
              if input_list[k][0] == input_list[i][0]:
                if input_list[k][1] == 'WA':
                  miss += 1
                    
            seikai_list.append(input_list[i][0])
                
    print("{} {}".format(seikai, miss))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
A = [input().split() for i in range(M)]
s1=list()
s2=list()
p=0
w=0
for i in range(M):
    if A[i][0] not in s2 and A[i][1]=="WA":
        s1 +=A[i][0]
    if A[i][0] not in s2 and A[i][1]=="AC":
        p+=1 
        s2 +=A[i][0]
        w += int(s1.count(A[i][0]))        
print(p,w)

Submission status: Runtime Error

Solution code:
l=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

for n in range(26):
  if C == l[n]:
    n+=1
    print(l[n])
  else:
    continue

Submission status: Runtime Error

Solution code:
m = input()
print(chr(rd(m)+1))

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
ac = [0] * n
pen = [0] * n
pen_count = 0
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if ac[p] == "AC":
        continue
    elif s == "AC":
        ac[p] = "AC"
    else:
        pen[p] += 1
 
for i in range(n):
    if ac[i] == "AC":
        pen_count += pen[i]
 
print(ac.count("AC"), pen_count)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
ac = [0] * n
pen = [0] * n
pen_count = 0
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if ac[p] == "AC":
        continue
    elif s == "AC":
        ac[p] = "AC"
    else:
        pen[p] += 1

for i in range(n):
    if ac[i] == "AC":
        pen_count += pen[i]

print(ac.count("AC"), pen_count)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split()) #n:問題数 m:提出回数
ac = [0] * n
pen = [0] * n
pen_count = 0
for i in range(m):
    p, s = input().split()#p = 1, s = "WA"
    p = int(p) - 1
    if ac[p] == "AC":
        continue
    elif s == "AC":
        ac[p] = "AC"
    else:
        pen[p] += 1

for i in range(n):
    if ac[i] == "AC":
        pen_count += pen[i]

print(ac.count("AC"), pen_count)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
ac = [0] * n
pen = [0] * n
pen_count = 0
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if ac[p] == "AC":
        continue
    elif s == "AC":
        ac[p] = "AC"
    else:
        pen[p] += 1

for i in range(m):
    if ac[i] == "AC":
        pen_count = pen[i]

print(ac.count("AC"), pen_count)

Submission status: Runtime Error

Solution code:
a = input()
abc = 'abcdefghijklmnopqrstuvwxyz'

for i in range(26):
    if a = abc[i]:
        print(abc[i+1])
        break

Submission status: Runtime Error

Solution code:
C = input()
alphabet = {1:"a", 2:"b", 3:"d", 4:"d", 5:"e", 6:"f", 7:"g", 8:"h", 9:"i", 10:"j", 11:"k", 12:"l", 13:"m", 14:"n", 15:"o", 16:"p", 17:"q", 18:"r", 19:"s", 20:"t", 21:"u", 22:"v", 23:"w", 24:"x", 25:"y", 26:"z"}
keys = [k for k, v in alphabet.items() if v == C][0]
print(alphabet[int(keys) + 1])

Submission status: Runtime Error

Solution code:
n,k,m = map(int, input().split())
a = input().split()
a = [int(_a) for _a in a]
ans = m*n - sum(a)
if ans >= k:
  ans = -1
print(ans)

Submission status: Runtime Error

Solution code:
a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
C = input()
print(a[a.index(C)+1])

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
ans = [input().split() for _ in range(m)]
ac = []
wn = []
acn,wan = 0,0
for i in ans:
  for j in range(len(ac)):
    if i[0] != ac[j]:
      if i[1] == 'AC' :
        wan += wn.count(i[0])
        ac += [i[0]]
        acn += 1
      else :
        wn += [i[0]]
print(acn,wan)

Submission status: Runtime Error

Solution code:
#c welcome to atcoder
import sys
n,m=map(int,input().split())
ps=[]
num={}
#辞書
ac=0
pena=0
if m==0:
    print('0 0')
    sys.exit()
for i in range(m):
    result=input().split()
    ps.append(result)

for x in ps:
    print(x[0])
    if x[0] not in num:
        num[x[0]]=0
    print(num[x[0]])
    if x[1]=="WA" and num[x[0]]==0:
        pena+=1
    if x[1]=="AC" and num[x[0]]==0:
        ac+=1
        num[x[0]]=1

print(num)

print(ac,pena)

Submission status: Runtime Error

Solution code:
import math
n = int(input())
a = []
m = n
for i in range(n):a.append(list(map(int, input().split())))

def distant(x1, y1, x2, y2):
    return math.sqrt(abs(x1-x2)**2+abs(y1-y2)**2)

ma = 0
while(m!=0):
    for i in range(m):
        if(i != m-1):
            p = distant(a[i][0], a[i][1], a[m - 1][0], a[m - 1][1])

            #print(p)
            #print(a[i][0], a[i][1], a[m-1][0], a[m-1][1])

            ma = max(ma, p)
    m = m - 1
print(ma/2)

Submission status: Runtime Error

Solution code:
import numpy as np
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
A=np.array(A)
MOD=10**9+7

def cmb(n, k, mod, fac, ifac): #calc nCk under mod
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod

def make_tables(mod, n): #Make factorial and inverse tables under mod 
    fac = [1, 1] # factorial table
    ifac = [1, 1] #factorial of inverse table
    inverse = [0, 1] #inverse
 
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac
MOD=10**9+7
Nmax=10**5
fac,ifac = make_tables(MOD,Nmax)

combs=[0]*N
for i in range(0,N-K+1):
  combs[i]=cmb(N-i-1, K-1, MOD, fac, ifac)
#print(combs)
neg=combs
pos=sorted(combs)
pos=np.array(pos)
neg=np.array(neg)
X=(A*pos-A*neg)
print(X.sum()%MOD)

Submission status: Runtime Error

Solution code:
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N,K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
max=0
min=0
for i in range(K-1,N):
    max+=A[i]*comb(i,K-1)

for i in range(N-K+1):
    min+=A[i]*comb(N-1-i,K-1)
ans=(max-min)%(10**9 +7)
print(ans)

Submission status: Runtime Error

Solution code:
"""
author : dokueki
"""
s = input()
t = "abcdefghijklmnopqrstuvwxyza"
for i in range(len(t)):
    if t[i] == a:
        print(t[i+1])
        break

Submission status: Runtime Error

Solution code:
x = input()
print(chr(ord(x)+1)

Submission status: Runtime Error

Solution code:
import math
inp = input().split()
n,k = int(inp[0]),int(inp[1])
a = [int(x) for x in input().split()]
a.sort()
ans =0
for ini in range(0,n-k+1):
  for end in range(ini+k-1,n):
    m = end-ini-1
    r = k-2
    combi = math.factorial(m) // (math.factorial(m - r) * math.factorial(r))
    ans += (a[end]-a[ini])*combi

ans = ans % (10**9+7)
print(ans)

Submission status: Runtime Error

Solution code:
inp = input().split()
n,k = int(inp[0]),int(inp[1])
a = [int(x) for x in input().split()]
a.sort()
ans =0
for ini in range(0,n-k+1):
  for end in range(ini+k-1,n):
    m = end-ini-1
    r = k-2
    combi = math.factorial(m) // (math.factorial(m - r) * math.factorial(r))
    ans += (a[end]-a[ini])*combi

ans = ans % (10**9+7)
print(ans)

Submission status: Runtime Error

Solution code:
H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]
from collections import deque
ans = 0
for i in range(H):
  for j in range(W):
    if S[i][j]=='#':
      continue
    inf = 10**5
    A = [[inf]*W for _ in range(H)]
    A[i][j]=0
    judge = [[False]*W for _ in range(H)]
    judge[i][j]=True
    q = deque([[i,j]])
    while q:
      a = q.popleft()
      x=a[0]
      y=a[1]
      b = A[x][y]
      for m in [[x-1,y],[x+1,y],[x,y-1],[x,y+1]]:
        h = m[0]
        w = m[1]
        if (h<0)or(h>H-1)or(w<0)or(w>W-1):
          continue
        if S[h][w]=='#':
          continue
        c = b+1
        if judge[h][w]:
          continue
        A[h][w]=c
        judge[h][w]=True
        q.append([h,w])
        
    A = [a for b in A for a in b if a!=inf]
    ans = max(ans,max(A))
    
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

x = list(map(int, input().split()))

N, M = x[0], x[1]

ac, wa = np.array([0 for i in range(N)]), np.array([0 for i in range(N)])

for i in range(M):
    num, result = input().split()
    num = int(num) - 1

    if ac[num] == 1:
        pass
    else:
        if result == "AC":
            ac[num] = 1
        else:
            wa[num] += 1

print(np.sum(ac), np.sum(wa))

Submission status: Runtime Error

Solution code:
print(int("a"))

Submission status: Runtime Error

Solution code:
from collections import deque

INF = float('inf')

h,w = map(int, input().split())

point_list = []
for i in range(w*h):
    point_list.append([w*h]*w*h)
maze = []

Q = deque([])


for i in range(h):
    tmp = list(input())
    maze.append(tmp)

for s_y in range(h):
    for s_x in range(w):
        if maze[s_y][s_x] == "#":
            continue
        check = []
        Q.append((s_y,s_x))
        check.append((s_y,s_x))
        point_list[s_x+s_y*w][s_x+s_y*w] = 0
        while Q:
            y, x = Q.popleft()
            if y == 0:
                pass
            elif maze[y-1][x]=="#":
                pass
            else:
                point_list[s_x+s_y*w][x+(y-1)*w] = min(point_list[s_x+s_y*w][x+(y-1)*w],point_list[s_x+s_y*w][x+y*w]+1)
                if (y-1,x) in check:
                    pass
                else:
                    check.append((y-1,x))
                    Q.append((y-1,x))
                    

            if y == h-1 :
                pass
            elif maze[y+1][x]=="#":
                pass
            else:
                point_list[s_x+s_y*w][x+(y+1)*w] = min(point_list[s_x+s_y*w][x+(y+1)*w],point_list[s_x+s_y*w][x+y*w]+1)
                if (y+1,x) in check:
                    pass
                else:
                    check.append((y+1,x))
                    Q.append((y+1,x))
                    

            if x==0:
                pass
            elif maze[y][x-1]=="#":
                pass
            else:
                point_list[s_x+s_y*w][(x-1)+y*w] = min(point_list[s_x+s_y*w][(x-1)+y*w],point_list[s_x+s_y*w][x+y*w]+1)
                if (y,x-1) in check:
                    pass
                else:
                    check.append((y,x-1))
                    Q.append((y,x-1))
                    

            if x==w-1:
                pass
            elif maze[y][x+1]=="#":
                pass
            else:
                point_list[s_x+s_y*w][(x+1)+y*w] = min(point_list[s_x+s_y*w][(x+1)+y*w],point_list[s_x+s_y*w][x+y*w]+1)
                if (y,x+1) in check:
                    pass
                else:
                    check.append((y,x+1))
                    Q.append((y,x+1))
                    
max_list = []
for i in range(w*h):
    tmp = set(point_list[i])
    if min(tmp)==w*h:
        continue
    if w*h in tmp:
        tmp.remove(w*h)
    max_list.append(max(tmp))

ans = max(max_list)
print(ans)

Submission status: Runtime Error

Solution code:
from collections import deque
import numpy as np
import math

h, w = list(map(int, input().split()))
SHWs = [input() for i in range(h)]

def bfs(sy, sx):
    visited = [[-1]*w for i in range(h)]
    visited[sy][sx] = 0
    que = deque([[sy, sx]])
    while que:
        
        y,x = que.popleft()
        for i, j in [(1,0),(0,1),(-1,0),(0,-1)]:
            next_y, next_x = y+i, x+j
            # print(visited)
            if next_y < 0 or next_x < 0 or next_y > h-1 or next_x > w-1:
                continue
            if SHWs[next_y][next_x] == '.' and (visited[next_y][next_x] == -1 or visited[next_y][next_x] > visited[y][x]+1):
                visited[next_y][next_x] = visited[y][x] + 1
                que.append([next_y, next_x])
    
    return np.amax(np.array(visited))

            
ans = 0
for sy in range(h):
    for sx in range(w):
        if SHWs[sy][sx] == '#':
            continue
        count = bfs(sy=sy, sx=sx)

        if count > ans:
            ans = count


print(ans)

Submission status: Runtime Error

Solution code:
print(char(ord(input()) + 1))

Submission status: Runtime Error

Solution code:
char(ord(input()) + 1)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
Q_n = [0] * N
C = [0] * N

Ans = 0
Pen = 0
for i in range(M):
    p, S = input().split()
    p = int(p)-1
    if (S == 'AC') and (Q_n[p] == 0):
        Q_n[p] = 1
        Ans += 1
        Pen += C[p]
    elif (S == 'WA'):
        C[p] += 1
        
print(Ans, Pen)

Submission status: Runtime Error

Solution code:
n, k, m = map(int, input().split())
l = list(map(int, input().split()))

A = n*m - sum(l)

print(max(0, A) if A <= k else -1)

Submission status: Runtime Error

Solution code:
from collections import deque

H, W = map(int, input().split())
maze = []
for _ in range(H):
    maze.append(list(input()))


def successors(x, y):
    locations = []
    # 下に行けるかの判定
    if (x + 1 < H) and (maze[x + 1][y] != '#'):
        locations.append((x + 1, y))
    # 上に行けるかの判定
    if (x - 1 >= 0) and (maze[x - 1][y] != '#'):
        locations.append((x - 1, y))
    # 右に行けるかの判定
    if (y + 1 < W) and (maze[x][y + 1] != '#'):
        locations.append((x, y + 1))
    # 左に行けるかの判定
    if (y - 1 >= 0) and (maze[x][y - 1] != '#'):
        locations.append((x, y - 1))
    return locations


def bfs(initial, successors):
    # goal判定はなく、一番遠いところで返す
    frontier = deque()
    frontier.append((initial, None))
    # tuple
    explored = {initial}

    while len(frontier):
        current_node = frontier.popleft()
        current_state = current_node[0]
        for child in successors(*current_state):
            if str(child) in [str(i) for i in explored]:
                continue
            explored.add(child)
            frontier.append((child, current_node))
    return current_node


def node_to_path_count(node):
    counter = 0
    while node[1] is not None:
        counter += 1
        node = node[1]
    return counter


ans = 0
for x in range(H):
    for y in range(W):
        if maze[x][y] == '.':
            solution = bfs((x, y), successors)
            counter = node_to_path_count(solution)
            if ans < counter:
                ans = counter

print(ans)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())

lac = [0] * n
lwa = [0] * n

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if lac[p] == 0:
        if s == 'WA':
            lwa[p] += 1
        if s == 'AC':
            lac[p] = 1

print(sum(lac), sum(x * y for x, y in zip(lac, lwa)))

Submission status: Runtime Error

Solution code:
from collections import deque

def solve(S, s):
    if S[s[0]][s[1]] != ".":
        return -1
    queue = deque([s])
    visited = [[-1 for _ in range(W)] for _ in range(H)]
    visited[s[0]][s[1]] = 0
    while queue:
        y, x = queue.popleft()
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y + j, x + k
            if new_x in range(W) and new_y in range(H) and S[new_y][new_x] == "." and visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x] + 1
                queue.append([new_y, new_x])
    #    for v in visited:
    #        print(v)
    return max(max(visited))

H, W = map(int, input().split())
S = [input() for _ in range(H)]
ans = -1
for i in range(W):
    for l in range(H):
        ans = max(ans, solve(S, [i, l]))
print(ans)

Submission status: Runtime Error

Solution code:
mod=10**9+7
n,k=map(int,input().split())
l=sorted(map(int,input().split()))
ans=0
ll=1
ans+=ll*l[k-1]%mod
b,s=1,1
for i in range(k,n):
  ll=ll*i//(i-k+1)
  ans+=l[i]*ll%mod
  s*=i
  b*=(i-k+1)
ml=s//b

ans-=ml*l[0]
ans%=mod
for i in range(1,n-k+1):
  ml=ml*(n-i-k+1)//(n-i)
  ans-=ml*l[i]%mod

print(ans%mod)

Submission status: Runtime Error

Solution code:
N,M = list(map(int,input().split()))
moto = list()
for i in range (M):
  moto.append(input())
 
monme = list()
seigo = list()
i = 0
while i < M:
  a = list(moto[i].split())
  monme.append(int(a[0]))
  seigo.append(a[1])
  i += 1
  
monme2 = list()
seigo2 = list()
j = 1
 
while j <= N:
  k = 0
  while k < M:
    if monme[k] == j:
      monme2.append(monme[k])
      seigo2.append(seigo[k])
    k += 1
  j += 1
 
seitou = 0
pena = 0
c = 1
while c <= N:
  d = 0
  karinopena = 0
  while d < M:
    if monme2[d] == c:
      if seigo2[d] == 'WA':
        karinopena += 1
      else:
        seitou += 1
        pena += karinopena
        d = M
    d += 1
  c += 1
print(seitou,pena)

Submission status: Runtime Error

Solution code:
def main():
    import math
    def f(m, n, k):
        return int(math.factorial(n-1-m)/(math.factorial(k-1)*math.factorial(n-k-m)))
    n, k = list(map(int, input().split()))
    a = list(map(int, input().split()))
    a = sorted(a)
    # print(a)
    ans = 0
    law = int(pow(10, 9) + 7)
    for i in range(n - k + 1):
        # print(i, n, k)
        # print(f(i, n, k))
        ans += (a[n-1-i] - a[i]) * f(i, n, k)
        ans = ans % law
    print(int(ans))
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N, M = input().split()
N = int(N)
M = int(M)
p = []
S = []
for i in range(M):
    a, b = input().split()
    a = int(a)
    p.append(a)
    S.append(b)
right = 0
wrong = 0
for j in range(M):
    if right[p[j] - 1] == 0:
        if S[k] == 'WA':
            wrong += 1
        elif S[k] == 'AC' and :
            right += 1
print(str(right) + ' ' + str(wrong))

Submission status: Runtime Error

Solution code:
from operator import mul
from functools import reduce


def cmb(n, r):
    if n <= r:
        return 1
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N, K = map(int, input().split(" "))
A = list(map(int, input().split(" ")))
A.sort()
fmax = 0
fmin = 0
for i in range(K, N+1):
    fmax += A[i-1] * cmb(i-1, K-1)
    fmin += A[-i] * cmb(i-1, K-1)
print((fmax - fmin) % 1000000007)

Submission status: Runtime Error

Solution code:
c=int(input())
if c == a :
    print("b")
elif c == b :
    print("c")
elif c == c :
    print("d")
elif c == d :
    print("e")
elif c == e :
    print ("f")
elif c == f :
    print("g")
elif c == g :
    print("h")
elif c == h :
    print("i")
elif c == i :
    print("j")
elif c == j :
    print("k")
elif c == k :
    print("l")
elif c == l :
    print("m")
elif c == m :
    print("n")
elif c == n :
    print("o")
elif c == o :
    print("p")
elif c == p :
    print("q")
elif c == q :
    print("r")
elif c== r :
    print("s")
elif c == s :
    print("t")
elif c == t :
    print("u")
elif c == u :
    print("v")
elif c == v :
    print("w")
elif c == w :
    print("x")
elif c == x :
    print("y")
elif c == y :
    print("z")

Submission status: Runtime Error

Solution code:
import sys

def main():
    N, M = list(map(int, input().split()))
    
    inputs = [input().split() for i in range(M)]
    has_been_solved = set()

    penalty = {}
    correct = 0

    for i in inputs:
        
        num = int(i[0])
        if num in has_been_solved:
            continue

        if i[1] == 'AC':
            correct += 1
            has_been_solved.add(num)
        else:
            if num not in penalty:
                penalty[num] = 1
            else:
                penalty[num] += 1
    print(correct, sum([penalty[p] for p in has_been_solved]))         
        

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 12 22:19:09 2020

@author: nanasakiwataru
"""


ans = chr(ord(C) + 1)
st = C + 'の次は' + ans + 'です。'
print(st)