akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
    #define mp make_pair
    #define f first
    #define s second
    using namespace std;
    int n,krawedzie,akt,pot,nieumiemy,last;
    vector<pair<int,int> >g[25];
    int main()
    {
    ios_base::sync_with_stdio(0);
    cin>>n;
    n--;
    for(int i=1;i<=19;i++)g[i].push_back(mp(i+1,0));
    krawedzie+=19;
    akt=1;
    pot=1;
    while(2*pot-1<=n)
        {
        g[akt].push_back(mp(akt+1,pot));
        krawedzie++;
        pot*=2;
        akt++;
        }
    pot/=2;
    akt--;
    nieumiemy=pot*2;
    last=n;
    while(pot)
        {
        if(pot<=last-nieumiemy+1)
            {
            g[akt].push_back(mp(20,last-pot+1));
            krawedzie++;
            last-=pot;
            }
        pot/=2;
        akt--;
        }
    cout<<20<<' '<<krawedzie<<'\n';
    for(int i=1;i<=20;i++)
        {
        for(int j=0;j<g[i].size();j++)
            {
            cout<<i<<' '<<g[i][j].f<<' '<<g[i][j].s<<'\n';
            }
        }
    }
     


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


int main() {
    ll n,k; cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll m=0;
    
    // if(n==k){
    //     cout << 1 << endl;
    //     return 0;
    // }

    rep(i,n){
        if(a[i]==1){
            m=i+1;
        }
    }

    ll x1=m-1;
    ll x2=n-m;
    ll ans=0;
    k--;
    ll amari=k;
    while(x1>0){
        amari=x1;
        x1-=k;
        ans++;
    }
    x2-=(k-amari);
    while(x2>0){
        x2-=k;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "ctime"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> K;
	map<long long int, int>m;
	for (long long int i = 2; i*i <= K; i++) {
		while (K%i == 0) {
			K /= i;
			m[i]++;
		}
	}
	if (K != 1)m[K]++;
	long long int ans = 1;
	for (auto i : m) {
		for (int j = 0; j < i.second / N; j++)ans *= i.first;
	}
	cout << ans << endl;
	return 0;
}

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



 
int main() {
	int N; cin >> N;
	vector<int> B(N - 1);
	rep(i, N - 1) cin >> B[i];
	uint64_t ans = B[0] + B[N - 2];
	for (int i = 0; i < N - 2; i++) {
		//if (B[i] < B[i + 1])
		ans += min(B[i], B[i + 1]);
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	static Scanner sc;
	static PrintWriter out;
	static char grid[][];
	static int h,w;
	static int memo[][];
	static final int uncal = -1,mod = 1_000_000_007;
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		h = sc.nextInt();
		w = sc.nextInt();
		grid = new char[h][w];
		memo = new int[h][w];
		clear();
		for (int i = 0; i < h; i++) {
			grid[i] = sc.nextLine().toCharArray();
		}
		out.println(dp(0, 0));
		out.flush();
		out.close();
	}
	static void clear() {
		for(int[]a:memo){
			Arrays.fill(a, uncal);
		}
	}
	static int dp(int i,int j) {
		if(i+1 == h && j+1 == w) return 1;
		if(memo[i][j] != uncal)
			return memo[i][j];
		int right = 0,down =0;
		if(j+1<w && grid[i][j+1]=='.')
			right = dp(i, j+1)%mod;
		if(i+1<h && grid[i+1][j]=='.')
			down = dp(i+1, j)%mod;
		return memo[i][j] = (right + down)%mod;
	}
	static class Scanner{
		BufferedReader br;
		StringTokenizer st;
		public Scanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		private String next() throws Exception{
			while(st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws Exception{
			return Integer.parseInt(next());
		}
		public long nextLong() throws Exception{
			return Long.parseLong(next());
		}
		public double nextDouble() throws Exception{
			return Double.parseDouble(next());
		}
		public String nextLine() throws Exception {
			return br.readLine();
		}

	}
}


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

int main(){

  int c[4][4];
  for(int i=1; i < 4; i++){
    for(int j=1; j < 4; j++){
      cin >> c[i][j];
    }
  }

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

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

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

  int n, ans = 0;
  string s;
  cin >> n >> s;
  for(char i = '0';i <= '9';i ++){
    for(char j = '0';j <= '9';j ++){
      for(char z = '0';z <= '9';z ++){

	bool na, su, nasu;
	na = su = nasu = false;
	rep(x, n){
	  if(su){
	    if(s[x] == z){
	      nasu = true;
	    }
	  } else if(na){
	    if(s[x] == j){
	      su = true;
	    }
	  } else {
	    if(s[x] == i){
	      na = true;
	    }
	  }
	}
	if(nasu){
	  ans ++;
	}
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 384
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<vector<long long int>>num(N, vector<long long int>(10));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> num[i][j];
		}
	}
	M = LLONG_MIN;
	vector<vector<long long int>>p(N, vector<long long int>(11));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 11; j++) {
			cin >> p[i][j];
		}
	}
	for (int i = 1; i < 1024; i++) {
		int box = i;
		vector<bool>flag(10, false);
		int bag = 0;
		while (box) {
			if (box % 2) {
				flag[bag] = true;
			}
			box /= 2;
			bag++;
		}
		K = 0;
		for (int j = 0; j < N; j++) {
			int fig = 0;
			for (int k = 0; k < 10; k++) {
				if (flag[k]&&num[j][k]) {
					fig++;
				}
			}
			K += p[j][fig];
		}
		M = max(M, K);
	}
	cout << M << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		ArrayList<String> array = new ArrayList<String>();

		try {
			String str = null;
			while ((str = br.readLine()) != null) {
				array.add(str);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				br.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		
		for(String s : array) {
			String[] data = s.split(" ");
			LinkedList<Double> list = new LinkedList<Double>();
			
			int fugo = 1;
			for(String value : data) {
				String regex = "^[+\\-*/]$";
				Pattern p = Pattern.compile(regex);
				Matcher m = p.matcher(value);
				if(m.find() == false) {
					//数字
					list.push(Double.valueOf(value)  * fugo);
					fugo = 1;
				} else {
					if(list.size() == 0 && value.equals("-")) {
						fugo = -1;
						continue;
					}
					
					double a = list.pop();
					double b = list.pop();
					
					char c = value.charAt(0);
					switch((int)c) {
					case '+' :list.push(b + a); break;
					case '-' :list.push(b - a); break;
					case '*' :list.push(b * a); break;
					case '/' :list.push(b / a); break;
					}
				}
			}
			System.out.println(list.pop());
		}
	}
}

Measured memory_bytes: 17084
#!/usr/bin/env python3
import sys


def solve(N: int, X: "List[int]"):
    p = round(sum(X) / len(X))
    ans = sum([(x - p)**2 for x in X])
    print(ans)

    #return


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X)

if __name__ == '__main__':
    main()


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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 2e5+5;

ll pre[N] , suf[N] , n , a[N] , ans=0;


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

    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> a[i];
        pre[i] = __gcd(pre[i-1] , a[i]);
    }

    ans = pre[n];
    for(int i=n; i>0; i--)
    {
        suf[i] = __gcd(suf[i+1] , a[i]);
    }

    for(int i=1; i<=n; i++)
    {
        ll tmp = __gcd(suf[i+1] , pre[i-1]);
        ans = max(ans , tmp);
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 5996
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	static int ary[];
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		Main app = new Main();
		
		int n = Integer.valueOf(reader.readLine());
		
		int mat[][] = new int[n][n];
		int sum[][] = new int[n + 1][n + 1];
		
		app.input(reader.readLine());
		mat[0][0] = sum[1][1] = ary[0];
		for(int i = 1; i < n; i++){
			mat[0][i] = ary[i];
			sum[1][i + 1] = mat[0][i] + sum[1][i];
		}
		for(int i = 1; i < n; i++){
			app.input(reader.readLine());
			for(int j = 0; j < n; j++){
				mat[i][j] = ary[j] + mat[i - 1][j];
				
				if(j > 0){
					sum[i + 1][j + 1] = mat[i][j] + sum[i + 1][j];
				}else{
					sum[i + 1][1] = mat[i][j];
				}
			}
		}
		
		int S, max = -99999;
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				for(int w = 1; w <= i; w++){
					for(int h = 1; h <= j; h++){
						S = sum[i][j] - sum[i - w][j] - sum[i][j - h] + sum[i - w][j - h];
						max = Math.max(max, S);
					}
				}
			}
		}
		System.out.println(max);
		
		reader.close();
	}
	
	public void input(String source){
		String str[] = source.split(" ");
		ary = new int[str.length];
		for(int i = 0; i < str.length; i++){
			ary[i] = Integer.valueOf(str[i]);
		}
	}
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

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

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

