akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline int gcd(int a, int b) { while(a) swap(a, b%=a); return b; }


#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}

int loadvec(vector<int>& v, int N=-1) {
    if (N == 0) {
        v.clear();
        return 0;
    }
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    return i;
}
void read_cr() {
    fgets(_buf, 256, stdin);
}


template <typename T>
vector<T> divisors(T x){
    vector<T> res;
    T sq = sqrt(x);
    for (int n=1; n<=sq; ++n){
        T q = x / n, r = x % n;
        if (r) continue;
        res.push_back(n);
        if (q != n) res.push_back(q);
    }
    return move(res);
}

int solve(int N, vi& a) {
    set<int> candidates;
    vi a0_ = divisors(a[0]);
    candidates.insert(ALL(a0_));
    vi a1_ = divisors(a[1]);
    candidates.insert(ALL(a1_));

    priority_queue<int> pq;
    for (int n: candidates){
        int cnt = 0;
        for (int ai: a) {
            if (ai % n == 0) ++cnt;
        }
        if (cnt >= N-1) pq.push(n);
    }
    return pq.top();
}

int main() {
    vi a;
    int N = loadvec(a);
    cout << solve(N,a) << endl;
    return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
struct segtree{
private:
  int siz;
  vector<ll> node,lazy;
  ll seg_inf;
public:
  segtree(ll n){
    siz=1;
    while(siz<=n) siz*=2;
    node.resize(siz*2-1,0);
    lazy.resize(siz*2-1,0);
    seg_inf=17441744174417;
  }
  void eval(ll k){
    node[k]+=lazy[k];
    if(k<siz-1){
      lazy[2*k+1]+=lazy[k];
      lazy[2*k+2]+=lazy[k];
    }
    lazy[k]=0;
  }
  void plus(ll a,ll b,ll x,ll k,ll l,ll r){
    eval(k);
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      lazy[k]+=x;
      eval(k);
    }
    else{
      plus(a,b,x,2*k+1,l,(l+r)/2);
      plus(a,b,x,2*k+2,(l+r)/2,r);
      node[k]=min(node[2*k+1],node[2*k+2]);
    }
  }
  void add(ll a,ll b,ll x){
    plus(a,b,x,0,0,siz);
  }
  ll get_min(ll a,ll b,ll k,ll l,ll r){
    eval(k);
    if(r<=a||b<=l) return seg_inf;
    if(a<=l&&r<=b) return node[k];
    else return min(get_min(a,b,2*k+1,l,(l+r)/2),get_min(a,b,2*k+2,(l+r)/2,r));
  }
  ll min_q(ll s,ll t){
    return get_min(s,t,0,0,siz);
  }
  void debug(int f){
    if(f==0){
      cout<<"node:";
      for(int i=0;i<node.size();i++) cout<<node[i]<<" ";
    }
    else{
      cout<<"lazy:";
      for(int i=0;i<lazy.size();i++) cout<<lazy[i]<<" ";
    }
    cout<<endl;
  }
};
int main(){
  int n,q;
  cin>>n>>q;
  segtree seg=segtree(n);
  for(int i=0;i<q;i++){
    int f;
    cin>>f;
    if(f==0){
      int s,t; ll x;
      cin>>s>>t>>x;
      seg.add(s,t+1,x);
    }
    else{
      int s,t;
      cin>>s>>t;
      cout<<seg.min_q(s,t+1)<<endl;
    }
  }
}



Measured memory_bytes: 7060
# ABC100D - Patisserie ABC
def calc(func: "func") -> int:
    cakes = [func(x, y, z) for x, y, z in zip(*[iter(XYZ)] * 3)]
    cakes.sort(reverse=1)
    return max(sum(cakes[:M]), -sum(cakes[-M:]))


def main():
    global M, XYZ
    N, M, *XYZ = map(int, open(0).read().split())
    if M == 0:
        print(0)
        return
    ans = max(
        calc(lambda x, y, z: x + y + z),
        calc(lambda x, y, z: x + y - z),
        calc(lambda x, y, z: x - y + z),
        calc(lambda x, y, z: x - y - z),
    )
    print(ans)


