TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo.   As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times.  Find the N-th smallest integer that would make Ringo happy.

Submission attempts (in order):
def main():
    d,n = map(int, input().split())
    a_list = []
    
    if d == 0:
        for i in range(0,100):
            a_list.append(i)

    elif d == 1:
        for i in range(100, 10000, 100):
            a_list.append(i)
    else:
        for i in range(10000, 1000000, 10000):
            a_list.append(i)

    #print(n-1)
    print(a_list[n-1])
    #print(len(a_list))
    
if __name__ == '__main__':
    main()

import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, gcd
from copy import deepcopy

def main():
    d,n = map(int, input().split())
    a_list = []
    
    if d == 0:
        for i in range(0,100):
            a_list.append(i)

    elif d == 1:
        for i in range(100, 10000, 100):
            a_list.append(i)
    else:
        for i in range(10000, 1000000, 10000):
            a_list.append(i)

    #print(n-1)
    print(a_list[n-1])
    #print(len(a_list))
    
if __name__ == '__main__':
    main()

def main():
    d,n = map(int, input().split())
    if n == 100:
        print((100**d) * (n+1)) 
    else:
        print((100**d) * n)  
if __name__ == '__main__':
    main()

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo.   As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times.  Find the N-th smallest integer that would make Ringo happy.

Submission attempts (in order):
# -*- coding: utf-8 -*-
D,N = map(int,input().split())
if D == 0:
  print(D)
else:
  print(N*(100**D))

# -*- coding: utf-8 -*-
N,D = map(int,input().split())
E = 100**D
print(str(N)+str(E))


# -*- coding: utf-8 -*-
N,D = map(int,input().split())
if D == 0:
  print(N)
else:
  print(N*100 ** D)

# -*- coding: utf-8 -*-
N,D = map(int,input().split())
if D == 0:
  print(N)
else:
  print(N*100 ** D)

D,N = map(int,input().split())
if N != 100:
    if D >= 1:
        print(N * 100**D)
    else:
        print(N)
else:
        print(101*100**D)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo.   As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times.  Find the N-th smallest integer that would make Ringo happy.

Submission attempts (in order):
d,n = map(int,input())
ans = (100 ** d) * n
print(ans)

d,n = map(int,input().split())
if n < 100:
  ans = (100 ** d) * n
  print(ans)
else:
  ans = (100 ** (d+1)) + 100 ** d
  print(ans)

Verdicts: Runtime Error

Accepted
Problem: Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo.   As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times.  Find the N-th smallest integer that would make Ringo happy.

Submission attempts (in order):
D, N = map(int, input().split())

print(N * 100 ** D)D, N = map(int, input().split())

if N != 100:
    print(N * 100 ** D)
else:
    print((N + 1) * 100 ** D)

D, N = map(int, input().split())

if N != 100:
    print(N * 100 ** D)
else:
    print((N + 1) * 100 ** D)

Verdicts: Runtime Error

Accepted
Problem: Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo.   As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times.  Find the N-th smallest integer that would make Ringo happy.

Submission attempts (in order):
D,N = map(int, input().split())

if N == 100:
	print(101 * (100 ** d))
else:
	print(n * (100 ** d))

D,N = map(int, input().split())

if N == 100:
	print(101 * (100 ** d))
else:
	print(N * (100 ** d))

D,N = map(int, input().split())

if N == 100:
	print(101 * (100 ** D))
else:
	print(N * (100 ** D))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo.   As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times.  Find the N-th smallest integer that would make Ringo happy.

Submission attempts (in order):
D,N = map(int,input().split()
print(100**D*N if N!=100 else 100**D*(N+1))

D,N = map(int,input().split())
print(100**D*N if N!=100 else 100**D*(N+1))

Verdicts: Runtime Error

Accepted
Problem: Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo.   As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times.  Find the N-th smallest integer that would make Ringo happy.

Submission attempts (in order):
a, b = int(input())
print((100**a)*b)

a, b = map(int,input().split())
if a == 0 and b == 100:
  print(101)
elif a == 1 and b == 100:
  print(10100)
elif a == 2 and b == 100:
  print(1010000)
else:
  print((100**a)*b)


Verdicts: Runtime Error

Accepted
Problem: Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo.   As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times.  Find the N-th smallest integer that would make Ringo happy.

Submission attempts (in order):
n,d=map(int,input().split())
print(n*100**d if d!=100 else n*101**d)

d,n=map(int,input().split())
print(n*100**d if n!=100 else 101*100**d)

Verdicts: Wrong Answer

Accepted
Problem: Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo.   As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times.  Find the N-th smallest integer that would make Ringo happy.

Submission attempts (in order):
print(int(input()) * (100 ** int(input()))) 

d, n = map(int, input().split())
print(100 ** d * 101 if n == 100 else 100 ** d * n)


Verdicts: Runtime Error

Accepted
Problem: Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo.   As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times.  Find the N-th smallest integer that would make Ringo happy.

Submission attempts (in order):
a,b = map(int,input().split())
if b = 100:
     print((100**a) * (b+1))
else:
    print((100**a) * (b))


a,b = map(int,input().split())
if b == 100:
     print((100**a) * (b+1))
else:
    print((100**a) * (b))


Verdicts: Runtime Error

Accepted
Problem: Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo.   As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times.  Find the N-th smallest integer that would make Ringo happy.

Submission attempts (in order):
D,N=input().split()
print(100**D*5)

D,N=map(int,input().split())
if N<100:
  print(100**D*N)
  exit()
print(100**D*101)

Verdicts: Runtime Error

Accepted
Problem: Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo.   As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times.  Find the N-th smallest integer that would make Ringo happy.

Submission attempts (in order):
0 5

d, n = map(int, input().split())
if n < 100:
    print(n * (100 ** d))
else:
    print(101 * (100 ** d))
    

Verdicts: Runtime Error

Accepted
Problem: Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo.   As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times.  Find the N-th smallest integer that would make Ringo happy.

Submission attempts (in order):
import sys


 def solve(d,n):
    if  n != 100 :
        return (100**d)*n
    elif n == 100:
         return (d**100)*101 
    else:
        return n


def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b] = line.split(' ')
    return (int(str_a), int(str_b))

