akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;

const int N = 5;
const int di[] = {0,1,0,-1};
const int dj[] = {1,0,-1,0};
const char C[] = {'R','D','L','U'};
int g[N][N];
int main(void){
  fill(g[0],g[N],0);
  for(int s = 0 ; s < 2 * N - 1 ; s ++){
    for(int j = 0 ; j < N - 1 + s % 2 ; j ++){
      int i = s / 2;
      char a;
      cin>> a;
      if(a=='1'){
	if(s%2==0){
	  g[i][j] |= (1<<0);
	  g[i][j+1] |= (1<<2);
	} else{
	  g[i][j] |= (1<<1);
	  g[i+1][j] |= (1<<3); 
	}
      }
    }
  }

  int i,j,d;
  i = j = d = 0;
  do{
    for(int k = 0 ; k < 4 ; k ++){
      int nd = (d+3+k) % 4;
      if(g[i][j] & (1<<nd)){
	d = nd;
	i += di[d];
	j += dj[d];
	cout << C[d];
	break;
      }
    }
  }while(!(i==0 && j==0));
  cout<<endl;
  
}

Measured memory_bytes: 1132
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    rep(i, N) cin >> H[i];
    vector<vector<int>> graph(N);
    rep(i, M) {
        int A, B;
        cin >> A >> B;
        graph[A - 1].push_back(B - 1);
        graph[B - 1].push_back(A - 1);
    }
    
    int ans = 0;
    rep(i, N) {
        bool judge = true;
        for (int n : graph[i]) {
            if (H[i] <= H[n]) judge = false;
        }
        if (judge) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8800
n, m = map(int, input().split())
cake = []
su = [[],[],[],[],[],[],[],[]]

for i in range(n):
    num = list(map(int, input().split()))
    cake.append(num)

for i in range(n):
    su[0].append(cake[i][0]+cake[i][1]+cake[i][2])
    su[1].append(cake[i][0]+cake[i][1]-cake[i][2])
    su[2].append(cake[i][0]-cake[i][1]+cake[i][2])
    su[3].append(-cake[i][0]+cake[i][1]+cake[i][2])
    su[4].append(cake[i][0]-cake[i][1]-cake[i][2])
    su[5].append(-cake[i][0]+cake[i][1]-cake[i][2])
    su[6].append(-cake[i][0]-cake[i][1]+cake[i][2])
    su[7].append(-cake[i][0]-cake[i][1]-cake[i][2])

def maxJud(arr,m):
    arr.sort(reverse = True)
    summ = sum(arr[:m])
    return summ

fini = []
for i in range(8):
    fini.append(maxJud(su[i], m))


print(max(fini))

Measured memory_bytes: 3700
f_inf = float('inf')
N, K = map(int, input().split(' '))
h = list(map(int, input().split(' ')))
h.append(f_inf)
h.append(f_inf)
dp = [f_inf for _ in range(N + 100)]
dp[0] = 0
for i in range(N - 1):
  for j in range(1, K + 1):
    if i + j > N - 1:
      break
    dp[i+j] = min(dp[i] + abs(h[i+j] - h[i]), dp[i+j])
print(dp[N-1])

Measured memory_bytes: 60512
#include <queue>
#include <cstdio>
#include <cstring>

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

using namespace std;

typedef long long ll;

const int INF=1<<29;

struct edge{ int v,cost; };

void Dijkstra(int n,const vector<edge> *G,int s,int *dist){
	rep(u,n) dist[u]=(u==s?0:INF);
	priority_queue< pair<int,int> > Q; Q.push(make_pair(0,s));
	while(!Q.empty()){
		int d_now=-Q.top().first,u=Q.top().second; Q.pop();
		if(d_now>dist[u]) continue;
		rep(i,G[u].size()){
			int v=G[u][i].v,cost=G[u][i].cost;
			if(dist[v]>dist[u]+cost){
				dist[v]=dist[u]+cost;
				Q.push(make_pair(-dist[v],v));
			}
		}
	}
}

int main(){
	int n,m; scanf("%d%d",&n,&m);
	static vector<edge> G[100000];
	rep(i,m){
		int u,v,cost; scanf("%d%d%d",&u,&v,&cost); u--; v--;
		G[u].push_back((edge){v,cost});
		G[v].push_back((edge){u,cost});
	}

	int a,b,q; scanf("%d%d%d",&a,&b,&q); a--; b--;
	static int c[40000],d[40000];
	rep(i,q) scanf("%d%d",c+i,d+i), c[i]--, d[i]--;

	// calculate distances from a/b
	static int dist_a[100000]; Dijkstra(n,G,a,dist_a);
	static int dist_b[100000]; Dijkstra(n,G,b,dist_b);

	// build the shortest path DAG from a to b
	static vector<int> H[100000];
	rep(u,n) rep(i,G[u].size()) {
		int v=G[u][i].v,cost=G[u][i].cost;
		if(dist_a[u]+cost+dist_b[v]==dist_a[b]) H[u].push_back(v);
	}

	// find a topological order of H
	vector<int> top;
	static int deg[100000]; // degree of vertices
	rep(u,n) rep(i,H[u].size()) {
		int v=H[u][i];
		deg[v]++;
	}
	queue<int> Q; Q.push(a);
	while(!Q.empty()){
		int u=Q.front(); Q.pop();
		top.push_back(u);
		rep(i,H[u].size()){
			int v=H[u][i];
			deg[v]--;
			if(deg[v]==0) Q.push(v);
		}
	}

	// query
	rep(i,(q+63)/64){
		static ll dp[100000];
		memset(dp,0,sizeof dp);
		rep(j,64) if(64*i+j<q) dp[c[64*i+j]]|=1LL<<j;
		rep(i,top.size()){
			int u=top[i];
			rep(j,H[u].size()){
				int v=H[u][j];
				dp[v]|=dp[u];
			}
		}
		rep(j,64) if(64*i+j<q) puts(dp[d[64*i+j]]&(1LL<<j)?"Yes":"No");
	}

	return 0;
}

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

int main(){
  string s;
  int k;
  cin >> s >> k;
  set<string> st;
  int n = s.size();
  for(int i=0; i<n; ++i) for(int j=1; i+j<=n || j <= 5; ++j){
    string ns = s.substr(i,j);
    if(st.size() >5){
      if(*st.rbegin() > ns){
        st.insert(ns);
        st.erase(*st.rbegin());
      }
    }
    else st.insert(ns);
  }
  auto it = st.begin();
  for(int i=1; i<k; ++i) ++it;
  cout << *it << endl;
}


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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
// #define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int a, b;
int32_t main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	cin >> a >> b;
	if (a >= 13) cout << b << endl;
	else if (a >= 6) cout << b/2 << endl;
	else cout << 0 << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include <math.h>
using namespace std;
# define maxn 100000 

int main(){
  // int N,u[maxn],v[maxn],w[maxn],col[maxn];
  // cin>>N;
  // for(int i(0);i<N;i++){
  //   cin>>u[i]>>c[i]>>w[i];
  // }
  // col[0]=1; 
  // 
  // for(int i(0);i<N;i++){
  //   
  // }
  long double sum(0);
  int N,K;
  cin>>N>>K;
  for(int i(1);i<=N;i++){
    int tmp=i;
    int cnt(0);
    for(int j(1);j<=K;j++){
      if (tmp>=K){
        break;
      }
      tmp*=2;
      cnt+=1;
    }
    sum += (long double)1.0/powl((long double)2.0,(long double)cnt);
  }
  cout << setprecision(15)<< (long double)sum/N;
  // string S;
  // cin>>S;
  // int y1=atoi((S[0]+S[1]).c_str()),y2=atoi((S[2]+S[3]).c_str());
  // if (y1!=0 && y1<=12){
  //   if (y2!=0 && y2<=12){
  //     cout << "AMBIGUOUS";
  //   }else{
  //     cout<<"MMYY";
  //   }
  // }else{
  //   if (y2!=0 && y2<=12){
  //     cout << "YYMM";
  //   }else{
  //     cout<<"NA";
  //   }
  // }
  return 0;
}


Measured memory_bytes: 888
#include <iostream>

int main()
{
    long a, b;
    while (std::cin >> a >> b) {
        if (b > a) {
            long tmp = a;
            a = b;
            b = tmp;
        }

        long m = a;
        long n = b;

        while (n != 0) {
            long tmp = n;
            n = m % n;
            m = tmp;
        }
        std::cout << m << " " << (a * b / m) << std::endl;
    }

    return 0;
}

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

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

using namespace std;

struct Point { double x,y; };

const int DIFF = 50;
int r,n;
bool bits[100][100];

int main(){
  while( cin >> r >> n, r|n ){
    vector<Point> ps;
    memset(bits,false,sizeof(bits));
    rep(i,n) {
      int xL,xR,h;
      cin >> xL >> xR >> h;
      xL += DIFF, xR += DIFF;
      rep(y,h) REP(x,xL,xR) bits[y][x] = true;
    }
    rep(y,100){
      REP(x,-r,r) if( !bits[y][x+DIFF] ) {
	ps.push_back((Point){x,y});
	ps.push_back((Point){x+1,y});
      }
    }
    assert( !ps.empty() );
    double mini = INT_MAX;
    rep(i,(int)ps.size()) {
      double X = ps[i].x;
      double Y = sqrt( r * r - X * X );
      mini = min(mini,ps[i].y-Y+r);
    }
    printf("%.10f\n",mini);
  }
  return 0;
}

Measured memory_bytes: 1388
#include <stdio.h>

int main()
{
	int val[3];
	scanf("%d %d %d", &val[0], &val[1], &val[2]);

	for (int i = 2; i > 0; --i)
	{
		for (int j = 0; j < i; ++j)
		{
			if (val[i] < val[j])
			{
				int tmp = val[j];
				val[j] = val[i];
				val[i] = tmp;
			}
		}
	}

	printf("%d %d %d\n", val[0], val[1], val[2]);
	return 0;
}


Measured memory_bytes: 2688
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in(),D=in();
	vector<vector<int>> X(N,vector<int>(D));
	REP(i,N){
		REP(j,D){
			X[i][j] = in();
		}
	}

	int num =0 ;
	REP(i,N){
		for(int j=i+1;j<N;j++){
			int dist = 0;
			REP(n,D){
				dist += (X[i][n]-X[j][n])*(X[i][n]-X[j][n]);
			}
			int sdist = sqrt(dist);
			if(dist==sdist*sdist) num++;
		}
	}
	
	out(num);
	return 0;
}


