akhauriyash/Code-Regression huggingface dataset:
from heapq import heappush,heappop,heapify

n = int(input())
G = [[] for _ in range(n)]
info = []

for i in range(n):
    info =  list(map(int,(input().split())))[2:]
    for j in range(int((len(info))/2)):
        G[i].append((info[2*j],info[2*j+1]))

color = ["white" for _ in range(n)]
dist = [(1<<21) for _ in range(n)]
que = []

def dijkstra():
    dist[0] = 0
    que.append((0,0)) #(dist,node)
    while que:
        heapify(que)
        u = que.pop()[1]
        # print(u)
        color[u] = "black"
        for j in range(len(G[u])):
            if dist[u] + G[u][j][1] < dist[G[u][j][0]]:
                heappush(que,(dist[u] + G[u][j][1],G[u][j][0]))
                dist[G[u][j][0]] = dist[u] + G[u][j][1]

# for i in range(n):
#     print(*G[i])

dijkstra()

for i,dist in enumerate(dist):
    print(i,dist)



Measured memory_bytes: 6204
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	while(true)
	    {
		String str=scan.next();
		if(str.equals("0"))break;
		int countA=0,countB=0;
		if(str.charAt(str.length()-1)=='A')
		    {
			countA+=1;
			//countB-=1;
		    }
		else if(str.charAt(str.length()-1)=='B')
		    {
		    countB+=1;
		    //countA-=1;
		    }
		for(int i=1;i<str.length();i++)
		    {
			if(str.charAt(i)=='A')countA+=1;
			else countB+=1;
		    }
		if(str.charAt(str.length()-1)=='B'&&(countB<countA))
		    {
			countB-=1;
			countA+=1;
		    }
		else if(str.charAt(str.length()-1)=='A'&&(countB>countA))
		    {
			countA-=1;
			countB+=1;
		    }
		System.out.println(countA+" "+countB);
	    }
    }
}

Measured memory_bytes: 17136
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cctype>
#include <functional>
#include <map>
using namespace std;
using ll = long long;

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

bool dpx[8010][16010];
bool dpy[8010][16010];

int main(){
    string str;
    int x,y;
    vector<int> vecx,vecy;
    cin >> str;
    cin >> x >> y;
    int cnt = 0;
    bool is_x = true;

    rep(i,8010){
        rep(j,16010){
            dpx[i][j] = dpy[i][j] = false;
        }
    }

    rep(i,str.length()){
        if(str[i] == 'F'){
            cnt++;
        }else if(str[i]=='T'){
            if(is_x)vecx.push_back(cnt);
            else vecy.push_back(cnt);
            is_x = !is_x;
            cnt = 0;
        }
    }

    if(str[str.length()-1] != 'T'){
        if(is_x)vecx.push_back(cnt);
        else vecy.push_back(cnt);
    }

    dpx[0][vecx[0]+8000] = true;
    bool res=false,res2=false;

    reps(i,1,vecx.size()){
        rep(j,16000){
            if(j-vecx[i] >= 0){
                if(dpx[i-1][j-vecx[i]]){
                    dpx[i][j] = true;
                }
            }
            if(j+vecx[i] < 16009){
                if(dpx[i-1][j+vecx[i]]){
                    dpx[i][j] = true;
                }
            }
        }
    }

    if(vecy.size() > 0){
        dpy[0][vecy[0]+8000] = dpy[0][8000-vecy[0]]= true;
        reps(i,1,vecy.size()){
            rep(j,16000){
                if(j-vecy[i] >= 0){
                    if(dpy[i-1][j-vecy[i]]){
                        dpy[i][j] = true;
                    }
                }
                if(j+vecy[i]< 16009){
                    if(dpy[i-1][j+vecy[i]]){
                        dpy[i][j] = true;
                    }
                }
            }
        }
    }

    if(dpx[vecx.size()-1][8000+x]){
        if(vecy.size() > 0){
            if(dpy[vecy.size()-1][8000+y]) cout << "Yes" << endl;
            else cout <<"No" << endl;
        }else{
            if(y==0) cout << "Yes" << endl;
            else cout <<"No" << endl;
        }
    }
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 250752
#include<stdio.h>
#include<string.h>

int main(){
int x,y;
int c[3];
scanf("%d%d",&x,&y);
if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12)){
	
	printf("Yes\n");
	
	
	
}else if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)){
	
	
	printf("Yes\n");
	
	
}else if(x==2&&y==2){
	
	printf("Yes\n");
	
	
}else{
	
	printf("No\n");
}
	
	return 0;
}

Measured memory_bytes: 128
from math import factorial

def combi(n, k):
  return factorial(n) // factorial(n-k) // factorial(k)

N, P = map(int, input().split())
A = list(map(int,input().split()))

e = len([a for a in A if a % 2 == 0])
o = N - e

