akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

class SCC{
public:
	vector<vector<int> > G,rG,graph;
	vector<int> vs,cmp;
	vector<bool> used;
	int V,cnt;
	SCC(int node_size){
		V = node_size;
		G.resize(V),rG.resize(V);
		used.resize(V),cmp.resize(V);
	}
	void add_edge(int from,int to){
		G[from].push_back(to);
		rG[to].push_back(from);
	}
	void dfs(int u){
		used[u] = true;
		for(int v : G[u]){
			if(!used[v]){
				dfs(v);
			}
		}
		vs.push_back(u);
	}
	void dfs(int u,const int k){
		used[u] = true;
		cmp[u] = k;
		for(int v : rG[u]){
			if(!used[v]){
				dfs(v,k);
			}
		}
	}
	int solve(){ //強連結成分の数を返す
		fill(used.begin(),used.end(),false);
		rep(i,V){
			if(!used[i]){
				dfs(i);
			}
		}
		fill(used.begin(),used.end(),false);
		cnt = 0;
		for(int i=V-1;i>=0;i--){
			if(!used[vs[i]]){
				dfs(vs[i],cnt++);
			}
		}
		return cnt;
	}
	void make_graph(){
		graph.resize(cnt);
		rep(i,V){
			for(int v : G[i]){
				if(cmp[i] != cmp[v]){
					graph[cmp[i]].pb(cmp[v]);
				}
			}
		}
	}
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    SCC sc(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        sc.add_edge(a,b);
    }
    sc.solve();
    int q;
    cin >> q;
    rep(i,q){
        int a,b;
        cin >> a >> b;
        cout << (sc.cmp[a] == sc.cmp[b]) << "\n";
    }
    return 0;
}


Measured memory_bytes: 4548
import numpy as np
n, m, c = map(int,raw_input().split())
b = map(int,raw_input().split())
a = []
count = 0
for i in range(n):
	total = 0
	a = map(int, raw_input().split())
	for j in range(m):
		multi = a[j] * b[j]
		total += multi
	if total + c > 0:
		count += 1

print count

Measured memory_bytes: 19312
#include <bits/stdc++.h>

