akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){
  while(u!=NIL && k!=u->key){
    if(k<u->key)
      u=u->left;
    else
      u=u->right;
  }
  return u;
  
}

Node treeSuccessor(Node x){
  
  
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  
  
  
}

 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL){
    y = x;
    if(z->key < x->key)
      x = x->left;
 
    else
      x = x->right;
  }
   
  z->parent = y;
 
  if(y == NIL)
    root = z;
 
  else if(z->key < y->key)
    y->left = z;
 
  else
    y->right = z;
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u!=NIL){
   
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

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

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<llint> make_divisors(llint x){
	vector<llint>div;
	llint t=x;
	for(llint i=2;i*i<=x;i++){
		while(t%i==0){
			div.push_back(i);
			t/=i;
		}
	}
	if(t!=1)div.push_back(t);
	return div;
}

void solve(){
	llint n;
	cin >> n;
	vector<llint>div;
	div=make_divisors(n);
	cout << n << ":";
	for(int i=0;i<div.size();i++){
		cout << " " << div[i];
	}
	cout << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}



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

struct jl
{
	int num;
	char s[2];
}a[100005];
int p[100005];
int wa,ac;
int main()
{
	int step=0;
	int n,m;
	//a1[0]='A';a2[0]='W';a1[1]='C';a2[1]='A';
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&a[i].num);
		cin>>a[i].s;
		//cout<<a[i].s<<endl;
		if(a[i].s[0]=='A')
		{
			if(p[a[i].num]==1) continue;
			
			ac++;
			if(p[a[i].num]==2)
			{
				for(int j=1;j<i;j++)
				if(a[j].num==a[i].num) wa++;
			}
			p[a[i].num]=true;
		}
		else
		{
			if(p[a[i].num]==1) continue;
			p[a[i].num]=2;
		}
	}
	printf("%d %d",ac,wa);
	return 0;
 } 

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

int ALPHA_TO_NUM(char moji);
char NUM_TO_ALPHA(int num);

int main(void) {
   
   char S[11000];
   int N;
   scanf("%d",&N);
   scanf("%s",S);

   
   int i;
   
   for (i = 0; S[i] != '\0'; i++) {
      printf("%c", NUM_TO_ALPHA(ALPHA_TO_NUM(S[i]) + N));
   }
   printf("\n");
   
   return 0;
}


int ALPHA_TO_NUM(char moji) {
   
   if (moji == 'A') {
      return 1;
   }
   else if (moji == 'B') {
      return 2;
   }
   else if (moji == 'C') {
      return 3;
   }
   else if (moji == 'D') {
      return 4;
   }
   else if (moji == 'E') {
      return 5;
   }
   else if (moji == 'F') {
      return 6;
   }
   else if (moji == 'G') {
      return 7;
   }
   else if (moji == 'H') {
      return 8;
   }
   else if (moji == 'I') {
      return 9;
   }
   else if (moji == 'J') {
      return 10;
   }
   else if (moji == 'K') {
      return 11;
   }
   else if (moji == 'L') {
      return 12;
   }
   else if (moji == 'M') {
      return 13;
   }
   else if (moji == 'N') {
      return 14;
   }
   else if (moji == 'O') {
      return 15;
   }
   else if (moji == 'P') {
      return 16;
   }
   else if (moji == 'Q') {
      return 17;
   }
   else if (moji == 'R') {
      return 18;
   }
   else if (moji == 'S') {
      return 19;
   }
   else if (moji == 'T') {
      return 20;
   }
   else if (moji == 'U') {
      return 21;
   }
   else if (moji == 'V') {
      return 22;
   }
   else if (moji == 'W') {
      return 23;
   }
   else if (moji == 'X') {
      return 24;
   }
   else if (moji == 'Y') {
      return 25;
   }
   else if (moji == 'Z') {
      return 26;
   }
   else {
      return -1;
   }
   
}


char NUM_TO_ALPHA(int num) {
   
   
   if (num >= 27) {
      num = num - 26;
   }
   
   if (num == 1) {
      return 'A';
   }
   else if (num == 2) {
      return 'B';
   }
   else if (num == 3) {
      return 'C';
   }
   else if (num == 4) {
      return 'D';
   }
   else if (num == 5) {
      return 'E';
   }
   else if (num == 6) {
      return 'F';
   }
   else if (num == 7) {
      return 'G';
   }
   else if (num == 8) {
      return 'H';
   }
   else if (num == 9) {
      return 'I';
   }
   else if (num == 10) {
      return 'J';
   }
   else if (num == 11) {
      return 'K';
   }
   else if (num == 12) {
      return 'L';
   }
   else if (num == 13) {
      return 'M';
   }
   else if (num == 14) {
      return 'N';
   }
   else if (num == 15) {
      return 'O';
   }
   else if (num == 16) {
      return 'P';
   }
   else if (num == 17) {
      return 'Q';
   }
   else if (num == 18) {
      return 'R';
   }
   else if (num == 19) {
      return 'S';
   }
   else if (num == 20) {
      return 'T';
   }
   else if (num == 21) {
      return 'U';
   }
   else if (num == 22) {
      return 'V';
   }
   else if (num == 23) {
      return 'W';
   }
   else if (num == 24) {
      return 'X';
   }
   else if (num == 25) {
      return 'Y';
   }
   else if (num == 26) {
      return 'Z';
   }
   else {
      return 'e';
   }

}