ans = 0
if P == 0:
  for i in range(0, o+1, 2):
    ans += combi(o, i)
  print(ans * pow(2, e))
else:
  for i in range(1, o+1, 2):
    ans += combi(o, i)
  print(ans * pow(2, e))

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

map<int, int> res;
int dp[30][80];

void prime_factor(int n){
    for(int i=2;i*i<=n;i++){
        while(n % i == 0){
            res[i]++;
            n /= i;
        }
    }

    if(n != 1) res[n]++;
}

int main(){
    int n; cin >> n;

    for(int i=2;i<=n;i++) prime_factor(i);

    vector<int> fac;
    for(auto it : res) fac.push_back(it.second);

    for(int i=0;i<30;i++) dp[i][1] = 1;
    for(int i=0;i<fac.size();i++){
        for(int j=0;j<80;j++){
            dp[i+1][j] = dp[i][j];
            for(int k=1;k<min(80, fac[i]+1);k++){
                if(j % (k+1) == 0) dp[i+1][j] += dp[i][j / (k+1)];
            }
        }
    }

    cout << dp[fac.size()][75] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,i,j,a[10000],num=0;

  scanf("%d",&n);

  for(i=0;i<=n-1;i++){
    scanf("%d",&a[i]);

    for(j=2;j*j<a[i];j++){
      if(a[i]%j==0)break;
    }
    if(j*j>a[i])num++;    
  }
  
  printf("%d\n",num);
  
  return 0;
}



Measured memory_bytes: 2084
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

n,k = myinput()
d = []
A = []
for i in range(k):
    d.append( int(input()) )
    A.append(list(myinput()))
# print(d)
# print(A)

ls = [0]*n
for i in range(k):
    a = A[i]
    for j in range(len(a)):
        s = a[j] - 1
        ls[s] = 1
# print(ls)
ans = n - sum(ls)
print(ans)

