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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

//π M_PI
//deg = rad*180/M_PI

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if ( a+b+c >= 22 ) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
    return 0;
}


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

lint num_fac(lint n, lint p) {
    lint res = 0;
    lint pow = p;
    while (n / pow) {
        res += n / pow;
        pow *= p;
    }
    return res;
}

int main() {
    lint n;
    cin >> n;
    lint ans;
    if (n % 2 == 0) {
        lint k = n / 2;
        lint a = num_fac(k, 2) + k;
        lint b = num_fac(k, 5);
        ans = min(a, b);
    } else {
        ans = 0;
    }
    cout << ans << endl;
}

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


int sx, sy, tx, ty;
int main(){
    cin >> sx >> sy >> tx >> ty;
    for(int i = 0; i < ty - sy; i++){
        cout << "U";
    }
    for(int i = 0; i < tx - sx; i++){
        cout << "R";
    }
    for(int i = 0; i < ty - sy; i++){
        cout << "D";
    }
    for(int i = 0; i < tx - sx; i++){
        cout << "L";
    }
    cout << "L";
    for(int i = 0; i < ty - sy + 1; i++){
        cout << "U";
    }
    for(int i = 0; i < tx - sx + 1; i++){
        cout << "R";
    }
    cout << "D";
    cout << "R";
    for(int i = 0; i < ty - sy + 1; i++){
        cout << "D";
    }
    for(int i = 0; i < tx - sx + 1; i++){
        cout << "L";
    }
    cout << "U";
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

#define ff first
#define ss second
#define pb push_back
#define sz size()
#define mp make_pair
#ifndef ONLINE_JUDGE 
#include "/home/asif/Codes/Library/debug.h"
#endif
/*--------------------------------------------------------------------*/

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int main() {

  int n;
  cin >> n; std::vector<int> A(n), B(n);
  for(int i = 0; i < n; i++) cin >> A[i] >> B[i];
  sort(A.begin(), A.end()); sort(B.begin(), B.end());
  if(n & 1){
    cout << max(0, B[n / 2] - A[n / 2] + 1) << endl;
  }
  else {
    cout << max(0, (B[n / 2] + B[(n / 2) - 1]) - (A[n / 2] + A[(n / 2) - 1]) + 1) << endl;
  }

  return 0;
}

Measured memory_bytes: 4812
h, n = map(int, input().split())
ab = []
for _ in range(n):
    ab.append(list(map(int, input().split())))
inf = 1001001001
lis = [inf] * (2*10**4+5)
lis[0] = 0
for i in range(len(lis)):
    for j in range(n):
        a = ab[j][0]
        b = ab[j][1]
        if i+a < len(lis):
            lis[i+a] = min(lis[i]+b, lis[i+a])
print(min(lis[h:]))

Measured memory_bytes: 42220
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.trim().split('\n');

var line;
while (line = lines.shift()) {
	var speed = +line;

	for (var f = 1;; f++) {
		var t = Math.sqrt((f * 5 - 5) / 4.9);
		var v = 9.8 * t;

		if (v >= speed) {
			console.log(f);
			break;
		}
	}
}

Measured memory_bytes: 7644
#include<stdio.h>
#define MAX 1000000
#define NIL -1

struct Node {
  int p,l,r;
};
struct Node T[MAX];
int n;

void preParse(int u) {
  if(u == NIL) return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u) {
  if(u == NIL) return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u) {
  if(u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main() {
  int i,id,l,r,root;

  scanf("%d",&n);

  for(i = 0;i < n;i++) {
    T[i].p = NIL;
  }

  for(i = 0;i < n;i++) {
    scanf("%d%d%d",&id,&l,&r);
    T[id].l = l;
    T[id].r = r;
    if(l != NIL) T[l].p = id;
    if(r != NIL) T[r].p = id;
  }

  for(i = 0;i < n;i++) {
    if(T[i].p == NIL) root = i;
  }
  printf("Preorder\n");
  preParse(root);
  printf("\n");

  printf("Inorder\n");
  inParse(root);
  printf("\n");

  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2048
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    long X =sc.nextLong();
    if(X<0){X=-X;}
    long K =sc.nextLong();
    long D =sc.nextLong();
    long w =X/D;
    long ans;
    if(w>K){ans=X-K*D;}
    else{
      long z = X-w*D;
      long p =K-w;
      if(p%2==0){ans =z;}
      else{ans =z-D;}
    }
    ans =Math.abs(ans);
    System.out.println(ans);
  }
}

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

//素数ならば1，そうでなければ0を返す関数
int primality(int number);

//正の整数numberの因数分解での素数pの指数を返す関数
int exponent(int number, int p);

int main(void){
  int N;
  int s, t, u;//N!の因数分解での素数pの指数
  int count = 0;//七五数の個数
  int i, j, k, l;//カウンタ

  scanf("%d", &N);

  for(i = 2; i <= N; i++){
    if(primality(i) == 1){
      //N!の因数分解での素数iの指数sを求める
      s = 0;
      for(l = 1; l <= N; l++){
        s += exponent(l, i);
      }

      //p^74の形の七五数をカウント
      if(s >= 74){
        count++;
      }
    }
  }

  for(i = 2; i <= N; i++){
    for(j = i+1; j <= N; j++){
      if(primality(i) == 1 && primality(j) == 1){
        //N!の因数分解での素数iの指数sを求める
        s = 0;
        for(l = 1; l <= N; l++){
          s += exponent(l, i);
        }

        //N!の因数分解での素数jの指数tを求める
        t = 0;
        for(l = 1; l <= N; l++){
          t += exponent(l, j);
        }

        //p^2 q^24, p^4 q^14, p^14 q^4, p^24 q^2 (p < q) の形の七五数をカウント
        if(s >=  2 && t >= 24){
          count++;
        }
        if(s >=  4 && t >= 14){
          count++;
        }
        if(s >= 14 && t >=  4){
          count++;
        }
        if(s >= 24 && t >=  2){
          count++;
        }
      }
    }
  }

  for(i = 2; i <= N; i++){
    for(j = i+1; j <= N; j++){
      for(k = j+1; k <= N; k++){
        if(primality(i) == 1 && primality(j) == 1 && primality(k) == 1){
          //N!の因数分解での素数iの指数sを求める
          s = 0;
          for(l = 1; l <= N; l++){
            s += exponent(l, i);
          }

          //N!の因数分解での素数jの指数tを求める
          t = 0;
          for(l = 1; l <= N; l++){
            t += exponent(l, j);
          }

          //N!の因数分解での素数kの指数uを求める
          u = 0;
          for(l = 1; l <= N; l++){
            u += exponent(l, k);
          }

          //p^2 q^4 r^4, p^4 q^2 r^4, p^4 q^4 r^2 (p < q < r)の形の七五数をカウント
          if(s >= 2 && t >= 4 && u >= 4){
            count++;
          }
          if(s >= 4 && t >= 2 && u >= 4){
            count++;
          }
          if(s >= 4 && t >= 4 && u >= 2){
            count++;
          }
        }
      }
    }
  }

  printf("%d\n", count);
  return 0;
}

int primality(int number){
  int i;

  if(number <= 1){
    return 0;
  }else{
    for(i = 2; i < number; i++){
      if(number%i == 0){
        return 0;
      }
    }
    return 1;
  }
}

int exponent(int number, int p){
  int s = 0;//指数

  if(number <= 0){
    printf("error: non-positive number\n");
    exit(0);
  }else if(primality(p) == 0){
    printf("error: composite number\n");
    exit(0);
  }

  while(number%p == 0){
    s++;
    number /= p;
  }
  return s;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))


lli rs[500005];

int main(void){
	int n;
	lli p,q,cs=0;
	scanf("%d%lld%lld",&n,&p,&q);
	rep(i,n){
		lli a;
		scanf("%lld",&a);
		cs+=a;
		rs[i] = q*p-a-(i*p);
		//printf("%d : %lld\n",i,rs[i]);
	}
	lli s=2*p;
	
	
	sort(rs,rs+n,greater<lli>());
	
	lli ans=0;
	lli sr=0;
	reg(i,0,n){
		lli nc = sr + s * i * (i-1) / 2;
		//printf("%d : %lld : %lld\n",i,sr,nc);
		ans = max(ans,nc);
		sr+=rs[i];
	}
	
	printf("%lld\n",ans+cs);
	return 0;
}

Measured memory_bytes: 7196
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            if (input[1] == "+")
            {
                Console.WriteLine("{0}", int.Parse(input[0]) + int.Parse(input[2]));
            }
            else
            {
                Console.WriteLine("{0}", int.Parse(input[0]) - int.Parse(input[2]));
            }
        }
    }
}