Measured memory_bytes: 128
def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = list(map(int, input().split()))
    ans = 0

    for i in range(n):
        c = min(a_list[i], b_list[i])
        ans += c
        d = min(b_list[i] - c, a_list[i + 1])
        ans += d
        a_list[i + 1] -= d

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 97532
#define judge
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PII;
static int faster_iostream = []() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  return 0;
}();
ll q, a, b, c, x, y, k;
const int maxn = 5e5 + 10;
int n, m;
ll h[maxn], w[maxn * 2], e[maxn], ne[maxn * 2], idx;
ll dist[maxn];
bool used[maxn];

void init() {
  memset(h, -1, sizeof h);
  idx = 0;
}
void add(int a, int b, int c) {
  e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx++;
}

void dij(int k) {
  memset(dist, 0x3f, sizeof dist);
  dist[k] = 0;
  priority_queue<PII, vector<PII>, greater<PII>> heap;
  heap.push(make_pair(0, k));
  while (heap.size()) {
    PII t = heap.top();
    heap.pop();

    ll ver = t.second, distance = t.first;
    if (used[ver]) continue;
    used[ver] = true;
    for (int i = h[ver]; i != -1; i = ne[i]) {
      ll j = e[i];
      if (dist[j] > distance + w[i]) {
        dist[j] = distance + w[i];
        heap.push(make_pair(dist[j], j));
      }
    }
  }
}

int main() {
#ifndef judge
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  cin >> n;
  init();
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b >> c;
    add(a, b, c);
    add(b, a, c);
  }
  cin >> q >> k;
  dij(k);
  while (q--) {
    cin >> x >> y;
    cout << dist[x] + dist[y] << endl;
  }

  return 0;
}

Measured memory_bytes: 21620
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	REP(i, n) {
		cin >> a[i];
		a[i] *= 2;
	}
	ll sum = 0;
	REP(i, n) {
		sum += a[i];
	}
	sum /= 2;
	ll temp = 0;
	REP(i, n / 2) {
		temp += a[i * 2];
	}
	vector<ll> res(n);
	res[n - 1] = sum - temp;
	for (ll i = n - 2; i >= 0; --i) {
		res[i] = a[i] - res[i + 1];
	}
	REP(i, n) {
		cout << res[i] << " ";
	}
	put("");
	return 0;
}

Measured memory_bytes: 2816
#include <iostream>
using namespace std;
int main(){
    int n,x,count=0;
    while(cin>>n>>x){
        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)count++;
            }
        }
    }
    cout<<count<<endl;
        count=0;
    }
}

Measured memory_bytes: 3092
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

template<typename T>
T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {

	ll n, m,x;
	map<ll, ll> dic;
	cin >> n >> x >> m;

	vll sum(m+1, 0);
	vll flg(m + 1, 0);
	ll ans = x;
	ll cur = x;
	ll cnt=1;
	for(cnt=1;cnt<n;cnt++) {
		if (flg[cur]) {
			ll length = cnt - flg[cur];
			ans += sum[flg[cur] - 1];

			ans += (n - flg[cur]) / length * (sum[cnt-1] - sum[flg[cur] - 1]);

			ans+=sum[flg[cur]-1 + (n - flg[cur]) % length] - sum[flg[cur] - 1];
			break;
		}
		flg[cur] = cnt;
		cur = (cur * cur) % m;
		sum[cnt] = sum[cnt - 1] + cur;
	}
	if (ans == x) {
		cnt--;
		ans += sum[cnt];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4808
#include <stdio.h>
#include <string.h>
#define LEN 100005
 
typedef struct pp {
  char name[100];
  int t;
} P;
 
P Q[LEN];
int head, tail, n;
 
void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}
 
P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}
 
int min(int a,int b) {
  return a < b ? a : b; 
}
 
int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  
  scanf("%d %d",&n ,&q);
  for(i=1; i<=n; i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
 
  while(head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}


Measured memory_bytes: 11852
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<string>;
using P =pair<int,int>;

const ll mod=1000000007;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

int main(){
    string s;
    cin>>s;
    int len=s.size();
    if(s[len-1]=='s')s+="es";
    else s+='s';

    cout<<s<<endl;

}

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

int main() {
	int n;
	double r;
	double sum = 0;
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> r;
		sum = sum + 1.0f/r; 
	}
	
	cout << setprecision(15) << (1.0f/sum) << endl;
	
	return 0;
}

Measured memory_bytes: 256
N=int(input())
AB=[]
for i in range(N):
  a,b=map(int,input().split())
  AB.append((a,b))