Measured memory_bytes: 74892
#include <iostream>
int a[20];
using namespace std;
bool dfs(int i,int b,int c)
{
    if (i == 11) return true;
    if (a[i] > b) if(dfs(i + 1,a[i],c)) return true;
    if (a[i] > c) if(dfs(i + 1,b,a[i])) return true;
    return false;
}
int main()
{
    int n;
    cin >> n;
    while (n--)
    {
        for (int i = 1; i <= 10; ++i)
            cin >> a[i];
        if (dfs(1, 0, 0)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,m,x;
	int k,l=0,r=0;
	cin>>n>>m>>x;
	for(int i=1;i<=m;i++)
	{
		cin>>k;
		if(k>x)r++;
		else l++;
	}
	cout<<min(r,l);
	return 0;
}

Measured memory_bytes: 256
N=int(input())
import math
def primes(a,x):
    if x < 2: return []
    primes=[i for i in range(x)]
    primes[1]=0
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0
    return [prime for prime in primes if prime>a and prime%5==1]
L=primes(0,55555)[0:N]
print(' '.join(map(str, L)))

Measured memory_bytes: 5272
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  vector<pair<double,string>> a(n);
  rep(i,n){
    cin >> a[i].first >> a[i].second;
  }
  double sum=0;
  rep(i,n){
    if(a[i].second=="BTC"){
      sum +=380000*a[i].first;
    }
    else
      sum +=a[i].first;
  }
  cout << fixed << setprecision(10) << sum << endl;
}

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

int main()
{
    string s;cin>>s;
    int i;
    int ans=0;
    char now=s.at(0);
    for(i=1;i<s.length();i++)
    {
        if(now!=s.at(i))
        {
            now=s.at(i);
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
from collections import Counter
from functools import reduce
from itertools import combinations
from operator import xor

n = int(input())
nodes = [0] * n
for _ in range(n - 1):
    x, y, a = map(int, input().split())
    nodes[x] ^= a
    nodes[y] ^= a

c = Counter(nodes)
ans = 0
remains = set()
for i, v in c.items():
    if i == 0:
        continue
    ans += v // 2
    if v % 2:
        remains.add(i)

for r in (3, 4, 5):
    while True:
        for ns in combinations(remains, r):
            if reduce(xor, ns) == 0:
                remains.difference_update(ns)
                ans += r - 1
                break
        else:
            break
print(ans)


Measured memory_bytes: 4332
#include <bits/stdc++.h>
#define trav(a, b) for(auto& a: b)
#define all(a) a.begin(), a.end()
#define gottagofast ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
	gottagofast;
	ll n, m;
	cin >> n >> m;
	ll ans = 1;
	for(ll i = 1; i * i <= m; ++i) {
		if(m % i == 0) {
			if(i * n <= m) {
				ans = max(ans, i);
			}
			if(i != m / i) {
				ll d = m / i;
				if(d * n <= m) {
					ans = max(d, ans);
				}
			}
		}
	}
	cout << ans;
	return 0;

}

Measured memory_bytes: 256
n = int(input())
s = list(map(int, input().split()))
sum = 0
for i in range(n):
    sum += s[i]
ave = round(sum / n)

for i in range(n):
    s[i] = s[i] - ave
    s[i] = s[i] * s[i]
ans = 0
for i in range(n):
    ans += s[i]

print(ans)

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

int main() {
    string s;
    map<char, int> mp;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        mp[s[i]]++;
        if (mp[s[i]] == 2) {
            cout << "no" << endl;
            return 0;
        }
    }

    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys


def bfs(s, trail):
    q = deque()
    q.append((s, 0))
    trail[s] = 0
    while q:
        p, step = q.popleft()
        for np in edge[p]:
            nstep = step + 1
            if trail[np] > nstep:
                q.append((np, nstep))
                trail[np] = nstep


N = int(input())
edge = [[] for _ in range(N)]
for s in sys.stdin.readlines():
    a, b = map(int, s.split())
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)


INF = 10 ** 9
path0 = [INF] * N
pathN = [INF] * N

bfs(0, path0)
bfs(N - 1, pathN)

fennec = 0
snuke = 0
for i in range(N):
    if path0[i] <= pathN[i]:
        fennec += 1
    else:
        snuke += 1

ans = 'Fennec' if fennec > snuke else 'Snuke'
print(ans)


Measured memory_bytes: 29348
#include<stdio.h>

#define MAXLEN 20000

typedef struct Pool {
	int position;
	int area;
} P;
char buf[ MAXLEN+2 ];
int stack[ MAXLEN+2 ];
P areas[ 10002 ];
int sindex, aindex;

int main( int argc, char *argv[] ) 
{
	int pool, sum = 0;
	int i, j;

	fgets( buf, MAXLEN, stdin );	
	sindex = aindex = 0;
	for( i=0; '\0'!=buf[i]; i++ ) {
		if( '\\' == buf[i] ) {
			stack[ sindex++ ] = i;
		} else if( 0 < sindex && '/' == buf[i] ) {
			j = stack[ --sindex ];
			pool = i - j;
			sum += pool;
			while( 0 < aindex ) {
				if( j < areas[ aindex-1 ].position ) {
					pool += areas[ --aindex ].area;
				} else {
					break;
				}
			}
			areas[ aindex ].position = j;
			areas[ aindex++ ].area = pool;
		}
	}
	printf( "%d\n", sum );
    if( 0 < aindex ) {
        printf( "%d ", aindex );
    } else {
    	printf( "%d", aindex );
    }
    for( i=0; i<aindex; i++ ) {
        printf( "%d", areas[ i ].area );
        if( i != aindex-1 ) printf( " " );
    }
    printf( "\n" );
    
    return 0;
}

Measured memory_bytes: 620
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
typedef long long ll;
int main(){
	int n,a[100][100];
	cin>>n;
	ll ans=0;
	rep(i,n) rep(j,n) cin>>a[i][j];
	rep(i,n) rep(j,i) ans+=min(a[j][i],a[i][j]);
	cout<<ans<<endl;
}

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

int n ;

pair < long long , int > d[100010] ;

int nChild[100010] ;

map < long long , int > f;

vector < pair < int , int > > lis ;

int main(){
    #define NAME "example"
    //freopen(NAME".inp", "r", stdin) ; freopen(NAME".out", "w", stdout) ;

    ios_base :: sync_with_stdio(false) ;

    cin >> n ;

    for (int i = 1; i <= n; ++ i) cin >> d[i].first, d[i].second = i ;

    sort(d + 1, d + n + 1) ;

    long long total = 0 ;

    for (int i = 1; i <= n; ++ i) f[d[i].first] = d[i].second ;
    for (int i = n; i >= 2; -- i){
        long long foo = d[i].first + 2ll * (nChild[d[i].second] + 1) - 1ll * n ;
        int bar = f[foo] ;
        if(!bar) return cout << -1 , 0 ;
        nChild[bar] += nChild[d[i].second] + 1 ;
        if(bar != d[1].second && 2 * nChild[bar] >= n) return cout << -1, 0 ;
        lis.push_back(make_pair(d[i].second, bar)) ;
        total += 1ll * (nChild[d[i].second] + 1) ;
    }
    if(total != d[1].first) return cout << -1, 0 ;

    for (int i = 0; i < (int)lis.size(); ++ i) cout << lis[i].first << " " << lis[i].second << endl ;

    return 0 ;
}


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

#define fi first
#define se second
#define endl '\n'
#define lc (rt<<1)
#define rc (rt<<1|1)
#define mp make_pair
#define pb push_back
#define lowbit(a) (a&(-a))
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define mst(a,v) memset(a,v,sizeof(a))
#define debug(x) cout<<#x": "<<x<<'\n';
#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

const int N=100010;
const int mod=1e9+7;
const ld PI=acos(-1.0);
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;

template<typename T>inline void gmax(T &A,T B) {(A<B)&&(A=B);}
template<typename T>inline void gmin(T &A,T B) {(A>B)&&(A=B);}

template <class T>
inline bool re(T &ret)
{
    char c;
    int sgn;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    ret*=sgn;
    return 1;
}

vi g[N];
int dp[N];
bool vis[N];

void dfs(int u)
{
    vis[u]=true;
    for(auto x: g[u])
    {
        if(!vis[x]) dfs(x);
        gmax(dp[u],dp[x]+1);
    }
}

int main()
{
#ifdef local
    //freopen("in.txt", "r", stdin);
#endif
    IOS;
    int n,m;
    cin>>n>>m;
    while(m--)
    {
        int u,v;
        cin>>u>>v;
        g[u].pb(v);
    }
    for(int i=1; i<=n; i++) if(!vis[i]) dfs(i);
    cout<<*max_element(dp+1,dp+n+1);
    return 0;
}


Measured memory_bytes: 8320
import java.util.*;

public class Main {
    private static double solve(int N, int[] a) {
        int[] state = new int[4];
        for (int i = 0; i < N; i++)
            state[a[i]] += 1;

        return solve(N, state, new double[N+1][N+1][N+1]);
    }

    private static double solve(int N, int[] state, double[][][] memo){
        double e = memo[state[1]][state[2]][state[3]];
        if (e > 0) return e;

        for (int s = 1; s <= 3; s++){
            if (state[s] == 0) continue;

            int current = state[s];
            int nonZero = N - state[0];

            state[s] -= 1;
            state[s-1] += 1;
            e += ((double)current/nonZero)*(solve(N, state, memo) + (double)N/nonZero);
            state[s-1] -= 1;
            state[s] += 1;
        }

        memo[state[1]][state[2]][state[3]] = e;

        return e;
    }

    public static double run(Scanner scanner) {
        int N = scanner.nextInt();
        int[] a = new int[N];
        for (int i=0; i < N; i++) a[i] = scanner.nextInt();

        return solve(N, a);
    }

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            System.out.println(run(scanner));
        }
        //Tests.run();
    }
}


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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int MOD = (int) 20050321;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1000000 + 20;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL m = MOD) {LL res = 1; for(; n; n >>= 1, a = a * a % m) if(n & 1) res = res * a % m; return res;}