class Combination{
	constexpr static int atcoder_mod = 1000000007;
	vector<ll> fac,finv,inv;
public:
	Combination(ll N){
		fac.resize(N+1);
		finv.resize(N+1);
		inv.resize(N+1);
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for(int i=2;i<=N;i++){
			fac[i] = fac[i-1] * i % atcoder_mod;
			inv[i] = atcoder_mod - inv[atcoder_mod%i] * (atcoder_mod/i) % atcoder_mod;
			finv[i] = finv[i-1] * inv[i] % atcoder_mod;
		}
	}
	ll Caluclation(ll n,ll r){
		if(n < r) return 0;
		if (n < 0 || r < 0) return 0;
		return fac[n] * (finv[r] * finv[n-r] % atcoder_mod) % atcoder_mod;
	}
	ll GetFInv(ll i){
		return finv[i];
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int X=in(),Y=in();
	if((X+Y)%3){
		out(0);
		return 0;
	}

	int MD=X+Y;
	int N=MD/3;
	if(X<N || X>MD-N){
		out(0);
		return 0;
	}

	Combination comb(N);
	out(comb.Caluclation(N,X-N));
	return 0;
}


Measured memory_bytes: 15872
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

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

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

  int res = gcd(a, b);
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll x,y;
  cin >> x >> y;
  ll ans=0;
  while(x<=y) {
    x*=2;
    ans++;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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


int dp__[100];

//最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp__[n] = 1;
  if(dp__[n] != -1) return dp__[n];
  return dp__[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  double n, k;
  cin >> n >> k;
  double ans = 0;
  REP(i, n+1){
    double p = 1;
    int x = i;
    while(x < k){
      p *= 0.5;
      x *= 2;
    }
    ans += p / n;
  }
  printf("%.10f\n", ans);
}




Measured memory_bytes: 256
n= int(input())
a=list(map(int,input().split()))
a.sort()
ans=1
for i in a:
    ans=ans*i
    if ans>(10**18):
        print(-1)
        break
    elif ans==0:
        print(ans)
        break
if ans<=(10**18)and ans!=0:
    print(ans)

Measured memory_bytes: 21640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    vector<bool> c(n);
    rep(i,m){
        int a,l;
        cin >>a >>l;
        rep(j,l){
            int k = (a+j)%n;
            c[k] = true;
        }
    }

    map<int,int> ct;
    vector<bool> vis(n);
    rep(i,n)if(c[i]){
        if(vis[i]) continue;
        queue<int> que({i});
        vis[i] = true;
        int cc = 1;
        while(!que.empty()){
            int v = que.front();
            que.pop();
            for(int j:{n-1,1}){
                int nx = (v+j)%n;
                if(c[nx] && !vis[nx]){
                    que.push(nx);
                    vis[nx] = true;
                    ++cc;
                }
            }
        }

        ++ct[cc];
    }

    vector<pair<int,int>> ans;
    for(auto &p:ct) ans.pb(p);
    reverse(all(ans));
    for(const auto &p:ans) cout << p.fi << " " << p.se << "\n";
    return 0;
}



Measured memory_bytes: 3168
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, a, b, c, d;
string s;
int main() {
  cin >> n >> a >> b >> c >> d >> s;
  s.insert(begin(s), '.'); // to 1 indexed

  bool res = true;
  for (i64 i = a; i <= max(c, d) - 1; ++i) {
    if (s[i] == '#' && s[i + 1] == '#') res = false;
  }
  bool jump = true;
  if (d < c) {
    jump = false;
    for (i64 i = b; i <= d; ++i) {
      if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
        jump = true;
      }
    }
  }
  if (res && jump) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>


using namespace std;

// vector<int> s = cumulativeSum(vs,N);
// [left, right) => s[right] - s[left]
vector<int> cumulativeSum(vector<int> vs, int N) {
    vector<int> rs(N + 1, 0);
    for (int i = 0; i < N; ++i) {
        rs[i + 1] = rs[i] + vs[i];
    }
    return rs;
}

int main() {

    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;

    vector<int> vs;

    for (int i = 0; i < N - 1; ++i) {
        if (S[i] == 'A' and S[i + 1] == 'C') {
            vs.push_back(1);
        } else {
            vs.push_back(0);
        }
    }

    vector<int> ss = cumulativeSum(vs, vs.size());

    for (int i = 0; i < Q; ++i) {
        int l, r;
        cin >> l >> r;
        cout << (ss[r-1] - ss[l-1]) << endl;
    }

    return 0;

}

Measured memory_bytes: 1904
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define s(v)       sort(v.begin(),v.end())
#define r(v)       reverse(v.begin(),v.end())
#define pf         printf
#define sf         scanf
#define GCD(x,y)   __gcd(x, y)
#define pb         push_back
#define ll         long long
#define vs         v.size()
#define ss         s.size()

using namespace std;
int main()
{
    long long int n,sum=0,mx=0;
     vector<int>v;
     cin>>n;
     while(n--)
     {
         int a;
         cin>>a;
         v.pb(a);
     }
     for(int i=0;i<v.size();i++)
     {
         if(mx<v[i]) mx=v[i];
         if(mx>v[i]) sum+=(mx-v[i]);
     }
     cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 4292
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ld t, a;
    cin >> n >> t >> a;
    int ans = -1;
    ld p = INF;
    rep(i, n) {
        ld h;
        cin >> h;
        ld now = t - h * 0.006;
        if(chmin(p, abs(now - a))) ans = i + 1;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    vector<int> a(3);
    for(int i=0;i<3;i++)cin>>a[i];
    sort(a.begin(),a.end());
    int k;
    cin>>k;
    a[2]=a[2]*pow(2,k);
    int ans=0;
    for(int i=0;i<3;i++)ans+=a[i];
    cout<<ans<<endl;
    return 0;
}


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

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

    int digit[200000];

    for (int i = 0; i < n.length(); i++) {
        digit[i] = n.at(i) - '0';
    }

    int sum = 0;
    for (int i = 0; i < n.length(); i++) {
        sum += digit[i];
    }
    if (sum % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 4496
#include<iostream>
using namespace std;
int main(){
 
  int cost,M,N;
  while(1){
    int sum=0,buf=0;
    
    cin >> cost;
    if(cost ==0)break;
    for(int i=0;i<12;i++){
      cin>>M>>N;
      sum+=(M-N);
      if(sum>=cost && buf==0){
	buf=i+1;
      }
    }
    if(buf==0) cout<<"NA"<<endl;
    else cout<<buf<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7

def inv(x):
    return pow(x, mod - 2, mod)

def c(n, k):
    ue, sita = 1, 1
    for i in range(0, k):
        ue = ue * (n - i) % mod
       	sita = sita * (i + 1) % mod
    return ue * inv(sita) % mod


print(((pow(2, n, mod) - c(n, a) - c(n, b) - 1) % mod + mod) % mod)


Measured memory_bytes: 9172
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#define mp make_pair
#define pb push_back
using namespace std;

string s;
int w;

string ans;

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

    cin >> s;
    cin >> w;

    for(int i = 0; i < s.size(); i += w)
        ans.pb(s[i]);

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
import sys
#import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

S = list(rs())
p_cnt = S.count('p')
g_cnt = len(S) - p_cnt
possible = (g_cnt-p_cnt) // 2
print(possible)
# 44

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

int main(){
  string s; cin >> s;
  int ans = 1000;
  for(int i = 0; i < s.size() - 2; i++){
    int tmp = (s[i] - '0') * 100 + (s[i+1]-'0')*10 + (s[i+2] - '0');
    ans = min(ans, abs(tmp - 753));
  }
  cout << ans << endl;
}
                                                      
      

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define M 1000000007
#define endl "\n"
#define int long long 
using namespace std;
int max(int a,int b)
{
	if(a>b)
	{
		return a;
	}
	return b;
}
int32_t main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n;
    cin>>n;
    int v[n];
    int c[n];
    for(int i=0;i<n;i++)
    {
    	cin>>v[i];
    }
    for(int i=0;i<n;i++)
    {
    	cin>>c[i];
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
    	ans+=max(0,v[i]-c[i]);
    }
    cout<<ans;
}


Measured memory_bytes: 256
words = lambda t : list(map(t, input().split()))
n,m = words(int)
xs = []
for i in range(m):
    a,b,c = words(int)
    xs.append((b,a,c))

sxs = reversed(sorted(xs))

ans = [-1] * n
ans[-1] = 0
#print(sxs)
for b,a,c in sxs:
    #print(ans, a,b,c)
    if ans[b-1] == -1:
        #print("con")
        continue
    for i in range(a-1,b-1):
        if ans[i] != -1 and ans[i] <= ans[b-1] + c:
            break
        ans[i] = ans[b-1] + c

print(ans[0])


Measured memory_bytes: 65624
def read_input():
    a,b,c=map(int, input().split())
    if 2<=a<=5 and 1<=b<=100 and b<c<=200:
        return a,b,c
    else :
        print("Error")
        exit()

def main():
    num = 10

    r,D,x=read_input()
    sum_x=x

    for i in range(num):
        sum_x=r*sum_x-D
        print(sum_x)
        sum_x=sum_x



if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
  int n,k; cin >> n >> k;
  long ans=k;
  for(int i=0;i<n-1;i++)
    ans=ans*(k-1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> P;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

map <ll, ll> mp;

void solve(void){
    ll N, K, l = -1;
    cin >> N >> K;
    rep(N, i) {
        ll a, b; cin >> a >> b;
        mp[a] += b;
        l = max(l, a);
    }
    ll kosu = 0LL;
    for (llP p : mp) {
        if (kosu + p.second >= K) {
            cout << p.first << endl;
            return;
        }
        kosu += p.second;
    }
    cout << l << endl;
}

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


Measured memory_bytes: 4224
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int l[2005];
set<int> bad;
int n, k, q;

int main() {
  scanf("%d%d%d", &n, &k, &q);
  for(int i = 0; i < n; i++) {
    scanf("%d", &l[i]);
    bad.insert(l[i]);
  }
  bad.insert(0);
  int ret = 1 << 30;
  for(int thresh: bad) {
    vector<int> all;
    for(int i = 0; i < n;) {
      if(l[i] <= thresh) {
        i++;
        continue;
      }
      int j = i+1;
      while(j < n && l[j] > thresh) j++;
      // i inclusive, j exclusive
      vector<int> inside;
      for(int a = i; a < j; a++) {
        inside.push_back(l[a]);
      }
      sort(inside.begin(), inside.end());
      for(int a = 0; a + k <= inside.size(); a++) {
        all.push_back(inside[a]);
      }
      i = j;
    }
    sort(all.begin(), all.end());
    if(all.size() >= q) {
      ret = min(ret, all[q-1] - all[0]);
    }
    else {
      break;
    }
  }
  printf("%d\n", ret);
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
# IMPORT ###############################################################################################################
import sys                                                      # システム
sys.setrecursionlimit(10**6)                                    # 再帰処理の上限変更
from collections import deque, Counter                          # キュー・個数カウント
from itertools   import accumulate, permutations, combinations  # 累積和・順列・組み合わせ
from operator    import itemgetter                              # ソート補助
from bisect      import bisect_left, bisect_right, bisect       # 二分探索
from heapq       import heappop, heappush                       # プライオリティキュー
from fractions   import gcd                                     # 最大公約数
from math        import ceil, floor, sqrt, cos, sin, tan, pi    # 数学処理
from copy        import deepcopy                                # オブジェクトコピー
import numpy         as np                                      # 数値計算

# MAIN #################################################################################################################
def main():
    # Init #############################################################################################################
    im = InputManager()
    # Input ############################################################################################################
    pqr = im.inputMultiple(aslist=True)
    # Logic ############################################################################################################
    print("{}".format(sum(pqr) - max(pqr)))
    # Output ###########################################################################################################

    # Return ###########################################################################################################
    return

# INPUT MANAGER ########################################################################################################
class InputManager(object):
    def __init__(self):
        pass

    @staticmethod
    def inputSingle(dtype=int):
        return dtype(input())
    
    @staticmethod
    def inputMultiple(dtype=int, aslist=False):
        if aslist:
            return list(map(dtype, input().split()))
        else:
            return map(dtype, input().split())

    @staticmethod
    def input2D(h, dtype=int):
        return [list(map(dtype, input().split())) for i in range(h)]

# CALL MAIN ############################################################################################################
main()

Measured memory_bytes: 13672
<?php
fscanf(STDIN, "%d %d %d", $a, $b, $x);

$full = $a * $a * $b;

if($x >= $full / 2){
  $amari = $full - $x;
  $amariHeight = $amari / $a / $a * 2;
  echo atan($amariHeight / $a) / pi() * 180;
}else{
  $height = $x / $a / $b * 2;
  echo 90 - atan($height / $b) / pi() * 180;
}


Measured memory_bytes: 4604
#include <iostream>
#include<stdio.h>
using namespace std;

int main()
{
    string s,x[7]={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    cin>>s;
    for(int i=0;i<7;i++){
        if(x[i]==s){
           printf("%d",7-i);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli, lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout << (x ? "Yes" : "No") << endl;
#define YES(x) cout << (x ? "YES" : "NO") << endl;
#define out(s) cout << s << endl;
#define Reverse(x) reverse(all(x));
#define Sort(x) sort(all(x));
#define pb(s) push_back(s);
#define sp " "
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(), s.end()
void vout(vi v)
{
    for (lli i = 0; i < v.size(); i++)
        cout << v.at(i) << endl;
}
int main()
{
    cout << std::fixed << std::setprecision(10);
    lli x;
    cin >> x;
    out((x==1?0:1));
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
using ll = long long;
using ull = unsigned long long;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
const ll md = 1000000007;
vector<ll> fact(1e6 + 7), invfact(1e6 + 7);

ll fn(ll a, ll r, ll n, ll mod = md) {
    ll res = 1, x = r%mod;
    ll ans = 0;
    while(n) {
        if(n&1) ans = (x*ans + res)%mod;
        res = ((res*x)%mod + res%mod)%mod;
        x = (x*x)%mod;
        n = n/2;
    }
    ans = (ans*a)%mod;
    return ans;
}

ll nCr(ll n, ll r) {
    if(r == 0) return 1;
    ll num = fact[n];
    ll den = (invfact[r] % md *invfact[n-r] % md)%md;
    return (num*den)%md;
}

ll mul(ll a, ll b, ll mod = md) {
    ll res = (a%mod * b%mod)%mod;
    return res;
}

ll mulm(ll a, ll b, ll mod = md) {
    ll r = 0;
    a %= mod;
    while (b) {
        if (b & 1) r = (r+a)%mod;
        a = (a+a)%mod;
        b = b/2;
    }
    r %= mod;
    return r;
}

ll power(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = (res*x)%mod;
        n = n/2;
        x = (x*x)%mod;
    }
    return res;
}

ll power2(ll x, ll n) {
    ll res = 1;
    while (n)  
    {  
        if (n & 1)  res = (res*x);  
        n = n/2; 
        x = (x*x);  
    }  
    return res;
}

bool is_prime(ll x) {
    if(x == 1 || x == 0) return false;
    for(int i=2; i*i <= x; i++) {
        if(x%i == 0) return false;
    }
    return true;
}

ll compgcd(ll n, vector<ll> const &primes) { 
    ll res = n; 
    for (ll i=0; primes[i]*primes[i] <= n; i++) {
        if (n % primes[i]== 0) { 
            res -= (res / primes[i]); 
            while (n%primes[i]== 0) {
               n/=primes[i]; 
            }
        } 
    } 
    if (n > 1) {
       res -= (res / n); 
    }
    return res; 
} 

void sieve(vector<bool> &prime, vector<ll> &primes, ll lim) {
    for(int i = 2; i*i <= lim; i++) {
        if(prime[i]) {
            for(int j = 2; j*i <= lim; j++) {
                prime[j*i] = false;
            }
        }
    }
    for(int i = 2; i <= lim; i++) {
        if(prime[i]) {
            primes.push_back(i);
        }
    }
}

void sieveGCD(ll lim, vector<ll> &tab, vector<ll> const &primes) {
    for(int  i = 1; i <= lim; i++) {
        tab[i] = i;
    }
    for(int i = 0; i<primes.size() && primes[i] <= lim; i++) {
        tab[primes[i]] = primes[i]-1;
        for(int j = 2; primes[i]*j <= lim; j++) {
            tab[primes[i]*j] = (tab[primes[i]*j]/primes[i])*(primes[i]-1);
        }
    }
}

ll calc(ll a, ll b, ll r) {
    ll total = r+1;
    ll tmp = a*b;
    ll count = (r/tmp)*max(a,b) + max(a,b);
    if((r/tmp)*tmp + max(a,b) > r) {
        count -= ((r/tmp)*tmp + max(a,b) - r - 1);
    }
    total -= count;
    return total;
}

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, r, ir;
    cin >> n >> r;
    if(n < 10) {
        ir = r + 100*(10 - n);
    } else {
        ir = r;
    }
    cout << ir << endl;
    return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    int minn = 10000;
    for(int i = 0; i < s.size() - t.size() + 1; i++){
        int tmp = 0;
        for(int j = 0; j < t.size(); j++){
            if(s[i+j] == t[j]){
                tmp++;
            }
        }

        int okikae = t.size() - tmp;
        if(minn > okikae)minn = okikae;
    }

    cout << minn << endl;
}

Measured memory_bytes: 3624
N, Y = map(int,input().split())
x,y,z = -1,-1,-1
for i in range(N+1):
  for j in range(N-i+1):
    if Y == 10000*i+5000*j+1000*(N-i-j):
      x,y,z = i,j,N-i-j
 
print(x,y,z)

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

#define M 1000000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return (key%M); }
int h2(int key){ return 1+(key%(M-1)); }//ここの 1+(key%(M-1) は、どんな計算でもよく、ここの計算結果分の距離ずつ進んで、空いている場所を探す。

int find(char str[]){
  long long Key,i,h;
  Key=getKey(str);
  for(i=0;;i++){
    h=(h1(Key)+i*h2(Key))%M;
    if(strcmp(H[h],str)==0){
      return 1;
    }
    else if(strlen(H[h])==0){
      return 0;
    }
  }
  return 0;
}

int insert(char str[]){
  long long Key,i,h;
  Key=getKey(str);
  for(i=0;;i++){
    h=(h1(Key)+i*h2(Key))%M;//ここの (h1(key)+i*h2(key))%M は、どんな計算でもよく、ここの計算結果分の距離ずつ進んで、空いている場所を探す。
    if(strcmp(H[h],str)==0){
      return 1;
    }
    else if(strlen(H[h])==0){//H[h]がまだ何も入ってない場所だった時
      strcpy(H[h],str);
      return 0;
    }
  }
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
  scanf("%d", &n);
    
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
	
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)==1){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }

  return 0;
}
/*
int getChar(char ch)
{
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

//convert a string into an integer value
long long getKey(char str[])
{
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return ; }
int h2(int key){ return ; }


char H[M][L];
int i=0;
int find(char str[]){
  int j;
  for(j=0;j<i;j++)
    {
      if(strcmp(H[j],str)==0)
	{
	  return 1;
	}
    }
  return 0;
}

int insert(char str[]){
  //static int i=0;
  strcpy(H[i],str);
  i++;
}

int main(){
  int i, n;
  char str[L], com[9];
  //for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
  scanf("%d", &n);
    
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
	
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)==1){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }

  return 0;
}


*/



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

signed main() {
	int N;
	cin>>N;
	vector<int> p(N);
	vector<int> a(N);
	int tmp=-1;
	for(int i=0;i<N;i++){
		tmp*=-1;
		cin>>a[i];
		p[0]+=tmp*a[i];
	}
	p[0]/=2;
	cout<<p[0]*2<<' ';
	for(int i=0;i<N-1;i++){
		p[i+1]=a[i]-p[i];
		cout<<p[i+1]*2<<' ';
	}
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

typedef int64_t ll;

constexpr int dx[4] = { 1, 0, -1, 0 };
constexpr int dy[4] = { 0, 1, 0, -1 };

#define SPRE(x) setprecision(x) // 精度を指定

int main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
	int N, sum = 0;
	cin >> N;
	std::vector<int> a,b;
	int sumb = 0;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		b.push_back(tmp);
		sumb += tmp;
	}
	int suma = 0;
	for (int i = 0; i < N; i++) {
		suma += a[i];
		sum = max(suma + sumb, sum);
		sumb -= b[i];
	}
	cout << sum << '\n';


}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define PER(i, a, b) for(int i = a; i >= b; i--)
#define LL long long
#define lowbit(x) x &(-x)

inline int read() {
    int x = 0, flag = 1;char ch = getchar();
    while(!isdigit(ch)) {
        if(ch == '-') flag = - 1;
        ch = getchar();
    }
    while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
    return x * flag;
}
int n;
int main() {   
    cin >> n;
    for(int i = 1; i <= 360; ++i) {
        if(!((i * n) % 360)) {
            cout << i << endl;
            break;
        }
    }
	return 0;
}


Measured memory_bytes: 3560
import java.util.Scanner;

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

    int w = scanner.nextInt();
    int h = scanner.nextInt();
    int x = scanner.nextInt();
    int y = scanner.nextInt();
    int r = scanner.nextInt();

    if (0 <= x-r && 0 <= y-r && x+r <= w && y+r <= h) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 17356
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pp push

using namespace std;
int main()
{
	ll k;cin>>k;
	string s;
	cin>>s;
	string f="";
	if(s.size()>k){
		for(ll i=0;i<k;i++)
		f+=s[i];
		f+="...";
		cout<<f;
	}
	else{
		cout<<s;
	}
}

Measured memory_bytes: 3632
import math, cmath
 
def koch(v1, v2, n):
    if n == 0:
        return [v1, v2]
     
    rad60 = math.pi/3
    u1 = (v2 - v1)/3
    u2 = cmath.rect(abs(u1), cmath.phase(u1)+rad60)
    q1 = v1 + u1
    q2 = q1 + u2
    q3 = q1 + u1
    if n == 1:
        return [v1,q1,q2,q3,v2]
    else:
        x1 = koch(v1,q1,n-1)[:-1]
        x2 = koch(q1,q2,n-1)[:-1]
        x3 = koch(q2,q3,n-1)[:-1]
        x4 = koch(q3,v2,n-1)
        x = x1 + x2 + x3 + x4
    return x
 
n = int(raw_input())
v1 = complex(0,0)
v2 = complex(100,0)
 
for e in koch(v1,v2,n):
    print e.real,e.imag

Measured memory_bytes: 7112
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
bool G[300000]={};
int main(){
	
	for(int i=8;i<=300000;i+=7){G[i]=true;
		for(int j=6;j*j<=i;j+=7)
		{if(i%(j)==0||i%(j+2)==0){G[i]=false;break;}
		}
	}
	for(int i=6;i<=300000;i+=7){G[i]=true;
		for(int j=6;j*j<=i;j+=7)
		{if(i%(j)==0||i%(j+2)==0){G[i]=false;break;}
		}
	}

	

	int N;
	while(1){
		cin>>N;if(N==1)break;
		cout<<N<<":";
		for(int i=7;i<=300000;i+=7)
		{if(G[i-1]==true){
		
			if(N%(i-1)==0)cout<<" "<<i-1;
		}
		if(G[i+1]==true){
			if(N%(i+1)==0)cout<<" "<<i+1;
			
		}}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1452
#include <iostream>\
#include <cstdio>
using namespace std;

int main()
{
	int x,a,b;
	cin>>x>>a>>b;
	
	x=x-a;
	while(x>=b)
	{
		x=x-b;
	}
	
	cout<<x;
	return 0;
}

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

const int INF = 1e9;

vector<int> get_divisors(int n) {
  vector<int> divisors;
  if (n == 1) {
    divisors.push_back(1);
    return divisors;
  }
  for (int i=1; i*i<n; i++) {
    if (n % i == 0) {
      divisors.push_back(i);
      if (i*i != n) {
        divisors.push_back(n / i);
      }
    }
  }
  sort(divisors.begin(), divisors.end());
  return divisors;
}
int main() {
  int n, m;
  cin>>n>>m;
  vector<int> divisors = get_divisors(m);
  reverse(divisors.begin(), divisors.end());
  for (int d: divisors) {
    if (m / d >= n) {
      cout<<d<<endl;
      return 0;
    }
  }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n;
	pii ba[252521];
	cin>>n;
	REP(i, n){
		cin>>ba[i].second>>ba[i].first;
	}
	sort(ba, ba+n);
	int now=0;
	REP(i, n){
		if(now+ba[i].second>ba[i].first){
			cout<<"No"<<'\n';
			return 0;
		}
		now+=ba[i].second;
	}
	cout<<"Yes"<<'\n';
	return 0;
}


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

#define ll long long
using namespace std;

int main() {
	ll x; cin >> x;
	unordered_map<ll, ll> map;
	ll i = 0LL;
	ll n, n5;
	while (true) {
		n = i;
		n5 = n*n*n*n*n;
		if (map.find(n5-x) != map.end()) {
			cout << n << " " << map[n5-x];
			return 0;
		}
		if (map.find(n5+x) != map.end()) {
			cout << map[n5-x] << " " << n;
			return 0;
		} 
		map[n5] = n;
		n = -i;
		n5 = n*n*n*n*n;
		if (map.find(n5-x) != map.end()) {
			cout << n << " " << map[n5-x];
			return 0;
		}
		if (map.find(n5+x) != map.end()) {
			cout << map[n5-x] << " " << n;
			return 0;
		}
		map[n5] = n;
		i += 1LL;
	}
}


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

int main()
{
    int a,b,c;

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    if (a==b || a==c || b==c || a>b || a>c || b>c)
        printf("No\n");
    else
        printf("%s\n", (a<b<c)?"Yes":"No");
    return 0;
}

Measured memory_bytes: 580