Measured memory_bytes: 256
import java.io.ByteArrayInputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	
	String INPUT = "";
	
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
		PrintWriter out = new PrintWriter(System.out);
		
		solve(sc, out);
		out.flush();
	}
	
	void solve(Scanner sc, PrintWriter out) {
		int n = sc.nextInt();
		int max = -1000001;
		int min = 1000001;
		BigDecimal sum = new BigDecimal(0);
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if (a > max) max=a;
			if (a < min) min=a;
			sum = sum.add(new BigDecimal(a));
		}
		System.out.println(min +" " + max + " " + sum);
	}
}



Measured memory_bytes: 42340
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}


int main(){
  
  int n;
  cin>>n;
  string s;
  cin>>s;
  bool dp1[n][10] = {};
  bool dp2[n][100] = {};
  bool dp[n][1000] = {};
  REP(i,n){
    int temp = s[i] - '0';
    if(i==0){
      dp1[i][temp] = true;
      continue;
    }
    REP(j,10){
      dp1[i][j] = dp1[i-1][j];
    }
    dp1[i][temp] = true;
  }
  for(int i = 1; i<n; i++){
    if(i == 1){
      string t = s.substr(0,2);
      int temp = stoi(t);
      dp2[i][temp] = true;
      continue;
    }
    REP(j,100){
      dp2[i][j] = dp2[i-1][j];
      int temp = s[i] - '0';
      if(temp != j%10)continue;
      dp2[i][j] = dp2[i][j] || dp1[i-1][j/10];
    }
  }
    
  for(int i = 2; i<n; i++){
    if(i == 2){
      string t = s.substr(0,3);
      int temp = stoi(t);
      dp[i][temp] = true;
      continue;
    }
    REP(j,1000){
      dp[i][j] = dp[i-1][j];
      int temp = s[i] - '0';
      if(temp != j%10)continue;
      dp[i][j] = dp[i][j] || dp2[i-1][j/10];
    }
  }
  
  int ans = 0;
  REP(j,1000){
    if(dp[n-1][j]){
      ans++;
    }
  }
  cout<<ans<<endl;
    
  return 0; 
}