def main():
    a, b = readQuestion()
    answer = solve(a, b)
    print(answer)
    
if __name__ == '__main__':
    main()

import sys


def solve(d,n):
    if  n != 100 :
        return (100**d)*n
    elif n == 100:
         return (100**d)*101 
    else:
        return n


def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b] = line.split(' ')
    return (int(str_a), int(str_b))

def main():
    a, b = readQuestion()
    answer = solve(a, b)
    print(answer)
    
if __name__ == '__main__':
    main()

Verdicts: Runtime Error

Accepted
Problem: Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo.   As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times.  Find the N-th smallest integer that would make Ringo happy.

Submission attempts (in order):
D,N=map(int,input().split())
print(100^D*N)

D,N=map(int,input().split())
print((100^D)*N)

D,N=map(int,input().split())
if N==100:
    A=100**D*(N+1)
else:
    A=100**D*N
print(A)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo.   As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times.  Find the N-th smallest integer that would make Ringo happy.

Submission attempts (in order):
D, N = map(int, input().split())
N = str(N)
if D==0:
  print(N+'00')
elif D==1:
  print(N+'0000')
elif D==2:
  print(N+'000000')

D,N= map(int,input().split())
if(N==100):
    print(100**D*101)
else:
    print(100**D*N)

Verdicts: Wrong Answer

Accepted
Problem: Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo.   As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times.  Find the N-th smallest integer that would make Ringo happy.

Submission attempts (in order):
D,N = [int(s) for s in input().split()]
print (100 ** D) * N

def LI():
	return [ int(s) for s in input().split() ]
  
D,N = LI()
 
print((100**D) * N) if N != 100 else print((100**D)*(N+1))

Verdicts: Runtime Error

Accepted
Problem: Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo.   As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times.  Find the N-th smallest integer that would make Ringo happy.

Submission attempts (in order):
d, n = map(int, input().split())
print(100**d*(n+n==100))

d, n = map(int, input().split())
print(100**d*(n+(n==100)))

Verdicts: Wrong Answer

Accepted
Problem: Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo.   As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times.  Find the N-th smallest integer that would make Ringo happy.

Submission attempts (in order):
d, n = map(int,input().split())

print(0 if d == 0 else 100**d*n)

d,n = map(int, input().split())