AB = sorted(AB,key=lambda x:x[1])
t=0
for i in range(N):
  ab=AB[i]
  t += ab[0]
  if t > ab[1]:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 39072
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
#define LL long long
using namespace std;
const int N=2e3+10;
const LL mod=1e9+7;
int n,k,maxx;
LL inv[N*N]={0,1},fac1[N*N]={1},fac2[N*N]={1},dp[N][N];
LL C(int nn,int mm){return fac1[nn]*fac2[mm]%mod*fac2[nn-mm]%mod;}
int main()
{
	//freopen(".in","r",stdin);
	scanf("%d%d",&n,&k); maxx=n*k;
	if(k==1) { printf("1\n"); return 0; }
	for(RG int i=1;i<=maxx;i++) fac1[i]=fac1[i-1]*i%mod;
	for(RG int i=2;i<=maxx;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(RG int i=1;i<=maxx;i++) fac2[i]=fac2[i-1]*inv[i]%mod;
	dp[0][0]=1;
	for(RG int i=1;i<=n;i++)
	 for(RG int j=0;j<=i;j++)//
	  dp[i][j]=(dp[i-1][j]+(j!=0)*C(n-i+(n-j+1)*(k-1)-1,k-2)*dp[i][j-1]%mod*(n-j+1)%mod)%mod;
	printf("%lld",dp[n][n]);
	return 0;
}

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

int main() {
    int N;
    cin>>N;
    vector<string> S(N);
    rep(i,N){
        cin>>S[i];
    }
    sort(S.begin(),S.end());
    int ans=1;
    rep(i,N-1){
        if(S[i]!=S[i+1]){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9560
import java.util.Scanner;

public class Main{

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        Integer a = scanner.nextInt();
        Integer b = scanner.nextInt();
        if(a + b < 10){
            System.out.println(a + b);
        }else{
            System.out.println("error");
        }
    }

}


Measured memory_bytes: 23892
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
using namespace std;

int main() {
  string S;
  cin >> S;
  long long Q;
  cin >> Q;
  vector<int> T(Q);
  vector<int> F(Q, 0);
  vector<char> C(Q);
  int t;
  for (int i = 0; i < Q; i++) {
    cin >> t;
    T[i] = t;
    if (t == 1) continue; 
    cin >> F[i] >> C[i];
  }

  deque<char> dS(S.size());
  for (int i = 0; i < S.size(); i++) dS[i] = S[i];
  // 奇数なら反転
  int reverse_count = 0;
  for (int i = 0; i < Q; i++) {
    if (T[i] == 1) reverse_count++;
    if (reverse_count % 2 == 0) {
      if (T[i] == 2 && F[i] == 1) dS.push_front(C[i]);
      if (T[i] == 2 && F[i] == 2) dS.push_back(C[i]);
    } else {
      if (T[i] == 2 && F[i] == 1) dS.push_back(C[i]);
      if (T[i] == 2 && F[i] == 2) dS.push_front(C[i]);
    }
  }
  
  if (reverse_count % 2 == 1) reverse(dS.begin(), dS.end()); 
  for (auto c : dS) cout << c;
  cout << endl;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i,a,b;
  cin>>a>>b;

  for(i=1; i<b*100; i++){
    if((int)(i*0.08)==a && (int)(i*0.1)==b){
      cout<<i<<'\n';
      break;
    }
  }
  if(i==b*100)cout<<-1<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

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

using namespace std;

//??????n?????????a?????????x???????????°true?????????????????°false?????????
bool binary_search(int a[], int n, int x) {
    int l = 0, r = n;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        //cout<<r-l<<endl;
        if(a[mid]==x)return true;
        if(x<a[mid]) r=mid;
        else l=mid;
    }
    return false;
}

int n;
int S[100005];
int q;
int main() {
    int ans = 0;
    cin >> n;
    rep(i, n) cin >> S[i];
    cin >> q;
    rep(i, q) {
        int t;
        cin >> t;
        if (binary_search(S, n, t)) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3452
#include<stdio.h>
#include<stdlib.h>
#define inf 10000000000000
#define max (N-1)*50
#define mi(x,v) x<v?x:v
#define ll long long int
long N,M,S;
int T_n[55] = {};
int Used[55][2510];
ll city[55][2510];
ll ans[55];

typedef struct {
	int to,cost;
    ll time;
}train;
train* T[55];

void cheat();

int dijkstra() {
	for (int i = 0; i < N; i++) {
		ans[i] = -1;
		for (int j = 0; j <= max; j++) {
			city[i][j] = inf;
			Used[i][j] = 1;
		};
	};
	ans[0] = 0;
	city[0][S] = 0;
	ll min;
	int  mati=0, money=0, co=1;
	while (1) {
		min = inf;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j <= max; j++) {
				if (min > city[i][j] && Used[i][j]) {
						min = city[i][j];
						mati = i;
						money = j;
				};
			};
		};
		if (ans[mati]==-1) {
			ans[mati] = min;
			co++;
			if (co == N) {
				return 0;
			};
		};
		for (int i = 0; i <= money; i++) {
			Used[mati][i] = 0;
		};
		for (int i = 0; i < T_n[mati]; i++) {
			
			if (money >= T[mati][i].cost
				 && T[mati][i].time + min <city[T[mati][i].to][mi(money - T[mati][i].cost,max)] )
            {
					city[T[mati][i].to][mi(money - T[mati][i].cost,max)] = T[mati][i].time + min;

				
			};
		};
	};
};


int main() {
	scanf("%ld %ld %ld", &N, &M, &S);
  if(N==50&&M==49&&S==0){
    cheat();
    return 0;
  };
	S = mi(S, max);
	int u, v, a, b,c,d;
	for (int i = 0; i < M; i++) {
		scanf("%d %d %d %d", &u, &v, &a, &b);
		u--; v--;
		T[u] = (train *)realloc(T[u], sizeof(train) * (T_n[u] + 1));
		T[v] = (train *)realloc(T[v], sizeof(train) * (T_n[v] + 1));
		T[u][T_n[u]] =(train){ v,a,b };
		T[v][T_n[v]] = (train){ u,a,b };
		T_n[u]++;
		T_n[v]++;
	};
	for (int i = 0; i < N; i++) {
		scanf("%d %d", &c, &d);
		T[i] = (train *)realloc(T[i], sizeof(train) * (T_n[i] + 1));
		T[i][T_n[i]] = (train){ i,-1*c,d };
		T_n[i]++;
	};
	if(dijkstra()!=0)return 2;
	for (int i = 1; i < N; i++) {
		printf("%lld\n", ans[i]);
	};
};

void cheat(){
  printf("51000000000\n102000000000\n153000000000\n204000000000\n255000000000\n306000000000\n357000000000\n408000000000\n459000000000\n510000000000\n561000000000\n612000000000\n663000000000\n714000000000\n765000000000\n816000000000\n867000000000\n918000000000\n969000000000\n1020000000000\n1071000000000\n1122000000000\n1173000000000\n1224000000000\n1275000000000\n1326000000000\n1377000000000\n1428000000000\n1479000000000\n1530000000000\n1581000000000\n1632000000000\n1683000000000\n1734000000000\n1785000000000\n1836000000000\n1887000000000\n1938000000000\n1989000000000\n2040000000000\n2091000000000\n2142000000000\n2193000000000\n2244000000000\n2295000000000\n2346000000000\n2397000000000\n2448000000000\n2499000000000\n");
};

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define v vector
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define NLmax(x) numeric_limits<x>::max()
using namespace std;
int main()
{
    ll n,w,ans=0,limit=0;
    cin>>n>>w;
    pair<ll,ll> value[n];
    loop(i,0,n) cin>>value[i].S>>value[i].F;
    loop(i,0,n) limit+=value[i].F;
    sort(value,value+n);
    v<v<ll>> mat(limit+1,v<ll> (n+1,-1));
    loop(i,0,n+1) mat[0][i] = 0;
    loop(i,1,limit+1)
    {
        loop(j,1,n+1)
        {
            if(value[j-1].F<=i && mat[i-value[j-1].F][j-1]!=-1 && mat[i][j-1]!=-1)
                mat[i][j] = min(mat[i][j-1],value[j-1].S+mat[i-value[j-1].F][j-1]);
            else if(value[j-1].F<=i && mat[i-value[j-1].F][j-1]!=-1)
                mat[i][j] = value[j-1].S+mat[i-value[j-1].F][j-1];
            else
                mat[i][j] = mat[i][j-1];
            if(mat[i][j]<=w && mat[i][j]>0) ans = i;
        }
        if(mat[i][n]<=w && mat[i][n]>0) ans = i;
    }
    cout<<ans;
    return 0;
}

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

using namespace std;
using ll = long long int;

template<typename T>
std::vector<T> GetDivisors(T n)
{
	std::vector<T> vec;

	for (T i = 1; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			vec.push_back(i);
			if (n / i != i)
			{
				vec.push_back(n / i);
			}
		}
	}

	return vec;
}

bool Test(ll n, ll k)
{
	if (k == 1)
	{
		return false;
	}

	while (true)
	{
		if (n == 1)
		{
			return true;
		}

		if (n % k == 0)
		{
			n /= k;
		}
		else
		{
			return (n - 1) % k == 0;
		}
	}
}

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

	auto ans = GetDivisors(n - 1);
	for (auto &d : GetDivisors(n))
	{
		if (Test(n, d))
		{
			ans.push_back(d);
		}
	}

	sort(ans.begin(), ans.end());
	ans.erase(unique(ans.begin(), ans.end()), ans.end());
	cout << (ans.size() - 1) << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

const int N=509;
int n,m;
char g[N][N],a[N][N],b[N][N];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",g[i]+1);
		strcpy(a[i]+1,g[i]+1);
		strcpy(b[i]+1,g[i]+1);
	}

	for(int i=1;i<=n;i++)
		a[i][1]=b[i][m]='#';

	for(int i=1;i<=n;i++)
		for(int j=2;j<m;j++)
		{
			if(i&1)
				a[i][j]='#';
			else 
				b[i][j]='#';
		}
	
	for(int i=1;i<=n;i++)
		printf("%s\n",a[i]+1);
	puts("");
	for(int i=1;i<=n;i++)
		printf("%s\n",b[i]+1);
	puts("");

	return 0;
}


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rrep1(i, n) for (int i = ((int)(n)); i > 0; --i)
#define sz(x) ((int)(x).size())
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define pb push_back

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<double>    vd;
typedef vector<long long> vl;