Measured memory_bytes: 32768
#if defined(__GNUC__)
#include <bits/stdc++.h>
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#if defined(__GNUC__)
#define __int32 __int32_t
#endif // __GNUC__

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) std::sort(ALL(x))
#define RSORT(x, T) std::sort(ALL(x), greater<T>())
#define REVERCE(x) std::reverce(ALL(x))

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)

struct md {
	int y;
	int x;
};

itn main() {
	std::ios::sync_with_stdio(false);

	vector<vector<int>> c(3);

	REP(i, 3) {
		c[i].resize(3);
		REP(j, 3) {
			cin >> c[i][j];
		}
	}

	int sub;

	REP(i, 3) {
		sub = min({ c[i][0] , c[i][1], c[i][2]});
		REP(j, 3) {
			c[i][j] -= sub;
		}
	}

	REP(i, 3) {
		sub = min({ c[0][i] , c[1][i], c[2][i] });
		REP(j, 3) {
			c[j][i] -= sub;
		}
	}

	bool flag = true;

	REP(i, 3) {
		REP(j, 3) {
			if (c[i][j]) {
				flag = false;
			}
		}
	}

	if (flag) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
from fractions import gcd
#[N,K] = list(map(int,input().split()))
#A = list(map(int,input().split()))
#[A,B,C,D] = list(map(int,input().split()))
[A,B,C,D] = list(map(int,input().split()))
def lcm(x, y):
    return (x * y) // gcd(x, y)
x_c = (B//C) - ((A-1)//C)
x_d = (B//D) - ((A-1)//D)
x_cd = (B//lcm(C,D)) - ((A-1)//lcm(C,D))
ans = (B - A + 1) - (x_c + x_d -x_cd)
print(ans)

Measured memory_bytes: 5844
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN,datX,datT) = readLine.split(" ").map(_.toInt)

    val a = (datN / datX) + (if(datN % datX != 0) 1 else 0)

    val ans = a * datT
    println(ans)
  }
}


Measured memory_bytes: 54772
import sys
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
xyh.sort(key=lambda x:x[2],reverse=True)
if xyh[0][2]==0:
  total=0
  for i in range(n):
    total+=xyh[i][0]
  cx=total//n
  total=0
  for i in range(n):
    total+=xyh[i][1]
  cy=total//n
  ch=abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)
  print(cx,cy,ch)
  sys.exit()  