if __name__ == "__main__":
    main()

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

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static int mod = 998244353;
	static long inf = (long) 1e18 + 1;
	static int[] col;
	static int n, m;
	static ArrayList<Integer>[] ad;
	static long[][][] memo;
	static HashSet<Integer> h;
	static int[] a;
	static Integer[][] g;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		HashMap<Integer, Integer> hm = new HashMap<>();
		long ans = 0;
		hm.put(0, 1);
		String s = sc.nextLine();
		int[] pos = new int[s.length() + 1];
		pos[0] = 1;
		for (int i = 1; i < s.length() + 1; i++)
			pos[i] = 10 * pos[i - 1] % 2019;
		int v=0;
		sb=new StringBuilder();
		sb.append(s);
		sb.reverse();
		int b=1;
		for (int i = 0; i < s.length(); i++) {
			v = (v+(Integer.parseInt(sb.charAt(i) + ""))*b) % 2019;
		//	System.out.println(v);
			ans += hm.getOrDefault(v, 0);
			hm.put(v, hm.getOrDefault(v, 0) + 1);
			b=b*10%2019;
		}
		System.out.println(ans);
		out.flush();
	}

	static long modPow(long a, long e)

	{
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res = (res * a) % mod;
			a = (a * a) % mod;
			e >>= 1;
		}
		return res;
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 55388
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if((a*b) % 2 == 1) cout<<"Odd"<<endl;
	else cout<<"Even"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  
  int N, K, x, ball, i, sum = 0;
  
  cin >> N >> K;
  
  for(i = 0; i < N; i++){
    cin >> ball;
    if(ball <= (K/2)){
      sum += ball*2;
    }else{
      if(ball < K){
        sum += (K - ball)*2;
      }else{
        sum += (ball - K)*2;
      }
    }
  }
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"

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

  IN(A); IN(B);

  if (B == 1)
    OUT(0);
  else {
    int ans = 1, n = A;
    while (n < B) {
      n += A-1;
      ++ans;
    }
    OUT(ans);
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <fstream>
#include <string>
using namespace std;
int main()
{
    int a,b,c;
    int flags=0;
    cin>>a>>b>>c;
    for(int i=0;i*a<=c;i++)
    {
        if(i*a>=b)
        {
            cout<<"OK";
            flags=1;
            return 0;
        }
    }
    if(flags==0)
        cout<<"NG";
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
//ノート　isupperで大文字の判定　islowerで小文字の判定
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int d,n;
    std::cin >> d>>n;
    if(n==100)n++;
    std::cout <<int( pow(100,d)*n )<< std::endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N;

bool pdp[55560];
vector<int> Prime(){
	vector<int> ret;
	for(int i = 2; i < 55560; i++){
		if(!pdp[i]){
    		if(i % 5 == 1) ret.push_back(i);
    		for(int j = i + i; j < 55560; j += i){
    			pdp[j] = true;
    		}
		}
	}
	return ret;
}

int main(void){
    
    scanf("%d", &N);
    auto p = Prime();
    for(int i = 0; i < N; ++i){
        if(i) printf(" %d", p[i]);
        else printf("%d", p[i]);
    }
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    string ans = "APPROVED";
    for (int i = 0; i < n; i++)
    {
        if(a[i] % 2 == 0 && (a[i] % 3 != 0 && a[i] % 5 != 0))
        {
            ans = "DENIED";
        }
    }
    
    cout << ans << endl;
}


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


void solve(long long N, std::vector<long long> H){

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;cin >> N;
    long long x,x_;cin >> x_;
    vector<pair<long long,long long>> p;

    pair<long long,long long> t = make_pair(0,0);
    for(int i=1;i < N;i++){
        cin >> x;
        if (x_ >= x) t.second ++;
        else{
            p.push_back(t);
            t = make_pair(i,0);
        }
        x_ = x;
    }
    p.push_back(t);
    pair<long long,long long> ans = p[0];
    for(int i=1;i<p.size();i++){
        if(p[i].second > ans.second) ans = p[i];
        else continue;
    }

    cout << ans.second << endl;
}


Measured memory_bytes: 2420
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8= {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	static int[][] directions4= {{-1,0},{1,0},{0,-1},{0,1}};
	static int ans;
	static int[] parent;//union-find用
	static int[] rank;//union-find用

	public static void main(String[] args) throws IOException {
		//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//		String W	 = in.readLine();
		//		int num = Integer.parseInt(W.split(" ")[0]);

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		int K = sc.nextInt();

		int tmpAns = 0;
		while(B <=A) {
			tmpAns++;
			B*=2;
		}
		while(C <=B) {
			tmpAns++;
			C*=2;
		}
		if(tmpAns > K) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}


	}

	//BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for(int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
		return b == 0 ? a: gcd(b, a % b);
	}

	//Union-Find用の配列を要素数nで初期化
	static void ufInit(int n){
		parent = new int[n];
		rank = new int[n];
	}

	//Union-Findの要素の最上位の親（グループ名）を返す
	static int ufFind(int a) {
		if(parent[a]==a) {
			return a;
		}else {
			return ufFind(parent[a]);
		}
	}

	//Union-Find木を連結する
	static void ufUnite(int a, int b) {
		a = parent[a];
		b = parent[b];

		if(a==b) {
			return;
		}
		if(rank[a] > rank[b]){
			parent[b]=a;
		}else {
			parent[a]=b;
			if(rank[a]==rank[b]) {
				rank[b]++;
			}
		}
	}

	static boolean ufSame(int a, int b) {
		return ufFind(a)==ufFind(b);
	}
}


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

using namespace std;


typedef long long ll;

const int M = 1e9+7 ;

const ll INF = 1e18 ;