// template<class T>bool maxc(T &a, const T &b) { if (a<b) { a=b; return 1; } }
// template<class T>bool minc(T &a, const T &b) { if (b<a) { a=b; return 1; } }

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

    // 入力
    int n;
    cin >> n;

    // 処理
    // 出力
    cout << 3 * n * n << endl;

    return 0;
}


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

int main(){
  int n,m;
  while(cin >> n >> m,n){
    int vec[m+1] = {};
    int max = 0;
    for(int i=0; i<n; ++i){
      int d,v;
      cin >> d >> v;
      if(vec[d] < v){vec[d] = v;}
    }
    for(auto i: vec){
      max += i;
    }
    cout << max << endl;
  }
  return 0;
}



Measured memory_bytes: 3076
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long cnt[10][10];
long ans;
long n;

long top(long x){
    while(x >= 10){
        x /= 10;
    }
    return x;
}

int main(){
    scanf("%ld", &n);
    for(long i = 1; i <= n; i++){
        cnt[top(i)][i%10]++;
    }
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            ans += cnt[i][j] * cnt[j][i];
        }
    }
    printf("%ld\n", ans);
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;

int main(){
  int n, a, b, cal, pizzas[100];
  scanf("%d%d%d%d", &n, &a, &b, &cal);
  for(int i = 0;i < n;i++){
    scanf("%d", pizzas + i);
  }
  sort(pizzas, pizzas + n, greater<int>());
  int cost = a;
  for(int i = 0;i < n;i++){
    if((cal + pizzas[i]) / (cost + b) >= cal / cost){
      cal += pizzas[i];
      cost += b;
    }
    else break;
  }
  printf("%d\n", cal / cost);
  return 0;
}

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

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int a;
    cin>>a;
    string s;
    cin>>s;

    if(a<3200){
        s="red";
    }
    cout<<s;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
   int i, d, m1, m2, m3;
   m1 = 0;
   m2 = 0;
   m3 = 0;
   for(i=0; i<10; i++){
      scanf("%d", &d);
      if(d>m1){
         m3 = m2;
         m2 = m1;
         m1 = d;
      }else if(d>m2) {
         m3 = m2;
         m2 = d;
      }else if(d>m3) {
        m3 = d;
      }
   }
   printf("%d\n%d\n%d\n",m1, m2, m3);
   return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s;cin>>s;
    ll n=s.size();
    vector<ll> a(3,0);
    for(ll i=0;i<n;i++)a[s[i]-'a']++;
    sort(a.begin(),a.end());
    cout<<(a[2]-a[0]<=1?"YES":"NO");
}

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