for cx in range(101):
  for cy in range(101):
    ch=abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)+xyh[0][2]
    flg=0
    for i in range(n):
      if xyh[i][2]!=max(0, ch-abs(xyh[i][0]-cx)-abs(xyh[i][1]-cy)):
        flg=1
        break
    if flg==0:
      print(cx,cy,ch)
      sys.exit()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define mo 1000000007
#define ny 499122177
#define maxn 1000000000000000000LL
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long n,m,i,j,k,flag,u,v,ans,book[605],sum[605],f[605][605],g[605];
long long cz(int l,int r){
  	if(l>r)
	  	return 0;
  	return r-l+1-sum[r]+sum[l-1];
}
int main(){
  	n=read()*2;m=read()*2;
	g[0]=1;
  	for(i=1;i<=(m>>1);i++){
    	u=read();
		v=read();
    	book[u]=v;
		book[v]=u;
		sum[u]=1;
		sum[v]=1;
  	}
  	for(i=1;i<=n;i++)
	  	sum[i]+=sum[i-1];
  	for(i=2;i<=n;i+=2)
	  	g[i]=(i-1)*g[i-2]%mo;
  	for(i=1;i<=n;i++)
    	for(j=i;j<=n;j++)
      		if((j-i)&1){
		        flag=0;
		        for(k=i;k<=j;k++)
		          	if(book[k]&&(book[k]<i||book[k]>j)) 
					  	flag=1;
		        if(flag)
					continue;
		        f[i][j]=g[cz(i,j)];
		        for(k=i+1;k<j;k++)
		          	f[i][j]=(f[i][j]-f[i][k]*g[cz(k+1,j)]%mo+mo)%mo;
		        ans=(ans+f[i][j]*g[cz(1,i-1)+cz(j+1,n)])%mo;
	      	}
  	pus(ans,2);
  	return 0;
}

Measured memory_bytes: 3072
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())

if a == b:
  print('YES')
  exit()
if v<=w:
  print('NO')
  exit()

dx = abs(b-a)
dv = v-w
if dx/dv <= t:
  print('YES')
  exit()
print('NO')

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    lint a, b, n;
    cin >> a >> b >> n;

    auto f = [&](lint x) {
        return a * x / b;
    };
    
    cout << f(min(n, b-1)) << endl;
    return 0;
}

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


int main()
{
    int a[3];
    for(int i=0;i<3;i++) cin>>a[i];
    sort(a,a+3);
    if(a[0]+a[1]==a[2]) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll n;
cin>>n;
ll arr[n+2];
ll ars[n+1];
memset(ars,0,sizeof(ars));
for(ll i = 0;i<n+1;i++){
    cin>>arr[i];
}
for(ll i =0;i<n;i++){
    cin>>ars[i];
}
ll cnt = 0;
for(ll i = 0;i<n+1;i++){
   
  //cout<<cnt<<"\n";
    if(ars[i]>=arr[i]){
       
        ars[i] -= arr[i];
        cnt += arr[i];
         arr[i] = 0;
        if(i+1<n+1){
 if(ars[i]>= arr[i+1]){

ars[i] -= arr[i+1];
cnt += arr[i+1];
arr[i+1] = 0;
        }
       else{
           arr[i+1] -= ars[i];
           cnt += ars[i];
           ars[i] = 0;
       }
        }
        else{
            if(i+1<n+1){
arr[i+1] -= ars[i];
            
            cnt += ars[i];
            ars[i] = 0;
            }
            
        }
    }
    else{
        arr[i] -= ars[i];
        cnt += ars[i];
        ars[i] = 0;
        
    }
}
cout<<cnt<<"\n";
}


Measured memory_bytes: 1792
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}