print(100**d*(n + n//100))

Verdicts: Wrong Answer

Accepted
Problem: Takahashi and Aoki will play a game with a number line and some segments. Takahashi is standing on the number line and he is initially at coordinate 0. Aoki has N segments. The i-th segment is [L_i,R_i], that is, a segment consisting of points with coordinates between L_i and R_i (inclusive).  The game has N steps. The i-th step proceeds as follows:    * First, Aoki chooses a segment that is still not chosen yet from the N segments and tells it to Takahashi.   * Then, Takahashi walks along the number line to some point within the segment chosen by Aoki this time.  After N steps are performed, Takahashi will return to coordinate 0 and the game ends.  Let K be the total distance traveled by Takahashi throughout the game. Aoki will choose segments so that K will be as large as possible, and Takahashi walks along the line so that K will be as small as possible. What will be the value of K in the end?

Submission attempts (in order):

import numpy as np
from card3.void.stop_watch import stop_watch

@stop_watch
def main():
    n = int(input())
    L, R = [], []
    for i in range(n):
        l, r = map(int, input().split())
        L.append(l)
        R.append(r)
    ll = np.array(L); ll.sort(); ll = ll[::-1]
    rr = np.array(R); rr.sort()

    lll = ll.cumsum()
    rrr = rr.cumsum()

    x = (lll - rrr).max()
    y = (lll[1:] - rrr[:-1]).max()
    z = (lll[:-1] - rrr[1:]).max()

    print(2 * max(x, y, z))
if __name__ == '__main__':
    main()


import numpy as np

def main():
    n = int(input())
    L, R = [], []
    for i in range(n):
        l, r = map(int, input().split())
        L.append(l)
        R.append(r)
    ll = np.array(L); ll.sort(); ll = ll[::-1]
    rr = np.array(R); rr.sort()

    lll = ll.cumsum()
    rrr = rr.cumsum()

    x = (lll - rrr).max()
    y = (lll[1:] - rrr[:-1]).max()
    z = (lll[:-1] - rrr[1:]).max()

    print(2 * max(x, y, z))
if __name__ == '__main__':
    main()

Verdicts: Runtime Error

Accepted
Problem: Takahashi and Aoki will play a game with a number line and some segments. Takahashi is standing on the number line and he is initially at coordinate 0. Aoki has N segments. The i-th segment is [L_i,R_i], that is, a segment consisting of points with coordinates between L_i and R_i (inclusive).  The game has N steps. The i-th step proceeds as follows:    * First, Aoki chooses a segment that is still not chosen yet from the N segments and tells it to Takahashi.   * Then, Takahashi walks along the number line to some point within the segment chosen by Aoki this time.  After N steps are performed, Takahashi will return to coordinate 0 and the game ends.  Let K be the total distance traveled by Takahashi throughout the game. Aoki will choose segments so that K will be as large as possible, and Takahashi walks along the line so that K will be as small as possible. What will be the value of K in the end?

Submission attempts (in order):
N = int(input())
L,R = [None]*N,[None]*N
for i in range(N):
  L[i],R[i] = map(int,input().split())
L.sort(reverse=True)
R.sort()

def it():
  for l,r in zip(L,R):
    if r < l
      yield 2*(l-r)
    else:
      return

print(sum(it()))

N = int(input())
L,R = [None]*N,[None]*N
for i in range(N):
  L[i],R[i] = map(int,input().split())
L.append(0)
R.append(0)
L.sort(reverse=True)
R.sort()

def it():
  for l,r in zip(L,R):
    if r < l:
      yield 2*(l-r)
    else:
      return

print(sum(it()))

Verdicts: Runtime Error

Accepted
Problem: Takahashi and Aoki will play a game with a number line and some segments. Takahashi is standing on the number line and he is initially at coordinate 0. Aoki has N segments. The i-th segment is [L_i,R_i], that is, a segment consisting of points with coordinates between L_i and R_i (inclusive).  The game has N steps. The i-th step proceeds as follows:    * First, Aoki chooses a segment that is still not chosen yet from the N segments and tells it to Takahashi.   * Then, Takahashi walks along the number line to some point within the segment chosen by Aoki this time.  After N steps are performed, Takahashi will return to coordinate 0 and the game ends.  Let K be the total distance traveled by Takahashi throughout the game. Aoki will choose segments so that K will be as large as possible, and Takahashi walks along the line so that K will be as small as possible. What will be the value of K in the end?

Submission attempts (in order):
N=int(input())
LR=[None]*N
for i in range(N):
    LR[i]=list(map(int,input().split()))

RAN=(len(LR)+1)//2

LR_L=sorted(LR,key=lambda x: x[0],reverse=True)
LR_R=sorted(LR,key=lambda x: x[1])

ANS_k=[0]*(RAN*2+2)

for i in range(RAN):
    ANS_k[2*i+1]=ANS_k[2*i]+LR_L[i][0]
    ANS_k[2*i+2]=ANS_k[2*i+1]-LR_R[i][1]

print(ANS_k)
print(max(ANS_k)*2)


N=int(input())
LR=[None]*N
for i in range(N):
    LR[i]=list(map(int,input().split()))

RAN=(len(LR)+1)//2

LR_L=sorted(LR,key=lambda x: x[0],reverse=True)
LR_R=sorted(LR,key=lambda x: x[1])

ANS_l=[0]*(RAN*2+2)
ANS_r=[0]*(RAN*2+2)

for i in range(RAN):
    ANS_l[2*i+1]=ANS_l[2*i]+LR_L[i][0]
    ANS_l[2*i+2]=ANS_l[2*i+1]-LR_R[i][1]

    ANS_r[2*i+1]=ANS_r[2*i]-LR_R[i][1]
    ANS_r[2*i+2]=ANS_r[2*i+1]+LR_L[i][0]


print(max(max(ANS_l)*2,max(ANS_r)*2))

Verdicts: Wrong Answer

Accepted
Problem: Takahashi and Aoki will play a game with a number line and some segments. Takahashi is standing on the number line and he is initially at coordinate 0. Aoki has N segments. The i-th segment is [L_i,R_i], that is, a segment consisting of points with coordinates between L_i and R_i (inclusive).  The game has N steps. The i-th step proceeds as follows:    * First, Aoki chooses a segment that is still not chosen yet from the N segments and tells it to Takahashi.   * Then, Takahashi walks along the number line to some point within the segment chosen by Aoki this time.  After N steps are performed, Takahashi will return to coordinate 0 and the game ends.  Let K be the total distance traveled by Takahashi throughout the game. Aoki will choose segments so that K will be as large as possible, and Takahashi walks along the line so that K will be as small as possible. What will be the value of K in the end?

Submission attempts (in order):
n = int(input())
L,R = [],[]
for num in range(n):
	l,r = (int(i) for i in input().split())
	if l<=0<=r: continue
	L.append(l)
	R.append(r)
L,R,a,b = sorted(L),sorted(R),-1,0
if R and L and R[0]<=0 and L[-1]>=0:
	if abs(R[0])<L[-1]: flag,now,ans,a = True,L[-1],L[-1],-2
	else: flag,now,ans,b = False,R[0],abs(R[0]),1
elif R and L and R[0]<=0 and L[-1]<0: flag,now,ans,b = False,R[0],abs(R[0]),1
elif R and L and R[0]>0 and L[-1]>=0: flag,now,ans,a = True,L[-1],L[-1],-2
else: ans,now = 0,0
while ans!=0 and b-a!=len(L)+1:
	if flag: flag,now,ans,b = False,R[b],ans+abs(now-R[b]),b+1
	else: flag,now,ans,a = True,L[a],ans+abs(now-L[a]),a-1
if print(ans+abs(now))

n = int(input())
L,R = [],[]
for num in range(n):
	l,r = (int(i) for i in input().split())
	L.append(l)
	R.append(r)
L,R,a,b = sorted(L),sorted(R),-1,0
if R and L and R[0]<=0 and L[-1]>=0:
	if abs(R[0])<L[-1]: flag,now,ans,a = True,L[-1],L[-1],-2
	else: flag,now,ans,b = False,R[0],abs(R[0]),1
elif R and L and R[0]<=0 and L[-1]<0: flag,now,ans,b = False,R[0],abs(R[0]),1
elif R and L and R[0]>0 and L[-1]>=0: flag,now,ans,a = True,L[-1],L[-1],-2
else: ans,now = 0,0
while ans!=0 and b-a!=len(L)+1 and ((flag and R[b]<now) or (not flag and now<L[a])) and R[b]<L[a]:
	if flag: flag,now,ans,b = False,R[b],ans+abs(now-R[b]),b+1
	else: flag,now,ans,a = True,L[a],ans+abs(now-L[a]),a-1
print(ans+abs(now))


n = int(input())
L,R = [0],[0]
for _ in range(n):
	l,r = (int(i) for i in input().split())
	L.append(l)
	R.append(r)
L,R,ans = sorted(L)[::-1],sorted(R),0
for i in range(n+1):
	if L[i]>R[i]: ans+=L[i]-R[i]
	else: break
print(ans*2)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Takahashi and Aoki will play a game with a number line and some segments. Takahashi is standing on the number line and he is initially at coordinate 0. Aoki has N segments. The i-th segment is [L_i,R_i], that is, a segment consisting of points with coordinates between L_i and R_i (inclusive).  The game has N steps. The i-th step proceeds as follows:    * First, Aoki chooses a segment that is still not chosen yet from the N segments and tells it to Takahashi.   * Then, Takahashi walks along the number line to some point within the segment chosen by Aoki this time.  After N steps are performed, Takahashi will return to coordinate 0 and the game ends.  Let K be the total distance traveled by Takahashi throughout the game. Aoki will choose segments so that K will be as large as possible, and Takahashi walks along the line so that K will be as small as possible. What will be the value of K in the end?

Submission attempts (in order):
I,i,R=input,int,range
n,L,R,A,C=i(I()),[],[],0,0
for _ in R(n):l,r=map(i,I().split());L+=[l];R+=[r]
L=sorted(l)[::-1];R.sort()
for j in R(n):C+=(L[j]-R[j])*2;A=max(A,C)
print(A)

I,i,H=input,int,range
n,L,R,A,C=i(I()),[0],[0],0,0
for _ in H(n):l,r=map(i,I().split());L+=[l];R+=[r]
L=sorted(L)[::-1];R.sort()
for j in H(n):C+=(L[j]-R[j])*2;A=max(A,C)
print(A)

Verdicts: Runtime Error

Accepted
Problem: You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.  You can choose any two indices i and j such that 1 \leq i \leq j \leq n and reverse substring A_i A_{i+1} ... A_j.  You can perform this operation at most once.  How many different strings can you obtain?

Submission attempts (in order):
from scipy.misc import comb


def main():
    s = input()
    seq = [0]*26
    for i in range(len(s)):
        seq[ord(s[i])-ord('a')] += 1

    cnt = len(s)*(len(s)-1)//2

    for i in filter(lambda x:x!=0, seq):
        cnt -= comb(i, 2)

    print(int(cnt)+1)


if __name__ == '__main__':
    main()



def main():
    s = input()
    seq = [0]*26
    for i in range(len(s)):
        seq[ord(s[i])-ord('a')] += 1

    cnt = len(s)*(len(s)-1)//2

    for i in filter(lambda x:x!=0, seq):
        cnt -= i*(i-1)//2

    print(cnt+1)


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.  You can choose any two indices i and j such that 1 \leq i \leq j \leq n and reverse substring A_i A_{i+1} ... A_j.  You can perform this operation at most once.  How many different strings can you obtain?

Submission attempts (in order):
a = input()
count = 1
for left in range(len(a)):
    for right in range(left + 1, len(a)):
        if a[left:right + 1] != "".join(list(reversed(a[left:right + 1]))):
            count += 1
        else:
            print(a[left:right + 1])
print(count)

from collections import Counter
a = input()
k = Counter(a).values()
ans = len(a) * (len(a) - 1) // 2
for k_v in k:
    if k_v > 1:
        ans -= k_v * (k_v - 1) // 2
print(ans + 1)

Verdicts: Wrong Answer

Accepted
Problem: You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.  You can choose any two indices i and j such that 1 \leq i \leq j \leq n and reverse substring A_i A_{i+1} ... A_j.  You can perform this operation at most once.  How many different strings can you obtain?

Submission attempts (in order):
a=input()
l=len(a)
b=l*(l-1)/2+1
for i in range(97,123):
    c=a.count(chr(i))
    d=(c*(c-1))//2
    b-=d
print(b)

a=input()
l=len(a)
b=l*(l-1)//2+1
for i in range(97,123):
    c=a.count(chr(i))
    d=c*(c-1)//2
    b-=d
print(b)

Verdicts: Wrong Answer

Accepted
Problem: You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.  You can choose any two indices i and j such that 1 \leq i \leq j \leq n and reverse substring A_i A_{i+1} ... A_j.  You can perform this operation at most once.  How many different strings can you obtain?

Submission attempts (in order):
def main():
     s = list(input())
     count = (len(s)*len(s)-1)/2+1
     dic = {}
     for i in range(len(s)):
         try:
             dic[s[i]].append(i)
         except Exception:
             dic[s[i]] = [i]

     for j in dic.values():
         count-=(len(j)*len(j)-1)/2+1
     print(count)


if __name__=="__main__":
    main()

def main():
     s = list(input())
     count = int((len(s)*(len(s)-1))/2+1)
     dic = {}
     for i in range(len(s)):
         try:
             dic[s[i]].append(i)
         except Exception:
             dic[s[i]] = [i]

     for j in dic.values():
         count-=int((len(j)*(len(j)-1))/2)
     print(count)


if __name__=="__main__":
    main()

Verdicts: Wrong Answer

Accepted
Problem: You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.  You can choose any two indices i and j such that 1 \leq i \leq j \leq n and reverse substring A_i A_{i+1} ... A_j.  You can perform this operation at most once.  How many different strings can you obtain?

Submission attempts (in order):
s = input()

count = 1

for i in range(1, len(s)):
    ss = s[0:i]
    # print(ss, s[i])

    n = len(ss) - ss.count(s[i])
    count += n
    # print(n, count)
print(n)


s = input()

count = 1

alphabets = {}

alphabets[s[0]] = 1

for i in range(1, len(s)):
    for char, char_count in alphabets.items():
        if char != s[i]:
            count += char_count

    if s[i] in alphabets:
        alphabets[s[i]] += 1
    else:
        alphabets[s[i]] = 1

print(count)


Verdicts: Runtime Error

Accepted
Problem: You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.  You can choose any two indices i and j such that 1 \leq i \leq j \leq n and reverse substring A_i A_{i+1} ... A_j.  You can perform this operation at most once.  How many different strings can you obtain?

Submission attempts (in order):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A = input()
N = len(A)

ans = N*(N-1)//2

for v in Counter(A).values():
	ans -= v*(v+1)//2

print(ans+1)

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A = input()
N = len(A)

ans = N*(N-1)//2

for v in Counter(A).values():
	ans -= v*(v-1)//2

print(ans+1)

Verdicts: Wrong Answer

Accepted
Problem: You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.  You can choose any two indices i and j such that 1 \leq i \leq j \leq n and reverse substring A_i A_{i+1} ... A_j.  You can perform this operation at most once.  How many different strings can you obtain?

Submission attempts (in order):

import numpy as np

dic={}
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'

A = input()
for a in ascii_lowercase:
    dic[a]=[0]*len(A)

i=0
for l in A:
    dic[l][i]=1
    i+=1

for d in dic:
    dic[d]=np.cumsum(dic[d])



dp=[0]*len(A)
dp[0]=1
for i in range(1,len(A)):
    tmp = (i+1-dic[A[i]][i])
    print(tmp)
    dp[i]=dp[i-1]+tmp

print(dp[-1])


import numpy as np

dic={}
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'

A = input()
for a in ascii_lowercase:
    dic[a]=[0]*len(A)

i=0
for l in A:
    dic[l][i]=1
    i+=1

for d in dic:
    dic[d]=np.cumsum(dic[d])



dp=[0]*len(A)
dp[0]=1
for i in range(1,len(A)):
    tmp = (i+1-dic[A[i]][i])
    #print(tmp)
    dp[i]=dp[i-1]+tmp

print(dp[-1])


Verdicts: Wrong Answer

Accepted
Problem: You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.  You can choose any two indices i and j such that 1 \leq i \leq j \leq n and reverse substring A_i A_{i+1} ... A_j.  You can perform this operation at most once.  How many different strings can you obtain?

Submission attempts (in order):
from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    S = input()[:-1]
    N = len(S)
    C = Counter(S)
    ans = 0
    for v in C.values():
        ans += v*(v-1)//2
    print(N*(N-1)//2-ans)


solve()


from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    S = input()[:-1]
    N = len(S)
    C = Counter(S)
    ans = 0
    for v in C.values():
        ans += v*(v-1)//2
    print(N*(N-1)//2-ans+1)


solve()


Verdicts: Wrong Answer

Accepted
Problem: You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.  You can choose any two indices i and j such that 1 \leq i \leq j \leq n and reverse substring A_i A_{i+1} ... A_j.  You can perform this operation at most once.  How many different strings can you obtain?

Submission attempts (in order):
S = input()
N = len(S)
ans = N * (N - 1) // 2
a = []
for c in [chr(i) for i in range(97, 97+26)]:
    a.append(S.count(c))
ans -= sum(a)
print(ans)

S = input()
N = len(S)
ans = N * (N - 1) // 2 + 1
a = []
cnt = 0
for c in [chr(i) for i in range(97, 97+26)]:
    cnt = S.count(c)
    a.append(cnt * (cnt - 1) // 2)
ans -= sum(a)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.  You can choose any two indices i and j such that 1 \leq i \leq j \leq n and reverse substring A_i A_{i+1} ... A_j.  You can perform this operation at most once.  How many different strings can you obtain?

Submission attempts (in order):
from collections import Count
s = input()
n = len(s)
d = Count(s)
c = 0
for x in d:
  c += d[x]*(d[x]-1)//2
print(n*(n-1)//2 - c)

from collections import Counter
s = input()
n = len(s)
d = Counter(s)
c = 0
for x in d:
  c += d[x]*(d[x]-1)//2
print(1 + n*(n-1)//2 - c)

Verdicts: Runtime Error

Accepted
Problem: You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.  You can choose any two indices i and j such that 1 \leq i \leq j \leq n and reverse substring A_i A_{i+1} ... A_j.  You can perform this operation at most once.  How many different strings can you obtain?

Submission attempts (in order):
A = input()
ans = 1
for i in range(len(A)):
  for j in range(len(j,A)):
    if A[i] != A[j]:
      ans += 1
      
print(ans)

A = input()
ans = 1
for i in range(len(A)):
  for j in range(j,len(A)):
    if A[i] != A[j]:
      ans += 1
      
print(ans)


A = input()

Alphabet = list("abcdefghijklmnopqrstuvwxyz")

N = len(A)
ans = N*(N-1)/2 + 1

for i in Alphabet:
  z = 0
  for j in range(len(A)):
    if i == A[j]:
      z+=1
  if z>1:
    ans -= z*(z-1)/2
    
print(int(ans))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.  You can choose any two indices i and j such that 1 \leq i \leq j \leq n and reverse substring A_i A_{i+1} ... A_j.  You can perform this operation at most once.  How many different strings can you obtain?

Submission attempts (in order):
a=list(input())

unko=[0]*(ord("z")+1-ord("a"))

for aa in a:
    unko[ord(aa)-ord("a")]+=1
tmp=0
for u in unko:
    tmp+=(u*(u-1))//2

print((n*(n-1))//2-tmp)

a=list(input())

unko=[0]*(ord("z")+1-ord("a"))

for aa in a:
    unko[ord(aa)-ord("a")]+=1
tmp=0
for u in unko:
    tmp+=(u*(u-1))//2

print((len(a)*(len(a)-1))//2-tmp+1)

Verdicts: Runtime Error

Accepted
Problem: You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.  You can choose any two indices i and j such that 1 \leq i \leq j \leq n and reverse substring A_i A_{i+1} ... A_j.  You can perform this operation at most once.  How many different strings can you obtain?

Submission attempts (in order):
from collections import Counter
a=input()
c=Counter(a)
if n==1:print(1)
else:
    ans=n*(n-1)//2
    for i in c.values():
        if i==1:continue
        else:ans-=i*(i-1)//2
    print(ans+1)


from collections import Counter
a=input()
c=Counter(a)
n=len(a)
if n==1:print(1)
else:
    ans=n*(n-1)//2
    for i in c.values():
        if i==1:continue
        else:ans-=i*(i-1)//2
    print(ans+1)


Verdicts: Runtime Error

Accepted
Problem: You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.  You can choose any two indices i and j such that 1 \leq i \leq j \leq n and reverse substring A_i A_{i+1} ... A_j.  You can perform this operation at most once.  How many different strings can you obtain?

Submission attempts (in order):
n = str(input())
lis = [0 for i in range(26)]
ans = 1
for i in range(1,len(n)+1):
  ans += i
  lis[ord(n[i])-"a"] += 1
for i in range(26):
  for k in range(lis[i]-1):
    ans -= (k+1)
print(ans)

n = str(input())
lis = [0 for i in range(26)]
ans = 1
for i in range(len(n)):
  ans += i
  lis[ord(n[i])-ord("a")] += 1
for i in range(26):
  for k in range(lis[i]-1):
    ans -= (k+1)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.  You can choose any two indices i and j such that 1 \leq i \leq j \leq n and reverse substring A_i A_{i+1} ... A_j.  You can perform this operation at most once.  How many different strings can you obtain?

Submission attempts (in order):
s=list(input())
import collections
dics=collections.Counter(s)
num=len(s)
ans=num*(num-1)//2
for i in dics.values():
  ans-=(i*(i-1)//2)
print(ans)

s=input()
def cal(n):
  if len(s)==1:
    return 0
  else:
    new=s[0]
    ans=0
    cnt=0
    for i in range(1,n):
      if s[i]!=new:
        new=s[i]

        cnt=0

        ans+=(i+1)

        

      else: s[i]==new:

          
        cnt+=1

        ans+=cnt

    return ans


a=list(input())
ans=len(a)*(len(a)-1)//2
import collections
J=dict(collections.Counter(a))
for i in J.values():
    ans-=i*(i-1)//2
print(ans+1)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.  You can choose any two indices i and j such that 1 \leq i \leq j \leq n and reverse substring A_i A_{i+1} ... A_j.  You can perform this operation at most once.  How many different strings can you obtain?

Submission attempts (in order):
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    A=input()
    ac=list(Counter().values())
    len_a=len(A)
    ans=len_a*(len_a-1)//2
    for acc in ac:
        ans-=acc*(acc-1)//2
    print(ans)

if __name__=='__main__':
    main()

import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    A=input()
    ac=list(Counter(A).values())
    len_a=len(A)
    ans=len_a*(len_a-1)//2
    for acc in ac:
        ans-=acc*(acc-1)//2
    print(ans+1)

if __name__=='__main__':
    main()

Verdicts: Wrong Answer

Accepted
Problem: You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.  You can choose any two indices i and j such that 1 \leq i \leq j \leq n and reverse substring A_i A_{i+1} ... A_j.  You can perform this operation at most once.  How many different strings can you obtain?

Submission attempts (in order):
from collections import Counter
s=list(input())
n=len(s)
c=s.Counter()
ans=1+n*(n-1)//2
for i in c.values():
  ans-=i*(i-1)//2
print(ans)

from collections import Counter
s=list(input())
n=len(s)
c=Counter(s)
ans=1+n*(n-1)//2
for i in c.values():
  ans-=i*(i-1)//2
print(ans)

Verdicts: Runtime Error

Accepted
Problem: You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.  You can choose any two indices i and j such that 1 \leq i \leq j \leq n and reverse substring A_i A_{i+1} ... A_j.  You can perform this operation at most once.  How many different strings can you obtain?

Submission attempts (in order):
A=input()
ans=0
a=A.count("a")
b=A.count("b")
c=A.count("c")
d=A.count("d")
e=A.count("e")
f=A.count("f")
g=A.count("g")
h=A.count("h")
i=A.count("i")
j=A.count("j")
k=A.count("k")
l=A.count("l")
m=A.count("m")
n=A.count("n")
o=A.count("o")
p=A.count("p")
q=A.count("q")
r=A.count("r")
s=A.count("s")
t=A.count("t")
u=A.count("u")
v=A.count("v")
w=A.count("w")
x=A.count("x")
y=A.count("y")
z=A.count("z")
B=[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 aa in range(26):
  ans=ans+B[aa]*(len(A)-B[aa])
print(ans)

A=input()
ans=0
a=A.count("a")
b=A.count("b")
c=A.count("c")
d=A.count("d")
e=A.count("e")
f=A.count("f")
g=A.count("g")
h=A.count("h")
i=A.count("i")
j=A.count("j")
k=A.count("k")
l=A.count("l")
m=A.count("m")
n=A.count("n")
o=A.count("o")
p=A.count("p")
q=A.count("q")
r=A.count("r")
s=A.count("s")
t=A.count("t")
u=A.count("u")
v=A.count("v")
w=A.count("w")
x=A.count("x")
y=A.count("y")
z=A.count("z")
B=[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 aa in range(26):
  ans=ans+B[aa]*(len(A)-B[aa])
print(ans//2+1)

Verdicts: Wrong Answer

Accepted
Problem: You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.  You can choose any two indices i and j such that 1 \leq i \leq j \leq n and reverse substring A_i A_{i+1} ... A_j.  You can perform this operation at most once.  How many different strings can you obtain?

Submission attempts (in order):
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))
def plis(a): return " ".join(list(map(str, a)))

alf = list("abcdefghijklmnopqrstuvwxyz")
A = rls()
n = len(A)
ans = n*(n-1)/2 + 1
for i in alf:
    count = 0
    for j in A:
        if(i == j):
            count += 1
    ans -= count*(count-1)/2

print(ans)


def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))
def plis(a): return " ".join(list(map(str, a)))

alf = list("abcdefghijklmnopqrstuvwxyz")
A = rls()
n = len(A)
ans = n*(n-1)/2 + 1
for i in alf:
    count = 0
    for j in A:
        if(i == j):
            count += 1
    ans -= count*(count-1)/2

print(int(ans))


Verdicts: Wrong Answer

Accepted
Problem: You are participating in a quiz with N + M questions and Yes/No answers.  It's known in advance that there are N questions with answer Yes and M questions with answer No, but the questions are given to you in random order.  You have no idea about correct answers to any of the questions. You answer questions one by one, and for each question you answer, you get to know the correct answer immediately after answering.  Suppose you follow a strategy maximizing the expected number of correct answers you give.  Let this expected number be P/Q, an irreducible fraction. Let M = 998244353. It can be proven that a unique integer R between 0 and M - 1 exists such that P = Q \times R modulo M, and it is equal to P \times Q^{-1} modulo M, where Q^{-1} is the modular inverse of Q. Find R.

Submission attempts (in order):
M=8**7
m,f,g,i=M*476+1,[j:=1],[k:=1]*M,0
while i<M:i+=1;f+=f[-1]*i%m,
g+=pow(f[-1],m-2,m),
while i:g[i-1]=g[i]*i%m;i-=1
A,B=map(int,input().split())
if A<B:A,B=B,A
while j<=B:i+=k*f[A+B-j]*g[B-j];k=k*2%m;j+=1
print((i*f[B]*g[A+B]+A)%m))

M=8**7
m,f,g,i=M*476+1,[j:=1],[k:=1]*M,0
while i<M:i+=1;f+=f[-1]*i%m,
g+=pow(f[-1],m-2,m),
while i:g[i-1]=g[i]*i%m;i-=1
A,B=map(int,input().split())
if A<B:A,B=B,A
while j<=B:i+=k*f[A+B-j]*g[B-j];k=k*2%m;j+=1
print((i*f[B]*g[A+B]+A)%m)

Verdicts: Runtime Error

Accepted
Problem: Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.  They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card.  Let the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively. They would like to minimize |x-y|. Find the minimum possible value of |x-y|.

Submission attempts (in order):
def QSortPosition(list,low,high):
    LsaveNum=list[low]
    pivotkey=list[low]
    while(low<high):
        while(list[low]<pivotkey) :
            low+=1
        list[high]=list[low]
        high-=1
        while(list[high]>pivotkey):
            high-=1
        list[low]=list[high]
        low+=1
    list[low]=LsaveNum
    return low

def QSort(list,s,t):
    if(s<t):
        pivotkey=QSortPosition(list,s,t)
        QSort(list,s,pivotkey-1)
        QSort(list,pivotkey+1,t)
    return list

def FindMinS(list,length):
	count1=0
	sum=0

	while count1<length:
		sum=sum+list[count1]
		count1+=1

	InvidNum=length-1
	location=0
	count2=0
	MinList=[]

	while count2<InvidNum:
		count3=count2
		ab1=0
		ab2=0
		while count3<=location:
			ab1=ab1+list[count3]
			count3+=1
			ab2=sum-ab1
			ab3=abs(ab2-ab1)
			MinList.append(ab3)
		count2+=1

	MinList=QSort(MinList,0,InvidNum-1)
	return MinList[0]

num=input("请输入列表长度：")
count=0
list=[]
while count<num:
	listele=input("输入元素：")
	list.append(listele)
	count+=1
minnum=FindMinS(list,num)
print(minnum)

import sys

n = int(input())
a = []
b = input().split(" ")
for i in range(n):
	a.append(int(b[i]))

for i in range(1, n):
	a[i] += a[i-1]

mn = abs(a[n-1] - 2*a[0])
for i in range(1, n-1):
	mn = min(mn, abs(a[n-1] - 2*a[i]))

print(mn)


Verdicts: Runtime Error

Accepted
Problem: Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.  They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card.  Let the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively. They would like to minimize |x-y|. Find the minimum possible value of |x-y|.

Submission attempts (in order):
N = int(input())
a = list(map(int, input().split()))
s = []

b = 0
for i in range(N):
  b += a[i]
  s.append(b)

ans = 1
for i in range(N-1):
  ans = min(ans, 2*s[i]-s[N-1])
  # print(i)
  if s[i+1] == 0:
    ans = 0
  
print(ans)


N = int(input())
a = list(map(int, input().split()))
s = []

b = 0
for i in range(N):
  b += a[i]
  s.append(b)
  
ans = abs(2*s[0]-s[N-1])
#print(ans)
for i in range(N-1):
  ans = min(ans, abs(2*s[i]-s[N-1]))
  #print(ans)
  
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.  They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card.  Let the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively. They would like to minimize |x-y|. Find the minimum possible value of |x-y|.

Submission attempts (in order):
N, nums = int(input()), list(map(int, input().split()))
total, ano = sum(nums), 0
for i in range(len(nums)-1):
    total -= nums[i]
    ano += nums[i]    
    if abs(ano-total) < last_dif or i == 0:
        dif = abs(ano-total)
        last_dif = dif
print(dif)

N, nums = int(input()), list(map(int, input().split()))
total, ano = sum(nums), 0
for i in range(len(nums)-1):
    total -= nums[i]
    ano += nums[i]    
    if abs(ano-total) < last_dif or i == 0:
        dif, last_dif = abs(ano-total), dif
print(dif)

# N = int(input())
nums = list(map(int, input().split()))
total, ano = sum(nums), 0
last_dif = 100000000
for i in range(len(nums)-1):
    total -= nums[i]
    ano += nums[i]    
    if abs(ano-total) < last_dif:
        dif = abs(ano-total)
        last_dif = dif
print(dif)
    

N = int(input())
nums = list(map(int, input().split()))
total, ano = sum(nums), 0
last_dif = 100000000000000
for i in range(len(nums)-1):
    total -= nums[i]
    ano += nums[i]    
    if abs(ano-total) < last_dif:
        dif = abs(ano-total)
        last_dif = dif
print(dif)
    

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.  They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card.  Let the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively. They would like to minimize |x-y|. Find the minimum possible value of |x-y|.

Submission attempts (in order):
def c():
    import numpy as np

    N = int(input() )
    A = np.array([int(a) for a in input().split()])

    A_cum = np.cumsum(A)
    A_rev = A_cum[-1] - A_cum
    res = np.abs(A_rev - A_cum)[:-1]
    print(int(np.min(res)))

    print(A_cum, A_rev, res)


c()

def c():
    import numpy as np

    N = int(input() )
    A = np.array([int(a) for a in input().split()])

    A_cum = np.cumsum(A)
    A_rev = A_cum[-1] - A_cum
    res = np.abs(A_rev - A_cum)[:-1]
    print(int(np.min(res)))


c()

Verdicts: Wrong Answer

Accepted
Problem: Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.  They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card.  Let the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively. They would like to minimize |x-y|. Find the minimum possible value of |x-y|.

Submission attempts (in order):
@profile
def main():
    #N = int(input())
    #a = list(map(int, input().split()))
    N = 1000
    a = [i for i in range(N)]

    

    summation = []
    sumtemp = sum(a)
    tmp1 = 0
    for i in range(len(a)-1):
        tmp1 += a[i]
        tmp2 = sumtemp - tmp1
        tmp = abs(tmp1 - tmp2)
        summation.append(tmp)
        
    print(min(summation))

main()



@profile
def main():
    N = int(input())
    a = list(map(int, input().split()))
    #N = 1000
    

    

    summation = []
    sumtemp = sum(a)
    tmp1 = 0
    for i in range(len(a)-1):
        tmp1 += a[i]
        tmp2 = sumtemp - tmp1
        tmp = abs(tmp1 - tmp2)
        summation.append(tmp)
        
    print(min(summation))

main()



def main():
    N = int(input())
    a = list(map(int, input().split()))
    #N = 1000
    

    

    summation = []
    sumtemp = sum(a)
    tmp1 = 0
    for i in range(len(a)-1):
        tmp1 += a[i]
        tmp2 = sumtemp - tmp1
        tmp = abs(tmp1 - tmp2)
        summation.append(tmp)
        
    print(min(summation))

main()



Verdicts: Runtime Error

Runtime Error

Accepted