#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int N, M, K;
    cin >> N >> M >> K;
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= M; j++){
            if(M*i + j*(N-i - i) == K){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main() {
	string n;
	cin >> n;
	ll ans = n.size() - 1, cnt = 0;
	bool f = 0;
	if (n[0] != '9')f = 1;
	for (int i = 0; i <= ans; i++) {
		
		if (n[i] == '9')cnt++;
	}
	ans *= 9;
	if (f) {
		if(cnt==n.size()-1)ans += (n[0] - '0');
		else {
			ans += (n[0] - '0' - 1);
		}
	}
	else {
		if (cnt == n.size())ans += 9;
		else ans += 8;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
# Atcoder Vacation
n = int(input())
a = []
for i in range(n):
	a.append(list(map(int, input().strip().split())))
dp = [[0,0,0] for i in range(n)]
if n ==1:
	print(max(a[0]))
else:
	dp[0] = a[0]
	for i in range(1, n):
		dp[i][0] = a[i][0] + max(dp[i-1][1], dp[i-1][2])
		dp[i][1] = a[i][1] + max(dp[i-1][0], dp[i-1][2])
		dp[i][2] = a[i][2] + max(dp[i-1][1], dp[i-1][0])
	print(max(dp[-1]))
		

Measured memory_bytes: 47280
<>=~$";
@a=map[glob],<>;
for$b(0..7){
	@_=map{$t=0;$t+=$_*($b>>$i++%3&1?1:-1)for@$_;$t}@a;
	$s=0;
	$s+=$_ for(sort{$b<=>$a}@_)[0..$'-1];
	$s<$\or$\=$s
}
print


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=3e5+7;
typedef pair<int,int> pii;
struct node
{
	int x,y;
	bool operator < (const node &rhs) const
	{
		return x/pow(2,y)<rhs.x/pow(2,rhs.y);
	}
};
priority_queue<node> q;

int main()
{
	int n,m;cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		int x;cin>>x;node tmp;tmp.x=x;tmp.y=0;q.push(tmp);
	}
	while(m--)
	{
		node t=q.top();q.pop();
		int mm=t.x/(pow(2,t.y));
		if(mm==0) break;
		t.y++;q.push(t);
	}
	ll ans=0;
	while(!q.empty())
	{
		node t=q.top();q.pop();
		int mm=t.x/(pow(2,t.y));
		ans+=mm;
		if(mm==0) break;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;





int dp[100010][4];

void solve(long long N, vector<long long> a, vector<long long> b, vector<long long> c){
    for(int i = 0 ; i < 100010 ; i++)
        for(int j = 0 ; j < 4 ; j++)
            dp[i][j] = -1e9;

    dp[0][3] = 0;
    for(int i = 0 ; i < N ; i++){
        long long t[] = {a[i], b[i], c[i], 0ll};
        for(int j = 0 ; j < 4 ; j++){
            for(int k = 0 ; k < 4 ; k++){
                if( j != k ){
                    dp[i+1][k] = max<int>(dp[i+1][k], dp[i][j] + t[k]);
                }
            }
        }
    }
    int ans = -1e9;
    for(int i = 0 ; i < 3 ; i++){
        ans = max(ans, dp[N][i]);
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    vector<long long> a(N);
    vector<long long> b(N);
    vector<long long> c(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
    }
    solve(N, a, b, c);
    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;



int main() {
    fast

    int n;
    cin>>n;

    vector<int>arr(n);

    for(int i=0;i<n;i++){
        cin>>arr[i];
    }

    int ans=1;
    int mini=arr[0];

    for(int i=1;i<n;i++){
        if(arr[i]<=mini)ans++;

        mini=min(mini,arr[i]);
    }

    cout<<ans;




	return 0;
}


Measured memory_bytes: 1024
K = int(input())
A = [int(i) for i in input().split()]

N_min = 2
N_max = 2
for a in A[K::-1]:
	if N_min + (a - N_min) % a > N_max:
		print(-1)
		exit(0)
	else:
		# N_min -> smallest # that is # >= prev N_min and # % a == 0
		N_min += (a - N_min) % a
		# N_max -> smallest # that is # >= prev N_max and # % a == a-1
		N_max += (a - N_max - 1) % a
print(N_min, N_max)

Measured memory_bytes: 14224
#include <iostream>
#include <stdio.h>

using namespace std;

int sum (int a[3]) {
  int sum = 0;
  for (int i=0;i<3;i++) {
    sum += a[i];
  }
  return sum;
}

bool check (int card[3][3]) {
  bool isBingo = false;
  int array[3] = {0,0,0};
  for (int i=0;i<3;i++) {
    if (sum(card[i]) == 0) isBingo = true;
    int ver[3] = {card[0][i],card[1][i],card[2][i]};
    if (sum(ver) == 0) isBingo = true;
  }
  
  int dia[3] = {card[0][0],card[1][1],card[2][2]};
  if (sum(dia) == 0) isBingo = true;
  
  int dia2[3] = {card[2][0],card[1][1],card[0][2]};
  if (sum(dia2) == 0) isBingo = true;
  
  return isBingo;
}

int main () {
  int bingoCard[3][3];
  for (int i=0;i<3;i++) {
    scanf("%d %d %d", &bingoCard[i][0], &bingoCard[i][1], &bingoCard[i][2]);
  }
  int num;
  while (cin >> num) {
    for (int i=0;i<3;i++) {
    	for (int j=0;j<3;j++) {
          if (num == bingoCard[i][j]){ 
            bingoCard[i][j] = 0;
          }
    	}
    }
  } 
  if (check(bingoCard) == true) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#define LL long long
#define N 200005
using namespace std;
const LL inf=1e9;
LL n,s,a[N];
int main()
{
	scanf("%lld",&n);
	{
		for (LL i=1;i<=n;i++) scanf("%lld",&a[i]);
		LL ans=0,j=0,x=0,sum=0;
		for (LL i=1;i<=n;i++)
		{
			while (x==sum && j<=n)
			{
				j++;
				x^=a[j];
				sum+=a[j];
//				cout<<x<<" "<<sum<<" "<<j<<endl;
			}
			ans+=j-i;
			x^=a[i];
			sum-=a[i];
		}
		printf("%lld",ans);
	}
	return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/python3
# -*- coding: utf-8 -*-

def main():
    a = int(input())
    b = int(input())
    c = int(input())
    x = int(input())
    cnt = 0
    for i in range(a + 1):
        y = x - 500 * i
        if y <= 0:
            if y == 0:
                cnt += 1
            break
        for j in range(b + 1):
            z = y - 100 * j
            if z <= 0:
                if z == 0:
                    cnt += 1
                break
            if z // 50 <= c:
                cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;

int N,K;
int calc(int a){
	int total = 0;
	for (int i = 1, la; i <= a; i = la + 1) {
		int x = a / i;
		la = a / (a / i);
		int y = (a - K)/x;
		total += max(0,y-i+1);
	}
	total += (N-a);
	return total;
}

int main(){
	// a - K >= [a/b]*b
	cin>>N>>K;
	long long total = 0;
	for(int i=max(1,K);i<=N;i++) total += calc(i);
	cout<<total<<endl;
	return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
ch, cw = map(int,input().split())
dh, dw = map(int,input().split())
s = [list(input()) for _ in range(h)]
ch -= 1
cw -= 1
dh -= 1
dw -= 1
vec5 = []
vec = [(1, 0), (0, 1), (-1, 0), (0, -1)]
for i in range(-2, 3):
    for j in range(-2, 3):
        if abs(i) + abs(j) < 2:
            continue
        vec5 += [(i,j)]

c = 0
q = [(ch, cw)]
while len(q) > 0:
    nq = []
    while len(q) > 0:
        i, j = q.pop()
        s[i][j] = c
        nq += [(i,j)]
        for v in vec:
            ii = i + v[0]
            jj = j + v[1]
            if 0 <= ii < h and 0 <= jj < w and s[ii][jj] == '.':
                q += [(ii, jj)]


    while len(nq) > 0:
        i, j = nq.pop()
        for v in vec5:
            ii = i+v[0]
            jj = j+v[1]
            if 0 <= ii < h and 0 <= jj < w and s[ii][jj] == '.':
                q += [(ii, jj)]
    c += 1
if s[dh][dw] == '.':
    print(-1)
else:
    print(s[dh][dw])


Measured memory_bytes: 180588
import bisect
N,M,V,P = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
A.reverse()

AP = A[P-1]
D = [AP - A[i] for i in range(N)]
if V <= P:
	for i in range(N):
		if D[i] > M:
			print(i)
			exit()
l,r = P-1,N
while r - l > 1:
	p = (l+r)//2
	# A[p] + M < A[P]
	if D[p] > M:
		r = p
		continue
	n = P + (N-1 - p)
	if V <= n:
		l = p
		continue
	v = V - n
	d = []
	m = A[p] + M
	sumd = []
	nonzero = p
	for i in range(P-1, p):
		diff = min(M, m - A[i])
		if nonzero == p and diff > 0:
			nonzero = i
		d.append(diff)
		if i == P-1:
			sumd.append(diff)
		else:
			sumd.append(sumd[-1] + diff)
	if sumd[-1] < v * M or p - nonzero < v:
		r = p
	else:
		l = p

print(r)

Measured memory_bytes: 20488
ans=0
N,M,QQ=map(int,input().split())
Q=[]
for _ in range(QQ):
    a,b,c,d=map(int,input().split())
    Q.append([a,b,c,d])
def check(a):
    tmp=0
    for q in Q:
        if a[q[1]]-a[q[0]]==q[2]:
            tmp+=q[3]
    return tmp

for A1 in range(1,M+1):
    for A2 in range(A1,M+1):
        for A3 in range(A2,M+1):
            for A4 in range(A3,M+1):
                for A5 in range(A4,M+1):
                    for A6 in range(A5,M+1):
                        for A7 in range(A6,M+1):
                            for A8 in range(A7,M+1):
                                for A9 in range(A8,M+1):
                                    for A10 in range(A9,M+1):
                                        ans=max(ans,check([0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10]))
print(ans)



Measured memory_bytes: 9268
#include <bits/stdc++.h>
using namespace std;
long long sum,a[305][305];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
			cin>>a[i][j];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<i;j++)
		{
			long long t=a[i][j]+1;
			for(int k=0;k<n;k++)
			{
				if(i==k||j==k)
					continue;
				t=min(t,a[i][k]+a[k][j]);
			}
			if(t<a[i][j])
			{
				cout<<"-1";
				return 0;
			}
			if(t>a[i][j])
				sum+=a[i][j];
		}
	}
	cout<<sum;

	return 0;
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;
const int K = 1e5 + 100;

int dp[K];

int main() {
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    dp[0] = 1;
    while (n--) {
        int x;
        cin >> x;
        int sum = 0;
        for (int i=0; i<=x; i++) {
            sum = (sum + dp[k-i]) % MOD;
        }
        for (int i=k; i>=0; i--) {
            sum = (sum + MOD - dp[i]) % MOD;
            dp[i] = (dp[i] + sum) % MOD;
            if (i-x-1 >= 0) {
                sum = (sum + dp[i-x-1]) % MOD;
            }
        }
    }
    cout << dp[k] << '\n';
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, a, b, i, j, k, s = 0;
	cin >> n >> a >> b;
	for (i = 1; i <= n; i++) {
		int x = i, ss = 0;
		while (x > 0) {
			ss += x % 10;
			x /= 10;
		}
		if ((ss >= a) && (ss <= b)) 
			s += i;
	}
	cout << s << "\n";


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,m;
  cin >> n >> m;
  vec x(n),y(m);
  for(ll i=0;i<n;i++) cin >> x[i];
  for(ll i=0;i<m;i++) cin >> y[i];
  ll w=0;
  ll h=0;
  for(ll i=0;i<n-1;i++) {
    (w+=(x[i+1]-x[i])*(i+1)%mod*(n-i-1)%mod)%=mod;
  }
  for(ll i=0;i<m-1;i++) {
    (h+=(y[i+1]-y[i])*(i+1)%mod*(m-i-1)%mod)%=mod;
  }
  cout << w*h%mod << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#define N 200000

void swap(int *x, int *y)
{
	int t;
	t=*x;
	*x=*y;
	*y=t;
 } 
 
 int main()
 {
 	int i,j,k,n,a[N];
 	scanf("%d",&n);
 	for(i=0;i<n;i++)
 	scanf("%d",&a[i]);
 	for(i=0;i<n-1;i++)
 		for(j=n-1;j>=i+1;j--)
 		{
 			if(a[j]<a[j-1])
 			{
 				swap(&a[j],&a[j-1]);
 				k++;
			 }
		 }
 	for(i=0;i<n;i++)
	{
		if(i>0)printf(" ");
		printf("%d",a[i]);
	}
	printf("\n");
	printf("%d\n",k);
 }


Measured memory_bytes: 2104
#include <stdio.h>

int main()
{
	int A[3][3]; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) scanf ("%d", &A[i][j]);
	int n; scanf ("%d", &n); while (n--){
		int x; scanf ("%d", &x);
		for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) if (A[i][j] == x) A[i][j] = -1;
	}

	for (int i = 0; i < 3; i++) if (A[i][0] == -1 && A[i][1] == -1 && A[i][2] == -1){
		puts("Yes"); return 0;
	}
	for (int i = 0; i < 3; i++) if (A[0][i] == -1 && A[1][i] == -1 && A[2][i] == -1){
		puts("Yes"); return 0;
	}
	if (A[0][0] == -1 && A[1][1] == -1 && A[2][2] == -1){
		puts("Yes"); return 0;
	}
	if (A[2][0] == -1 && A[1][1] == -1 && A[0][2] == -1){
		puts("Yes"); return 0;
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 3164
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, groupby
from math import sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop
import sys
stdin = sys.stdin
mod = 10**9 + 7

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

n, a, b = na()

ans = (n //(a+b))*a
res = n - (n // (a+b) * (a+b))
ans += min(res, a)
print(ans)

Measured memory_bytes: 3444
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine());
		Dice[] dice=new Dice[n];
		for(int i=0;i<n;i++){
			dice[i]=new Dice(br.readLine().split(" "));
		}
		boolean uniq=true;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(isSameDice(dice[i],dice[j]))
					uniq=false;
			}
		}
		if(uniq){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
	
	static boolean isSameDice(Dice dice1, Dice dice2){
		boolean match=false;
		for(int i=0;i<6;i++){
			for(int j=0;j<4;j++){
				dice2.spinR();
				if(dice1.match(dice2)){
					match=true;
					break;
				}
			}
			if(match) break;
			if(i%2==0){
				dice2.throwN();
			}else{
				dice2.throwW();
			}
			if(dice1.match(dice2)){
				match=true;
				break;
			}
		}
		return match;
	}
	
	static class Dice {
		private String top,front,right,left,back,bottom;

		public Dice(String[] lbl){
			top=lbl[0];
			front=lbl[1];
			right=lbl[2];
			left=lbl[3];
			back=lbl[4];
			bottom=lbl[5];
		}
		
		public void throwN(){ String tmp=top; top=front; front=bottom; bottom=back; back=tmp; }
		public void throwS(){ String tmp=top; top=back; back=bottom; bottom=front; front=tmp; }
		public void throwE(){ String tmp=top; top=left; left=bottom; bottom=right; right=tmp; }
		public void throwW(){ String tmp=top; top=right; right=bottom; bottom=left; left=tmp; }
		public void spinR(){ String tmp=front; front=left; left=back; back=right; right=tmp; }

		public String getTop() { return top; }
		public String getFront() { return front; }
		public String getRight() { return right; }
		public String getLeft() { return left; }
		public String getBack() { return back; }
		public String getBottom() { return bottom; }
		
		public boolean match(Dice dice2){
			if(this.getTop().equals(dice2.getTop())&&this.getFront().equals(dice2.getFront())
					&&this.getRight().equals(dice2.getRight())&&this.getLeft().equals(dice2.getLeft())
					&&this.getBack().equals(dice2.getBack())&&this.getBottom().equals(dice2.getBottom())){
				return true;
			}else{
				return false;
			}
		}
	}
}

Measured memory_bytes: 21508
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<long> a(N), b(M);
    for(int i=0; i<N; i++)cin >> a[i];
    for(int i=0; i<M; i++)cin >> b[i];
    vector<long> c = convolution(a, b);
    for(int i=0; i<N+M-1; i++){
        if(i)cout<<" ";
        cout << c[i];
    }cout << endl;
    return 0;
}

Measured memory_bytes: 27260
/***************************************************
 * Problem Name : A.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2020-02-20
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
int main () {
    //~ __FastIO;
    //~ cout << setprecision (10);
    //~ cout << fixed;
    string s1, s2, s;
    int a, b;
    cin >> s1 >> s2;
    cin >> a >> b;
    cin >> s;

    if (s == s1) a--;
    else if (s == s2) b--;

    cout << a << " " << b << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * https://atcoder.jp/contests/abc065/submissions/3882674 を参考に作成
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			Node[] nodes = new Node[n];
			IntStream.range(0, n).forEach(i -> nodes[i] = new Node(i, scanner.nextInt(), scanner.nextInt()));
			// X座標でソート
			Arrays.sort(nodes, (n1, n2) -> n1.x - n2.x);
			IntStream.range(0, n - 1).forEach(i -> {
				nodes[i].edges.add(new Edge(nodes[i], nodes[i + 1], nodes[i + 1].x - nodes[i].x));
				nodes[i + 1].edges.add(new Edge(nodes[i + 1], nodes[i], nodes[i + 1].x - nodes[i].x));
			});
			// Y座標でソート
			Arrays.sort(nodes, (n1, n2) -> n1.y - n2.y);
			IntStream.range(0, n - 1).forEach(i -> {
				nodes[i].edges.add(new Edge(nodes[i], nodes[i + 1], nodes[i + 1].y - nodes[i].y));
				nodes[i + 1].edges.add(new Edge(nodes[i + 1], nodes[i], nodes[i + 1].y - nodes[i].y));
			});
			System.out.println(getResult(nodes[0], n));
		}
	}

	/**
	 * @param src 開始ノード
	 * @param n   町の数
	 * @return srcの町からすべての町への道路の最小コスト
	 */
	private static long getResult(Node src, int n) {
		BitSet visited = new BitSet(n);
		Queue<Edge> queue = new PriorityQueue<>((e1, e2) -> e1.cost - e2.cost);
		queue.addAll(src.edges);
		visited.set(src.id, true);
		long result = 0L;
		while (!queue.isEmpty()) {
			Edge edge = queue.poll();
			if (!visited.get(edge.to.id)) {
				result += edge.cost;
				visited.set(edge.to.id, true);
				queue.addAll(edge.to.edges);
			}
		}
		return result;
	}

	/**
	 * ノードを格納するクラス
	 */
	private static final class Node {
		final int id;
		final int x;
		final int y;
		List<Edge> edges = new ArrayList<>();

		Node(int id, int x, int y) {
			super();
			this.id = id;
			this.x = x;
			this.y = y;
		}
	}

	/**
	 * 辺を表すクラス
	 */
	private static final class Edge {
		/** 始点 */
		@SuppressWarnings("unused")
		final Node from;
		/** 終点 */
		final Node to;
		/** コスト */
		final int cost;

		Edge(Node from, Node to, int cost) {
			super();
			this.from = from;
			this.to = to;
			this.cost = cost;
		}
	}
}


Measured memory_bytes: 107920
n,k = map(int,input().split())
s = input()
befores = '1'
cnt = 0
snum = []
for S in s:
	if S == befores:
		cnt += 1
	else:
		snum.append(cnt)
		cnt = 1
		befores = S
snum.append(cnt)
if s[-1] == '0':
    snum.append(0)
kazu = sum(snum[0:k * 2  + 1])
kaisuu = sum(snum[0:k * 2  + 1])
time = int((len(snum) - k * 2 - 1) / 2 )
one = 0
zero = 1
k = k * 2
for i in range(time):
	kazu = kazu - snum[one] - snum[zero] + snum[one + k + 2] + snum[zero + k]
	kaisuu = max(kaisuu,kazu)
	one += 2
	zero += 2
print(kaisuu)

Measured memory_bytes: 4476
import numpy as np

N = int(input())
A = list(map(int, input().split()))
dict_ = {}

for i, n in enumerate(A):
  dict_[i] = n
  
dict_sorted = sorted(dict_.items(), key=lambda x:x[1])

for d in dict_sorted:
  print(d[0] + 1, end=" ")

Measured memory_bytes: 36244
#include<iostream>

using namespace std;

int main() {

	int n;

	char s[100001];

	cin >> n >> s;

	int ans = n;
	for (int i = 1; i < n; i++) {
		if (s[i] == s[i - 1])ans--;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math


def get_int():return int(stdin.readline().strip())
def get_tuple():return map(int, stdin.readline().split())
def get_list():return list(map(int, stdin.readline().split()))

d,t,s = get_tuple()
t_r = d/s
if t<t_r: print("No")
else: print("Yes")

Measured memory_bytes: 9648
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=100005;
int num,n,m,head[maxn],t[maxn<<1],ne[maxn<<1];
inline void addedge(int x,int y){
	ne[++num]=head[x];head[x]=num;t[num]=y;
	ne[++num]=head[y];head[y]=num;t[num]=x;
}
int fa[maxn],dfn[maxn],tme,sz[maxn],val[maxn];
int cyc[maxn],cnt,oncyc[maxn],S,T;
inline void dfs(int x,int f,int v){
	fa[x]=f;dfn[x]=++tme;sz[x]=1;val[x]=v;v^=1;
	forE(i,x)if(t[i]!=f){
		if(!dfn[t[i]]){
			dfs(t[i],x,v);
			val[x]+=val[t[i]];
			sz[x]+=sz[t[i]];
		}else if (dfn[t[i]]<dfn[x]){
			int c=x,a=t[i];
			while(c!=a){
				cyc[++cnt]=c;oncyc[c]=1;c=fa[c];
			}++cnt;S=x;T=a;
		}
	}
}
int va[maxn];
int main(){
	read(n);read(m);
	rep(i,1,n)head[i]=-1;
	rep(i,1,m){
		int x,y;read(x);read(y);
		addedge(x,y);
	}
	dfs(1,0,0);
	if(!cnt||!(cnt&1)){
		if(2*val[1]!=sz[1]){
			puts("-1");
			return 0;
		}
	}else{
		if((2*val[1]-sz[1])&1){
			puts("-1");return 0;
		}
	}
	int myt=(2*val[1]-sz[1])/2,res=abs(myt);
	if(cnt&1){
		while(S!=T){
			sz[S]+=myt;
			oncyc[S]=0;
			S=fa[S];
		}
		while(T){
			sz[T]+=myt*2;
			T=fa[T];
		}
	}
	rep(i,1,n)if(!oncyc[i])res+=abs(2*val[i]-sz[i]);
	if(!(cnt&1)){
		rep(i,1,cnt-1)va[i]=2*val[cyc[i]]-sz[cyc[i]];
		va[cnt]=0;sort(va+1,va+cnt+1);res+=abs(va[(cnt+1)/2]); 
		rep(i,1,cnt-1)res+=abs(va[(cnt+1)/2]-2*val[cyc[i]]+sz[cyc[i]]);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 7424
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

const MOD: i64 = 1000000000 + 7;

fn solve(mut xs: Vec<i64>, mut ys: Vec<i64>) -> i64 {
    xs.sort();
    ys.sort();

    let mut x_total = 0;
    let len = xs.len() as i64;
    for i in 0..len {
        x_total += (2 * i + 1 - len) * xs[i as usize];
        x_total %= MOD;
        if x_total < 0 {
            x_total += MOD;
        }
    }

    let mut y_total = 0;
    let len = ys.len() as i64;
    for i in 0..len {
        y_total += (2 * i + 1 - len) * ys[i as usize];
        y_total %= MOD;
        if y_total < 0 {
            y_total += MOD;
        }
    }
    (x_total  * y_total) % MOD
}

fn main() {
    input!{
        n: usize,
        m: usize,
        xs: [i64; n],
        ys: [i64; m],
    }
    println!("{}", solve(xs, ys));
}


Measured memory_bytes: 10232
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int p[100010],isp[100010],P;

int sieve(int n){
	fill(isp+2,isp+n+1,1);
	int P = 0;
	rep2(i,2,n+1)if(isp[i]){
		p[P++] = i;
		for(int j=i*2;j<=n;j+=i)isp[j]=0;
	}
	return P;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	P = sieve(100000);
	int m,a,b;
	while(cin>>m>>a>>b && m){
		int ans0,ans1,best=-1;
		rep(i,P){
			if(p[i]*p[i] > m)break;
			int q = min(m/p[i], p[i]*b/a);
			while(!isp[q]) q--;
			if(p[i]*q > best){
				best = p[i]*q;
				ans0 = p[i];
				ans1 = q;
			}
		}
		cout<<ans0<<" "<<ans1<<endl;
	}
}

Measured memory_bytes: 1624
//#define _CRT_SECURE_NO_WARNINGS = false	
//#include <stdlib.h>;
#include <stdio.h>;
//#include "Main.h"
void bubbleSort1(int arr[], int len) //
{
	int temp;
	int i, j;
	for (i = 0; i < len - 1; i++)
	{/* 外循环为排序趟数，len个数进行len-1趟 */
		for (j = 0; j < len - 1 - i; j++)
		{
			/* 内循环为每趟比较的次数，第i趟比较len-i次 */
			if (arr[j] > arr[j + 1])
			{
				/* 相邻元素比较，若逆序则交换（升序为左大于右，降序反之） */
				temp = arr[j];
				arr[j] = arr[j + 1];
				arr[j + 1] = temp;
			}
		}
	}
}

int main(void)
{
	// Your code here!
	int n;
	int a[1000];
	double ans ;

	scanf("%d", &n);
	for (int i = 0; i<n; i++) 
	{
		scanf("%d", &a[i]);
	}
	bubbleSort1(a ,n);
	ans = (double)a[0];
	//printf("%d", ans);
	for (int i = 0; i<n; i++)
	{
		ans = (ans + (double)a[i]) / 2.0;
		//printf("%f", ans);
		//printf("%d ", a[i]);
	}
	printf("%f", ans);
	//system("pause");
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
  
int top, S[1000];
  
  
void push(int x){
    top++;
    S[top] = x;
}
  
int pop(){
    top--;
    return S[top+1];
}
  
  
int main(void) {
    int a,b;
    top=0;
    char s[100];
    while( scanf("%s",s) != EOF){
        if( s[0]=='+'){
            a = pop();
            b = pop();
            push(a+b);
        } else if( s[0] == '-'){
            b=pop();
            a=pop();
            push(a-b);
        } else if( s[0] == '*'){
            a = pop();
            b= pop();
            push(a *b);
        } else{
            push(atoi(s));
        }
    }
      
    printf("%d\n",pop());
      
    return 0;
}

Measured memory_bytes: 548
#include<iostream>
#include<string>
int main(){
std::string input;
std::cin>>input;
std::string ans="Yes";
for (int i=1;i<=input.length();i++){
  if((i%2==0&&(input[i-1]=='R'))||(i%2==1&&(input[i-1]=='L'))){
    ans="No";
  }
}
std::cout<<ans<<std::endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r = sc.nextInt();
		if (n >= 10) {
			System.out.println(r);
		} else {
			System.out.println(r + (100 * (10 - n)));
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

int n;
int a[3009];
vector<int> G[3009];

int dfs(int v, int p) {
    int res = a[v];
    for(auto &&u : G[v])
        if(u != p)
            if(dfs(u, v) < a[v]) res = 1 << 30;
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n - 1) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    vector<int> ans;
    rep(i, n) if(dfs(i, -1) == 1 << 30) ans.push_back(i + 1);

    rep(i, ans.size()) cout << (i ? " " : "") << ans[i];
    cout << "\n";

    return 0;
}

Measured memory_bytes: 3996
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define TEST cout << "ococo" << endl;
using namespace std;

int main(void){
	long long n;
	cin >> n;
	long double root = sqrt(n);
	long int rootI = root;
	for (long int i = rootI; i != 0; i--) {
		if (n % i == 0) {
			long long temp = n / i;
			cout << (temp + i - 2) << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
using namespace std;
int main()
{
    int N; cin >> N;
    while (N--) {
        int a[10];
        stack<int> b, c;
        for (int i = 0; i < 10; ++i) cin >> a[i];
        b.push(0);
        c.push(0);
        bool ok = true;
        for (int i = 0; i < 10; ++i) {
            if (b.top() > c.top()) {
                if (b.top() < a[i]) b.push(a[i]);
                else if (c.top() < a[i]) c.push(a[i]);
                else ok = false;
            }
            else {
                if (c.top() < a[i]) c.push(a[i]);
                else if (b.top() < a[i]) b.push(a[i]);
                else ok = false;
            }
        }
        cout << (ok ? "YES" : "NO") << endl;
    }
    return 0;
}

Measured memory_bytes: 0
import math
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N):
    for j in range(i+1, N):
        distance = 0
        for k in range(D):
            distance += (X[i][k] - X[j][k])**2
        if math.sqrt(distance)%1 == 0:
            ans += 1
print(ans)


Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))

for i in range(1, n):
    print(' '.join(map(str, a)))
    key = a[i]
    j = i - 1

    while j >= 0 and a[j] > key:
        a[j+1] = a[j]
        j -= 1

    a[j+1] = key

print(' '.join(map(str, a)))


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define ll long long

string s,t;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin>>s>>t;
    
    int res=0;
    for (int i=0; i<s.size(); i++){
        if (s[i]!=t[i]) res++;
    }
    
    
    cout<<res;
    
    return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;


int main(){
    int score = 0;
    int N = 26;
    int D;
    cin>> D;

    vector<int> c(N+1);
    vector<vector<int>> s(D+1, vector<int>(N+1));
    vector<int> t(D+1);
    vector<int> last(N+1, 0);

    for(int i=1; i<=N; i++){
        cin>>c[i];
    }
 
    for(int i=1; i<=D; i++){
        for(int j=1; j<=N; j++){
            cin>>s[i][j];
        }
    }
    for(int i=1; i<=D; i++){
        cin>>t[i];
    }

    for(int d = 1; d <= D; d++){
        score += s[d][t[d]];
        last[t[d]] = d;

        int penalty = 0;
        for(int i = 1; i <= N; i++){
            penalty += c[i]*(d-last[i]);    
        }
        //cout<<"ペナルティ : "<<penalty<<endl;
        score -= penalty;        
 
        cout<< score <<endl;
    }
    return 0;
}


Measured memory_bytes: 3688
import java.util.Scanner;

class Main {

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);

        int x = scan.nextInt();
        int i = 1;
        while( x > 0 ){
            System.out.println("Case "+i +": "  + x);
            x = scan.nextInt();
            i++;
        }
    }
}



Measured memory_bytes: 42896
#include<iostream>
#include<string>
using namespace std;

int main(){
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int res = 0;
    for(int i =0; i <= a;i++){
        for(int j=0; j<=b;j++){
            for(int k=0; k<= c; k++){
                int total = 500*i + 100*j + 50*k;
                if(total == x) ++res;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
        int N;
        int K;
        char str[200];

        scanf("%d %d", &N, &K);
        scanf("%s", str);

        str[K-1] = str[K-1] + ('a' - 'A');

        printf("%s\n", str);
        return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
    int n,m,a,b,t[100000]={0},i;
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d%d",&a,&b);
        t[a-1]++;
        t[b-1]++;
    }
    for(i=0;i<n;i++)printf("%d\n",t[i]);
    return 0;
}

Measured memory_bytes: 512
#!python3

def LI():
    return list(map(int, input().split()))

# input
N = int(input())
A = LI()

INF = 10 ** 10


def main():
    x, y = 0, sum(A)
    ans = INF
    for a in A[:-1]:
        x += a
        y -= a
        ans = min(ans, abs(x - y))
    
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 24816
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    def find(x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par[x])
            return par[x]

    def unite(x, y):
        x = find(x)
        y = find(y)
        if x == y:
            return False
        else:
            if par[x] > par[y]:
                x, y = y, x
            par[x] += par[y]
            par[y] = x
            return True

    def same(x, y):
        return find(x) == find(y)

    def size(x):
        return -par[find(x)]

    def members(x):
        root = find(x)
        return [i for i in range(n) if find(i) == root]

    def roots():
        return [i for i, x in enumerate(par) if x < 0]

    def group_count(self):
        return len(roots())

    n, m = map(int, input().split())
    par = [-1] * n
    m = map(int, read().split())
    ab = zip(m, m)
    abs = set()
    for a, b in ab:
        a -= 1
        b -= 1
        tmp = (min(a, b), max(a, b))
        abs.add(tmp)
    for abse in abs:
        unite(abse[0], abse[1])
    rs = roots()
    r = 0
    for rse in rs:
        r = max(r, size(rse))
    print(r)
if __name__ == '__main__':
    main()

Measured memory_bytes: 113624
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 10e9+7LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    string s; cin >> s;
    yn(s[2] == s[3] && s[4] == s[5]);
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

const int MAXN = 200010;

const int LG = 22;
int x[MAXN], p[MAXN][LG], f[MAXN * 3], v[MAXN], vs = 0;
int f2[MAXN * 3],  p2[MAXN][LG];

int main()
{
	int n;
	scanf("%d%d", &n, v);
	vs = 0;
	while (v[vs] > 0)
	{
		v[vs + 1] = v[vs] / 2;
		vs++;
	}
	vs++;
	for (int i = 0; i < n; i++)
		scanf("%d", x + i);

	for (int i = 0; i < vs; i++)
	{
		p[n][i] = p[n - 1][i] = n;
		for (int j = n - 2; j >= 0; j--)
		{
			if (x[j + 1] - x[j] > v[i]) p[j][i] = j + 1;
			else p[j][i] = p[j + 1][i];
		}
	}
	for (int i = 0; i < vs; i++)
	{
		p2[0][i] = p2[1][i] = 0;
		for (int j = 2; j <= n; j++)
		{
			if (x[j - 1] - x[j - 2] > v[i]) p2[j][i] = j - 1;
			else p2[j][i] = p2[j - 1][i];
		}
	}
	memset(f, 0, sizeof(f));
	for (int i = 0; i < (1 << vs); i++)
		for (int j = 0; j < vs; j++)
		{
			if (i & (1 << j)) continue;
			int nv = i + (1 << j);
			f[nv] = max(f[nv], p[f[i]][j]);
		}
	for (int i = 0; i < (1 << vs); i++) f2[i] = n;
	for (int i = 0; i < (1 << vs); i++)
		for (int j = 0; j < vs; j++)
		{
			if (i & (1 << j)) continue;
			int nv = i + (1 << j);
			f2[nv] = min(f2[nv], p2[f2[i]][j]);

		}
	int msk = (1 << vs) - 1;
	
	int l, r;
	for (l = 0; l != n; l = r)
	{
		r = p[l][0];
		bool ok = false;
		for (int i = 0; i < (1 << vs); i++)
		{
			if (i & 1) continue;
			if ((f[i] >= l) && (f2[msk - 1 - i] <= r))
				ok = true;
		}
		for (int i = l; i < r; i++)
			if (!ok) printf("Impossible\n");
			else printf("Possible\n");
	}
	return 0;
}


Measured memory_bytes: 43008
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
int abs(int a){
    return a<0?-a:a;
}
int main(){
    int d,n,m;
    while(cin>>d,d){
        cin>>n>>m;
        vector<int>s;
        for(int i=0;i<n-1;i++){
            int a;
            cin>>a;
            s.push_back(a);
        }
        s.push_back(0);
        sort(s.begin(),s.end());
        for(int i=0;i<s.size();i++){
            if(s[i]>=d/2)break;
            s.push_back(s[i]+d);
        }
        s.push_back(1e9+1);
        int sum=0;
        while(m--){
            int p;
            cin>>p;
            vector<int>::iterator ite;
            ite=upper_bound(s.begin(),s.end(),p);
            sum+=min(abs(p-(*(ite-1))),abs(p-(*ite)));
        }
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    string str;
    cin>>str;
    if(str[0]=='R'&&str[1]=='R'&&str[2]=='R')
    {
        cout<<"3\n";
    }
    else if((str[0]=='R'&&str[1]=='R')||(str[1]=='R'&&str[2]=='R'))
    {
        cout<<"2\n";
    }
    else if(str[0]=='R'||str[1]=='R'||str[2]=='R')
    {
        cout<<"1\n";
    }
    else
    {
        cout<<"0\n";
    }
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int n = S.length();
    rep(i, n - 1) {
        if(S[i] == S[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }
    rep(i, n - 2) {
        string K;
        K += S[i];
        K += S[i + 1];
        K += S[i + 2];
        sort(K.begin(), K.end());
        if(K[0] == K[1] || K[1] == K[2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
// const ll MAXN = 

ll n;
vector<pii> x;
map<pii,ll> ocur;

pii operator - (pii a,pii b) {
    pii ret = pii(a.X-b.X,a.Y-b.Y);
    return ret;
}
ll ans;
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n;
    ans = n;
    x = vector<pii>(n);
    REP (i,n) {
        cin >> x[i].X >> x[i].Y;
    }

    REP (i,n) {
        REP (j,n) {
            if (i != j) {
                ocur[x[j]-x[i]]++;
            }
        }
    }

    for (auto p : ocur) {
        ans = min(ans,n-p.Y);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384