LL n, m;
LL a[maxn], b[maxn];
map<LL, LL> mp;

void work()
{
    cin >>n >>m;
    for(int i = 1; i <= n; i++) cin >>a[i];

    mp[0]++;
    LL ans = 0;
    LL acc = 0;
    for(int i = 1; i <= n; i++)
    {
        if(i - m >= 0)
            mp[b[i - m]]--;

        acc += a[i] - 1;
        acc = (acc % m + m) % m;

        ans += mp[acc];
        mp[acc]++;
        b[i] = acc;

    }

    cout <<ans <<endl;
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 15872
n = gets.chomp.to_i
d_arr = gets.chomp.split(" ").map(&:to_i)

sum = 0
d_arr.each_with_index do |d1, n1|
  d_arr.each_with_index do |d2, n2|
    next if n1 >= n2
    sum += d1 * d2
  end
end

puts sum


Measured memory_bytes: 3836
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	long long n;
	cin >> n;

	vector<int> a(n);
	vector<int> b(n * (n + 1) / 2);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int s = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			b[s++] = abs(a[i] - a[j]);
		}
	}

	int max = b[0];
	for (int i = 1; i < n*(n + 1) / 2; i++) {
		if (max < b[i]) {
			max = b[i];
		}
	}
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  string s, t;
  cin >> s >> t;
  cout << (s[0] == t[0]) + (s[1] == t[1]) + (s[2] == t[2]) << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = System.Console.ReadLine().Trim();
            int iN = int.Parse(sS);
            sS = System.Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "No";
            if (iN % 2 == 0)
            {
                string s1 = sS.Substring(0, iN / 2);
                string s2 = sS.Substring(iN / 2, iN / 2);
                if (s1 == s2) { sOut = "Yes"; }
            }

            // 出力
            System.Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 11220
from collections import deque
n, q = map(int, input().split())
a = deque()
for i in range(n):
    name, time = input().split()
    a.append([name, int(time)])
cnt = 0
while a:
    t = a.popleft()
    if t[1] <= q:
        cnt += t[1]
        print(t[0], cnt)
    else:
        cnt += q
        t[1] -= q
        a.append(t)


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