Measured memory_bytes: 2776
# yorikatu_58_a.py
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = sum(B)
for i in range(N-1):
    if A[i]+1==A[i+1]:
        ans += C[A[i]-1]
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#define max(a,b) ((a)>(b)?(a):(b))

typedef long long ll;
const int maxn=300+10,mod=1000000007;
int f[maxn][maxn][maxn];
bool g[maxn][maxn][maxn];

void set(int op,int l1,int r1,int l2,int r2){
	for(int i=l1;i<=r1;++i)
		for(int j=l2;j<=r2;++j)
			g[op][i][j]=1;
	for(int i=l1;i<=r1;++i)
		for(int j=l2;j<=r2;++j)
			g[i][op][j]=1;
	for(int i=l1;i<=r1;++i)
		for(int j=l2;j<=r2;++j)
			g[i][j][op]=1;
}

int main(){
	// freopen("in.txt","r",stdin);
	int n,m,l,r,t;ll ans=0;scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i){
		scanf("%d%d%d",&l,&r,&t);
		if(t==1){
			set(r,0,r,l,r);
			set(r,l,r,0,r);
		}
		else if(t==2){
			set(r,l,r,l,r);
			set(r,0,l-1,0,l-1);
		}
		else{
			set(r,0,r,0,l-1);
			set(r,0,l-1,0,r);
		}
	}
	f[0][0][0]=1;
	for(int i=0;i<=n;++i)
		for(int j=0;j<=n;++j)
			for(int k=0;k<=n;++k)if(!g[i][j][k]){
				t=max(max(i,j),k)+1;
				f[t][j][k]+=f[i][j][k];
				f[t][j][k]%=mod;
				f[i][t][k]+=f[i][j][k];
				f[i][t][k]%=mod;
				f[i][j][t]+=f[i][j][k];
				f[i][j][t]%=mod;
			}
	for(int i=0;i<=n;++i)
		for(int j=0;j<=n;++j)if(!g[n][i][j])
			ans+=f[n][i][j];
	for(int i=0;i<=n;++i)
		for(int j=0;j<=n;++j)if(!g[i][n][j])
			ans+=f[i][n][j];
	for(int i=0;i<=n;++i)
		for(int j=0;j<=n;++j)if(!g[i][j][n])
			ans+=f[i][j][n];
	printf("%lld\n",ans%mod);
	return 0;
}

Measured memory_bytes: 143616
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)

using namespace std;

const int N=2e5+100,mod=1e9+7;
int n,x,f[N],g[N],a[N];

void upd(int &x,int y){x+=y; x-=x>=mod?mod:0;}

