akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>       // printf,scanf
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>  //sort,binarySearch
#include <functional> 
#include <iomanip>    // setprecision
#include <utility>    // c+11 Array
#include <set>
#include <sstream>
#include <map>
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238462643383279
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define pb(x) push_back(x)
#define debug(x) cout << #x << " = " << x << endl;
#define debret(x) debug(x) ; return 0;

using namespace std;

int main(){

    int N;
    cin >> N;

    int a[N+1];
    int b[N+1];
    int p[N+1];
    int r[N+1];

    FOR(i,1,N+1){
        cin >> p[i];
        r[p[i]] = i;
    }

    FOR(i,1,N+1){
        a[i] = 30000*i;
        b[i] = 30000*(N-i) + r[i];
    }
    FOR(i,1,N+1){
        cout << a[i] << " ";
    }
    cout << endl;
    FOR(i,1,N+1){
        cout << b[i] << " ";
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
int a[50];
int fibonacci(int n){
  if(n==0||n==1) return a[n]=1;
  if(a[n]!=-1) return a[n];
  return a[n]=fibonacci(n-1)+fibonacci(n-2);
}
int main(){
  int n,i;
  for(i=0;i<50;i++) a[i]=-1;
  scanf("%d",&n);
  printf("%d\n",fibonacci(n));
  return 0;
}

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

int main(){
  double r;
  double syuu,menseki;
  
  cin >> r;
  
  syuu = 2*3.141592653589*r;
  menseki = r*r*3.141592653589;

  cout <<fixed<<setprecision(6)<<menseki <<" "<< syuu <<endl;
  
  return 0;
}

Measured memory_bytes: 3264
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)


int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int ans = a+b+c;
    int mx = max({a,b,c});
    
    for (int i = 0; i < k;i++){
        mx *= 2;
    }
    cout << ans-max({a,b,c}) +mx << endl;

    

   return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
ll n,p,a[N];
ll C(ll n,ll m)
{
	ll res=1;
	for(ll i=1;i<=m;i++)
	{
		res=res*(n-m+i);
		res/=i;
	}
	return res;
}
int main()
{
	while(cin>>n>>p)
	{
		ll x,ans=0,even=0,odd=0;
		for(int i=1;i<=n;i++)
		{
			cin>>x;
			if(x%2)
				odd++;
			else
				even++; 
		} 
		for(int i=0;i<=even;i++)
		{
			for(int j=0;j<=odd;j++)
			{
				if(j%2==p%2)
				{
					ans+=C(even,i)*C(odd,j);	
					
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n, m, k = map(int, input().split())
a_m, b_m = [], []
c_k, d_k = [], []
def minus(x):
    return int(x)-1

friends_list = [[] for i in range(n)]
block_list = [[] for i in range(n)]
for i in range(m):
    a_m.append(0)
    b_m.append(0)
    a_m[i], b_m[i] = map(minus, input().split())
    friends_list[a_m[i]].append(b_m[i])
    friends_list[b_m[i]].append(a_m[i])
for i in range(k):
    c_k.append(0)
    d_k.append(0)
    c_k[i], d_k[i] = map(minus, input().split())
    block_list[c_k[i]].append(d_k[i])
    block_list[d_k[i]].append(c_k[i])

# どのグループに属しているかを返す
def find(x):
    if parents[x] < 0:
        return x
    else:
        parents[x] = find(parents[x])
        return parents[x]

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

def union_size(x):
    return -parents[find(x)]

def blocks_in_union(x):
    count = 0
    for block in block_list[x]:
        if find(x) == find(block):
            count += 1
    return count

parents =[ -1 for i in range(n)]
for i in range(m):
    unite(a_m[i], b_m[i])
for i in range(n):
    print(union_size(i)-1-len(friends_list[i])-blocks_in_union(i), end=' ')


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

int main()
{
	long long n;
	cin >> n;
	long long k = 0;
	for (long long i = ceil(sqrt(n)); i > 0; i--) {
		if (n % i == 0) {
			k = (i + (n / i) - 2);
			break;
		}
	}

	cout << k << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
using namespace std;
int n,k,l,v;
int ua[200005],on[200005],an[200005];
vector <int> ro[200005],ra[200005];
map <pair<int,int>,int> ma;
void dfs1(int x){
	ua[x]=true;
	on[x]=v;
	for (int i=0;i<ro[x].size();i++){
		if (!ua[ro[x][i]]){
			dfs1(ro[x][i]);
		}
	}
}
void dfs3(int x){
	ua[x]=true;
	an[x]=v;
	for (int i=0;i<ra[x].size();i++){
		if (!ua[ra[x][i]]){
			dfs3(ra[x][i]);
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>k>>l;
	for (int i=0;i<k;i++){
		int p,q;
		cin>>p>>q;
		ro[p].push_back(q);
		ro[q].push_back(p);  
	}
	for (int i=0;i<l;i++){
		int p,q;
		cin>>p>>q;
		ra[p].push_back(q);
		ra[q].push_back(p);  
	}
	v=1;
	for (int i=1;i<=n;i++){
		if (!ua[i]){
			dfs1(i);
			v++;
		}
	}
	for (int i=1;i<=n;i++){
		ua[i]=false;
	}
	v=1;
	for (int i=1;i<=n;i++){
		if (!ua[i]){
			dfs3(i);
			v++;
		}
	}
	for (int i=1;i<=n;i++){
		ma[mp(on[i],an[i])]++;
	}
	for (int i=1;i<=n;i++) cout<<ma[mp(on[i],an[i])]<<' ';
	return 0;
}

Measured memory_bytes: 28672
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 2248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;

const int MAXN = 5e3+3; //AREGLAAAAAAAAR!!!!

int main(){
	int n,a;
	rii(n,a);
	int ans=n/500;
	n=n%500;
	if(n>a) printf("No\n");
	else printf("Yes\n");

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int data[10][7]={{0,1,1,1,1,1,1},{0,0,0,0,1,1,0},
		   {1,0,1,1,0,1,1},{1,0,0,1,1,1,1},
		   {1,1,0,0,1,1,0},{1,1,0,1,1,0,1},
		   {1,1,1,1,1,0,1},{0,1,0,0,1,1,1},
		   {1,1,1,1,1,1,1},{1,1,0,1,1,1,1}};

  while(1){
    int n,no,set[7]={0};
    cin >> n;
    if(n==-1)break;
    while(n--){
      cin >> no;
      for(int i=0,flg=0;i<7;i++,flg=0){
	if(!data[no][i]&&set[i]==1)set[i]--,flg=1;
	if(data[no][i]&&set[i]==0)set[i]++,flg=1;
	cout << (flg?1:0);
      }
      cout << endl;
    }
  }
}

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

using namespace std;
using ll = long long;

void solve() {
    int k;
    cin >> k;
    ll res = 0;
    for (int i = 1; i <= k; ++i) {
        for (int j = 1; j <= k; ++j) {
            int g = __gcd(i, j);
            for (int l = 1; l <= k; ++l) {
                res += __gcd(g, l);
            }
        }
    }
    cout << res;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);

    solve();
}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static List<int>[] li;
	static bool[] b;
	static int t=0;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		li=new List<int>[s[0]+1];
		b=new bool[s[0]+1];
		int f=0,x=0,f1=0,f2=0;
		for(int i=1;i<=s[0];i++){li[i]=new List<int>();}
		for(int i=0;i<s[1];i++){
			int[] q=sc.Ia;
			li[q[0]].Add(q[1]);
			li[q[1]].Add(q[0]);
		}
		string ans="Yes";
		for(int i=1;i<=s[0];i++){
			if(li[i].Count%2==1){ans="No";break;}
			if(li[i].Count==4){
				if(f==0){f1=i;}
				else{f2=i;}
				f++;
			}
			if(li[i].Count>=6){x++;}
		}
		if(x==0&&f<2){ans="No";}
		else if(x==0&&f==2){
			b[f1]=true;
			Fu(f1,f2);
			if(t!=2){ans="No";}
		}
		Console.WriteLine("{0}",ans);
	}
	static void Fu(int a,int g){
		if(a==g){t++;return;}
		b[a]=true;
		for(int i=0;i<li[a].Count;i++){
			if(!b[li[a][i]]){Fu(li[a][i],g);}
		}
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 29452
# from itertools import combinations
def Sum(A, n): 
    array_sum = 0
    for i in range(0, n, 1): 
        array_sum = array_sum + A[i] 
    array_sum_square = array_sum * array_sum 
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += A[i] * A[i] 
    return (array_sum_square -individual_square_sum) // 2
n=int(input())
a=[int(i) for i in input().split()]
print(Sum(a,n)%(10**9+7))
    

Measured memory_bytes: 31372
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n,t=map(int,input().split())
d1=[[0]*t for i in range(n+1)]
d2=[[0]*t for i in range(n+1)]

ab=[list(map(int,input().split())) for _ in range(n)]

for i in range(1,n+1):
    a=ab[i-1][0]
    b=ab[i-1][1]
    for j in range(t):
        if j<a:
            d1[i][j]=d1[i-1][j]
        else:
            d1[i][j]=max(d1[i][j],d1[i-1][j],d1[i-1][j-a]+b)
    a,b=ab[n-i]
    for j in range(t):
        if j<a:
            d2[n-i][j]=d2[n-i+1][j]
        else:
            d2[n-i][j]=max(d2[n-i][j],d2[n-i+1][j],d2[n-i+1][j-a]+b)
ans=0
for i in range(1,n+1):
    b=ab[i-1][1]
    for j in range(t):
        ans=max(ans,b+d1[i-1][j]+d2[i][t-1-j])
print(ans)

Measured memory_bytes: 217576
#include<iostream>
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int res=10000005;
	for(int st=0;st<=1;st++)
	{
	    int val=st;
	    int count=0;
	    for(int i=0;i<s.size();i++)
	    {
	        if(s[i]-'0'!=val)count++;
	        val=1-val;
	    }
	    res=min(res,count);
	}
		cout<<res<<endl;
	return 0;

}

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

int main(){
	int a, b;
	cin >> a >> b;
	
	int k;
	bool f = true;
	
	if( (a +b)%2 == 0) cout << (a + b) /2 << endl;
	else cout << "IMPOSSIBLE" << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int sum = 0;
        int i=0;
        while(sum<X){
            i++;
            sum += i;
        }
        System.out.println(i);
    }
}


Measured memory_bytes: 24020
#include <iostream>
#include <string>
#include <cstring>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
using namespace std;
int main(){
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int ans=0;
    if(x>=y){
        if(a+b>=c*2)ans+=c*2*y;
        else ans+=(a+b)*y;
        if(a>=c*2)ans+=c*2*(x-y);
        else ans+=a*(x-y);
    }else{
        if(a+b>c*2)ans+=c*2*x;
        else ans+=(a+b)*x;
        if(b>c*2)ans+=c*2*(y-x);
        else ans+=b*(y-x);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct node{
  int key;
  node *left,*right,*p;
  node(){}
  node(int key):key(key){left=right=p=NULL;};
};
node *root;
void insert(node z){
  node *y=NULL;
  node *x=root;
  while(x!=NULL){
    y=x;
    if(z.key<x->key) x=x->left;
    else x=x->right;
  }
  z.p=y;
  if(y==NULL) root=new node(z);
  else if(z.key<y->key) y->left=new node(z);
  else y->right=new node(z);
}
bool find(int z){
  node *x=root;
  while(x!=NULL){
    if(z==x->key) return true;
    if(z<x->key) x=x->left;
    else x=x->right;
  }
  return false;
}
void inorderTreeWalk(node *v){
  if(v==NULL) return;
  inorderTreeWalk(v->left);
  cout<<" "<<v->key;
  inorderTreeWalk(v->right);
}
void preorderTreeWalk(node *v){
  if(v==NULL) return;
  cout<<" "<<v->key;
  preorderTreeWalk(v->left);
  preorderTreeWalk(v->right);
}
signed main(){
  int n;
  cin>>n;
  root=NULL;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    //cout<<(root==NULL?-1:root->key)<<endl;
    if(s=="print"){
      inorderTreeWalk(root);
      cout<<endl;
      preorderTreeWalk(root);
      cout<<endl;
      continue;
    }
    int x;
    cin>>x;
    if(s=="insert"){
      insert(node(x));
    }
    if(s=="find"){
      cout<<(find(x)?"yes":"no")<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 21836
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int n, a;

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

    if(n % 500 <= a) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

ll A, V;
ll B, W;
ll T;

void solve()
{
	ll dist = abs(A-B);
	if(V <= W) cout << "NO\n";
	else{
		ll v = V-W;
		if(v*T >= dist){
			cout << "YES\n";
		}else{
			cout << "NO\n";
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> A >> V >> B >> W >> T;
	solve();
	return 0;
}

Measured memory_bytes: 3656
import sys
from collections import OrderedDict
input = sys.stdin.buffer.readline

n, m = [int(i) for i in input().split()]
links = OrderedDict()
ans = 0

for i in range(m):
    line = [int(i) for i in input().split()]
    links[i] = line[1:]

conditions = [int(i) for i in input().split()]

switchs = [0] * (n + 1)  # 0:off,1:on
states = [0] * m

for i in range(2**n):
    for j in range(n):
        if (i >> j) & 1:
            switchs[j] = 0
        else:
            switchs[j] = 1
    for i in range(m):
        link = links[i]
        _tmp = 0
        for x in link:
            _tmp += switchs[x - 1]
        if conditions[i] == _tmp % 2:
            states[i] = 1
        else:
            states[i] = 0
    if sum(states) == m:
        ans += 1

print(ans)


Measured memory_bytes: 74696
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int n, d, x, a[100]; cin >> n >> d >> x;
  REP(i, n) {
    cin >> a[i];
    int day = 1;
    while(day <= d){
      x++;
      day += a[i];
    }
  }
  cout << x << endl;

  return 0;
}

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    int n,m;
    cin >> n >> m;
    map<int,int> M;

    FOR(i,0,n){
        int t;
        cin >> t;

        while(t--){
            int x;
            cin >> x;
            M[x]++;
        }
    }

    int res=0;

    FORN(i,1,m){
        if(M[i]==n){
            res++;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		String t = sc.next();
		String is = null;
		if(t.matches(s + "[a-z]")) {
			is = "Yes";
		}
		else {
			is = "No";
		}
		System.out.println(is);
	}
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>x;
	cout<<(1000-x%1000)%1000<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
using namespace std;

bool cmp(int a, int b){
    return a > b;
}
int x, y, a, b, c;
const int maxn = 1e5 + 5;
int p[maxn], q[maxn], r[maxn];

int main(){
    cin >> x >> y >> a >> b >> c; 
    for(int i = 1;i <= a;i++){
        scanf("%d", &p[i]);
    }
    sort(p + 1, p + 1 + a, cmp);
    for(int i = 1;i <= b;i++){
        scanf("%d", &q[i]);
    }
    sort(q + 1, q + 1 + b, cmp);
    for(int i = 1;i <= c;i++){
        scanf("%d", &r[i]);
    }
    sort(r + 1, r + 1 + c, cmp);
    int pre = max(0, x - c);
    long long sum = 0;
    for(int i = 1;i <= pre;i++){
        sum += p[i];
    }
    for(int i = pre + 1;i <= x;i++){
        sum += r[i - pre];
    }
    int need = (x - pre);
    int left = c - need;
    for(int i = 1;i <= y;i++){
        sum += q[i];
    }
    priority_queue<int, vector<int>, greater<int> > pq;
    for(int i = 1;i <= y;i++){
        pq.push(q[i]);
    }
    for(int i = need + 1;i <= c;i++){
        sum += r[i];
        pq.push(r[i]);
        sum -= pq.top();
        pq.pop();
    }
    long long ans = sum;
    for(int i = pre + 1;i <= x;i++){
        sum += p[i];
        pq.push(r[x + 1 - i]);
        sum -= pq.top();
        pq.pop();
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


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

int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (; isdigit(c); c = getchar())
		x = x * 10 + c - 48;
	return x * f;
}
int h1, h2, m1, m2, k, ans;
int main() {
	h1 = read(); m1 = read(); h2 = read(); m2 = read(); k = read();
	int h = h2 - h1, m = m2 - m1;
	ans = h * 60 + m - k;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	cout << fixed << setprecision(6);
	double D[4] = {}, x[100], y[100];
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> y[i];
	}
	for (int i = 0; i < n; i++) {
		D[1] += fabs(x[i] - y[i]);
	}
	for (int i = 0; i < n; i++) {
		D[2] += fabs(x[i] - y[i])*fabs(x[i] - y[i]);
	}
	D[2] = sqrt(D[2]);
	for (int i = 0; i < n; i++) {
		D[3] += fabs(x[i] - y[i])*fabs(x[i] - y[i])*fabs(x[i] - y[i]);
	}
	D[3] = pow(D[3], 1. / 3);
	for (int i = 0; i < n; i++) {
		D[0] = max(D[0], fabs(x[i] - y[i]));
	}
	cout << D[1] << endl;
	cout << D[2] << endl;
	cout << D[3] << endl;
	cout << D[0] << endl;
	return 0;
}

Measured memory_bytes: 1332
import sys
A=range(10)
for n in map(int,sys.stdin):
  x=0
  for a in A:
    d=n-a
    if 0>d or d>27:continue
    for b in A:
      e=d-b
      if 0>e or e>18:continue
      for c in A:
        if (e-c)in A:x+=1
  print x

Measured memory_bytes: 4208
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin>>s;
  int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
  if(a-b-c-d==7){
    cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
  }
  else if(a-b-c+d==7){
    cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
  }
  else if(a-b+c-d==7){
    cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
  }
  else if(a-b+c+d==7){
    cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
  }
  else if(a+b-c-d==7){
     cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
  }
  else if(a+b+c-d==7){
    cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
  }
  else if(a+b-c+d==7){
    cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
  }
  else if(a+b+c+d==7){
     cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;;
  }
  return 0;
}


Measured memory_bytes: 256
n,m = gets.split.map(&:to_i)
a = Array.new(n+2,0)
m.times do
    l,r = gets.split.map(&:to_i)
    a[l] += 1
    a[r+1] -= 1
end
(0..n).each do |i|
    a[i+1] += a[i]
end
puts a.count(m)

Measured memory_bytes: 2556
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll N,C,K,t;cin>>N>>C>>K;
    ll bus = 0,next = 0, ans = 0;
    vector<ll> v(N);
    REP(i,N) cin>>v[i];
    sort(v.begin(),v.end());
    REP(i,N){
        t = v[i];
        if(bus==0){
            next = t + K;
            ++bus;
        } else if(next < t || bus==C){
            next = t + K;
            ++ans; bus = 1;
        } else {
            ++bus;
        }
    }
    if(bus) ++ans;

    cout << ans << '\n';
    return 0;
}

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

int main()
{
	int a,b,c,cnt=0,jud=0;
	cin>>a>>b>>c;
	a=a%b;
	for(int i=1; i<b; i++)
	{
		cnt=(a*i)%b;
		if(cnt==c){
			 cout<<"YES"<<endl;
			 jud=1;
			 break;
			}
	}
	if(jud==0)cout<<"NO"<<endl;
}


Measured memory_bytes: 256
/*
 * Problem Description: Graph I - Graph
 * Category: Graph
 * Author: Khan
 * Date: 18th October, 2017
 */

#include <iostream>
#include <cstring>
#include <algorithm>

#define MAXN 100

using namespace std;

int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
    int n, G[MAXN + 1][MAXN + 1], t;
    memset(G, 0, sizeof(G));
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> t >> t;
        int tmp;
        for (int j = 0; j < t; ++j)
        {
            cin >> tmp;
            G[i + 1][tmp] = 1;
        }
    }
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            if(j != 0)
                cout << " ";
            cout << G[i + 1][j + 1];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define rgi register int
#define ll long long
class fastin{
	private: int _ch,_f;
	public: inline fastin& operator>>(char&c) {c=getchar(); return *this;}
		template<typename _Tp> inline fastin& operator>>(_Tp&_x){
		_x=0; while(!isdigit(_ch)) _f|=(_ch==45),_ch=getchar();
		while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
		_f&&(_x=-_x,_f=0); return *this;}
	fastin() {_ch=_f=0;}
}fin;
class fastout{
#define endl '\n'
	private: int _num[32],_head;
	public: inline fastout& operator<<(char c) {putchar(c); return *this;}
		template<typename _Tp> inline fastout& operator<<(_Tp _x){
		_Tp _k; if(_x==0) {putchar('0'); return *this;} if(_x<0) putchar('-'),_x=-_x;
		while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
		while(_head>0) putchar(_num[_head]),--_head; return *this;}
	fastout() {_head=0;}
}fout;
// ----------------------------
// #define int ll
// using namespace std;
const int maxn=200004;
const int mod=998244353,inf=1000000007;

std::string ans;
signed main()
{
	ll n;
	fin>>n;
	for(ll i=1;n>=i;i*=26) n-=i,ans.push_back('a');
	for(rgi i=ans.size()-1;i>=0&&n;--i)
	{
		// fout<<n<<endl;
		ans[i]=char(n%26+'a');
		n/=26;
	}
	std::cout<<ans;
	return 0;
}
// ----------------------------
// by imzzy


Measured memory_bytes: 3632
import itertools
from pprint import pprint


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

plist=[]
clist=[]

bonus_masterlist=[]

for _ in range(d):
    p_temp,c_temp = map(int,input().split())
    plist.append(p_temp)
    clist.append(c_temp)


bonus_masterlist = list(itertools.product(range(2), repeat=d))
#bit全探索をやらなくても、itertoolsを使えば一瞬でできちゃう。(タプルのリスト)
#for i in range(2**d):
#    bonus_templist = [0] * d
#    for j in range(d):
#        if i >> j & 1:
#            bonus_templist[d-1-j] = 1
#    bonus_masterlist.append(bonus_templist)

#point_list = [100,200,300, ... ,d*100]
#max_list: plist = [p[0],p[1],p[2], ... ,p[d]]
#bonuspoint_list: clist = [c[0],c[1],c[2], ... ,c[d]]

count_list = [0] * d

mincount = 100 * 10

"""
def dfs(i):
    global mincount
    if sum([count_list[i] * 100*(i+1) for i in range(d)]) + sum([bonus_list[j] * clist[j] for j in range(d)]) >= g:
        if sum(count_list) < mincount:
            mincount = sum(count_list)
    elif plist[i] == count_list[i]:
        bonus_list[i] = 1
        dfs(i-1)
    elif plist[i] > count_list[i]:
        count_list[i] += 1
        dfs(i)
    return
"""

for bonus_tuple in bonus_masterlist:
    bonus_list = list(bonus_tuple)
    count_list = [x * y for (x, y) in zip(bonus_list, plist)]
    i = d-1
    while True:
        if sum([count_list[i] * 100*(i+1) for i in range(d)]) + sum([bonus_list[j] * clist[j] for j in range(d)]) >= g:
            if sum(count_list) < mincount:
                mincount = sum(count_list)
            break
        elif plist[i] == count_list[i]:
            bonus_list[i] = 1
            i -= 1
            continue
        elif plist[i] > count_list[i]:
            count_list[i] += 1
            continue


print(mincount)

Measured memory_bytes: 44248
def show(nums):
    for i in range(len(nums)):
        if i != len(nums) - 1:
            print(nums[i], end = ' ')
        else:
            print(nums[i])

n = int(input())
nums = list(map(int,input().split()))
show(nums)

for i in range(1,n):
        v = nums[i]
        j = i - 1
        while (j >= 0 and nums[j] > v):
            nums[j+1] = nums[j]
            j -= 1
        nums[j+1]=v

        show(nums)
        



Measured memory_bytes: 5980
#include<bits/stdc++.h>
using namespace std;
int ar[105];
int cur=10000;
int main(){
  	int n;cin>>n;for(int i=1;i<=n;i++)cin>>ar[i];int ans=0;
  	for(int i=1;i<=n;i++){
    	if(ar[i+1]==ar[i]){
        	ar[i+1]=cur--;ans++;
        }
    }
  	cout<<ans;
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long
#define db double
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T &a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T &a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T a) { return 1ll * a * a; }
template <class T> void compress(T &a){
  sort(all(a)); a.resize(unique(all(a)) - a.begin());  
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 1e9;
const int MOD = 1e9+7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

const int N = 2e5+1;
int n, a[N], b[N];

int main()
{
  fastio;
  int n; cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
  sort(a + 1, a + 1 + n); sort(b + 1, b + 1 + n);
  if (n & 1){
    int m = (n + 1) / 2;
    cout << b[m] - a[m] + 1;
  }
  else {
    int u = n / 2;
    int v = n / 2 + 1;
    cout << b[u] + b[v] - a[u] - a[v] + 1;
  }
  return 0;
}

Measured memory_bytes: 5176
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif


#define INF (1e+9)
int main(void) {
    int num;
    cin >> num;
    int signs = 0;
    int mmin = INF+1;
    int64_t sum = 0;
    for(int i = 0; i < num; i++) {
        int val;
        cin >> val;
        if(val < 0) signs++;
        val = abs(val);
        mmin = min(val, mmin);
        sum += val;
    }

    if(signs%2 == 0) {
        cout << sum << endl;
    } else {
        sum -= 2*mmin;
        cout << sum << endl;
    }
    return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    ll X, K, D;
    cin>>X>>K>>D;

    ll use = min(K, abs(X)/D);

    
    if (X > 0) {
	X -= use*D;
    } else if (X < 0) {
	X += use*D;
    }
    K -= use;
    K %= 2;


    if (K) {
	if (X > 0) {
	    X -= D;
	} else {
	    X += D;
	}
    }

    cout<<abs(X)<<endl;
    
    
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s;
        cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int n;
    scanf("%d",&n);

    int a[1000100]={};
    int ans=0;
    a[n]=1;
    ans++;
    while(true){
        if(a[n]==2){
            break;
        }
        if(n%2==0){
            n/=2;
            a[n]++;
            ans++;
        }else{
            n=n*3+1;
            a[n]++;
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}
 
 


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

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

    //freopen("in.txt", "r", stdin);
    long long n;
    set<string>st;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        st.insert(s);
    }
    cout<<st.size()<<"\n";
    return 0;
}


Measured memory_bytes: 19216
import java.io.PrintWriter

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val k = readInteger()
    val s = readLine()!!
    val ans = if (s.length <= k) {
        s
    } else {
        s.take(k) + "..."
    }
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 36032
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================

signed main() {
	ll n;
	cin >> n;
	VL a(n + 1), b(n);
	cin >> a >> b;

	ll ans = 0;
	REP(i, n) {
		ans += std::min(a[i], b[i]);
		b[i] -= std::min(a[i], b[i]);
		ans += std::min(a[i + 1], b[i]);
		a[i+1]-= std::min(a[i + 1], b[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false
	

int main() {
	int N;
	string S;
	cin >> N >> S;
	
	int x, ans;
	x = ans = 0;
	for (int i = 0; i < S.size(); i++) {
		x += (S[i] == 'I' ? 1 : -1);
		ans = max(ans, x);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

#define ARRAY_MAX 100005
#define MOD 1000000007


int main(){

    string s,t;
    cin >> s >> t;
    int maxi_index = 0;
    bool flag = false;
    if(s.length() < t.length()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    for(int i = 0;i <= s.length()-t.length();i++){
        //cout << i << endl;
        bool exist = true;
        if(s[i] == t[0] || s[i] == '?'){
            //先頭文字と一致したら
            //cout << i << " a " << endl;
            for(int j = i;j < i+t.length();j++){
                //cout << j << " b " << endl;
                if(s[j] != t[j-i]){
                    //一致しない
                    if(s[j] != '?'){
                        exist = false;
                        break;
                    }
                }
            }
            if(exist){
                maxi_index = max(maxi_index,i);
                flag = true;
            }
        }
    }

    if(flag){
        for(int i = maxi_index;i < maxi_index+t.length();i++){
            s[i] = t[i-maxi_index];
        }
        REP(i,s.length()){
            if(s[i] == '?'){
                s[i] = 'a';
            }
        }
        cout << s << endl;
    }else{
        cout << "UNRESTORABLE" << endl;
    }
  



    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int n,h[100],i,j=0,max=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&h[i]);
  }

  for(i=0;i<n;i++){
    if(h[i]>=max){
      j++;
      max=h[i];
    }
  }
  printf("%d\n",j);

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


int main(){
  int n;
    
  cin>>n;
  vector<int> t(n);
  rep(i,n)cin>>t[i];
  int m;
  cin>>m;
  vector<int> p(m),x(m);
  rep(i,m)cin>>p[i]>>x[i];
  long long sum=0;
  rep(i,n){
    sum+=t[i];
  }
  rep(i,m){
    
   cout<<sum-t[p[i]-1]+x[i]<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005

int n,x,y,v[100005];

ll mod=1e9+7,dp[100005][2];

vector <int> g[100005];

void DFS(int nod){
    v[nod]=1;
    dp[nod][0]=dp[nod][1]=1;
    for(int i : g[nod]){
        if(!v[i]){
            DFS(i);
            dp[nod][0]*=(dp[i][0]+dp[i][1]); dp[nod][0]%=mod;
            dp[nod][1]*=dp[i][0]; dp[nod][1]%=mod;
        }
    }
}

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    for(int i=1;i<n;i++){
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }
    DFS(1);
    cout << (dp[1][0]+dp[1][1])%mod;
}


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

typedef long long ll;

int main(){
	//Code here bby
  int n;
  cin>>n;
  map<ll, int> freq;
  int idx = 0;
  ll sum = 0;
  while(idx < n){
    ll elem;
    cin>>elem;
    if(freq.count(elem)){
      freq[elem]++;
    } else {
      freq[elem] = 1;
    }
    sum += elem;
    idx++;
  }
  int q;
  cin>>q;
  while(q--){
    ll a, b;
    cin>>a>>b;
    ll dif = b - a;
    sum += dif * (freq[a]);
    freq[b] += freq[a];
    freq[a] = 0;
    cout<<sum<<endl;
  }
}


Measured memory_bytes: 9472
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define DB double
#define SG string
#define LL long long
#define Fp(A,B,C,D) for(A=B;A<=C;A+=D)
#define Fm(A,B,C,D) for(A=B;A>=C;A-=D)
#define Clear(A) memset(A,0,sizeof(A))
using namespace std;
const LL Mod=1e9+7;
const LL Max=3e5+5;
const LL Inf=1e18;
char CH[Max];
LL N,Ans=Inf,A[Max],B[Max];
inline LL Read(){
	LL X=0;char CH=getchar();bool F=0;
	while(CH>'9'||CH<'0'){if(CH=='-')F=1;CH=getchar();}
	while(CH>='0'&&CH<='9'){X=(X<<1)+(X<<3)+CH-'0';CH=getchar();}
	return F?-X:X;
}
inline void Write(LL X){
	if(X<0)X=-X,putchar('-');
	if(X>9)Write(X/10);
	putchar(X%10+48);
}
int main(){
	LL I,J,K;
	N=Read();scanf("%s",CH+1);
	Fp(I,1,N,1){
		A[I]=A[I-1];
		B[I]=B[I-1];
		if(CH[I]=='E'){
			A[I]++;
		} else {
			B[I]++;
		}
	}
	Fp(I,1,N,1){
		LL Cnt=0;
		if(CH[I]=='E'){
			Cnt=B[I-1]+(A[N]-A[I]);
		} else {
			Cnt=B[I-1]+(A[N]-A[I]);
		}Ans=min(Ans,Cnt);
	}Write(Ans);
	return 0;
}

Measured memory_bytes: 5248