int main() {
  int N,K;
  cin >> N;
  cin >> K;
  int R,S,P;
  cin >> R;
  cin >> S;
  cin >> P;
  string T;
  cin >> T;
  int ans=0;
  for (int i=0; i<K; i++){
    if (T.at(i)=='r') ans=ans+P;
    if (T.at(i)=='s') ans=ans+R;
    if (T.at(i)=='p') ans=ans+S;
  }
  for (int i=K; i<N; i++){
       if (T.at(i)==T.at(i-K)) T.at(i)='x';
       else {
          if ((T.at(i)!=T.at(i-K)) && (T.at(i)=='r')) ans=ans+P;
          if ((T.at(i)!=T.at(i-K)) && (T.at(i)=='s')) ans=ans+R;
          if ((T.at(i)!=T.at(i-K)) && (T.at(i)=='p')) ans=ans+S;
       }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
S="1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
A=list(map(int,S.split(',')))
K=int(input())
print(A[K-1])

Measured memory_bytes: 38256
func readInt() -> Int {
    Int(readLine()!)!
}
 
func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}
 
prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}

let x = readInt()

print(x >= 30 ? "Yes" : "No")

Measured memory_bytes: 7604
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const ll INF = +10010010000;


typedef pair<ll,ll> P;
const ll MO = 1000000007;

int main(){
    // priority_queue<ll, vector<ll>, greater<ll>> p;
    priority_queue<ll> p;
    int n,m;
    cin >> n >> m;
    rep(i,n){
        ll a; cin >> a;
        p.push(a);
    }
    rep(i,m){
        ll a = p.top();p.pop();
        // cout << a << endl;
        a/=2;
        p.push(a);
    }
    ll ans = 0;
    rep(i,n){
        ans += p.top();p.pop();
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int N, D;
    cin >> N >> D;
    vector<vector<double>> X(N,vector<double>(D));
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < D; j++)
        {
            cin >> X[i][j];
        }
        
    }
    double Sum = 0;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = i; j < N; j++)
        {
            if(i!=j){
                for (int k = 0; k < D; k++)
                {
                    Sum +=pow(X[i][k]-X[j][k],2);
                }
                Sum = pow(Sum,0.5);
                if(abs(round(Sum)-Sum) <= DBL_EPSILON){
                    ans++;
                }
                Sum = 0;
            }
        }
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> Pair;
using namespace std;
vector<ll> primes;