int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N; 
    cin  >>  N;

    vector<vector<int>> A(N, vector<int>(2));

    for (int i = 0; i < N; ++i) {
        cin >> A[i][0] >> A[i][1];
    }

    auto comp = [&](vector<int>& a, vector<int>& b) {
        return a[0] + a[1] < b[0] + b[1];
    };

    sort(A.begin(), A.end(), comp);

    vector<vector<ll>> dp (N+1 , vector<ll> (N+1, INF)); 

    



    for(int i = 0 ; i <= N; ++i){

        dp[i][0] = 0 ;
    }

    for(int i = 1 ; i <= N; ++i){
        for(int j = 1 ; j <= i ; ++j ){
            dp[i][j] = dp[i-1][j]; 
            if (A[i-1][0] >= dp[i-1][j-1]){
                dp[i][j] = min(dp[i][j] , dp[i-1][j-1] + A[i-1][1]);
            }
        }
    }


    for(int j = N ;  j >= 0; --j){
        if (dp[N][j] != INF){
            cout <<  j << "\n"; 
            break; 
        }
    }

    



    
  
    return 0;
}



Measured memory_bytes: 196224
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

typedef struct POINT_tag{ double x, y;}POINT_t;
typedef struct LINE_tag{ POINT_t a, b;}LINE_t;

int side(POINT_t *p, LINE_t *e){
  POINT_t p1 = *p;
  POINT_t p2 = e->a;
  POINT_t p3 = e->b;

  const int n = p1.x * (p2.y - p3.y) + p2.x * (p3.y - p1.y) + p3.x * (p1.y - p2.y);
  if (n > 0) return 1;
  else if(n < 0) return -1;
  else return 0;
}

int main(){
  POINT_t a, b, c, d;
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y,&d.x,&d.y) != EOF){
    LINE_t ac, bd;
    ac.a = a; ac.b = c;
    bd.a = b; bd.b = d;
    if(side(&a, &bd) != side(&c, &bd) && side(&b, &ac) != side(&d, &ac)) puts("YES");
    else puts("NO");
  }
  return 0;
}

Measured memory_bytes: 1188
<?php
fscanf(STDIN,"%d %d %d",$H,$W,$N);
$ans = array(1 => 0,2 => 0,3 => 0,4 => 0,5 => 0,6 => 0,7 => 0,8 => 0,9 => 0);
$count = ($H - 2) * ($W - 2);
if($N >= 1){
$i = 1;
while($i <= $N){
fscanf(STDIN,"%d %d",$a,$b);
$j = -1;
while($j <= 1){
if($a + $j >= 2){
if($a + $j <= $H - 1){
$k = -1;
while($k <= 1){
if($b + $k >= 2){
if($b + $k <= $W - 1){
if(isset($map[$a + $j][$b + $k])){
++$map[$a + $j][$b + $k];
}else{
$map[$a + $j][$b + $k] = 1;
}
}
}
++$k;
}
}
}
++$j;
}
++$i;
}
foreach($map as $val){
foreach($val as $val2){
++$ans[$val2];
--$count;
}
}
}
echo $count , PHP_EOL , join(PHP_EOL,$ans);
?>

Measured memory_bytes: 219768
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <utility>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <set>
#include <chrono>
#include <climits>
#include <unordered_map>
#include <iomanip> 

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,st,end,inc) for(int i = st; i < end; i += inc)
#define repb(i,st,end,dec) for(int i = st; i >= end; i -= dec) 

#define MOD 1000000007

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;


int main(){
	fast;
	#ifdef LOCAL_PROJECT
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif

	auto start = high_resolution_clock::now(); 

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i = 0;i < n; i++)
		cin >> a[i];

	vector<int> dp(k+1, 0);
	for(int i = 1; i <= k; i++){
		for(int j = 0; j < n; j++){
			if (i - a[j] >= 0){
				if (dp[i-a[j]] == 0){
					dp[i] = 1;
					break;
				}
			}
		}
	}

	cout << ((dp[k] == 1)?"First":"Second") << "\n";

	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << fixed << setprecision(9) << double(duration.count()) / 1000000 << endl; 

	return 0;
}


Measured memory_bytes: 640
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

//const ll MOD = 998244353;
const ll MOD = 1e9+7;
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,sum=0,min=LLONG_MAX;
  std::cin>>n;
  bool isSame=true;
  rep(i,0,n){
    ll a,b;
    std::cin>>a>>b;
    sum+=a;
    if(a!=b){
      isSame=false;
      if(a>b){
        min=std::min(min,b);
      }
    }
  }

  if(isSame)std::cout<<0;
  else std::cout<<sum-min;

  return 0;
}

Measured memory_bytes: 256
min_ = -1000000
max_ =  1000000
k, x = input().split()
k, x = int(k), int(x)
ans = [x]

for i in range(1, k):
  l = x - i
  r = x + i
  if l >= min_:
    ans.insert(0, l)
  if r <= max_:
    ans.append(r)

for n in ans:
  print(n, end=' ')

