akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	n*=2;
	vector <int> A(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>A[i];
	}
	sort(A.begin(), A.end());
	int ans = 0;
	for (int i = 0; i < n; i+=2)
	{
		ans+=A[i];
	}
	cout<<ans<<"\n";
	return 0;
}

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

using namespace std;

#define int long long

using vint = vector<int>;

const int inf = 1LL<<55;

int V, E, K;
vector<vint> A;

vector<vint> calc(int m) {
  vector<vint> B = A;
  vector<vint> res(V, vint(V, -inf));
  for(int i = 0; i < V; ++i) res[i][i] = 0;
  while(m > 0) {
    if(m&1) {
      vector<vint> tmp(V, vint(V, -inf));
      for(int i = 0; i < V; ++i) tmp[i][i] = 0;
      for(int k = 0; k < V; ++k) {
	for(int i = 0; i < V; ++i) {
	  for(int j = 0; j < V; ++j) {
	    tmp[i][j] = max(tmp[i][j], res[i][k]+B[k][j]);
	  }
	}
      }
      res = tmp;
    }
    vector<vint> tmp(V, vint(V, -inf));
    for(int i = 0; i < V; ++i) tmp[i][i] = 0;
    for(int k = 0; k < V; ++k) {
      for(int i = 0; i < V; ++i) {
	for(int j = 0; j < V; ++j) {
	  tmp[i][j] = max(tmp[i][j], B[i][k]+B[k][j]);
	}
      }
    }
    B = tmp;
    m >>= 1;
  }
  return res;
}


int check(int m) {
  vector<vint> B = calc(m);
  int res = 0;
  for(int i = 0; i < V; ++i) {
    for(int j = 0; j < V; ++j) {
      res = max(res, B[i][j]);
    }
  }
  return res;
}

signed main() {
  cin >> V >> E >> K;
  A.resize(V, vint(V, -inf));
  for(int i = 0; i < V; ++i) A[i][i] = 0;
  for(int i = 0; i < E; ++i) {
    int u, v, c;
    cin >> u >> v >> c;
    A[u][v] = max(A[u][v], c);
  }
  int lb = -1, ub = 1111111;
  while(lb+1 < ub) {
    int mb = (lb+ub)/2;
    if(check(mb) >= K) ub = mb;
    else lb = mb;
  }
  if(ub == 1111111) {
    cout << -1 << endl;
    return 0;
  }
  cout << ub << endl;
  int ans = check(ub);
  if(ub <= 100) {
    vector<vint> rev(ub+1, vint(V, -1));
    vector<vint> dp(ub+1, vint(V, 0));
    for(int i = 0; i < ub; ++i) {
      for(int j = 0; j < V; ++j) {
	for(int k = 0; k < V; ++k) {
	  if(dp[i+1][k] < dp[i][j]+A[j][k]) {
	    dp[i+1][k] = dp[i][j]+A[j][k];
	    rev[i+1][k] = j;
	  }
	}
      }
    }
    int idx = -1;
    for(int i = 0; i < V && idx == -1; ++i) {
      if(ans == dp[ub][i]) idx = i;
    }
    vint vec;
    for(int l = ub; l >= 0; --l) {
      vec.push_back(idx);
      idx = rev[l][idx];
    }
    reverse(vec.begin(), vec.end());
    for(int i = 0; i < (int)vec.size(); ++i) {
      cout << vec[i] << " \n"[i==(int)vec.size()-1];
    }
  }


  return 0;
}



Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int number; cin >> number;
  int a = number/1000, b = (number-a*1000)/100, c = (number-a*1000-b*100)/10, d = number%10;
  
  for (int tmp = 0; tmp < (1 << 3); tmp++) {
    bitset<3> s(tmp);
    int sum = a;
    
    if(s.test(0)){
      sum += b;
    }
    else{
      sum -= b;
    }
    if(s.test(1)){
      sum += c;
    }
    else{
      sum -= c;
    }
    if(s.test(2)){
      sum += d;
    }
    else{
      sum -= d;
    }
    
    if(sum == 7){
      
      cout << a;
      if(s.test(0)){
        cout << "+";
      }
      else{
        cout << "-";
      }
      cout << b;
      if(s.test(1)){
        cout << "+";
      }
      else{
        cout << "-";
      }
      cout << c;
      if(s.test(2)){
        cout << "+";
      }
      else{
        cout << "-";
      }
      cout << d << "=7" << endl;
      break;
    }
  }  
}

Measured memory_bytes: 256
// ref: https://drken1215.hatenablog.com/entry/2019/04/27/224100_1

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int64 gcd(int64 a, int64 b){
    if(b==0){ return a; }
    return gcd(b, a%b);
}