int main(){
	scanf("%d",&n);
	rep (i,1,n) scanf("%d",&a[i]);
	n=unique(a+1,a+1+n)-a-1;
	f[0]=1;
	rep (i,1,n) upd(g[a[i]],f[i-1]),upd(f[i],g[a[i]]);
	printf("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <complex>
#include <cmath>

#define MAX_N 60
#define MAX_M 20
using namespace std;

#define P complex<int>

int abs( P p ){
  return sqrt( norm( p ) );
}

int main(){
  int n, m,mm;
  P org[MAX_M];
  P cmp[MAX_M];
  P d, o,c,deg;

  while( cin>>n && n ){

    cin >> mm;
    for( int i=0;i<mm;i++ )
      cin >> org[i].real() >> org[i].imag();

    d = org[0];
    for( int i=0;i<mm;i++ )
      org[i] = org[i] - d;

    for( int loop=1;loop<=n;loop++ ){
      cin >> m;
      for( int i=0;i<m;i++ )
	cin >> cmp[i].real() >> cmp[i].imag();
      if( m!=mm )
	continue;
      bool f=false;

      d= cmp[0] - org[0];
      for( int i=0;i<m;i++ ) // ツ閉スツ行ツ暗堋督ョ
	cmp[i] = cmp[i] - d;

      o = org[1] / abs(org[1]);
      c = cmp[1] / abs(cmp[1]);
      deg = P( 1,0 );

      while( o!=c ){
	c = c * P( 0,1 );
	deg *= P( 0,1 );
      }

      for( int i=1;i<m;i++ ) // ツ嘉アツ転
	cmp[i] = cmp[i] * deg;

      for( int i=1;i<m;i++ ){
	if( org[i]!=cmp[i] )
	  break;
	if( i==m-1 ) f=true;
      }

      if( !f ){
	d = cmp[m-1] - org[0];
	for( int i=0;i<m;i++ )
	  cmp[i] = cmp[i] - d; // ツ閉スツ行ツ暗堋督ョ
	o = org[1] / abs(org[1]);
	c = cmp[m-2] / abs(cmp[m-2]);
	deg = P( 1,0 );
	while( o!=c ){
	  c = c * P( 0,1 );
	  deg *= P( 0,1 );
	}
	for( int i=0;i<m-1;i++ ) // ツ嘉アツ転
	  cmp[i] = cmp[i] * deg;
	
	for( int i=0;i<m-1;i++ ){
	  if( org[i]!=cmp[m-i-1] )
	    break;
	  if( i==m-2 ) f=true;
	}
      }
      if( f )
	cout << loop << endl;
    
    }
    cout << "+++++"<<endl;
  }

  return 0;
}

Measured memory_bytes: 0
import java.util.*;
import java.io.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    long mod = 998244353;
    long[] frac, inv;
    public static void main(String[] args){
        Main main = new Main();
//        String ans = main.solve()<0?"No":"Yes";
        System.out.println(main.solve());
    }
    double solve(){
        double l = sc.nextDouble();
        l = l/3.0;
        return l*l*l;
    }
}


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

int main()
{
    int n,i,point;
    string shop_name;
    cin>>n;

    pair<pair<string,int>,int> data[n];
    for(i = 0; i < n; i++)
    {
        cin>>shop_name>>point;
        data[i] = make_pair(make_pair(shop_name,-point),i);
    }
    sort(data,data+n);

    for(i = 0; i < n; i++)
    {
        cout<<data[i].second+1<<endl;
    }
}

Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

vector<P> child[101][101];
Int height[101][101];
Int h[101];
Int dp[101][101][2];

Int n;


Int mod_pow(Int x, Int a, Int m = MOD){
  if(a == 0)return 1;
  Int res = mod_pow(x, a / 2, m);
  res = res * res % m;
  if(a % 2)res *= x;
  return res % m;
}

Int inv(Int x, Int m = MOD){
  return mod_pow(x, m-2, m);
}

void dfs(int l, int r, int base = 0){
  height[l][r] = INF * 2;
  for(int i = l;i <= r;i++){
    height[l][r] = min(height[l][r], h[i]);
  }
  int nl = l;
  int nc = 0;
  for(int i = l;i <= r;i++)nc += height[l][r] == h[i];
  while(true){
    while(nl <= r && h[nl] <= height[l][r])nl++;
    if(nl > r)break;
    Int nr = nl;
    while(nr+1 <= r && h[nr+1] > height[l][r])nr++;
    child[l][r].push_back(P(nl, nr));
    dfs(nl, nr, height[l][r]);
    nl = nr+1;
  }
  
  height[l][r] -= base;
  dp[l][r][0] = mod_pow(2, height[l][r]);
  dp[l][r][1] = mod_pow(2, nc);
  Int pk = 1;
  for(auto c:child[l][r]){
    pk *= dp[c.first][c.second][0];pk %= MOD;
    dp[l][r][1] *= (dp[c.first][c.second][0]*2 + dp[c.first][c.second][1]) % MOD;dp[l][r][1] %= MOD;
  }
  dp[l][r][0] *= pk;dp[l][r][0] %= MOD;
  dp[l][r][1] -= 2*pk;dp[l][r][1] %= MOD;
  //  cout << l<< " " << r << " " <<  dp[l][r][0] << " " << dp[l][r][1] << endl;
}

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

  dfs(0, n-1);
  Int res = dp[0][n-1][0] + dp[0][n-1][1];res %= MOD;
  if(res < 0)res += MOD;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 768
#include<stdio.h>

#define NIL -1
#define MAX 25

typedef struct Node{
  int id;
  int p;
  int left;
  int right;
}Node;

Node T[MAX];

void preParse(int u){
  if(u==NIL)return;
  printf(" %d",u);
  preParse(T[u].left);
  preParse(T[u].right);
}

void inParse(int u){
  if(u==NIL)return;
  inParse(T[u].left);
  printf(" %d",u);
  inParse(T[u].right);
}

void postParse(int u){
  if(u==NIL)return;
  postParse(T[u].left);
  postParse(T[u].right);
  printf(" %d",u);
}

int main(){
  int n,i,u,root;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].p=NIL;
    T[i].left=NIL;
    T[i].right=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d",&u);
    T[u].id=u;
    scanf("%d%d",&T[u].left,&T[u].right);
    if(T[u].left!=NIL)T[T[u].left].p=T[u].id;
    if(T[u].right!=NIL)T[T[u].right].p=T[u].id;
  }

  for(i=0;i<n;i++){
    if(T[i].p==NIL)
      root=i;
  }

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2140
#include <iostream>
#include <stdio.h>