Measured memory_bytes: 3064
/*
	12345
	1 2345
	12 345
	123 45
	1234 5
	1 2 345
	1 23 45
	1 234 5
	12 3 45
	12 34 5
	123 4 5
	1 2 3 45
	1 2 34 5
	1 23 4 5
	12 3 4 5
	1 2 3 4 5

	5: 1*16
	4: 10*8 1*8
	3: 100*4 10*4 1*8
	2: 1000*2 100*2 10*4 1*8
	1: 10000*1 1000*1 100*2 10*4 1*8
*/

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	s := getString()
	n := len(s)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		as[i], _ = strconv.Atoi(string(s[i]))
	}

	ans := 0
	ans += as[n-1] * (1 * pow(2, n-1))
	if n >= 2 {
		ans += as[n-2] * (1*pow(2, n-2) + 10*pow(2, n-2))
	}
	if n >= 3 {
		ans += as[n-3] * (1*pow(2, n-2) + 10*pow(2, n-3) + 100*pow(2, n-3))
	}
	if n >= 4 {
		ans += as[n-4] * (1*pow(2, n-2) + 10*pow(2, n-3) + 100*pow(2, n-4) + 1000*pow(2, n-4))
	}
	if n >= 5 {
		ans += as[n-5] * (1*pow(2, n-2) + 10*pow(2, n-3) + 100*pow(2, n-4) + 1000*pow(2, n-5) + 10000*pow(2, n-5))
	}
	if n >= 6 {
		ans += as[n-6] * (1*pow(2, n-2) + 10*pow(2, n-3) + 100*pow(2, n-4) + 1000*pow(2, n-5) + 10000*pow(2, n-6) + 100000*pow(2, n-6))
	}
	if n >= 7 {
		ans += as[n-7] * (1*pow(2, n-2) + 10*pow(2, n-3) + 100*pow(2, n-4) + 1000*pow(2, n-5) + 10000*pow(2, n-6) + 100000*pow(2, n-7) + 1000000*pow(2, n-7))
	}
	if n >= 8 {
		ans += as[n-8] * (1*pow(2, n-2) + 10*pow(2, n-3) + 100*pow(2, n-4) + 1000*pow(2, n-5) + 10000*pow(2, n-6) + 100000*pow(2, n-7) + 1000000*pow(2, n-8) + 10000000*pow(2, n-8))
	}
	if n >= 9 {
		ans += as[n-9] * (1*pow(2, n-2) + 10*pow(2, n-3) + 100*pow(2, n-4) + 1000*pow(2, n-5) + 10000*pow(2, n-6) + 100000*pow(2, n-7) + 1000000*pow(2, n-8) + 10000000*pow(2, n-9) + 100000000*pow(2, n-9))
	}
	if n == 10 {
		ans += as[n-10] * (1*pow(2, n-2) + 10*pow(2, n-3) + 100*pow(2, n-4) + 1000*pow(2, n-5) + 10000*pow(2, n-6) + 100000*pow(2, n-7) + 1000000*pow(2, n-8) + 10000000*pow(2, n-9) + 100000000*pow(2, n-10) + 1000000000*pow(2, n-10))
	}

	fmt.Println(ans)
}