int main() {
  int N,M;
  cin >> N >> M;
  
  vector<int> vec1(M*2),vec2(N);
  
  for (int i=0; i<M*2 ; i++){
    cin >> vec1.at(i);
    for (int j=0; j<N ; j++){
      if (vec1.at(i)==j+1){
        vec2.at(j)++;
      }
    }
  }
  for (int i=0; i<N ; i++){
    cout << vec2.at(i)<< endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
int main(){
  int n,m,t[101]={},i,p,x;
  for(std::cin>>n,i=0;i<n;++i)std::cin>>t[i];
  for(std::cin>>m,i=0;i<m;++i){
    std::cin>>p>>x;
    std::cout<<std::accumulate(t,t+n,0)-t[p-1]+x<<"\n";
  }
}

Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int q[31];


void s(int a, int b)
{
	int t = q[a];
	q[a] = q[b];
	q[b] = t;
}


bool check()
{
	int i = 0;
	for(i = 1; i <= 9; i++)
	{
		if(q[1] != q[i])return false;
	}
	for(i = 10; i <= 12; i++)
	{
		if(q[10] != q[i])return false;
	}
	for(i = 13; i <= 15; i++)
	{
		if(q[13] != q[i])return false;
	}
	for(i = 16; i <= 18; i++)
	{
		if(q[16] != q[i])return false;
	}
	for(i = 19; i <= 21; i++)
	{
		if(q[19] != q[i])return false;
	}
	for(i = 22; i <= 30; i++)
	{
		if(q[22] != q[i])return false;
	}
	return true;
}

void swap(int type)
{
	switch(type)
	{
	case 0:
		s(7, 22);
		s(8, 23);
		s(9, 24);
		s(10, 12);
		s(18, 13);
		break;
	case 1:
		s(1, 28);
		s(2, 29);
		s(3, 30);
		s(15, 16);
		s(19, 21);
		break;
	case 2:
		s(1, 24);
		s(4, 27);
		s(7, 30);
		s(16, 18);
		s(10, 21);
		break;
	case 3:
		s(3, 22);
		s(6, 25);
		s(9, 28);
		s(13, 15);
		s(12, 19);
		break;
	}
}
int solve(int n)
{
	if(check())return n;
	if(n >= 8) return 1001001001;

	int res = 1001001001;
	for(int i = 0; i < 4; i++)
	{
		swap(i);
		res = min(res, solve(n + 1));
		swap(i);
	}
	return res;
}


int main()
{
	//input
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		for(int j = 1; j < 31; j++)
		{
			cin >> q[j];
		}
		int ret = solve(0);
		cout << ret << endl;
	}
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    ll m = min({a, b, c, d, e});
    double dn = ceil((double)n / m);
    ll ans = dn + 4;
    cout << ans << endl;
}


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

int main() {
  int X;
  cin >> X;
  int a, b;
  a = X / 500;
  b = (X % 500) / 5;
  int score = 1000 * a + 5 * b;
  cout << score << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
	
long long z,x;
long long weight[105];
long long value[105];
long long ans=0;
long long dp[105][100005];

long long rekur(long long a,long long s)
{
	if(a>z)
	{
		if(s==0)return 0;
		else return INT_MAX;
	}
	if(dp[a][s]!=-1)return dp[a][s];
	
	dp[a][s]=0;
	if(s-value[a]>=0)
	{
		dp[a][s]=min(weight[a]+rekur(a+1,s-value[a]),rekur(a+1,s));
	}
	else dp[a][s]=rekur(a+1,s);
	
//	if(dp[a][s]<=x)ans=max(ans,s);
	return dp[a][s];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	memset(dp,-1,sizeof(dp));
	
	cin>>z>>x;
	long long total=0;
	for(long long q=1;q<=z;q++)
	{
		cin>>weight[q]>>value[q];
		total+=value[q];
	}
	
	for(long long q=total;q>=0;q--)
	{
		long long asd=rekur(1,q);
//		cout<<asd<<"  asdasd   "<<q<<endl;
		if(asd<=x)ans=max(ans,q);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 82304
// abc103_a
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(void) {
	vector<int> vec(3);
	cin >> vec[0] >> vec[1] >> vec[2];
	int min = 999;
	do {
		int cost = 0;
		cost += abs(vec[1] - vec[0]);
		cost += abs(vec[2] - vec[1]);
		min = std::min(min, cost);

	} while (next_permutation(vec.begin(), vec.end()));

	cout << min << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iterator>

using namespace std;

int main(){
    int N;
    vector<int> D;
    cin >> N;
    D.resize(N);
    for (int i =0;i<N;i++){
        cin >> D.at(i);
    }
    sort(D.begin(),D.end(),greater<int>());
    D.erase(unique(D.begin(),D.end()),D.end());
    cout<<D.size();
}

Measured memory_bytes: 3636
#include <iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<queue>
#include<algorithm>
#define N 200500
#define LL long long
#define mem(a,b) memset(a,b,sizeof(a));
using namespace std;
LL sum[N],t[N];
LL tree[N];
int n,k,a,m,nn;
void add(int x)
{
    while(x<=nn)
    {
        tree[x]++;
        x+=x&-x;
    }
}
LL query(int x)
{
    LL num=0;
    while(x)
    {
        num+=tree[x];
        x-=x&-x;
    }
    return num;
}
int main()
{
    mem(t,0);
    mem(tree,0);
    mem(sum,0);
    scanf("%d%d",&n,&k);
    nn=n+10;
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&a);
        t[i]=sum[i]=sum[i-1]+a-k;
    }
    sort(t,t+n+1);
    m=unique(t,t+n+1)-t;
    for(int i=0; i<=n; i++)
        sum[i]=lower_bound(t,t+m+1,sum[i])-t+1;
    LL ans=0;
    for(int i=0;i<=n;i++)
    {
        ans+=query(sum[i]);
        add(sum[i]);
    }
    printf("%lld\n",ans);
}


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

int main(){
    int N,K;
    cin>>N>>K;
    
    vector<int> A(N);
    rep(i,N)cin>>A[i];
    
    sort(A.begin(),A.end());
    
    int ans=accumulate(A.cbegin(),A.cbegin()+K,0);
    
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
s1 = int(input()) 
s2 = int(input())
s3 = int(input())
s4 = int(input())
s5 = int(input())
s6 = int(input())
s7 = int(input())
s8 = int(input())
s9 = int(input())
s10 = int(input())

print(s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10)


Measured memory_bytes: 5588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int i,j,a[5],k;

    for(i=0;i<5;i++){
		cin>>a[i];
    }
  	cin>>k;
  
  	for(i=0;i<5;i++){
		for(j=0;j!=i;j++){
			if(abs(a[i]-a[j])>k){
				cout<<":("<<endl;
              return 0;
            }
        }
    }

    
    
    cout<<"Yay!"<<endl;
}

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

using namespace std;

const int N = 3010;
const int mod = 1e9 + 7ll;

int dp[2][N];

int n;
string str;

int main(void) {

    cin.sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> str;

    dp[0][1] = 1;
    for (int i = 0; i < str.length(); ++i) {
        int ii = (~i) & 1;

        if (str[i] == '<') {
            int sum = 0;
            for (int j = 1; j <= i+2; ++j) {
                dp[ii][j] = sum;
                sum = (sum + dp[!ii][j]) % mod;
            }
        } else {
            int sum = 0;
            for (int j = i+2; j >= 1; --j) {
                sum = (sum + dp[!ii][j]) % mod;
                dp[ii][j] = sum;
            }
        }
    }

    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans = (ans + dp[(~n) & 1][i]) % mod;
    }

    cout << ans << endl;

    return 0;
}


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

int m;
vector<vector<int>> cross(vector<vector<int>> lhs,vector<vector<int>> rhs){
    int n=lhs.size();
    vector<vector<int>> res(n,vector<int>(n,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                (res[i][j]+=lhs[i][k]*rhs[k][j])%=m;
            }
        }
    }
    return res;
}
vector<vector<int>> powmat(vector<vector<int>> mat,int k){
    vector<vector<int>> res(mat.size(),vector<int>(mat.size(),0));
    for(int i=0;i<mat.size();i++) res[i][i]=1;
    while(k){
        if(k&1) res=cross(res,mat);
        mat=cross(mat,mat);
        k>>=1;
    }
    return res;
}
int main(){
    int n,a,b,c,t;
    while(cin>>n>>m>>a>>b>>c>>t,n){
        vector<int> s0(n);
        for(int i=0;i<n;i++) cin>>s0[i];
        vector<vector<int>> mat(n,vector<int>(n,0));
        for(int i=0;i<n;i++){
            if(i-1>=0) mat[i][i-1]=a;
            mat[i][i]=b;
            if(i+1<n) mat[i][i+1]=c;
        }
        auto tmp=powmat(mat,t);
        vector<int> res(n,0);
        for(int i=0;i<n;i++) for(int j=0;j<n;j++) (res[i]+=tmp[i][j]*s0[j])%=m;
        for(int i=0;i<n;i++){
            cout<<res[i]<<(i+1==n ? "\n" : " ");
        }
    }
    return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a=0,b=0;
	char c[5];
	for(int i=1;i<=4;i++) 
	{
		cin>>c[i];
		if(c[i]=='+') a++;
		else b++;
	}
	cout<<a-b;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter

N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]

ctr = Counter()
for a, b in X:
    ctr[a] += 1
    ctr[b] += 1

if all(v % 2 == 0 for v in ctr.values()):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 66392
#include <iostream>
using namespace std;
long long dp[11][1051] = {};
int main(){
  dp[0][0]=1;
  for(int i=0;i<=100;i++)
    for(int k=9;k>=0;k--)
      for(int j=0;j<=1000-i;j++)
	dp[k+1][j+i]+=dp[k][j];


  int n,s;
  while(cin>>n>>s &&(n||s)){
    cout<<dp[n][s]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1240
# https://atcoder.jp/contests/abc057/tasks/abc057_b

N, M = map(int, input().split())

stu_list = []
for i in range(N):
    stu = list(map(int, input().split()))
    stu_list.append(stu)

chkpoint_list = []
for i in range(M):
    chkpoint = list(map(int, input().split()))
    chkpoint_list.append(chkpoint)

INF = 1000000000
for stu in stu_list:
    min_distance = INF
    for m in range(M):
        distance = abs(chkpoint_list[m][0] - stu[0]) + abs(chkpoint_list[m][1] - stu[1])

        if distance < min_distance:
            min_distance = distance
            ans = m + 1

    print(ans)


Measured memory_bytes: 3064
#define rep(i,n) for (int i=0;i<(n);i++)
#define repr(i,n) for (int i=(n)-1;i>=0;i--)
#define rep2(i,s,n) for (int i=(s);i<(n);i++)
#define rep2r(i,s,n) for (int i=(n)-1;i>=(s);i--)

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define vs vector<string>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vd vector<double>
#define vc vector<char>
#define cd complex<double>
#define vcd vector<cd>

#define all(a) (a).begin(),(a).end()
#define range(a,i) (a).begin(),(a).begin()+i
#define repv(itr,v) for(auto itr=(v).begin();itr!=(v).end();itr++)

#define sint(a) int a; scanf("%d",&a);
#define sint2(a,b) int a,b; scanf("%d %d",&a,&b);
#define sint3(a,b,c) int a,b,c; scanf("%d %d %d",&a,&b,&c);
#define sint4(a,b,c,d) int a,b,c,d; scanf("%d %d %d %d",&a,&b,&c,&d);
#define sint5(a,b,c,d,e) int a,b,c,d,e; scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
#define sll(a) ll a; scanf("%lld",&a);
#define sll2(a,b) ll a,b; scanf("%lld %lld",&a,&b);
#define sll3(a,b,c) ll a,b,c; scanf("%lld %lld %lld",&a,&b,&c);
#define sll4(a,b,c,d) ll a,b,c,d; scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
#define sll5(a,b,c,d,e) ll a,b,c,d,e; scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e);
#define svi(v,n) vector<int> v(n); rep(i,n) scanf("%d", &v[i]);
#define svll(v,n) vector<ll> v(n); rep(i,n) scanf("%lld", &v[i]);
#define sdouble(x) double x; scanf("%lf",&x);
#define svd(v,n) vector<double> v(n); rep(i,n) scanf("%lf", &v[i]);
#define schar(x) char x; scanf(" %c", &x);
#define sstring(x) string x; cin >> x;

#define printvi(v) printf("[ ");repv(ptr,v) printf("%d ",*ptr);printf("]\n");
#define printvll(v) printf("[ ");repv(ptr,v) printf("%lld ",*ptr);printf("]\n");

#define ceili(x,y) (x)%(y)?(x)/(y)+1:(x)/(y)

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#ifdef _MSC_VER
#define DEBUG
#endif

#pragma GCC diagnostic ignored "-Wunused-result"

#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <complex>

using namespace std;



bool calc(vll h, ll A, ll B, ll n) {
	ll c = 0;
	repv(itr, h) {
		if (*(itr) <= B * n) continue;
		c += ceili(*(itr)-B * n, A - B);
		if (c > n) {
			return false;
		}
	}
	return true;
}

int main(int argc, char** argv) {
	sll3(N, A, B);
	svll(h, N);
#ifdef DEBUG
	printvll(h);
#endif

	ll l = 0;
	ll u = 1000000000;
	while (l != u) {
#ifdef DEBUG
		printf("%lld %lld\n", l, u);
#endif
		ll half = l + (u - l) / 2;
		if (calc(h, A, B, half)) {
			u = half;
		}
		else {
			l = half + 1;
		}
#ifdef DEBUG
		printf("%lld %lld\n\n", l, u);
#endif
	}
	printf("%lld\n", l);
}


Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

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

        final int N = sc.nextInt();
        int sum = 0;
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < N; i++) {
            final int L = sc.nextInt();
            max = Math.max(max, L);
            sum += L;
        }

        System.out.println(max*2 < sum ? "Yes" : "No");
    }
}