using namespace std;
int main(void){
    int a;
    int b;
    
    while(1){
        cin>>a;
        cin>>b;
        
        if(a==0&&b==0){
            break;
        }
        
        for(int i=0;i<a;i++){
            for(int j=0;j<b;j++){
                cout<<"#";
            }
            cout<<endl;
        }
        
        cout<<endl;
    }
    
    
    return 0;
}


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

int main (){
  int n;cin>>n;
  string s;cin>>s;
  ll numR=0,numG = 0,numB = 0;
  rep(i,n){
    if (s.at(i) == 'R'){
      numR++;
    }
    else if (s.at(i) == 'G'){
      numG++;
    }
    else if (s.at(i) =='B'){
      numB ++;
    }
  }
  ll sum = 0;
  rep(i,n){
    for (int j = 1;j<=(n-i-1)/2;j++){
      if (s.at(i) != s.at(i+j) && s.at(i) != s.at(i + 2*j) && s.at(i+j) != s.at(i+2*j)){
        sum++;
      }
    }
  }
  cout << numR*numG*numB - sum << endl;
}

Measured memory_bytes: 3628
n = int(input())
s = list(input())

#!/usr/bin/env python
def caesar(s, n):
    ns = []
    for ch in s:
        # A - Z
        if ('A' <= ch and ch <= 'Z'):
            ns.append(chr((ord(ch) - ord('A') + n) % 26 + ord('A')))
        # a - z
        elif ('a' <= ch and ch <= 'z'):
            ns.append(chr((ord(ch) - ord('a') + n) % 26 + ord('a')))
        # 0 - 9
        elif ('0' <= ch and ch <= '9'):
            ns.append(chr((ord(ch) - ord('0') + n) % 10 + ord('0')))
        # no change for other characters
        else:
            ns.append(ch)
    return "".join(ns)

result = caesar(s, n)
print(result)

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pll> vp;
typedef vector<ll> vll;

const int MAX_V = 10000;

int V, E;
vi G[MAX_V];
vi rG[MAX_V];
vi vs;
bool used[MAX_V];
int cmp[MAX_V];

void addEdge(int from, int to) {
    G[from].emplace_back(to);
    rG[to].emplace_back(from);
}

void dfs(int v) {
    used[v] = true;
    rep(i, G[v].size()) {
        if (!used[G[v][i]]) dfs(G[v][i]);
    }
    vs.emplace_back(v);
}

void rdfs(int v, int k) {
    used[v] = true;
    cmp[v] = k;
    rep(i, rG[v].size()) {
        if (!used[rG[v][i]]) rdfs(rG[v][i], k);
    }
    vs.emplace_back(v);
}

int scc() {
    memset(used, 0, sizeof(used));
    vs.clear();
    rep(v, V) {
        if (!used[v]) dfs(v);
    }
    memset(used, 0, sizeof(used));
    int k = 0;
    for (int i = vs.size() - 1; i >= 0; i--) {
        if (!used[vs[i]]) rdfs(vs[i], k++);
    }
    return k;
}

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

    cin >> V >> E;
    rep(i, E) {
        int s, t;
        cin >> s >> t;
        addEdge(s, t);
    }

    scc();

    int Q;
    cin >> Q;
    rep(i, Q) {
        int u, v;
        cin >> u >> v;
        cout << (cmp[u] == cmp[v]) << endl;
    }

}

Measured memory_bytes: 4740
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
map<pii,int> zz;
int N,K,L;
int fa[MAXN],col[MAXN][2],tot;
int getfa(int x) {
    return fa[x] == x ? x : fa[x] = getfa(fa[x]);
}
void Solve() {
    read(N);read(K);read(L);
    for(int i = 1 ; i <= N ; ++i) fa[i] = i;
    int a,b;
    for(int i = 1 ; i <= K ; ++i) {
	read(a);read(b);
	fa[getfa(a)] = getfa(b);
    }
    tot = 0;
    for(int i = 1 ; i <= N ; ++i) {
	if(getfa(i) == i) col[i][0] = ++tot;
    }
    for(int i = 1 ; i <= N ; ++i) col[i][0] = col[getfa(i)][0];
    for(int i = 1 ; i <= N ; ++i) fa[i] = i;
    for(int i = 1 ; i <= L ; ++i) {
	read(a);read(b);
	fa[getfa(a)] = getfa(b);
    }
    tot = 0;
    for(int i = 1 ; i <= N ; ++i) {
	if(getfa(i) == i) col[i][1] = ++tot;
    }
    for(int i = 1 ; i <= N ; ++i) col[i][1] = col[getfa(i)][1];
    for(int i = 1 ; i <= N ; ++i) {
	zz[mp(col[i][0],col[i][1])]++;
    }
    for(int i = 1 ; i <= N ; ++i) {
	out(zz[mp(col[i][0],col[i][1])]);space;
    }
    enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 14336
#include<iostream>
#include<string>

using namespace std;

int main() {
	string s;
	cin >> s;
	int len = (int)s.size();

	if (s[0] == 'A') {
		s[0] = 'a';
		int a;
		for (a = 2; a < len - 1; a++) {
			if (s[a] == 'C') {
				s[a] = 'c';
				break;
			}
		}
		if (a == len - 1) {
			cout << "WA";
		}
		else {
			string ss = s;
			for (int b = 0; b < len; b++) ss[b] = tolower(ss[b]);
			if (ss != s)cout << "WA";
			else cout << "AC";
		}
	}
	else cout << "WA";

	cout << endl;

	return 0;
}

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

using namespace std;


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

	int a, b, c, ans = 0, x;
	cin >> a >> b >> c;
	x = min(b, c);
	ans += 2 * x;
	b -= x; c -= x;
	x = min(a, c);
	ans += x;
	a -= x; c -= x;
	if (c > 0) ans++;
	if (b > 0) ans += b;

	cout << ans << "\n";


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,a,b;
  cin >> n >> a >> b;

  cout << ((b-a)%2==0 ? "Alice" : "Borys") << endl;
  return 0;
}

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