func pow(a, b int) int {
	x := float64(a)
	y := float64(b)
	return int(math.Pow(x, y))
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
N = int(input())
X_ls = list(map(int, input().split(' ')))
rst = -1
for i in range(min(X_ls), max(X_ls) + 1):
    val = 0
    for j in X_ls:
        val += (i - j) ** 2
    if rst == -1:
        rst = val
    else:
        rst = min(rst, val)
print(rst)

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

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

    vector<char> A(4);
    for(int i = 0; i < 4; i++) cin >> A[i];

    for(int i = 0; i < (1 << 3); i++) {
        int x = A[0] - '0';
        vector<char> S;
        for(int j = 0; j < 3; j++) {
            if(i & (1 << j)) {
                x -= A[j + 1] - '0';
                S.push_back('-');
            } else {
                x += A[j + 1] - '0';
                S.push_back('+');
            }
        }
        if(x == 7) {
            cout << A[0];
            for(int j = 0; j < 3; j++) {
                cout << S[j] << A[j + 1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
}

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

def aa(s, n, t):
    if n == N:
        print(s)
        return
    for i in range(t):
        aa(s+chr(97+i), n+1, t)
    aa(s+chr(97+t), n+1, t+1)
    return


aa("a", 1, 1)

Measured memory_bytes: 9040
//ProblemD.cpp

#include <iostream>

static std::istream & ip = std::cin;
static std::ostream & op = std::cout;

#if OJ_MYPC
#include <ojio.h>
#endif

#ifndef OPENOJIO
#define OPENOJIO
#endif

#if 1 || DEFINE
/***************************************************************/
typedef unsigned long long u64;
typedef long long s64;

typedef unsigned uint;

#define ABS(x) ((x) > 0 ? (x) : -(x))

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define MIN3(x, y, z) MIN(x, MIN(y, z))
#define MAX3(x, y, z) MAX(x, MAX(y, z))

#define FillZero(arr) memset(arr, 0, sizeof(arr));

/***************************************************************/
#endif //1 || DEFINE

#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>

//001
//op << setfill('0') << setw(3) << setiosflags(ios::right) << 1;

//op << fixed << setprecision(20);

using namespace std;

//ProblemD.cpp

#define MAXN 100005
#define MAXRC 100005

#define MAXINT 0x7FFFFFFF
#define MININT 0x80000000

struct Near
{
	int nid;
	s64 sum;

	Near(int nid, int sum) : nid(nid), sum(sum) {}
};

int r, c, n;
vector<Near> nears[MAXRC * 2];
s64 x[MAXRC * 2];
bool vis[MAXRC * 2];

s64 xm, ym;

bool dfs(int id, s64 val) {
	if (vis[id]) {
		if (x[id] != val) return false;
		else return true;
	}

	vis[id] = true;
	x[id] = val;

	if (id >= r) ym = MIN(ym, val);
	else xm = MIN(xm, val);

	for (auto near : nears[id]) {
		if (!dfs(near.nid, near.sum - val))
			return false;
	}

	return true;
}

int main(int argc, char* argv[])
{
	OPENOJIO;

	ip >> r >> c >> n;

	for (int i = 1; i <= n; ++i) {
		int ri, ci, ai;
		ip >> ri >> ci >> ai;

		--ri; --ci;

		nears[ri].push_back(Near(ci + r, ai));
		nears[ci + r].push_back(Near(ri, ai));
	}

	bool rst = true;

	for (int i = 0; i < r + c; ++i) vis[i] = false;

	for (int i = 0; i < r + c; ++i) {
		if (vis[i]) continue;

		xm = MAXINT, ym = MAXINT;
		if (!dfs(i, 0) 
			|| xm + ym < 0) { rst = false; break; }
	}
	op << (rst ? "Yes" : "No") << endl;

	return 0;
}
/***************************************************************/


Measured memory_bytes: 15104
def main():
    N = int(input())
    d = [0 for _ in range(N)]
    r = 100
    ii = 0
    for i in range(1, r):
        ii += 2* i - 1
        for j in range(1, i + 1):
            s = i + j
            c = ii + s * j
            l = 6
            if i == j:
                l = 3
            if c + 1 + s > N:
                break
            for k in range(1, j + 1):
                c += 2* k - 1 + s
                if c <= N:
                    if j == k:
                        l = 3
                        if i == k:
                            l = 1
                    d[c - 1] += l
                else:
                    break
    print(*d, sep="\n")


if __name__ == "__main__":
    main()


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  int n;
  cin>>n;
  vector<ll> a(n);
  cin>>a;

  int now = 1;
  int ans = 0;
  rep(i,n){
    if(a[i]==now){
      now++;
    }
  }
  if(now==1)cout<<(-1)<<endl;
  else cout<<(n-now+1)<<endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REP1(i,n) for(int i=1; i<=(int)(n); i++)
#define SORT(v) sort(v.begin(), v.end())
#define REVERSE(v)  reverse(v.begin(), v.end())
using namespace std;

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

  int N,M,X,Y; cin>>N>>M>>X>>Y;
  vector<int> x(N); REP(i,N) cin>>x[i];
  vector<int> y(M); REP(i,M) cin>>y[i];

  SORT(x);
  SORT(y);

  int Z;
  if(x[N-1] < y[0]) Z = y[0];

  string ans = "War";
  while(Z > x[N-1]) {
    if(X < Z && Z <= Y) {
      ans = "No War";
      break;
    }
    Z--;
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <map>

#include <string.h>
#define inf 0x7fffffff
using namespace std;
//1232
int a,b,c,k,n,m,l[5200][5010],j[100010],o[100200],i,d,dx[10]={0,1,0,-1},dy[10]={1,0,-1,0};
long long x,y,z;
stack<int> s;
struct P
{
    int x;
    int y;
    bool operator<(const P &a)const
    {
        return y>a.y;
    }
};

 map<int, int> p;
queue<P> q;
priority_queue<int> q1;
string r,r1[110];
//char r[2000000],r1[5000000];
vector<P> v[5010];

bool sdf(int a,int b)
{
    if(l[a]!=l[b])
    return l[a]<l[b];
        else
        return l[a+c]<l[b+c];
}

//alohomora
int main()
{
    scanf("%d",&a);
    k=1;
    for(;(k*k+k)/2<a;k++);

    printf("%d",k);
    return 0;
}

Measured memory_bytes: 384
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int main()
{
	int n;
	cin>>n;
	if(n==25) puts("Christmas");else
	if(n==24) puts("Christmas Eve");else
	if(n==23) puts("Christmas Eve Eve");else
	puts("Christmas Eve Eve Eve");
	rt0;
}

Measured memory_bytes: 256
import math

n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
p_1, p_2, p_3, p_infinit = 0, 0, 0, 0
dis_list = []
for i in range(n):
    dis_list.append(abs(x[i] - y[i]))
    sum_d = abs(x[i] - y[i])
    p_1 += sum_d
    p_2 += sum_d ** 2
    p_3 += sum_d ** 3
p_2 = math.sqrt(p_2)
p_3 = p_3 ** (1 / 3)

print(p_1)
print(p_2)
print(p_3)
print(max(dis_list))


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

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

    string s;
    cin >> s;
    rep(qi, s.size()) cout << "x";
    cout << endl;
}


Measured memory_bytes: 256
s = input()
n = len(s)
ans = []

for i in range(2**(n-1)):
    test = ""
    num = str(bin(i))[2:].zfill(n-1)
    for j in range(n-1):
        test += s[j]
        if num[j] == '1':
            test += '+'
    test += s[-1]
    ans.append(eval(test))
print(sum(ans))

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>



int main(void)
{
    char i[1000];
    int count;
    int sum;
    while(1){
        count = 0;
        sum = 0;
        scanf("%s", i);
        if(i[0] == '0') break;
        do{
            sum += (int)i[count] - 48;
            //printf("%ld\n",i%10);
           count++;
            
        }while(i[count] != '\0');
        printf("%ld", sum);
        putchar('\n');
    }

    return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
   	#endif
    double a,b;
    cin>>a>>b;
    cout<<round((a+b)/2);
   	return 0;
}

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

#ifdef DEBUG
#include "debug.h"
#endif

using namespace std;

#define mp make_pair
#define mt make_tuple
#define all(a) (a).begin(), (a).end()
#define rep(i, a, b) for (int (i) = (a); (i) < (b); ++(i))
#define sz(a) ((int)(a).size())
#define make_unique(a) (a).resize(unique(all((x))) - (x).begin())

typedef long long ll;

template<typename T> inline bool mmin(T& a, const T &b) { return b < a ? (a = b, true) : false; }
template<typename T> inline bool mmax(T& a, const T &b) { return b > a ? (a = b, true) : false; }

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 1, cnt = 1; i < n; i++) {
        if (a[i] == a[i - 1]) {
            cnt++;
        } else {
            cnt = 1;
        }
        if (cnt % 2 == 0) {
            ans++;
        }
    }
    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int bw(const void *a, const void *b)
{
    return *(int *)b - *(int *)a;
}
int main()
{
    int n;
    int l[11], subsum = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &l[i]);
    }
    qsort(l, n, sizeof(l[1]), bw);
    for (int i = 1; i < n; i++)
    {
        subsum += l[i];
    }
    if (l[0] < subsum)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

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

        while(true) {
            int n = sc.nextInt();
            int x = sc.nextInt();
            int sum = 0;

            if(n==0 && x==0) {
                break;
            }

            for(int i = 1;i<=n;i++){
                for(int j = i+1;j<=n;j++){
                    for(int k = j+1;k<=n;k++){
                        if(i+j+k==x){
                            sum++;
                        }
                    }
                }
            }
            System.out.println(sum);

        }
    }
}