int64 gcd_range(vector<int> vA, int l, int r){
    int64 ret=vA[l];
    for(int i=l+1; i<r; ++i){
        ret = gcd(vA[i], ret);
    }
    return ret;
}

int64 max(int64 l, int64 r){ return (r>=l ? r:l); }

int main(){
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    
    int N; cin >> N;
    vector<int> vA(N); for(int i=0; i<N; ++i){ cin >> vA[i]; }
    
    vector<int> vL(N+1, 0); for(int i=0; i< N; ++i){ vL[i+1] = gcd(vL[i], vA[i  ]); }
    vector<int> vR(N+1, 0); for(int i=N; i>=1; --i){ vR[i-1] = gcd(vR[i], vA[i-1]); }
    
    int ret = 0;
    for(int i=0; i<N; ++i){
        ret = max(ret, gcd(vL[i], vR[i+1]));
    }
    
    cout << ret << endl;
    
    return 0;
}


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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> a(n); rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());

	queue<int> p, m;
	p.push(a[n - 1]); m.push(a[0]);
	int ans = a[n - 1] - a[0];
	for (int i = 1; i < n - 1; ++i) {
		if (a[i] >= 0) {
			p.push(a[i]);
			ans += a[i];
		} else {
			m.push(a[i]);
			ans -= a[i];
		}
	}

	printf("%d\n", ans);

	if (p.size() == 1) {
		printf("%d %d\n", p.front(), m.front());
		int d = p.front() - m.front();
		p.pop(), m.pop();
		while (not m.empty()) {
			printf("%d %d\n", d, m.front());
			d -= m.front();
			m.pop();
		}
		assert(d == ans);
		return 0;
	}

	int d = m.front() - p.front();
	printf("%d %d\n", m.front(), p.front());
	m.pop(); p.pop();

	while (p.size() > 1) {
		printf("%d %d\n", d, p.front());
		d = d - p.front(); p.pop();
	}

	assert(p.size() == 1);

	if (m.size() >= 1) {
		int d2 = p.front() - m.front();
		printf("%d %d\n", p.front(), m.front());
		p.pop(); m.pop();
		while (m.size() > 0) {
			printf("%d %d\n", d2, m.front());
			d2 = d2 - m.front(); m.pop();
		}
		printf("%d %d\n", d2, d);
		assert(d2 - d == ans);
	} else {
		printf("%d %d\n", p.front(), d);
		assert(p.front() - d == ans);
	}
	return 0;
}


Measured memory_bytes: 2688
def cal(S):
    N = len(S)
    num,cnt = 0,0
    mod = 2019
    rem = [0 for _ in range(mod)]
    for i in range(N):
        num = (num + int(S[N-1-i]) * pow(10,i,mod)) % mod
        rem[num] += 1

    output = rem[0] * (rem[0] + 1) // 2
    for i in range(1,mod):
        output += rem[i] * (rem[i]-1) // 2

    return output

def main():
    S = input()

    print(cal(S))

if __name__ == "__main__":
    main()


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

int main(){

int c;
cin>>c;
string tarou, hanako;
int tarou_p=0,hanako_p=0,size_s;
int flag;
for( int i=0;i<c;i++){

    cin>>tarou>>hanako;
    if(tarou.size()<hanako.size()){
        size_s=tarou.size();
        flag=0;
    }else{
        size_s=hanako.size();
        flag=1;
    }
    for(int j=0;j<size_s;j++){
        if(tarou[j]>hanako[j]){
            tarou_p+=3;
            break;
        }else if(tarou[j]<hanako[j]){
            hanako_p+=3;
            break;
        }
        if(j==size_s-1 && tarou.size()==hanako.size()){
            tarou_p++;
            hanako_p++; 
        }else if(j==size_s-1){
            if(flag==0){
                hanako_p+=3;
            }else if(flag==1){
                tarou_p+=3;
            }
        }   
    }
    /*cout<<tarou_p<<" "<<hanako_p<<endl;*/
}
cout<<tarou_p<<" "<<hanako_p<<endl;
    return 0;
}


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

using namespace std;

#define __unique(a) sort(a.begin(), a.end()); a.resize(distance(a.begin(), unique(a.begin(), a.end())));
#define foreach(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define FOR(i, a, b) for(int i = a, _b = (b) ; i <= _b ; i++)
#define FORD(i, a, b) for(int i = a, _b = (b) ; i >= _b ; i--)

typedef long long int64;

const int MAXV = 1e5 + 10; 
const int inf = 1e9 + 7; 
vector<int> tree[MAXV]; 
int n, nPainted;
vector <int> painted; 
int a[MAXV];
int dad[MAXV];
int lo[MAXV], hi[MAXV];
int dist[MAXV];  
bool success = true;

void dfs (int x, int parent) {
	dad[x] = parent; 
	foreach (y, tree[x]) {
		if (*y == parent) continue; 
		dfs(*y, x);
	}
}