ll N, A, B;
int main() {

	cin >> N >> A >> B;

	if (abs(A - B) % 2 == 0) {
		cout << "Alice" << endl;

	}

	else {
		cout << "Borys" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
al = list(map(int, input().split()))

def gcd(a,b):
    while b!=0:
        a,b = b,a%b
    return a

res = al[0]
for i in range(1,n):
    res = gcd(res,al[i])

print(res)


Measured memory_bytes: 14252
#include<algorithm>
#include<map>
#include<cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define itr(it,a) for(auto it=(a).begin();it != (a).end();++it)

int N, M;
int h[1500], w[1500];
std::map<int, int> cnth, cntw;

int main()
{
  while( scanf( "%d%d", &N, &M ), N|M )
  {
    cnth.clear(); cntw.clear();
    
    int ans = 0;

    rep( i, N )
      scanf( "%d", h+i );

    rep( i, M )
      scanf( "%d", w+i );

    rep( i, N )
    {
      int s = 0;
      repi( j, i, N )
      {
	s += h[j];
	++cnth[s];
      }
    }
    
    rep( i, M )
    {
      int s = 0;
      repi( j, i, M )
      {
	s += w[j];
	++cntw[s];
      }
    }

    std::map<int, int>::iterator it;
    itr( i, cnth ) if( (it = cntw.find(i->first)) != cntw.end() )
      ans += i->second*it->second;

    printf( "%d\n", ans );
  }
  
  return 0;
}

Measured memory_bytes: 29544
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
map<pair<int,int>,int> m;
int n,ans,a[100005];
vector<int> g[100005];
void dfs(int x,int y,int z){
	ans=max(ans,z);
	set<int> s;
	s.insert(z);
	int ab=1;
	for(int i=0;i<g[x].size();i++)
		if(g[x][i]!=y){
			for(int j=ab;;j++,ab++)
				if(!s.count(j)){
					a[m[make_pair(x,g[x][i])]]=j;
					s.insert(j);
					dfs(g[x][i],x,j);
					break;
				}
		}
}
int main(){
	n=read();
	for(int i=1;i<n;i++){
		int x=read(),y=read();
		g[x].push_back(y),g[y].push_back(x);
		m[make_pair(x,y)]=m[make_pair(y,x)]=i;
	}
	for(int i=0;i<g[1].size();i++){
		a[m[make_pair(1,g[1][i])]]=i+1;
		dfs(g[1][i],1,i+1);
	}
	printf("%d\n",ans);
	for(int i=1;i<n;i++)
		printf("%d\n",a[i]);
	return 0;
}

Measured memory_bytes: 27520
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int A, B;
    cin >> A >> B;
    int win = 0;
    if(A != 1 && B != 1) {
        if(A < B)
            win = 2;
        else if(A > B)
            win = 1;
        else
            win = 0;
    } else if(A == 1 && B == 1) {
        win = 0;
    } else {
        if(A == 1)
            win = 1;
        if(B == 1)
            win = 2;
    }
    if(win == 1)
        cout << "Alice" << endl;
    else if(win == 2)
        cout << "Bob" << endl;
    else
        cout << "Draw" << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            ans += A[i]*A[j];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())

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

L = {}
R = {}

for i in range(N):
  t = A[i]+i
  if t in L:
    L[t] += 1
  else:
    L[t] = 1
  s = i - A[i]
  if s in R:
    R[s] += 1
  else:
    R[s] = 1  
#print(L,R)
ans = 0
for i in range(N):
  t = A[i]+i
  #ans += R[t]
  if t in R.keys():
    ans += R[t]
    #print(t,R[t])
print(ans)

Measured memory_bytes: 138764
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using INT=mp::cpp_int;
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
INT LCM(INT x,INT y){
  INT z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
INT modinv(INT a, INT m) {
    INT b = m, u = 1, v = 0;
    while (b) {
        INT t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main() {
  cout << fixed << setprecision(30);
  ll n,m;
  cin>>n>>m;
  vec out(m);
  vec check(n+1,1);
  loop(i,m){
    cin>>out[i];
    check[out[i]]=0;
  }
  vec dp(n+1);
  dp[0]=1;
  if(n==1){
    if(m)putout(0);
    else putout(1);
  }
  else{
    loop(i,n){
      Loop(j,i+1,min(i+2,n)+1){
        if(check[j]){
          dp[j]+=dp[i];
          dp[j]%=1000000007;
        }
      }
    }
    putout(dp[n]);
  }
}


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

// 素数判定を行う
bool isPrime(int n){
    
    if (n == 1) return false;
    
    for (int i = 2; i * i <= n; i++){
        if (n % i == 0) return false;
    }
    return true;
}

int main(){
    int q;
    cin >> q;
    
    // 2017-like numberの数を事前計算しておく
    vector<int> s(100002,0);
    for (int i = 1; i <= 100000; i++) {
        s[i] += s[i-1];
        
        if (i % 2 == 1 && isPrime(i) && isPrime((i+1)/2)) s[i]++;
    }
    
    for (int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        cout << s[r] - s[l-1] << endl; // 範囲内の2017-like numberの数を出力せよ
    }
    
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {    
    public static void main(String[] args){        
        Scanner sc = new Scanner(System.in);                
        
        long W = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        
        long k = Math.abs(b-a);
        
        if(b > a + W){
            System.out.println(b - (a + W));
            return;
        }else if(a <= b && b <= a + W || a <= b + W && b+W <= a + W){
            System.out.println(0);            
            return;
        }else if(b + W < a){
            System.out.println(Math.abs(a - (b + W)));
            return;
        }
                
    }            
}

        
        

Measured memory_bytes: 21972
#include<stdio.h>
int p_tax, a_tax, price, max, search_cnt;

int MAX(int a, int b)
{
    return (a > b) ? a : b;
}

int tax_calcurate(int tax, int left, int right)
{
    return left * (100 + tax) / 100 + right * (100 + tax) / 100;
}

void Max_Search(int left, int right)
{
    int tmp = 0, p_price;
    if( left <= right ){
        p_price = tax_calcurate(p_tax, left, right);
        if(  p_price == price ) tmp = tax_calcurate( a_tax, left, right );
        max = MAX( max, tmp);

        if(( p_price == price && search_cnt <= price / 2) ||( p_price < price && search_cnt <= price / 2)) Max_Search( search_cnt++, price );
        else Max_Search( left, right - 1);
    }
}

int main()
{
    while(1){
        scanf("%d %d %d", &p_tax, &a_tax, &price);
        max = search_cnt = 1;

        if( p_tax == 0 && a_tax == 0 && price == 0 ) break;
        Max_Search(search_cnt, price);
        printf("%d\n", max);

    }
    return 0;
}

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


void solve(long long K, std::string S){
    if (S.length() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) << "..." << endl;
    }
    
}

int main(){
    long long K;
    scanf("%lld",&K);
    std::string S;
    std::cin >> S;
    solve(K, S);
    return 0;
}


Measured memory_bytes: 3684
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
#include<math.h>
using namespace std;
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  int ans;
  if(B+C>=A){
    ans=C-(A-B);
  }
  else{
    ans=0;
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	float kane = 100000;
	int kane_int = 100000;
	
	scanf("%d", &n);
	
	while (n != 0){
		kane *= 1.05;
		kane_int = kane;
		if ((kane_int % 1000) != 0){
			kane += 1000 - (kane_int % 1000);
		}
		
		n--;
	}
	
	printf("%.0f\n", kane);
	
	return (0);
}

Measured memory_bytes: 1692
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;

void solve(long long N, long long K){
    if(K > (N-1)*(N-2)/2){
        cout<<-1<<endl; return;
    }
    K = (N-1)*(N-2)/2 - K;
    cout << K+N-1 << endl;;
    for(ll i=2; i <= N; i++){
        cout << "1 " << i<< endl;
    }
    for(ll i=2; i<N; i++){
        if(K == 0) break;
        for(ll j = i+1; j <= N; j++){
            if(K == 0) break;
            cout<< i <<" "<<j<<endl;
            K--;
        }
    }

    
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
points = []
xMin = yMin = 10 ** 10
xMax = yMax = -10 ** 10
xKeys = set((-10 ** 10, 10 ** 10))
yKeys = set((-10 ** 10, 10 ** 10))
for _ in range(n):
    x, y = map(int, input().split())
    xMin = min(xMin, x)
    xMax = max(xMax, x)
    yMin = min(yMin, y)
    yMax = max(yMax, y)
    xKeys.add(x)
    yKeys.add(y)
    points.append((x, y))

xKeyToI = {}
xIToKey = {}
for i, key in enumerate(sorted(list(xKeys))):
    xKeyToI[key] = i
    xIToKey[i] = key

yKeyToI = {}
yIToKey = {}
for i, key in enumerate(sorted(list(yKeys))):
    yKeyToI[key] = i
    yIToKey[i] = key

xLen = len(xKeyToI)
yLen = len(yKeyToI)

mp = [[0] * (xLen + 2) for _ in range(yLen + 2)]
for x, y in points:
    ix, iy = xKeyToI[x], yKeyToI[y]
    mp[iy][ix] += 1


for y in range(1, yLen + 1):
    for x in range(xLen + 1):
        mp[y][x + 1] += mp[y][x]
        mp[y][x] += mp[y - 1][x]

ans = 10 ** 20
for py in range(1, yLen):
    for px in range(1, xLen):
        for h in range(yLen - py):
            for w in range(xLen - px):
                score = mp[py + h][px + w] - mp[py - 1][px + w] -\
                        mp[py + h][px - 1] + mp[py - 1][px - 1]
                if score >= k:
                    ans = min(ans, (xIToKey[px + w] - xIToKey[px]) * (yIToKey[py + h] - yIToKey[py])) 

print(ans)

Measured memory_bytes: 3192
# coding: utf-8
# Your code here!

input_line = input().rstrip().split(" ")
Answer = 0

X = int(input_line[0])
K = int(input_line[1])
D = int(input_line[2])

# 場合1 : 0に届かない場合

if X > 0 and X - K * D >= 0:
    Answer = X - K * D
elif X < 0 and X + K * D <= 0:
    Answer = X + K * D

# 場合2 : 0をまたいで移動する場合

elif X >= 0:
    nearpin = X - abs(int(X / D)) * D
    nokori = K - abs(int(X / D))
    if nokori % 2 == 0:
        Answer = nearpin
    else:
        Answer = nearpin - D
elif X < 0:
    nearpin = X + abs(int(X / D)) * D
    nokori = K - abs(int(X / D))
    if nokori % 2 == 0:
        Answer = nearpin
    else:
        Answer = nearpin + D

print(abs(Answer))

Measured memory_bytes: 9212
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    string s,t;
    cin>>s>>t;
    int cnt=0;
    REP(i,3)
    {
        if(s[i]==t[i])cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)


int main()
{
  
        int n,m;
        scf(n),scf(m);

        int a[n],val=0,mn=mod;



        rep(i,0,n)
        scf(a[i]),val+=a[i],mn=min(a[i],mn);

    
         int ans=n;

         m-=val;

         ans+=(m/mn);

         prin(ans);
            
}

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

int main() {
    int temp, min_diff = INT_MAX;
    string s; cin >> s;
    for (int i = 0; i < s.length() - 2; i++) {
        temp = (s[i] - 48) * 100 + (s[i + 1] - 48) * 10 + (s[i + 2] - 48);
        min_diff = min(min_diff, abs(753 - temp));
    }
    
    cout << min_diff << '\n';
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
int main(void){
    int n;cin>>n;
    map<int,int> mp;
    for(int i=2;i<=n;i++){
        int x=i;
        for(int j=2;j<=sqrt(x);j++){
            while(x%j==0){
                mp[j]++;
                x/=j;
            }
        }
        if(x>1)mp[x]++;
    }
    combination c(10000);
    map<int,int> mp2;
    for(auto&p:mp){
        if(p.second>=2)mp2[2]++;
        if(p.second>=4)mp2[4]++;
        if(p.second>=14)mp2[14]++;
        if(p.second>=24)mp2[24]++;
        if(p.second>=74)mp2[74]++;
    }
    int res=0;
    
    res+=mp2[2]*mp2[4]*(mp2[4]-1)/2;
    res-=mp2[4]*(mp2[4]-1);
    res+=mp2[2]*mp2[24];
    res-=mp2[24];
    res+=mp2[4]*mp2[14];
    res-=mp2[14];
    res+=mp2[74];
    cout<<res<<endl;
}

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

int main() {
  int n;
  cin >> n;
  
  string x;
  vector<int> cnt(4);
  for(int i=0; i<n; i++) {
    cin >> x;
    if(x=="AC") cnt[0]++;
    else if(x=="WA") cnt[1]++;
    else if(x=="TLE") cnt[2]++;
    else if(x=="RE") cnt[3]++;
  }
  
  vector<string> str = {"AC", "WA", "TLE", "RE"};
  for(int i=0; i<4; i++) cout << str[i] << " x " << cnt[i] << endl;
  return 0;
}

Measured memory_bytes: 3628
from copy import copy
N = int(input())
Tlist = list(map(int,input().split()))
M = int(input())
PXlist = [tuple(map(int,input().split())) for _ in range(M)]

for num,res in PXlist:
    tmp = copy(Tlist)
    tmp[num-1] = res
    print(sum(tmp))


Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a * b % 2 == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }
}

Measured memory_bytes: 22612
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int n= sc.nextInt(), m =sc.nextInt();
        int[] rec = new int[m+1];
        for(int i=0;i<n;i++){
            int k = sc.nextInt();
            for(int j=0;j<k;j++){
                int a = sc.nextInt();
                rec[a] += 1;
            }
        }
        int ans=0;
        for(int i=1;i<=m;i++) {
            if(rec[i]==n) ans++;
        }
        System.out.println(ans);
    }
}


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

int getDigit(ll n){
    return to_string(n).length();
}

int main(){
    ll N;
    cin>>N;

    int min_digit=getDigit(N);

    for(ll i=1ll;i*i<=N;i++){
        if(N%i)continue;
        ll j=N/i;
        int cur=getDigit(j);

        if(min_digit>cur)min_digit=cur;
    }
    cout<<min_digit<<"\n";
    return 0;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}
#define int long long

inline int F(int x) { return (x / 2) * 2; }

signed main(void) {
	int ai, ao, at, aj, al, as, az, ans;
	read(ai); read(ao); read(at); read(aj); read(al); read(as); read(az);
	ans = ao;
	int res = 0;
	for (int k = 0; k <= min(3ll, min(ai, min(aj, al))); k++) {
		res = max(res, F(ai - k) + F(aj - k) + F(al - k) + k * 3);
	}
	cout << res + ans << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    string s;
    cin>>s;
    vector<int> cnt(3);
    for(auto c : s)cnt[c-'a']++;
    sort(cnt.begin(),cnt.end());
    if(cnt[2]-cnt[0]<=1)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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 (b<a) { a=b; return 1; } return 0; }

double dist(double x1, double y1, double x2, double y2){
    return sqrt((x2-x1)*(x2-x1) + (y2-y1) * (y2-y1));
}

int main()
{
    int n; cin >> n;
    vector<double> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    vector<int> a(n);
    rep(i, n) a[i] = i;
    int k=1;
    FOR(i, 1, n+1) k*=i; 
    double ans = 0;
    rep(i, k){
        double d = 0;
        rep(j, n-1) d += dist(x[a[j]], y[a[j]], x[a[j+1]], y[a[j+1]]);
        // pr(d);
        ans += d;
        next_permutation(ALL(a));
    }
    printf("%.10lf", ans/k);
    return 0;}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 55565
const int MOD = 1000000007;

vector<int> primes;
vector<bool> isPrime(maxn, true);

void sieve(int n = maxn - 10) {
    isPrime[0] = isPrime[1] = false;
    for (int i = 3; i * i <= n; i += 2)
        if (isPrime[i])
            for (int j = i * i; j <= n; j += 2 * i)
                isPrime[j] = false;
    primes.push_back(2);
    for (int i = 3; i <= n; i += 2)
        if (isPrime[i])primes.push_back(i);
}

void solve() {
    sieve();
    int n;
    cin >> n;

    int ct = 0;
    for (long long prime : primes) {
        if (prime % 5 == 1) {
            ct++;
            cout << prime << " ";
        }
        if (ct == n)break;
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
#define sz(v) (ll)v.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	set<char> odd,even;
	odd.insert('R');
	odd.insert('U');
	odd.insert('D');
	even.insert('L');
	even.insert('U');
	even.insert('D');
	for(ll i=0;i<sz(s);i++)
	{
		if((i+1)%2)
		{
			if(odd.find(s[i])==odd.end())
			{
				cout<<"No\n";
				return 0;
			}
		}
		else
		{
			if(even.find(s[i])==even.end())
			{
				cout<<"No\n";
				return 0;
			}
		}
	}
	cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 256
# Author: cr4zjh0bp
# Created: Thu Mar 12 19:47:42 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

N = ni()
a = na()

alice, bob = 0, 0
a.sort()
for i in range(N):
    if i % 2 == 0:
        alice += a[i]
    else:
        bob += a[i]

print(abs(alice - bob))

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

int main() {
  int n,d,x; cin>>n>>d>>x;
  vector<int> A(n);
  rep(i, n) cin>>A[i];

  rep(i, n) {
    int tmp=(d+A[i]-1)/A[i];
    x+=tmp;
  }
  cout<<x<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[100];

void push(int x) {
	S[++top] = x;
}

int pop() {
	top--;
	return S[top + 1];
}

int main() {
	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: 2144
n, a, b = map(int, input().split())

if (a - b) % 2 == 0:
    print(abs(b-a)//2)
else:
    ans = a + 1
    temp = b - a - 1
    ans += (temp-1) // 2
    ans2 = n - b + 1
    temp = a + ans2
    ans2 += (n - temp) // 2
    print(min(ans, ans2))

Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
set<int>mp;
int qq[10];
int mu[10];
int main()
{

    for(int i=0;i<5;i++)
        cin>>qq[i];
    int sum=0;
    for(int i=0;i<5;i++)
        sum+=(qq[i]+9)/10*10;
    for(int i=0;i<5;i++)
        qq[i]=qq[i]%10;
    sort(qq,qq+5);
    for(int i=0;i<5;i++)
    {
        if(qq[i]!=0)
        {
            sum=sum-10+qq[i];
            break;
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void swap(int *a, int *b){
	int t = *a;
	*a = *b;
	*b = t;
}

int main(void){
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a > b) swap(&a, &b);
	if (b > c) swap(&b, &c);
	if (a > b) swap(&a, &b);
	printf("%d %d %d\n", a, b, c);
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<math.h>
#include<string>
#include<sstream>

using namespace std;

int main(void){

    double a, b, ans;

    cin >> a >> b;

    ans = (a + b) / 2;

    cout << (floor(ans) == ans ? to_string(int(ans)): "IMPOSSIBLE") << endl;

    return 0;
}

Measured memory_bytes: 256
import collections as col


n,x,y = map(int,input().split())
dist = []
for i in range(1,n+1):
    for j in range(i+1,n+1):
        dist.append(min(abs(i-j), abs(i-x)+abs(j-y)+1, abs(i-y)+abs(j-x)+1))

cnt = col.Counter(dist)
for i in range(1,n): print(cnt[i])


Measured memory_bytes: 67800