Measured memory_bytes: 26668
#include <stdio.h>
int main()
{
	int N,K,P;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d %d",&K,&P);
		if(K%P==0)
			printf("%d\n",P);
		else
			printf("%d\n",K%P);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int POW(int x,int y){
    int res = 1;
    for(int i = 0;i < y;i++){
        res *= x;
        res %= MOD;
    }
    return res;
}

vector<int> Eratos(int n){
    vector<bool> num(n+1,true);
    vector<int> prime;
    num[0] = num[1] = false;
    for(int i = 2;i <= n;i++){
        if(num[i]){
            for(int j = 2*i;j <= n;j += i){
                num[j] = false;
            }
            prime.push_back(i);
        }
    }
    return prime;
}

int main(){
    int n;
    cin >> n;
    vector<int> prime = Eratos(1010);
    vector<int> d;
    for(int i = 0;i < prime.size();i++){
        int N = n;
        int div = 0;
        while(N != 0){
            div += N/prime[i];
            //cout << N/prime[i] << " " << div << endl;
            N /= prime[i];
        }
        d.push_back(div);
        //cout << prime[i] << " " << div << endl;
    }
    long long ans = 1;
    for(int i = 0;i < d.size();i++){
        ans *= (d[i]+1);
        ans %= MOD;
    }
    cout << ans << endl;
    //cin >> n;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    char cards[400];
    int h, i, j, l, m;
    
    while (1) {
	scanf("%s", cards);
	if (cards[0] == '-' && cards[1] == '\0')
	    break;

	l = 0;
	while (cards[l] != '\0')
	    l++;
	
	scanf("%d", &m);
	for (i = 0; i < m; i++) {
	    scanf("%d", &h);
	    for (j = 0; j < h; j++)
		cards[l + j] = cards[j];
	    for (j = 0; j < l; j++)
		cards[j] = cards[j + h];
	}

	cards[l] = '\n'; cards[l + 1] = '\0';
	printf("%s", cards);
    }
    return 0;
}


Measured memory_bytes: 2044
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    int N = readln.chomp.to!int;
    long[] a = readln.split.to!(long[]);
    auto list = DList!(long)();
    int ans = 0;
    foreach(i; 0..N) {
        if (list.empty || list.back < a[i]) {
            ans++;
            list.insertBack(a[i]);
        } else {
            while(!list.empty && list.back > a[i]) {
                list.removeBack;
            }
            if (list.empty || list.back != a[i]) {
                ans++;
                list.insertBack(a[i]);
            }
        }
    }
    ans.writeln;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;


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

    ll ans = 0, w = 0;
    bool ok = false;
    for(int i = 0; i < (int)s.size(); i++){
        if(s[i] == 'B') ok = true;
        if(s[i] == 'W' && ok) {
            ans += i - w;
        }
        if(s[i] == 'W') w++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3756
(function(input) {
  var p = input.replace(/\n$/, '').split('\n').map(Number);
  var n = p.length;
  for (var i = 0; i < n; i++) {
    var g = p.shift();
    var s = [];
    g.toString(2).split('').reverse().map(function(e, i) {
      if (e == 1) {
        s.push(Math.pow(2, i));
      }
    });
    console.log(s.join(' '));
  }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7908
require 'set'
lines = readlines.map{|line| line.split(' ').map(&:to_i)}
set = Set.new
a=[]
c=0
d=0
if lines[0][1]==0 then
  if lines[0][0]==1 then
    puts 0
    d=1
  else
  	puts 10**(lines[0][0]-1)
    d=1
  end
end

for i in 1..lines[0][1]
	if lines[i]==[1,0] && lines[0][0]>1 then
      puts '-1'
      d=1
      break
    end
    b=set.add?(lines[i][0])
    if b==nil then
      if !a.include?([lines[i][1],lines[i][0]]) then
        puts '-1'
        d=1
        break
      elsif a.include?([lines[i][1],lines[i][0]]) then
        next
      end
    end
    a.push([lines[i][1],lines[i][0]])
    c=c+lines[i][1]*(10**(lines[0][0]-lines[i][0]))
end
if d==0 && (c.to_s).length<lines[0][0] then
  c=c+10**(lines[0][0]-1)
end
if d==0 then
	puts c
end

Measured memory_bytes: 2044
#include<cstdio>
#include<cstring>

using namespace std;

int main()
{
    char str[110][110];
    char ch[20000];
    int n, m, len = 0;
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i++)
        scanf("%s", str[i]);
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
        {
            if(strcmp(str[i], str[j]) < 0)
            {
                char str1[110];
                strcpy(str1, str[i]);
                strcpy(str[i], str[j]);
                strcpy(str[j], str1);
            }
        }
    for(int i = 0; i < n; i++)
    {
        len += strlen(str[i]);
        strcat(ch, str[i]);
    }
    ch[len] = '\0';
    printf("%s", ch);
    return 0;
}


Measured memory_bytes: 256
import sys
n=int(sys.stdin.readline())
a=list(map(int,sys.stdin.readline().split()))
dp=[[0 for i in range(n)] for j in range(n)]
for i in range(n):
    dp[i][i]=a[i]
for i in range(2,n+1):
    for j in range(n-i+1):
        k=j+i-1 
        dp[j][k]=max(a[k]-dp[j][k-1],a[j]-dp[j+1][k])
print(dp[0][len(a)-1])

Measured memory_bytes: 119900
/*Coded by::
    **Avinash Tiwary**
    **BE/10298/2015**
    **Production Engineer**
    **Producing <code>**
*/
#include<bits/stdc++.h>
#define buf ios_base::sync_with_stdio (0), cin.tie (0)
typedef long long ll;
typedef double dob;
#define MAX 50010
#define M5 200009
#define M6 2000009
#define M 1000000007
#define inf LLONG_MAX
using namespace std;
typedef vector<ll> V;
typedef queue<ll > Q;
typedef stack<ll> S;
typedef pair<dob,ll> P;
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
ll fac[M6],not_prime[M6],ar[M6];
ll power(ll x,ll n)
{   if(n==0) return 1;
    else if(n%2 == 0) return power((x*x)%M,n/2);
    else return (x*power((x*x)%M,(n-1)/2))%M;
}
void fact(){
    fac[0]=1;
    for(ll i=1;i<M6;i++) fac[i]=(i*fac[i-1])%M;
}
void sieve(){
    not_prime[1]=1; not_prime[0]=1;
    for(ll p=2;p*p<M6;p++){
        if(!not_prime[p]){
            for(ll i=p*2;i<=M6;i+=p) not_prime[i]=1;
        }
    }
}
ll modi(ll a, ll m){
    ll m0 = m, t, q; ll x0 = 0, x1 = 1;
    if (m == 1) return 0;
    while (a > 1){  q = a / m; t = m; m = a % m, a = t;t = x0;x0 = x1 - q * x0; x1 = t;}
    if (x1 < 0) x1 += m0;return x1;
}
vector<list< ll > > g(M5);
int main(){
    buf; 
    //sieve(); 
    //fact();
    ll i,j,test,flag,t,ans,a,b,n,m,d,q,l; string s1,s2,s3;
    test=1;
    while(test--){
        cin>>s1;
        for(i=0;i<s1.size()-8;i++) cout<<s1[i];
        
        
        
        
        
    }
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <map>

struct UnionFind
{
    std::vector<int> parent; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int n) : parent(n)
    {
        //最初は全てが根であるとして初期化
        for (int i = 0; i < n; i++)
        {
            parent[i] = i;
        }
    }

    // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    int root(int x)
    {
        if (parent[x] == x)
        {
            return x;
        }
        return parent[x] = root(parent[x]);
    }

    // xとyの木を併合
    void unite(int x, int y)
    {
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;      //xとyの根が同じ(=同じ木にある)時はそのまま
        parent[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

namespace std
{
    template <>
    class hash<std::pair<int, int>>
    {
    public:
        size_t operator()(const std::pair<int, int> &x) const
        {
            // この計算がとても遅い
            return static_cast<int64_t>(x.first) * 2 * 100000 + x.second;
        }
    };
} // namespace std

int main()
{
    int n, k, l;
    std::cin >> n >> k >> l;

    UnionFind u1(n), u2(n);
    for (int i = 0; i < k; ++i)
    {
        int a, b;
        std::cin >> a >> b;
        --a;
        --b;

        u1.unite(a, b);
    }
    for (int i = 0; i < l; ++i)
    {
        int a, b;
        std::cin >> a >> b;
        --a;
        --b;

        u2.unite(a, b);
    }

    // unordered_mapの方がmapより速い
    std::unordered_map<std::pair<int, int>, int> counter;
    for (int i = 0; i < n; ++i)
    {
        const int index1 = u1.root(i), index2 = u2.root(i);
        const auto p = std::make_pair(index1, index2);
        ++counter[p];
    }

    for (int i = 0; i < n; ++i)
    {
        const int index1 = u1.root(i), index2 = u2.root(i);
        const auto p = std::make_pair(index1, index2);

        std::cout << counter[p];
        if (i == n - 1)
        {
            std::cout << std::endl;
        }
        else
        {
            std::cout << ' ';
        }
    }

    return 0;
}


Measured memory_bytes: 12744
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  ll n, m;
  cin >> n >> m;
  priority_queue<ll> pq;
  rep(i,n) {
    ll a;
    cin >> a;
    pq.push(a);
  }
  rep(i,m) {
    int a = pq.top();
    pq.pop();
    a /= 2;
    pq.push(a);
  }
  ll ans = 0LL;
  while(!pq.empty()) {
    int a = pq.top();
    pq.pop();
    ans += a;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>
#include <regex>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define P pair<int, int>

using namespace std;
using ll = int64_t;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int DX[] = {1, 1, 0, -1, -1, -1, 0, 1};
int DY[] = {0, -1, -1, -1, 0, 1, 1, 1};

int prime[1005];

void solve(){
    ll ans = 1;
    int n;
    cin >> n;
    rep(i, n) prime[i] = 0;
    for(int i = 2; i <= n; i++){
        int temp = i;
        for(int j = 2; j <= temp; j++){
            while(temp%j == 0){
                prime[j]++;
                temp /= j;
            }
        }
    }
    for(int i = 0; i <= n; i++){
        ans *= (prime[i]+1);
        ans %= mod;
    }
    cout << ans << endl;
}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


class BIT:
    def __init__(self, n):
        self.num = n
        self.dat = [0] * (self.num + 1)

    def add(self, i, x):
        i += 1
        while i <= self.num:
            self.dat[i] += x
            i += i & -i

    def sum(self, i):
        i += 1
        s = 0
        while i > 0:
            s += self.dat[i]
            i -= i & -i
        return s


n, q = LI()
ans = [0] * q
C = LI()
Q = [[] for _ in range(n)]
for i in range(q):
    l, r = LI()
    Q[r - 1] += [(i, l - 1)]

last = [-1] * (n + 1)
DD = {}
bit = BIT(n + 1)
for i, c in enumerate(C):
    col = C[i]
    bit.add(i, 1)
    if last[col] != -1:
        bit.add(last[col], -1)
    last[col] = i
    for qi, li in Q[i]:
        ans[qi] = bit.sum(i) - bit.sum(li - 1)


print(*ans, sep="\n")


Measured memory_bytes: 208636
while true
	nums = gets.split( " " ).map { | val | val.to_i }
	break if 0 == nums[0] && 0 == nums[1]

	nums[0].times {
		nums[1].times {
			print( "#" )
		}
		print( "\n" )
	}
	print( "\n" )
end

Measured memory_bytes: 6108