bool maximize (int &a, int b) { if (a < b) a = b; else return false; return true; }
bool minimize (int &a, int b) { if (a > b) a = b; else return false; return true; }
void bfs () {
	queue <int> q; 
	for (int i = 0; i < painted.size(); i++) q.push(painted[i]);
	int Time = 0; 
	while (not q.empty()) {
		//Time++; 
		//if (Time == 1000000) break; 
		int x = q.front(); q.pop();
		foreach (y, tree[x]) {
			if (lo[*y] == -inf) { /// chua duoc tinh
				lo[*y] = max(lo[*y], lo[x] - 1);
				hi[*y] = min(hi[*y], hi[x] + 1);
				q.push(*y);
			}
			else {
				if (lo[*y] % 2 == lo[x] % 2) {
					success = false;
					return; 
				}
				if (hi[x] + 1 < lo[*y] || hi[*y] < lo[x] - 1) {
					success = false; 
					return; 
				}
				bool changed = false; 
				if (maximize(lo[*y], lo[x] - 1)) changed = true; 
				if (minimize(hi[*y], hi[x] + 1)) changed = true;

				if (changed) q.push(*y);
			}
		}
	}
}

void paint () {
	queue <int> q; 
	for (int x = 1; x <= n; x++) {
		if (lo[x] == hi[x]) q.push(x);
	}
	while (not q.empty()) {
		int x = q.front(); q.pop();
		foreach (y, tree[x]) {
			if (lo[*y] == hi[*y]) {
				if (lo[*y] != lo[x] + 1 && lo[*y] != lo[x] - 1) {
					success = false; 
					return; 
				} 
				continue; 
			}
			if (lo[x] + 1 >= lo[*y] && lo[x] + 1 <= hi[*y]) {
				lo[*y] = lo[x] + 1;
				hi[*y] = lo[x] + 1;
				q.push(*y);  
			} else if (lo[x] - 1 >= lo[*y] && lo[x] - 1 <= hi[*y]) {
				lo[*y] = lo[x] - 1; 
				hi[*y] = lo[x] - 1;
				q.push(*y); 
			} else  {
				success = false; 
				return; 
			}

		}
	}
}