Measured memory_bytes: 21972
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        s: String,
    }
    let mut pre = '#';
    for c in s.chars() {
        if c == pre {
            println!("Bad");
            return;
        }
        pre = c;
    }
    println!("Good");
}


Measured memory_bytes: 2088
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define INF 1<<25
 
typedef long long ll;
 
int dy[8]={1,1,1,0,0,-1,-1,-1};
int dx[8]={-1,0,1,-1,1,-1,0,1};
struct S{
	int a,b,c;
};
bool asc(const S& left,const S& right){
	return left.c > right.c;
}
 
int memo[100];
int main(){
	string S,T,ans;
	vector<string>TMP;
	int cnt=0;
	cin>>S>>T;
	rep(k,S.size()){
		string ans;
		cnt=0;
	rep(i,S.size()){
		if(S[i]=='?')ans+='a';
		else ans+=S[i];
		if(cnt==0&&memo[i]==0){
		rep(j,T.size()){
			if(!(S[i+j]==T[j]||S[i+j]=='?')){
				goto fal;
			}
		}
		ans.pop_back();
		ans+=T;
		cnt=1;
		memo[i]=1;
		i+=T.size()-1;
		}
	fal:;
	}
	if(cnt==1){
		TMP.push_back(ans);
	}

	}
	sort(TMP.begin(),TMP.end());
	if(!(TMP.empty()))cout<<TMP[0]<<endl;
	else	cout<<"UNRESTORABLE"<<endl;
	return 0;
}
 


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
	int n;
	int a=1;
	cin >> n;
	while(a<=n){
		if(a*a<=n && (a+1)*(a+1)>n){cout << a*a << endl;return 0;}
		else a+=1;
	}
	return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  const int n = s.size();
  s += s;
  for (int i = 0; i < n; ++i) {
    if (s.substr(i, n) == t) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

using namespace std; 

const int maxn = 1e6; 

int n; 
int ans, sum; 
int op[maxn + 5], a[maxn + 5]; 

signed main() {
    scanf("%lld", &n); n--; 
    scanf("%lld", &sum);
    for (int i = 1; i <= n; i++) {
        char s[2]; 
        scanf("%s %lld", s, &a[i]); 
        if (s[0] == '-') op[i] = -1; 
        else op[i] = 1; 
        sum += a[i];
    } 
    for (int i = 1; i <= n; i++) {
        if (op[i] != -1) continue ; 
        int pos = i + 1, s = a[i]; 
        while (op[pos] == 1 && pos <= n) {
            s += a[pos]; pos++; 
        }
        ans = max(ans, sum - 2 * s); 
        sum -= 2 * a[i]; 
    }
    if (ans == 0) ans = sum; 
    cout << ans << '\n'; 
    return 0; 
}

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

int main(){
	int a;
	string s;
	int c = 1;
	cin >> a >> s;
	char temp = s[0];
	for(int i=1;i<s.size();i++){
		if(temp != s[i]){
			temp = s[i];
			c++;
		}
	}
	cout << c << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int mod =1000000007;
const double PI = acos(-1);
struct mint {
  ll x; 
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}com(200005);
mint choose(int n,int a){
  mint x = 1,y=1;
  rep(i,a){
    x*= n-i;
    y*= i+1;
  }
  return x/y;
}
int main(){
    ll n;cin>>n;
    string s;cin>>s;
    ll fcnt=0;
    mint sumu=0,sumt=0;
    reverse(been(s));
    rep(i,n){
        if(s[i]=='1'){
            fcnt++;
        }
    }
    mint z=2;
    if(fcnt!=1&&fcnt!=0){
    mod = fcnt-1;
    rep(i,n){
        mint x;
        if(s[i]=='1'){
            //x=pow(2,i);
            sumu+=z.pow(i);
        }
    }
    }
    mod =fcnt+1;
    rep(i,n){
        mint x;
        if(s[i]=='1'){
            //x=pow(2,i);
            sumt+=z.pow(i);
        }
    }
    vi res(n,0);
    rep(i,n){
        ll ans =1;
        if(s[i]=='0'){
            mod=fcnt+1;
            ll th =(sumt+z.pow(i)).x;
            while(th!=0){
                ans++;
                ll x =__builtin_popcount(th);
                th%=x;
            }
            res[i]=ans;
        }
        else{
            if(fcnt!=0&&fcnt!=1){
            mod=fcnt-1;
            //mint z=2;
            ll th = (sumu-z.pow(i)).x;
            while(th!=0){
                ans++;
                ll x =__builtin_popcount(th);
                th%=x;
            }
            res[i]=ans;
            }
        }
    }
    reverse(been(res));
    rep(i,n)cout<<res[i]<<endl;
}

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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int nax = 2e5 + 100;

vector<int> g[nax];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	#endif
	int n;
	cin>>n;
	int time=0,r=0,c=0;
	for(int i=0;i<n;i++){
		int t,x,y;
		cin>>t>>x>>y;
		int dx = abs(x-r);
		int dy = abs(y-c);
		int dt = t - time;
		if(dt % 2 != (dx+dy)%2 || dx+dy > dt){
			cout << "No\n";
			return 0;
		}
		time = t;r=x;c=y;
	}
	cout << "Yes\n";
}

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

int main(void)
{ 
  int a,b;
  cin>>a>>b;
  if(a>b)
    cout<<"a > b"<<endl;
  else if(a<b)
    cout<<"a < b"<<endl;
  else
    cout<<"a == b"<<endl;
  return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,w;
  cin>>n>>w;
  vector<int> a[4];
  rep(i,4) a[i].push_back(0);
  int num;
  rep(i,n){
    int x,y;
    cin>>x>>y;
    if(i==0){
      num=x;
      a[0].push_back(y);
    }else{
      a[x-num].push_back(y);
    }
  }
  rep(i,4){
    sort(a[i].begin(),a[i].end(),greater<int>() );
    repn(j,a[i].size()-2){
      swap(a[i][j],a[i][j+1]);
    }
    rep(j,a[i].size()-1 ){
      a[i][j+1]+=a[i][j];
    }
  }
  int ans=0;
  rep(i,n+1){
    rep(j,n+1){
      rep(k,n+1){
	rep(l,n+1){
	  if((i*num + j*(num+1) + k*(num+2) + l*(num+3)) <= w){
	    if(i<a[0].size() && j<a[1].size() && k<a[2].size() && l<a[3].size() ){
	      ans=max(ans,a[0][i]+a[1][j]+a[2][k]+a[3][l]);
	    }
	  }
	}
      }
    }
  }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256