#define N 600

int main(void)
{
	char s[N][N],a[N];
	int n,l,i,j;
	scanf("%d%d",&n,&l);
	for(i=0;i<n;i++){
		scanf("%s",s[i]);
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(strcmp(s[j-1],s[j])>0){
				strcpy(a,s[j-1]);
				strcpy(s[j-1],s[j]);
				strcpy(s[j],a);
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%s",s[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 256
void main() {
	auto ip = readln.split, a = ip[0], b = ip[1];
	if(a == b) "H".writeln;
	else "D".writeln;
}

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

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll T, ll X) {
  auto ans = (ld)T/X;
  cout << fixed << ans << endl;
}

int main() {
  ll T;
  cin >> T;
  ll X;
  cin >> X;
  solve(T, X);
  return 0;
}


Measured memory_bytes: 256
(* ??????????????????????????????????????\?????? *)
let h = ref 0

let parent i = int_of_float (floor (float_of_int i) /. 2.)

let left i = 2*i

let right i = 2*i + 1

let extract (t : int array) =
  let ret = t.(1) in
  t.(1) <- t.(!h);
  decr h;
  let rec max_heapify i =
    let l = left i in
    let r = right i in
    let m = if l <= !h && t.(l) > t.(i) then l else i in
    let m = if r <= !h && t.(r) > t.(m) then r else m in
    if m <> i then begin
      let tmp = t.(i) in t.(i) <- t.(m); t.(m) <- tmp;
      max_heapify m
    end in
  max_heapify 1;
  ret

let insert x (t : int array) =
  incr h;
  t.(!h) <- x;
  let rec doit i =
    if i > 1 && t.(parent i) < t.(i) then begin
      let tmp = t.(i) in t.(i) <- t.(parent i); t.(parent i) <- tmp;
      doit (parent i)
    end in
  doit !h

let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i ->
      let s1 = sub s 0 i in
      doit s1 (sub s (i + 1) (length s - length s1 - 1) :: acc)
  in doit str []

let () =
  let t = Array.make 2000001 0 in
  let rec doit () =
    match split (read_line ()) ' ' with
    | ["extract"] -> (Printf.printf "%d\n" (extract t); doit ())
    | ["insert"; n] -> (insert (int_of_string n) t; doit ())
    | _ -> ()
  in doit ()

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;

}

vector<bool> dp1(200001, false);
vector<bool> dp2(200001, false);

signed main() {
	ll n, a, b, c, d;
	string s;

	cin >> n >> a >> b >> c >> d >> s;

	if (c < d) {
		dp1[a] = true;
		FOR(i, a + 1, c + 1) {
			if (s[i - 1] == '.') {
				dp1[i] = dp1[i - 1] || dp1[i - 2];
			}
			else {
				dp1[i] = false;
			}
		}
		
		dp2[b] = true;
		FOR(i, b + 1, d + 1) {
			if (s[i - 1] == '.') {
				dp2[i] = dp2[i - 1] || dp2[i - 2];
			}
			else {
				dp2[i] = false;
			}
		}
		if (dp1[c] && dp2[d]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else if (c > d) {
		dp1[a] = true;
		FOR(i, a + 1, c + 1) {
			if (s[i - 1] == '.') {
				dp1[i] = dp1[i - 1] || dp1[i - 2];
			}
			else {
				dp1[i] = false;
			}
		}
		dp2[b] = true;
		FOR(i, b + 1, d + 1) {
			if (s[i - 1] == '.') {
				dp2[i] = dp2[i - 1] || dp2[i - 2];
			}
			else {
				dp2[i] = false;
			}
		}
		bool flag = false;
		FOR(i, b - 1, d) {
			if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
				flag = true;
				break;
			}
		}
		if (flag && dp1[c] && dp2[d]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else if (c == d) {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 640
n,k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
s = 0
for i in a:
    if a == 1:
        s = i
        break
t,u = divmod(n-1,k-1)
if u != 0:
    t += 1
print(t)

Measured memory_bytes: 13880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    string S;
    cin >> N >> S;
    vector<vector<int>> dp(N,vector<int>(N,0));
    int ans=0;
    for (int i=N-1;i>=0;i--){
        for (int j=N-1;j>=0;j--){
            if (S[i]==S[j]){
                if (i==N-1||j==N-1){
                    dp[i][j]=1;
                }
                else {
                    dp[i][j]=max(dp[i][j],dp[i+1][j+1]+1);
                }
            }
            ans=max(ans,min(dp[i][j],i-j));
        }
    }
    cout << ans << endl;
}

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


class graph
{
private:
    map<int,list<int> >l;
public:


void addEdge(int u,int w)
{
    l[u].push_back(w);
}
void dfsuti(int u,map<int,bool> &visited,int *dp)
{
    visited[u]=true;
    //cout<<u<<"->";

    for(auto i:l[u])
    {
        if(!visited[i])
            dfsuti(i,visited,dp);
        dp[u]=max(dp[u],1+dp[i]);
    }
}

void dfs(int n)
{
    int dp[n+1];
    memset(dp,0,sizeof(dp));
    map<int,bool>visited;
   /* for(int i=0;i<(n+1);i++)
        visited[i]=false;*/
    for(int i=1;i<=n;i++)
    {
        if(!visited[i])
            dfsuti(i,visited,dp);
    }
    int ans=0;
    //int p=*max_element(dp,dp+(n+1));
    for(int i=1;i<=n;i++)
        ans=max(ans,dp[i]);
    cout<<ans;

}
};

int main()
{
    int n,m;
    cin>>n>>m;
    graph g;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        g.addEdge(x,y);
    }
    g.dfs(n);
    return 0;
}


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

void helloWorld()
{
    cout << "Hello World";
}

void sum()
{
    int A, B;
    cin >> A >> B;
    cout << A + B;
}

int main()
{
    int N;

    cin >> N;
    if(N == 1) {
        helloWorld();
    } else if(N == 2) {
        sum();
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = 0;
			while ((n = int.Parse(Console.ReadLine())) != 0)
			{
				var p = new List<KeyValuePair<int, double>>();
				while (n-- != 0)
				{
					var ihw = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
					var bmi = (double)ihw[2] / Math.Pow((ihw[1] / 100d), 2);
					p.Add(new KeyValuePair<int, double>(ihw[0], Math.Abs(22 - bmi)));
				}

				Console.WriteLine(p.OrderBy(kv => kv.Value).ThenBy(kv => kv.Key).First().Key);
			}
		}
	}
}

Measured memory_bytes: 6740
import java.util.Scanner;

public class Main {

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

        int n = sc.nextInt();
        String s = sc.next();

        if (n % 2 == 1) {
            System.out.println("No");
            return;
        }

        String s1 = s.substring(0, n/2);
        System.out.println(s1.equals(s.substring(n/2, n)) ? "Yes": "No");
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;


int main(){
    ll q;
    cin >> q;
    bool is_prime[(int)1e5+1] = {};
    ll cnt[(int)1e5+1] = {};

    rep(i,2,1e5+1) is_prime[i] = true;

    rep(i,2,sqrt(1e5+1)+1){
        ll temp = 2;
        while(is_prime[i] && temp*i < 1e5+1){
            is_prime[temp*i] = false;
            temp++;
        }
    }

    rep(i,1,1e5+1){
        if(i % 2 && is_prime[i] && is_prime[(i+1)/2]){
            cnt[i]++;
        }
        cnt[i] += cnt[i-1];
        
    }

    rep(i,0,q){
        ll l,r;
        cin >> l >> r;
        cout << cnt[r] - cnt[l-1] << endl; 
    }


    return 0;
}

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

using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> suretu(n) ;
  
  for (int i=0;i<n;i++){
  	cin>>suretu.at(i);
  }
  
  for (int i=n-1;i>=0;i--){
    if(i!=n-1)cout<<" ";
      cout<<suretu.at(i);
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 3100
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=2e5+5,M=2005,Mod=1e9+7;
int a[N],b[N];
int dp[M<<1][M<<1],fac[M<<2],inv[M<<2];
#define C(n,m) (1ll*fac[n]*inv[m]%Mod*inv[n-m]%Mod)
#define dp(i,j) dp[i+M][j+M]
inline int qpow(int a,int b){
	int ans=1;while (b){if (b&1) ans=1ll*ans*a%Mod;b>>=1,a=1ll*a*a%Mod;}
	return ans;
}
inline int mo(int x){return x>=Mod?x-Mod:x;}
int main (){
	int n;scanf ("%d",&n);
	for (int i=1;i<=n;i++)
		scanf ("%d%d",&a[i],&b[i]);
	fac[0]=1;for (int i=1;i<=8000;i++) fac[i]=1ll*fac[i-1]*i%Mod;
	inv[8000]=qpow(fac[8000],Mod-2);for (int i=7999;i>=0;i--) inv[i]=1ll*inv[i+1]*(i+1)%Mod;
	for (int i=1;i<=n;i++) dp(-a[i],-b[i])++;
	for (int i=-2000;i<=2000;i++)
		for (int j=-2000;j<=2000;j++)
			dp(i,j)=mo(dp(i,j)+mo(dp(i-1,j)+dp(i,j-1)));
	int ans=0;
	for (int i=1;i<=n;i++) ans=((ans+dp(a[i],b[i])-C(2*(a[i]+b[i]),2*a[i]))%Mod+Mod)%Mod;
	printf ("%d",1ll*ans*qpow(2,Mod-2)%Mod);
	return 0;
}


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

int main()
{
    long long X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
    if (1.0 * X - 1.0 * K * D < 0)
    {
        K -= X / D, X %= D;
        cout << (K % 2 ? D - X : X) << '\n';
    }
    else cout << X - K * D << '\n';
}


Measured memory_bytes: 3552
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;

struct edge {
	int to, cost;
};
vector<edge>G[200020];

int col[200020];
bool vis[200020];
void dfs(int n, int res) {
	col[n] = res % 2;
	vis[n] = true;
	for (auto e : G[n]) {
		if (vis[e.to])continue;
		dfs(e.to, res + e.cost);
	}
}
void solve() {
	int N; cin >> N;
	REP(i, N - 1) {
		int u, v, c; cin >> u >> v >> c;
		u--, v--;
		G[u].push_back({ v,c });
		G[v].push_back({ u,c });
	}
	dfs(0, 0);
	REP(i, N)print(col[i]);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 11648
def knapsack01iter(n, W, weights, values, dp):
    for i in range(1,n+1):
        for j in range(0, W+1):
            if j < weights[i-1]: # if knapsack cannot fit item i
                dp[i][j] = dp[i-1][j]
            elif j >= weights[i-1]: # knapsack can fit item i
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-weights[i-1]]+values[i-1])
    
    return dp[-1][-1]
    
    
n,W = [int(x) for x in input().split()]
weights = []
values = []
for i in range(n):
    l = [int(x) for x in input().split()]
    weights += [l[0]]
    values += [l[1]]

# repeatableKnapsack(n, W, weights, values)

# dp = [[-1 for _ in range(W+1)] for _ in range(n+1)]
# res = knapsack01rec(n, W, weights, values, dp, n, W)
# print(dp)
dp = [[0 for _ in range(W+1)] for _ in range(n+1)]
res = knapsack01iter(n, W, weights, values, dp)
# print(dp)
print(res)

Measured memory_bytes: 217592
#include<stdio.h>
#define N 10
int integer[10];
void mountain(int *a);

int main(void){
	int i,j;
	for(i=0; i<N; i++){
	scanf("%d",&integer[i]);
	}


	mountain(integer);

	return 0;

}

void mountain(int *a){
		int t,s,tmp,c;
		
		for(s=0; s<N-1; s++){
			for(t=s+1; t<N; t++){
				if(*(a+t) > *(a+s)){
					tmp = *(a+t);
					*(a+t) = *(a+s);
					*(a+s) = tmp;
				}
			}
		}
		for(c=0; c<3; c++){
			printf("%d\n",*(a+c));
	}
}

Measured memory_bytes: 600
#include<stdio.h>
int main(){
  int n,m,a,i,d[1010],max,mi,b[1010]={0};
  scanf("%d %d",&n,&m);
  for(i=max=0;i<n;i++)scanf("%d",&d[i]);
  while(m--){
    scanf("%d",&a);
    for(i=0;a<d[i];i++);//printf("%d\n",i);
    b[i]++;
    if(max<b[i])max=b[mi=i];
  }
  printf("%d\n",mi+1);
  return 0;
}

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

int main( void )
{
    char c;
    cin >> c;
    string x = "aiueo";
    bool y = false;
    
    rep(i,x.size())
    {
        if ( c == x.at(i) )
        {
            y = true;
        }
    }
    
    if ( y )
        cout << "vowel" << endl;
    else
        cout << "consonant" << endl;
}

Measured memory_bytes: 256
/*
 * A_Circle_In_a_Rectangle.cpp
 *
 *  Created on: 2014/07/21
 *      Author: WanWan1985
 */
#include <iostream>
using namespace std;

int main(void) {
	int W, H, x, y, r = 0;
	cin >> W >> H >> x >> y >> r;

	// 長方形の中に円が含まれるかどうか判定
	if ((x - r >= 0) && (y - r >= 0) && (x + r <= W) && (y + r <= H) ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<iostream>
#include<utility>
#include<string>
#include<queue>
#define INF 100000000
using namespace std;
int main(){
  int h,w,w_cnt,cnt=0,tx,ty,c;
  queue<pair<int,int>> p;
  pair<int,int> tmp;
  char a;
  scanf("%d%d",&h,&w);
  w_cnt=h*w;
  int brack[1000][1000];
  for(int i=0;i<h;i++){
    string s;
    cin >> s;
    for(int j=0;j<w;j++){
      if(s[j]=='#'){
        brack[i][j]=0;
        w_cnt--;
        p.push(make_pair(i,j));
      }else{
        brack[i][j]=INF;
      }
    }
  }
   while(w_cnt!=0){
    tmp = p.front();
    p.pop();
    tx=tmp.first;
    ty=tmp.second-1;
    if(ty>=0){
      if(brack[tx][ty]==INF){
        p.push(make_pair(tx,ty));
        brack[tx][ty]=brack[tmp.first][tmp.second]+1;
        w_cnt--;
      }
    }
    ty=tmp.second+1;
    if(ty<=w-1){
      if(brack[tx][ty]==INF){
        p.push(make_pair(tx,ty));
        brack[tx][ty]=brack[tmp.first][tmp.second]+1;
        w_cnt--;
      }
    }
    ty=tmp.second;
    tx=tmp.first-1;
    if(tx>=0){
      if(brack[tx][ty]==INF){
        p.push(make_pair(tx,ty));
        brack[tx][ty]=brack[tmp.first][tmp.second]+1;
        w_cnt--;
      }
    }
    tx=tmp.first+1;
    if(tx<=h-1){
      if(brack[tx][ty]==INF){
        p.push(make_pair(tx,ty));
        brack[tx][ty]=brack[tmp.first][tmp.second]+1;
        w_cnt--;
      }
    }
        cnt = (cnt > brack[tmp.first][tmp.second]+1)?cnt:brack[tmp.first][tmp.second]+1;
  }
  printf("%d\n",cnt);

}


Measured memory_bytes: 12304
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=1e5+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,N,a[MAXN],b[MAXN],cnt[2],flg,vis[MAXN];ll ans;
struct Node{int x,p,opt;}p[MAXN<<1];
inline bool cmp(Node x,Node y){return x.x<y.x;}
int main(){
	n=read();
	Rep(i,1,n)p[++N]=(Node){read(),i,0},p[++N]=(Node){read(),i,1};
	sort(p+1,p+N+1,cmp);
	Rep(i,1,n)ans+=p[i].x,flg|=(vis[p[i].p]++),cnt[p[i].opt]++;
	if(flg||max(cnt[0],cnt[1])==n){cout<<ans<<'\n';return 0;}
	ans+=p[n+1].x-p[n].x,cnt[p[n].opt]--,cnt[p[n+1].opt]++;
	if(p[n+1].p!=p[n].p||max(cnt[0],cnt[1])==n){cout<<ans<<'\n';return 0;}
	cout<<min(ans+p[n+2].x-p[n+1].x,ans+p[n].x-p[n-1].x);
	return 0;
}




Measured memory_bytes: 6340
def main():
    x = int(input())
    a = 3760
    res = 100
    cnt = 0
    for i in range(1, a+1):
        res = int(res * 1.01)
        cnt += 1
        if res >= x:
            print(cnt)
            break
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 9176
#include <iostream>

using namespace std;
void Merge(int L[],int R[],int A[],int N);
void merge_sort(int A[],int N);

int main()
{
    int X,Y,A,B,C;
    int i,j=0;
    long MAX=0;
    cin >> X >> Y >> A >> B >> C;
    int red[A];
    int green[B];
    int coless[C];

    int largest[X+Y+C];
    for(i=0;i<A;i++) cin >> red[i];
    for(i=0;i<B;i++) cin >> green[i];
    for(i=0;i<C;i++) cin >> coless[i];

    merge_sort(red,A);
    merge_sort(green,B);
    merge_sort(coless,C);

    for(i=0;i<X;i++)
    {
        largest[j]=red[A-1];
        A--;
        j++;
    }

    for(i=0;i<Y;i++)
    {
        largest[j]=green[B-1];
        B--;
        j++;
    }

    for(i=0;i<C;i++)
    {
        largest[j]=coless[i];
        j++;
    }
    merge_sort(largest, j);

    for(i=0;i<X+Y;i++)
    {
        MAX+=largest[j-1];
        j--;
    }

    cout << MAX<<endl;

    return 0;
}

void merge_sort(int A[],int N)
{
    if(N==1) return;
    int I=N/2;
    int J=(N+1)/2;
    int L[I];
    int R[J];
    int i,j,k=0;

    for(i=0;i<I;i++)
    {
        L[i]=A[k];

        k++;
    }


    for(j=0;j<J;j++)
    {
        R[j]=A[k];

        k++;
    }

    merge_sort(L,sizeof(L)/4);
    merge_sort(R,sizeof(R)/4);
    Merge(L,R,A,N);
}

void Merge(int L[],int R[],int A[],int N)
{
    int Size=N;
    int i=0,j=0,k;
    for(k=0;k<Size;k++)
    {
        if(j==((Size+1)/2))
        {
            A[k]=L[i];
            i++;
            continue;
        }
        if(i==Size/2)
        {
            A[k]=R[j];
            j++;
            continue;
        }
        if(L[i]<=R[j])
        {
            A[k]=L[i];
            i++;
        }
        else
        {
            A[k]=R[j];
            j++;
        }

    }
}


Measured memory_bytes: 8088
def main():
    import sys
    input = sys.stdin.buffer.readline

    N = int(input())
    a = list(map(int, input().split()))

    c1, c2, c3 = 0, 0, 0
    for aa in a:
        if aa == 1:
            c1 += 1
        elif aa == 2:
            c2 += 1
        else:
            c3 += 1

    dp = [[[0]*(N+1) for _ in range(N+1)] for _ in range(N+1)]

    # メモ化再帰ではpypy3でもTLEするのでforループを使う
    # j==k==0の場合を計算 → k==0の場合を計算 → 一般の場合を計算
    for k in range(c3+1):
        for j in range(c3+c2-k+1):
            for i in range(N-j-k+1):
                if i == j == k == 0:
                    continue
                else:
                    tmp = N
                    if i > 0: # IndexError防止
                        tmp += dp[k][j][i-1]*i
                    if j > 0:
                        tmp += dp[k][j-1][i+1]*j
                    if k > 0:
                        tmp += dp[k-1][j+1][i]*k
                    dp[k][j][i] = tmp/(i+j+k) # 割り算をまとめないとTLE

    print(dp[c3][c2][c1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 505480
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int h, w, d;
char ch[4] = { 'R', 'Y', 'G', 'B' };

int main(int argc, char **argv) {
	cin >> h >> w >> d;
	REP(i, h) {
		REP(j, w) {
			cout << ch[(i + j) / d % 2 + (i - j + 1000 * d) / d % 2 * 2];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#include <math.h>
using namespace std;
    double a, b, x;
    double h;
long long n = 10000000;//誤差調整用
double tng;
double pi = M_PI;
double cngrd = pi / 180;//これをかけると度数からラジアンの変換可能
double cngan = 180 / pi;
double mini = 0.0000001;//微小量
void bs(long long l, long long m){/*binary-search*/
    if(abs(cngrd * (m - l) / n) <= mini){//誤差は10^(-6)まで
        if(a * a * b / 2 <= x)
        cout << 90 - (l + m) / 2 * mini << endl;
        else 
        cout << (l + m) / 2 * mini << endl;
        
    }
    else if(tan(cngrd * (l + m) / (2 * n)) > tng){//解よりも大きかった時の処理: lとl+m/2で探す
        cout << (l + m) / 2 << endl;
        bs(l, (l + m) / 2);
    }
    else {
        cout << (l + m) / 2 << endl;
        bs((l + m) / 2, m);//解よりも小さかかった時の処理: l+m/2とmで探す
    }
}
void solve(){
    cin >> a >> b >> x;
    int box = a * a * b;//箱の容積
    if(box / 2 <= x/*半分以上入っている時*/){
       h = (box - x) * 2 / (a * a);//空いてる三角の高さ
       std::cout << std::fixed;
    std::cout << std::setprecision(10) << atan2(h, a) * cngan << endl;
    }
    else {/*半分以下の時*/
        h = x * 2/ (a * b);//入ってる水の高さ
        std::cout << std::fixed;
    std::cout << std::setprecision(10) << atan2(b, h) * cngan << endl;
    }
}
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Main {

	
    public static void main(String[] args) {
    	
        Scanner in = new Scanner(System.in);
        
        int A = in.nextInt();
        int B = in.nextInt();
        int C = in.nextInt();
        int D = in.nextInt();
        
        System.out.println(Math.min(A, B)+Math.min(C, D));
        in.close();
    }

	
}


Measured memory_bytes: 23636