int main() {
    #define file "E2"
    //freopen(file".INP","r",stdin); freopen(file".OUT","w", stdout);
    ios :: sync_with_stdio(false);
    cin >> n; 
    for (int i = 1; i < n; i++) {
    	int x, y; 
    	cin >> x >> y; 
    	tree[x].push_back(y);
    	tree[y].push_back(x);
    }
    for (int x = 1; x <= n; x++) lo[x] = -inf, hi[x] = inf; 
    cin >> nPainted;
    for (int i = 1; i <= nPainted; i++) {
    	int vertex, value; 
    	cin >> vertex >> value;
    	painted.push_back(vertex);
    	a[vertex] = value;
    	lo[vertex] = value; 
    	hi[vertex] = value;  
    } 
    dfs(1, 0);
    //cout << "success = " << success << endl; 
    bfs();
    paint();
    if (success) {
    	cout << "Yes" << endl;
    	for (int x = 1; x <= n; x++) {
    		cout << lo[x] << '\n';
    	}
    } else {
    	cout << "No" << endl; 
    } 
    return 0; 	
}

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;
using pci = pair<char, int>;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int n; cin >> n;
	string s; cin >> s;
	int r[4005], g[4005], b[4005];
	int rcnt = 0, gcnt = 0, bcnt = 0;
	for(int i=0;i<n;i++){
		r[i] = rcnt;
		g[i] = gcnt;
		b[i] = bcnt;
		if(s[i]=='R') rcnt++;
		if(s[i]=='G') gcnt++;
		if(s[i]=='B') bcnt++;
	}
	r[n] = rcnt;
	g[n] = gcnt;
	b[n] = bcnt;

	ll ans =0LL;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if((s[i]=='R' && s[j]=='G') || (s[i]=='G' && s[j]=='R')){
				ans += b[n]-b[j+1];
				if(s[2*j-i]=='B') ans--;
			}
			if((s[i]=='G' && s[j]=='B') || (s[i]=='B' && s[j]=='G')){
				ans += r[n]-r[j+1];
				if(s[2*j-i]=='R') ans--;
			}
			if((s[i]=='B' && s[j]=='R') || (s[i]=='R' && s[j]=='B')){
				ans += g[n]-g[j+1];
				if(s[2*j-i]=='G') ans--;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=2019;

int main(){
    int N; cin >> N;
    cout << (1000-N%1000)%1000 << endl;
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  int a,N=0;
  a=S.size();
  // ここにプログラムを追記
  if(a%2==0){
    for (int i = 0; i < a/2; i++){
      if(S.at(i)!=S.at(a-i-1)) N++;
    }
  }else{
    for (int i = 0; i < (a-1)/2; i++){
      if(S.at(i)!=S.at(a-i-1)) N++;
    }
  }
  
  cout << N << endl; 
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<l_l> ba(n);
    rep(i,n){
        ll a,b;
        cin >> a >> b;
        ba[i] = make_pair(b,a);
    }
    sort(ba.begin(), ba.end());
    ll time = 0;
    rep(i,n){
        time += ba[i].second;
        if(time > ba[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 6404
def myAnswer(N:int,K:int,P:list) ->  int:
   ans =[]
   for p in P:
      tmp =(p+1)/2
      ans.append(tmp)
   # print(ans)
   accum = [sum(ans[:K])]
   for i in range(K,N,1):
      accum.append(accum[-1]-ans[i - K]+ans[i])
   # print(accum)
   return max(accum)

def modelAnswer():
   return
def main():
   N,K = map(int,input().split())
   P = list(map(int,input().split()))
   print(myAnswer(N,K,P[:]))
if __name__ == '__main__':
   main()

Measured memory_bytes: 25060
import heapq
n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)
for i in range(m):
  min = heapq.heappop(a)
  heapq.heappush(a, (-min//2)*(-1))
print(-sum(a))

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

using namespace std;

typedef long long ll;

vector<ll> a;

bool solve(ll i, ll index) {
  if (i == 0) {
    return true;
  }

  if (i < 0) {
    return false;
  }

  if (a.size() == index) {
    return false;
  }

  return solve(i - a[index], index + 1) || solve(i, index + 1);
}

int main() {
  ll n;
  cin >> n;
  while(n--) {
    ll i;
    cin >> i;
    a.push_back(i);
  }

  ll q;
  cin >> q;
  while(q--) {
    ll i;
    cin >> i;
    cout << (solve(i, 0) ? "yes" : "no") << endl;
  }

  return 0;
}



Measured memory_bytes: 3168
#include <iostream>
using namespace std;
int main(void){
    int a,h,w,cnt=0;
    
    cin>>a>>h>>w;
    int H[a],W[a];
    
    for(int i=0;i<a;i++){
        cin>>H[i]>>W[i];
        if(H[i]>=h&&W[i]>=w){
            cnt+=1;
        }
    }
    
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {
	
	public static HashMap<String,String> map = new HashMap<>();


	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int w = sc.nextInt();
		System.out.println(w * 32);
	}
}

Measured memory_bytes: 26200
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        System.out.println(execute(sc.nextLine()));

    }

    public static String execute(String input) {
        String[] charArray = input.split("");
        StringBuilder sb = new StringBuilder();
        for(String chara : charArray){
            if(sb.length() != 0 && chara.equals("B")){
                sb.deleteCharAt(sb.length() - 1);
            }
            else if(chara.equals("0") || chara.equals("1")){
                sb.append(chara);
            }
        }

        return sb.toString();
    }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define ld long double
int main() {
    int n;
    cin>>n;
    ld t,a;
    cin>>t>>a;
    ld ans =1000000000000;  int p=-1;
    for(int i=0;i<n;i++){
        ld x;
        cin>>x;
        ld tmp=t-x*0.006;
        if(abs(a-tmp) < ans ){
            ans=abs(a-tmp);
            p=i;
        }
    }
    cout<<p+1;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		// a + b + 2 sqrt(a * b) < c
		// 2 sqrt(a * b) < c - a - b
		boolean f = true;
		if(c - a - b < 0){
			f = false;
		}else{
			// 4 * a * b < d * d
			long d = c - a - b;
			if(4 * a * b < d * d){
				f = true;
			}else{
				f = false;
			}
		}
		if(f){
			System.out.println("Yes");			
		}else{
			System.out.println("No");						
		}
	}
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define int long long
#define D double
#define inf 123456789
#define mod 1000000007
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
#define rep(i , a , b) for(int i = (a) , i##Limit = (b) ; i <= i##Limit ; ++ i)
#define drep(i , b , a) for(int i = (a) , i##Limit = (b) ; i >= i##Limit ; -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define lb(x) (x)&(-(x))
#define ls k * 2
#define rs k * 2 + 1
#define maxn 100005
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) { int r = 1; while(b) { if(b & 1) r = Mul(r, a); a = Mul(a, a), b >>= 1; } return r; }
int n, m, sum;
map<int, int>a;
il int f(int x) {
	if(x == 1) return 1;
	return f(x / 2) * 2 + 1;
}
signed main() {
	n = read();
	printf("%lld", f(n));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

int main(){
  int a,b,c,x;
  int cnt=0;
  cin >> a >> b>>c>>x;
  LOOP(i,a+1){
    LOOP(j,b+1){
      int m = x - 500*i - 100*j;
      if(m <= c*50 && m>=0){
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: C - Minimization
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  printf("%d\n", (n - 1 + (k - 2)) / (k - 1));
  return 0;
}


Measured memory_bytes: 256
package main

import (
    "fmt"
)

func main() {
    var n int64
    var c int64
    c=0  
    fmt.Scan(&n)
    if n%2==1 {
        fmt.Print(c)
    }else{
        n = n/10
        c = c+n
        for n/5>0 {
            n = n/5
            c = c+n
        }
        fmt.Print(c)
    }    
}

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

int main() {
  int n; // ボールの個数
  int k; // ロボットBのx座標
  cin >> n >> k;
  // 各ボールのx座標
  vector<int> ball_x;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
  	ball_x.push_back(x);
  }
  
  // 最小距離を求め、合計していく
  int total_min_distance = 0;
  for (int i = 0; i < n; i++) {
  	int d_a = ball_x[i] * 2;
    int d_b = (k - ball_x[i]) * 2;
    total_min_distance += (d_a <= d_b) ? d_a : d_b;
  }
  
  cout << total_min_distance << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	char huruf;
	scanf("%c",&huruf);
	huruf >='A'&&huruf<='Z' ? printf("A\n") : printf("a\n");
//	if (huruf >='A' && huruf <='Z'){
//		printf("A\n");
//	}
//	else{
//		printf("a");
//	}
//	return 0;
}

Measured memory_bytes: 1512
#include<bits/stdc++.h>
#define rep(i, n) for (int i =1; i <= (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;

int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int main(){
   int sum=0;
   int k;cin>>k;
   rep(i,k){
     rep(j,k){
       rep(l,k){
         sum+=gcd(i,gcd(j,l));
       }
     }

   }
   
   cout << sum;
   return 0;
}

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

using namespace std;

#define endl '\n'
#define int long long
#define mod 1000000007

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

int dp[101][100001];

int knapsack(vector<int>& wt, vector<int>& val,int index,int weight) {
	if(index<0 || weight == 0) return 0;

	if(dp[index][weight]) return dp[index][weight];

	if(wt[index]<=weight) {
		dp[index][weight] = max(val[index] + knapsack(wt, val, index-1, weight-wt[index]) , knapsack(wt, val, index-1, weight));
		return dp[index][weight];
	}

	dp[index][weight] = knapsack(wt, val, index-1, weight);

	return dp[index][weight];
}

int32_t main() {

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	// input the size of the array and the weight of the knapsack
	int n, W;
	cin>>n>>W;

	// input the wt array and the value array
	vector<int> wt(n);
	vector<int> val(n);

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

	// run a recursive solution
	int maxValue = knapsack(wt, val, n-1, W);

	// return the max value
	cout<<maxValue;

    return 0;
}

Measured memory_bytes: 75072
#include<cstdio>
#include<algorithm>
using namespace std;
#define LL long long
long long N,Ans=1e18;
int main(){
	scanf("%lld",&N);Ans=N-1;
	for(LL i=1;i*i<=N;i++)
		if(N%i==0)Ans=min(Ans,(i-1)+(N/i-1));
	printf("%lld\n",Ans);
}


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

int main(void) {
  int N, K;
  cin >> N >> K;
  vector<long long> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }

  vector<long long> dp(N, 1e18);
  dp[0] = 0LL;
  for (int i = 0; i < N; i++) {
    for (int k = 1; k <= K; k++) {
      if (i + k >= N) break;
      dp[i + k] = min(dp[i + k], dp[i] + abs(h[i + k] - h[i]));
    }
  }
  cout << dp[N - 1] << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXN = 123456;
int a[MAXN];

int main() {
    int n;
    while (~scanf("%d", &n)) {
          for (int i = 0; i < n; i++) {
              scanf("%d", &a[i]);
          }
          sort(a, a + n);
          vector<int> line;
          for (int i = 0; i < n; i++) {
              int tmp = a[i];
              if (a[i] > (a[n - 1] / 2)) tmp = a[n - 1] - a[i];
              line.push_back(tmp);
          }
          sort(line.begin(), line.end());
          int cur = line[n - 1];
          for (int i = 0; i < n - 1; i++) {
              if (a[i] == (a[n - 1] - cur)) cur = a[i];
          }
          printf("%d %d\n", a[n - 1], cur);
    }
    return 0;
}


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

using namespace std;

int main(void){
    int N;
    string S;
    cin >> N;
    cin >> S;
    int ans = N;
    vector<int> w(N + 1, 0), b(N + 1, 0);
    for(int i = 0; i < N; i++){
        if(S[i] == '.'){
            w[i + 1] = w[i] + 1;
            b[i + 1] = b[i];
        }else{
            w[i + 1] = w[i];
            b[i + 1] = b[i] + 1;
        }
    }
    for(int i = 0; i <= N; i++){
        ans = min(w[N] - w[i] + b[i] - b[0], ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2180
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
#include<stdio.h>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    long long N;
    cin >> N;
    long long A[N+1];
    long long B[N];
    REP(i,N+1) cin >> A[i];
    REP(i,N) cin >> B[i];
    long long res=0,num=0;
    for(int i=0;i<N;++i){
        if(B[i]>=A[i]){
            B[i]-=A[i];
            num+=A[i];
            A[i]=0;
            if(B[i]>0){
                if(B[i]>=A[i+1]){
                    B[i]=0;
                    num+=A[i+1];
                    A[i+1]=0;
                }
                else{
                    A[i+1]-=B[i];
                    num+=B[i];
                }
            }
        }
        else{
            num+=B[i];
            A[i]-=B[i];
        }
    }
    cout << num;
    }

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

const ll N=2e3+10;
vec a(N);
ll c[N];
ll n,k,q;

ll check(ll l, ll r) {
  ll p=-1,s=0;
  for(ll i=0;i<=n;i++) {
    if(a[i]<c[l]) {
      ll t=0;
      for(ll j=p+1;j<i;j++) {
        if(a[j]<=c[r]) t++;
      }
      s+=max(0LL,min(t,i-p-k));
      p=i;
    }
  }
  return s>=q;
}

int main() {
  cin >> n >> k >> q;
  for(ll i=0;i<n;i++) {
    cin >> a[i];
    c[i]=a[i];
  }
  sort(c,c+n);
  ll ans=inf;
  for(ll i=0,j=0;i<n;i++) {
    while(j<n&&!check(i,j)) j++;
    if(j<n) ans=min(ans,c[j]-c[i]); 
  }
  cout << ans << endl;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
int N, M;
	cin >> N >> M;
	map<int, int> K;
	fx(M) {
		int m;
		cin >> m;
		K[m] = 1;
	}
	int S[110000];
	fx(N + 1) {
		S[x] = 0;
	}
	S[0] = 1;
	fyg(N+1,1) {
		if (K[y] == 1) { continue; }
		if (y == 1) {
			S[y] = S[y - 1];
		}
		else {
			S[y] = S[y - 1] + S[y - 2];
		}
		S[y] %= MOD;
	}
	ce(S[N])
    return 0;
}



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


int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int alice = 0, bob = 0;
    rep(i, N){
        if (i % 2 == 0){
            alice += a[i];
        }
        else{
            bob += a[i];
        }
    }
    cout << alice - bob << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

type p struct{ r, c int }

func (con *contest) main() error {
	var H, W, N int
	con.scan(&H, &W, &N)
	M := map[p]int{}
	for i := 0; i < N; i++ {
		var a, b int
		con.scan(&a, &b)
		for r := a - 3; r < a; r++ {
			if r < 0 || r > H-3 {
				continue
			}
			for c := b - 3; c < b; c++ {
				if c < 0 || c > W-3 {
					continue
				}
				M[p{r, c}]++
			}
		}
	}
	A := make([]int, 10)
	for _, v := range M {
		A[v]++
	}
	A[0] = (H-2)*(W-2) - len(M)
	for _, a := range A {
		con.println(a)
	}
	return nil
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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; }

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

// ------------------------------------------------------------------------------------------

signed main() {
  string s;
  cin >> s;

  int n = s.size();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= n; j++) {
      string t = "";
      for (int k = 0; k < n; k++) {
        if (i < k && k <= j) {
          continue;
        } else {
          t.push_back(s[k]);
        }
      }
      if (t == "keyence") {
        puts("YES");
        return 0;
      }
    }
  }

  puts("NO");

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<int> cards(n);
	long long raccoon = 0;
	for (int i = 0; i < n; ++i) {
		cin >> cards[i];
		raccoon += cards[i];
	}

	long long snuke = cards[0];
	raccoon -= snuke;
	long long min_diff = abs(snuke - raccoon);
	for (int i = 1; i < n - 1; ++i) {
		raccoon -= cards[i];
		snuke += cards[i];
		min_diff = min(min_diff, abs(snuke - raccoon));
	}

	cout << min_diff << "\n";

	return 0;

}

Measured memory_bytes: 1024
//not correct
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<int>;
using vec2 = vector<vector<int>>;
int main(){
    int m, a, b, c, d, sum;
    bool ans = true;
    string op1, op2, op3;
    cin >> m;
    a = m/1000;
    b = m/100 - a*10;
    c = m/10 - a*100 - b*10;
    d = m - a*1000 - b*100 - c*10;
        //10は回したいとおりの数、100はビットの数を入れる
    for (int tmp = 0; tmp < (1 << 3); tmp++) {
        bitset<3> s(tmp);
        // (ビット列sに対する処理)
       sum = a;
       if(s.test(0)){
            sum += b;
            op1 = "+";
        }else{
            sum -= b;
            op1 = "-";
        }
        if(s.test(1)){
            sum += c;
            op2 = "+";
        }else{
            sum -= c;
            op2 = "-";
        }
        if(s.test(2)){
            sum += d;
            op3 = "+";
        }else{
            sum -= d;
            op3 = "-";
        }
        if(sum == 7){
            cout << a << op1 << b << op2 << c << op3 << d << "=7" << endl;
            break;
        }
    }

}

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

const long long INF = 1LL<<60;

string s, t;
int dp[3100][3100] = {0};

int main() {
  cin >> s >> t;
  
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < t.size(); j++) {
      if (s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
      dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i + 1][j + 1]);
      dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j + 1]);
    }
  }

  string ans = "";
  int x = (int)s.size();
  int y = (int)t.size();
  while (x > 0 && y > 0) {
    if (dp[x][y] == dp[x - 1][y]) x--;
    else if (dp[x][y] == dp[x][y - 1]) y--;
    else {
      ans = s[x - 1] + ans;
      x--;
      y--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 37120
#include<stdio.h>
int main(void)
{
  int n;
  char hina[4]={'P','W','G','Y'};
  int count[4]={0};
  char s[128];
  scanf("%d",&n);
  for(int i=0;i<n*2;i++){
    char c;
    scanf("%c",&c);
    for(int i=0;i<4;i++){
      if(c==hina[i]){
        count[i]++;
      }
    }
  }

  int result=0;
  for(int i=0;i<4;i++){
    if(count[i]>0){
      result++;
    }
  }
  switch(result){
    case 3:
    puts("Three");
    break;

    case 4:
    puts("Four");
    break;
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

int main()
{
    int n[3], k;
    std::cin >> n[0] >> n[1] >> n[2] >> k;
    for (int i = 0; (i < k); ++i) {
        std::sort(n, n+3);
        n[2] *= 2;
    }
    std::cout << (n[0] + n[1] + n[2]) << std::endl;
    return 0;
}


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

char field[3][4];

char solve(){
	for(int i=0; i<3; i++){
		if(field[i][0] == field[i][1] && field[i][1] == field[i][2] && (field[i][0] == 'w' || field[i][0] == 'b'))
			return field[i][0];
	}
	for(int k=0; k<3; k++){
		if(field[0][k] == field[1][k] && field[1][k] == field[2][k] && (field[0][k] == 'w' || field[0][k] == 'b'))
			return field[0][k];
	}
	if(field[0][0] == field[1][1] && field[1][1] == field[2][2] && (field[0][0] == 'w' || field[0][0] == 'b'))
		return field[0][0];
	if(field[0][2] == field[1][1] && field[1][1] == field[2][0] && (field[0][2] == 'w' || field[0][2] == 'b'))
		return field[0][2];
	return 'N';
}

int main(){
	while(true){
		for(int i=0; i<3; i++){
			cin >> field[i];
			if(field[0][0] == '0')
				return 0;
		}
		char ans = solve();
		if(ans == 'N')
			cout << "NA\n";
		else
			cout << ans << endl;
	}
}

Measured memory_bytes: 0
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        Console.ReadLine();
        var h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int ans = 0;
        while (h.Sum() > 0)
        {
            int max = h.Max();
            var search = Enumerable.Repeat(false, h.Length).ToArray();
            for (int i = 0; i < h.Length; i++)
            {
                if (h[i] == max) search[i] = true;
            }
            int L = 0, R = search.Count() - 1;
            bool searched = false;
            for (int i = 0; i < search.Length; i++)
            {
                if (search[i] == true && !searched)
                {
                    L = i;
                    for (int j = i; j < search.Length; j++)
                    {
                        if (search[j] == false)
                        {
                            R = j - 1;
                            break;
                        }
                    }
                    searched = true;
                }
            }
            var list = new List<int>();
            list.Add(max);
            if (L != 0) list.Add(h[L - 1]);
            if (R != search.Count() - 1) list.Add(h[R + 1]);
            int cut = list[0];
            if (list.Count() == 2) cut = list[0] - list[1];
            else if (list.Count() == 3) cut = max - list.OrderBy(f => f).ToList()[1];
            for (int i = L; i <= R; i++) h[i] -= cut;
            ans += cut;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13396
import java.util.Scanner

object Main {
  def solve(A: Int, B: Int) = {
    import math.max
    max(max(A + B, A - B), A * B)
  }

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    println(solve(sc.nextInt(), sc.nextInt()))
  }
}


Measured memory_bytes: 25780
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int R, G;
  cin >> R >> G;
  
  cout << 2*G -R << endl;
  // ここにプログラムを追記
  
  //高橋君は, 現在のレーティングがRで, 次のコンテストでレーティングをちょうどG
  //にしたいと思っています。そのとき, 高橋君が取るべきパフォーマンスを求めなさい。


}

Measured memory_bytes: 256
n,m=list(map(int,input().split()))
a=[False]*100001
for i in range(m):
    a[int(input())]=True

ans=[0]*100001
ans[0]=1
if a[1]:
    ans[1]=0
else:
    ans[1]=1

for i in range(2,n+1):
    if a[i]:
        ans[i]=0
    else:
        ans[i]=ans[i-1]+ans[i-2]
print(ans[n]%1000000007)

Measured memory_bytes: 460788
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.replace(/\n$/,"")).split("\n");
while(true){
   var n=Arr.shift()-0;
   if(n===0)break;
   var ans=[];
   for(var I=0;I<n;I++){
      var arr=(Arr.shift()).split(" ");
      var name=arr.shift()-0;
      arr=arr.map(Number);
      var score=[0,0,0,0,0,0,0,0,0,0];
      var bonus=[];
      var ab=0;
      var now=0;
      for(var i=0;i<arr.length;i++){ 
         var v=arr[i];
         score[now]+=v;
         if(bonus.indexOf("b1")!=-1)bonus[bonus.indexOf("b1")]=v;
         if(bonus.indexOf("b1")!=-1)bonus[bonus.indexOf("b1")]=v;
         if(bonus.indexOf("b2")!=-1)bonus[bonus.indexOf("b2")]="b1";      
         if(now==9)continue;
         if(v==10){
            if(ab==0){bonus.push("b1");bonus.push("b2");}
            if(ab==1)bonus.push("b1");
            now++;
            ab=0;
         }else if(ab==1){
            if(score[now]==10)bonus.push("b1");
            now++;
            ab=0;
         }else if(ab==0){
            ab=1;
         }
      }
      score=score.concat(bonus);
      var sum=score.reduce(function(a,b){return a+b;});
      ans.push([name,sum]);
   }
   ans.sort(function(a,b){
      if(a[1]==b[1])return a[0]-b[0];
      else return b[1]-a[1];
   });
   ans.forEach(function(v){console.log(v[0]+" "+v[1]);});
}

Measured memory_bytes: 10092
N = int(input())
List = list()
for i in range(N):
  List.append(list(map(int, input().split())))
List = sum(List, [])
for i in range(1,N-1):
  if List[2*i-2] == List[2*i-1]:
    if List[2*i] == List[2*i+1]:
      if List[2*i+2] == List[2*i+3]:
        print("Yes")
        exit()
      else:
        pass
    else:
      pass
  else:
    pass
print("No")

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> res(n, 0);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (i % 2) res[0] -= a[i];
        else res[0] += a[i];
    }

    for (int i = 1; i < n; ++i) {
        res[i] = -res[i-1] + a[i-1] * 2;
    }
    for (int i = 0; i < n; ++i) {
        if (i < n-1) cout << res[i] << " ";
        else cout << res[i] << endl;
    }
}

Measured memory_bytes: 4748
#include <algorithm>
#include <cassert>
#include <functional>
#include <iostream>
#include <vector>

typedef long long ll;

using namespace std;

const int kN = 200;
int matr[kN][kN];
int a[kN * kN];
int h, w;

int main() {
  std::ios_base::sync_with_stdio(false);
  cin >> h >> w;
  int n; cin >> n;
  for (int i = 0; i < n; ++i) { cin >> a[i]; }
  a[n] = 100;
  int ind = 0;
  int rev = 0;
  for (int row = 0; row < h; ++row) {
    if (!rev) {
      for (int col = 0; col < w; ++col) {
        while (a[ind] == 0) { ++ind; }
        matr[row][col] = ind + 1;
        --a[ind];
      }
    } else {
      for (int col = w - 1; col >= 0; --col) {
        while (a[ind] == 0) { ++ind; }
        matr[row][col] = ind + 1;
        --a[ind];
      }
    }
    rev ^= 1;
  }
  for (int row = 0; row < h; ++row) {
    for (int col = 0; col < w; ++col) {
      cout << matr[row][col] << ' ';
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

P solve(Int a, Int b, Int A, Int B){
  //A * x > a && B * x >= b
  //A * x >= a && B * x > b
  //x > a / A && x >= b / B
  //x >= a / A && x > b / B
  Int x = max((a - 1) / A + 1, (b - 1) / B + 1);
  return P(A * x, B * x);
}


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);


  Int N;
  cin>>N;
  Int a = 0, b = 0;
  while(N--){
    Int A, B;
    cin>>A>>B;
    tie(a, b) = solve(a, b, A, B);
    pr(a, b);
  }

  Int ans = a + b;
  if(ans == 0) ans = 2;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256