ll gcd(ll x,ll y)
{
    ll r;
    if(x < y){
        swap(x,y);
    }
    while(y > 0){
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main()
{
    ll a,b;
    cin >> a >> b;
    ll ans = 1;
    ll x = gcd(a,b);
    ll num = x;
    for(ll i = 2; i * i <= x; i++){
        if(num % i == 0){
            while(num % i == 0){
                num /= i;
            }
            ans++;
        }
    }
    if(num != 1) ans++;
    cout << ans << 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 a = sc.nextInt();
		int b = sc.nextInt();
		int h = b - a;

		int bh = (1 + h) * h / 2;

		int ans = bh - b;

		System.out.println(ans);

	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll n;
ll h[100002];
ll memo[100002];

ll dp(int i){
  
	if (i == n) return 0;
	if (memo[i] != -1) return memo[i];

	ll ans = dp(i+1) + (abs(h[i]-h[i+1]));

	if (i < n-1) ans = min(ans, dp(i+2) + (abs(h[i]-h[i+2])));

	memo[i] = ans;

	return ans;
}

int main(){
	cin >> n;
  
	memset(memo, -1, sizeof memo);
  
	for (int i = 0; i < n; i++){ cin >> h[i]; }
  
  	n--;
  
	cout << dp(0) << endl;
	return 0;
}

Measured memory_bytes: 11388
function maxSum(arr,len){
var sumArr=[];
for(var i=0;i<arr.length-len;i++){
   var j=len;
   var sum=0;
   if(i==0){
      while(j>=0){sum+=arr[i+j];j--;}
   }else{
      sum=sumArr[i-1]-arr[i-1]+arr[i+j];
   }
   sumArr.push(sum);
}
sumArr.sort(function(a,b){return b-a;});
console.log(sumArr[0]);
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var a;
var b;
for(var i=0;i<Arr.length;i++){
   var Line=Arr[i].split(" ").map(Number);
   if(Line.length==2 || i==Arr.length-1){
      if(i!=0)maxSum(a,b);
      a=[];
      b=(Line[1]-0)-1;
   }else{
      a.push(Line[0]);
   }
if(Arr[i]=="0 0")break;
}

Measured memory_bytes: 34440
const Main = (input) => {
  const tmp = input.trim().split('\n')
  const K = parseInt(tmp[0])
  const A = parseInt(tmp[1].split(' ')[0])
  const B = parseInt(tmp[1].split(' ')[1])

  let result = 'NG'

  for (let i = A; i <= B; i++) {
    if ((i % K) === 0) {
      result = 'OK'
    }
  }

  console.log(result)
  return result
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 29624
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  int n, m; readV(n, m);
  int[] a, b; readC(n, a, b);
  int[] c, d; readC(m, c, d);

  foreach (i; 0..n) {
    auto x = 0, yi = int.max;
    foreach (j; 0..m) {
      auto y = (a[i]-c[j]).abs + (b[i]-d[j]).abs;
      if (y < yi) {
        yi = y;
        x = j;
      }
    }
    writeln(x+1);
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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; }

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

    ve_vei c(3, vei(3)); rep(i,3) rep(j,3) cin >> c[i][j];

    if((c[0][1] - c[0][0] == c[1][1] - c[1][0]) and (c[1][1] - c[1][0] == c[2][1] - c[2][0])) {
        if((c[0][2] - c[0][0] == c[1][2] - c[1][0]) and (c[1][2] - c[1][0] == c[2][2] - c[2][0])) {
            if((c[0][2] - c[0][1] == c[1][2] - c[1][1]) and (c[1][2] - c[1][1] == c[2][2] - c[2][1])) {
                cout << "Yes" << endl; 
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int a, b;
  cin >> a >> b;
  if (a+b >= 10) {
    cout << "error" << endl;
  } else {
    cout<< a+b << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, i, c=1, ans=0; cin >> N; int A[N];
for(i=0; i<N; i++){ cin >> A[i]; if(A[i]!=c){ans++;}else{c++;} }
if(ans==N){ ans=-1; }
cout << ans << "\n";
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>


     
#define INF 1e9
#define LINF 1e19
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define pb push_back
#define sz size()
     
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

     
const ll MOD = 1e9 + 7;
const ll ZER = 0;



int main(){
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> cnt(3, 0);
    rep(i, n){
        int p;
        cin >> p;
        if(p <= a)cnt[0]++;
        else if(a < p && p <= b)cnt[1]++;
        else cnt[2]++;
    }
    sort(ALL(cnt));
    cout << cnt[0] << endl;
}





Measured memory_bytes: 3108
import sys
input = sys.stdin.readline

def gcd(a, b):
    while a > 0:
        if a < b:
            a, b = b, a
        a = a % b
    return b

def main():
    n, x = map(int, input().split())
    town = map(int, input().split())

    distance = (abs(x-y) for y in town)
    res = next(distance)
    for d in distance:
        res = gcd(res, d)

    print(res)

if __name__ == "__main__":
    main()

Measured memory_bytes: 11168
#include<bits/stdc++.h>
using namespace std;
int n,fm,fm1,sm,sm1,a[200100];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]>sm){
			if(a[i]>fm) fm=a[i],fm1=i;
			else sm=a[i],sm1=i;
		}
	}
	for(int i=1;i<=n;i++){
		if(fm1==i) printf("%d\n",sm);
		else printf("%d\n",fm);
	}
}

Measured memory_bytes: 2432
H, W = map(int, input().split(' '))
N = int(input())
A = list(map(int, input().split(' ')))
M = [[0]*W for i in range(H)]
color = 1
num = 0
for i in range(H):
    for j in range(W):
        if i % 2 != 0:
            j = W - j - 1
        M[i][j] = color
        num += 1 
        if num == A[color-1]:
            color += 1
            num = 0
for i in range(H):
    print(' '.join(list(map(str, M[i]))))

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}

const int INF = 100000; 

int main(){
    vector<char> c(6, 0);
    for(int i = 0; i < 6; i++){
        cin >> c[i];
    }

    for(int i = 0; i < 3; i++){
        if(c[i] != c[5 - i]){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
	int a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;
	return 0;
}

Measured memory_bytes: 3632
InA = [int(i) for i in input().split()]

if InA[0] + InA[1] > InA[2] + InA[3] :
    print ("Left")
elif InA[0] + InA[1] < InA[2] + InA[3] :
    print ("Right")
elif  InA[0] + InA[1] == InA[2] + InA[3] :
    print ("Balanced")
else:
    print ("err")

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

int n;
int common_time = 1;

int adj_matrix[101][101] = {0};
int time_table[101][2] = {0};

void dfs(int node)
{
    if (time_table[node][0] == 0)
    {
        time_table[node][0] = common_time;
        common_time++;
    }
    else
    {
        return;
    }

    for (int i = 1; i <= n; i++)
    {
        if (adj_matrix[node][i] == 1)
        {
            dfs(i);
        }
    }

    time_table[node][1] = common_time;
    common_time++;
}

int main()
{
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            int v;
            cin >> v;
            adj_matrix[u][v] = 1;
        }
    }

    for (int i = 1; i <= n; i++)
    {
        dfs(i);
    }

    for (int i = 1; i <= n; i++)
    {
        cout << i << " " << time_table[i][0] << " " << time_table[i][1] << endl;
    }

    return 0;
}


Measured memory_bytes: 3060
N = int(input())
S = input()
from collections import deque
q = deque([])

if S == '(' or S == ')':
    print('()')
    exit()

l = []
cnt = 0
for i in range(N-1):
    if S[i] == '(':
        cnt += 1
        if S[i+1] == ')':
            l.append(['a', cnt])
            cnt = 0
        elif S[i+1] == '(' and i+1 == N-1:
            l.append(['a', cnt+1])
            cnt = 0
    elif S[i] == ')':
        cnt += 1
        if S[i+1] == '(':
            l.append(['b', cnt])
            cnt = 0
        elif S[i+1] == ')' and i+1 == N-1:
            l.append(['b', cnt+1])
            cnt = 0

if S[-1] != S[-2]:
    if S[-1] == '(':
        if l[-1][0] == 'a':
            l[-1][1] += 1
        else:
            l.append(['a', 1])
    elif S[-1] == ')':
        if l[-1][0] == 'b':
            l[-1][1] += 1
        else:
            l.append(['b', 1])


a = 0
b = 0
for i in range(len(l)):
    k, c = l[i]
    if k == 'a':
        q.append('('*c)
        a += c
    if k == 'b':
        q.append(')'*c)
        b += c
        if a < b:
            q.appendleft('('*(b-a))
            a += (b-a)
if a > b:
    q.append(')'*(a-b))

print(*q, sep='')


Measured memory_bytes: 38480
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    vector<int> a(9);
    for (int i=0; i<9; i++) {
        cin >> a.at(i);
    }
    int a_1 = 0;
    int b_1 = a.at(0) - a_1, b_2 = a.at(1) - a_1, b_3 = a.at(2) - a_1;
    int a_2 = a.at(3) - b_1, a_3 = a.at(6) - b_1;
    if (a.at(4) == a_2+b_2 && a.at(5) == a_2+b_3 && a.at(7) == a_3+b_2 && a.at(8) == a_3+b_3) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,i,j,k,x,y,ans;
int main(){//freopen("1.in","r",stdin);freopen("1.out","w",stdout);
	scanf("%d%d",&n,&m);ans=2000000000;for (i=1;i<=n;i++){scanf("%d%d",&x,&y);if (y<=m) ans=min(ans,x);}
	if (ans==2000000000) printf("TLE\n"); else printf("%d\n",ans);return 0;
}

Measured memory_bytes: 256
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,=pin()
    temp=[input() for i in range(N)]
    from collections import  Counter
    c=Counter(temp)
    print(len(c))
#%%submit!
resolve()


Measured memory_bytes: 38788
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()

print(math.ceil(N/2))

Measured memory_bytes: 6320
A, B, Q = [int(x) for x in input().split()]
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
X = [int(input()) for _ in range(Q)]

import bisect


def f(x):
    # X の左にあるのをS[i-1], T[j-1]
    # X もしくは Xの右にあるのをS[i], T[j] とする
    i = bisect.bisect_left(S, x)
    j = bisect.bisect_left(T, x)
    a1 = a2 = a3 = a4 = a5 = a6 = float("inf")

    # (1) S[i] --> T[j] or T[j] --> S[i]
    if len(S) > i and len(T) > j:
        a1 = max(S[i], T[j]) - x

    # (2) S[i] --> T[j-1]
    if len(S) > i and j - 1 >= 0:
        a2 = S[i] - x + S[i] - T[j - 1]

    # (3) T[j] --> S[i-1]
    if i - 1 >= 0 and len(T) > j:
        a3 = T[j] - x + T[j] - S[i - 1]

    # (4) S[i-1]  --> T[j]
    if i - 1 >= 0 and len(T) > j:
        a4 = x - S[i - 1] + T[j] - S[i - 1]

    # (5) T[j-1]  --> S[i]
    if len(S) > i and j - 1 >= 0:
        a5 = x - T[j - 1] + S[i] - T[j - 1]

    # (6) S[i-1] --> T[j-1] or T[j-1] --> S[i-1]
    if i - 1 >= 0 and j - 1 >= 0:
        a6 = x - min(S[i - 1], T[j - 1])

    return min(a1, a2, a3, a4, a5, a6)


for x in X:
    print(f(x))


Measured memory_bytes: 16168
S = list(input())
ki = ["R", "U", "D"]
gu = ["L", "U", "D"]
ans = 0
for i in range(len(S)):
    if (i%2 == 0) and (S[i] not in ki):
        ans += 1
    elif (i%2 == 1) and (S[i] not in gu):
        ans += 1

if ans == 0:
    print("Yes")
else:
    print("No")

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

int main() {
  int n, i;
  cin >> n;
  
  vector<int> a(n), b(n);
  for (i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  
  long long keep = 0;
  for (i = 0; i < n - 1; i++) {
    if (i % 2 == 0) {
      keep += a.at(i);
    }
    else {
      keep -= a.at(i);
    }
  }
  
  b.at(0) = (keep + a.at(n - 1)) / 2;
  cout << b.at(0) * 2 << endl;
  
  for (i = 0; i < n - 1; i++) {
    b.at(i + 1) = a.at(i) - b.at(i);
    cout << b.at(i + 1) * 2 << endl;
  }
}

Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <bitset>

using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	// Absolute
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	// GCD: a > b
	ul gcd(ul a,ul b) { return (!b) ? a : gcd(b,a%b); }
}

int main(int argc,char *argv[])
{
	ll n,k;
	std::cin >> n >> k;

	std::vector<ll> h(n,0);
	for(ll i = 0;i < n;++i) std::cin >> h[i];

	std::sort(h.begin(), h.end(), std::less<>());

	ll ans = 0;
	for(ll i = 0;i < n-k;++i) ans += h[i];

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int item_price;
	int n;
	int hate_num_cnt;
	bool iroha_ng = true;

	cin >> item_price >> hate_num_cnt;
	vector<int> hate_num(hate_num_cnt);

	for (int i=0; i<hate_num_cnt; i++) {
		cin >> hate_num.at(i);
	}

	while (iroha_ng || item_price > 90000) {
		int n = item_price;
		iroha_ng = false;

		while (n != 0) {
			if (count(hate_num.begin(), hate_num.end(), n%10)) {
				item_price++;
				iroha_ng = true;
				break;
			}
			n=n/10;
        }
    }

	cout << item_price;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner sc=new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		ArrayList<Integer> xArrayList = new ArrayList<>();

		for (int i=0; i<n; i++){
			xArrayList.add(Integer.parseInt(sc.next()));
		}
		Collections.sort(xArrayList);

		int ans = Integer.MAX_VALUE;
		for (int i=0; i<n-k+1; i++){
			ans = Math.min(ans, Math.min(Math.abs(xArrayList.get(i)) + Math.abs(xArrayList.get(i+k-1) - xArrayList.get(i)), Math.abs(xArrayList.get(i+k-1)) + Math.abs(xArrayList.get(i) - xArrayList.get(i+k-1))));
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 48944
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;

template<class T>
using vec = std::vector<T>;


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


// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}


void solve(istream& in, ostream& out) {
  auto n = next<int>(in);
  auto sumW = next<int>(in);
  vec<int> w(n), v(n);
  FOR(i, n) {
    w[i] = next<int>(in);
    v[i] = next<int>(in);
  }
  vec<int64_t> f(1000 * n + 1, -1);
  f[0] = 0;
  int mx = 0;
  FOR(i, n) {
    for (int cv = mx; cv >= 0; --cv) {
      if (f[cv] != -1 && f[cv] + w[i] <= sumW) {
        if (f[cv + v[i]] == -1) {
          f[cv + v[i]] = f[cv] + w[i];
        } else {
          f[cv + v[i]] = min(f[cv + v[i]], f[cv] + w[i]);
        }

        mx = max(cv + v[i], mx);
      }
    }
  }

  int res = 0;
  FOR(i, f.size()) {
    if (f[i] != -1 && f[i] <= sumW) {
      res = i;
    }
  }
  out << res << "\n";
}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
 
typedef long double ld;
 
#define MAXN 3010
 
int N;
ld p[MAXN];
ld dp[MAXN][2*MAXN];
 
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  dp[0][1+MAXN] = p[0];
  dp[0][-1+MAXN] = (ld)1-p[0];
  for (int i = 1; i < N; i++) {
    for (int j = -(i+1); j <= (i+1); j++) {
      dp[i][j+MAXN] = (p[i]*dp[i-1][j+MAXN-1]) + (((ld)1-p[i])*dp[i-1][j+MAXN+1]);
    }
  }
  ld ans = (ld)0;
  for (int i = MAXN+1; i < 2*MAXN; i++) {
    ans += dp[N-1][i];
  }
  cout << setprecision(10);
  cout << ans << endl;
}

Measured memory_bytes: 280960
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>

#define INF 100000000
#define EPS 1e-9

using namespace std;

typedef long long ll;

#define MAX_N 1000
ll N, M;
ll P[MAX_N+1];

vector<ll> ans_list;

int main(){

	while (true){
		vector<ll> date;
		cin >> N >> M;
		if (N == 0 && M == 0)
			break;
		P[0] = 0;
		for (int i = 1; i <= N; i++){
			cin >> P[i];
		}

		for (int i = 0; i <= N; i++){
			for (int j = i; j <= N; j++){
				date.push_back(P[i] + P[j]);
			}
		}

		sort(date.begin(), date.end());
		
		ll ans = 0;

		for (int num = 0; num < date.size(); num++){
			int lb = 0, ub = date.size();
			if (M < date[num])
				break;
			while (ub - lb > 1){
				int mid = (ub + lb) / 2;
				if (date[mid] > M - date[num])
					ub = mid;
				else
					lb = mid;
			}
			
			ans = max(ans, date[lb] + date[num]);
		}

		ans_list.push_back(ans);

	}

	for (int i = 0; i < ans_list.size(); i++){
		cout << ans_list[i] << endl;
	}

	return 0;

}

Measured memory_bytes: 9140