akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    private static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(final String[] args) throws IOException {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out, true);

        int n = in.nextInt();
        double p = 1.0;
        if (n >= 1) {
            int odds = n - (n / 2);
            p = (double) odds / (double) n;
        }
        out.printf("%.6f%n", p);
    }
}


Measured memory_bytes: 21588
N = int(input())
mod = 10 ** 9 + 7
D = [[[[0] * 4 for i in range(4)] for i in range(4)] for i in range(101)]

D[0][3][3][3] = 1
for i in range(100):
    for j in range(4):
        for k in range(4):
            for l in range(4):
                for x in range(4):
                    if k == 0 and l == 1 and x == 2:
                        continue
                    if k == 0 and l == 2 and x == 1:
                        continue
                    if k == 1 and l == 0 and x == 2:
                        continue
                    if j == 0 and l == 1 and x == 2:
                        continue
                    if j == 0 and k == 1 and x == 2:
                        continue
                    D[i + 1][k][l][x] += D[i][j][k][l] % mod
                    D[i + 1][k][l][x] %= mod
                    
ans = 0
for j in range(4):
    for k in range(4):
        for l in range(4):
            ans += D[N][j][k][l]
            ans %= mod
                    
print(ans)

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

class Dice {
public:
    // top, front, right, left, rear, bottom
    int label[6];

    void rotate(char dir) {
        int t;
        switch (dir) {
            case 'E':
                t = label[0];
                label[0] = label[3];
                label[3] = label[5];
                label[5] = label[2];
                label[2] = t;
                break;
            case 'W':
                t = label[0];
                label[0] = label[2];
                label[2] = label[5];
                label[5] = label[3];
                label[3] = t;
                break;
            case 'S':
                t = label[0];
                label[0] = label[4];
                label[4] = label[5];
                label[5] = label[1];
                label[1] = t;
                break;
            case 'N':
                t = label[0];
                label[0] = label[1];
                label[1] = label[5];
                label[5] = label[4];
                label[4] = t;
                break;
        }
    }
};


int main(void) {
    Dice d;
    string s;
    for (int i = 0; i < 6; i++) {
        cin >> d.label[i];
    }
    cin >> s;

    for (int i = 0; i < s.size(); i++) {
        d.rotate(s[i]);
    }

    cout << d.label[0] << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    char a[105][105];
    int h,w;

    cin >> h >> w;

    for (int i = 0;i < h;i++){
        for (int j = 0;j < w;j++){
            cin >> a[i][j];
        }
    }

    for (int i = 0;i < w+2;i++){
        cout << '#';
    }
    cout << endl;

    for (int i = 0;i < h;i++){
        cout << '#';
        for (int j = 0;j < w;j++){
            cout << a[i][j];
        }
        cout << '#' << endl;
    }

    for (int i = 0; i < w+2;i++){
        cout << '#';
    }

    cout << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;

// #define DEBUG

int main()
{
#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif
    int n, k, l, r, s, ans, counter;
    l = 0, r = 0, s = 0, counter = 0;

    vector<int> v;
    cin >> n >> k;
    int a[n] = {};
    int b[k] = {};
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        a[i] -= 1;
    }

    while (l < n && r <= n)
    {
        if (counter == k)
        {
            v.push_back(r - l);
            if (a[l] < k)
            {
                b[a[l]]--;
                if (b[a[l]] == 0)
                {
                    counter--;
                }
            }
            l++;
        }
        else
        {
            if (r < n)
            {
                if (a[r] < k)
                {
                    b[a[r]]++;
                    if (b[a[r]] == 1)
                    {
                        counter++;
                    }
                }
                r++;
            }
            else
                break;
        }
    }
    ans = 2 * n;
    for (auto itr = v.begin(); itr != v.end(); itr++)
    {
        ans = min(ans, *itr);
    }
    cout << ((ans == 2 * n) ? 0 : ans) << endl;

    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)


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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// ax+by=1の解
ll extgcd(ll a, ll b, ll& x, ll& y) {
	ll d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1; y = 0;
	}
	return d;
}

// mod mでのaの逆数
ll mod_inverse(ll a, ll m) {
	ll x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}
// a^k mod p
int modpow(int a, int k, int p) {
	int ans = 1;
	while (k > 0) {
		if (k % 2 == 1) {
			ans *= a;
			ans %= p;
		}
		a = (a * a) % p;
		k = k / 2;
	}
	return ans;
}
// https://atcoder.jp/contests/m-solutions2019/tasks/m_solutions2019_c

signed main() {

	int fac[200001];
	fac[0] = fac[1] = 1;
	for (int i = 2; i <= 200000; i++) fac[i] = (fac[i - 1] * i) % mod;

	int N, A, B, C;
	cin >> N >> A >> B >> C;

	int a = A * mod_inverse(A + B, mod) % mod;
	int b = B * mod_inverse(A + B, mod) % mod;
	int ans = 0;

	for (int k = 0; k <= N - 1; k++) {
		int comb = (((fac[N + k - 1] * mod_inverse(fac[N - 1], mod))%mod) * mod_inverse(fac[k], mod)) % mod;

		int p = modpow(a, N, mod) * modpow(b, k, mod) % mod;
		p+= modpow(b, N, mod) * modpow(a, k, mod) % mod;
		p %= mod;
		p *= comb;
		p %= mod;

		ans += p * (N + k) % mod;
		ans %= mod;
	}
	ans *= (100 * mod_inverse(100 - C, mod))%mod;

	cout << ans % mod << endl;



	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
  int a,b,c;cin>>a>>b>>c;
  if((a+b)==c ||a+c==b ||c+b==a)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, k, dummy;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> dummy;
    if (n == 1) {
        cout << 0 << endl;
    } else {
        cout << 1 + (n-1-1) / (k-1) << endl;
    }
    return 0;
}



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

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

Measured memory_bytes: 1160
#include<cstdio>
int abs(int x) {
	return x > 0 ? x : -x;
}
int main() {
	int n, x = 0, y = 0, t = 0, xs, ys, ts;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d%d", &ts, &xs, &ys);
		x = xs - x;
		y = ys - y;
		t = ts - t;
		if (abs(x) + abs(y) > t || abs(x + y - t) % 2 != 0) {
			printf("No");
			return 0;
		}
		x = xs;
		y = ys;
		t = ts;
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 128
/*! if g++ -g alds_1_7_d.cpp -o alds_1_7_d.out; then ./alds_1_7_d.out < alds_1_7_d.test; fi
 */

#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iterator>
#include <numeric>
#include <functional>
#include <climits>



using namespace std;
typedef unsigned long long ull;
typedef long long ll;

vector<int> pre(0);
vector<int> ipre(0);
vector<int> mid(0);
vector<int> imid(0);

class node{
public:
  int id, left, right;
  node(): id(-1), left(-1), right(-1){}
};

vector<node> tree(0);

int doit(int pl, int pr, int ml, int mr){
  if(pl == pr) return -1;
  int root_id = pre[pl];

  int ml1 = ml;
  int mr1 = imid[root_id];
  int ml2 = mr1 + 1;
  int mr2 = mr;

  int pl1 = pl + 1;
  int pr1 = pl1 + mr1 - ml1;
  int pl2 = pr1;
  int pr2 = pr;

  node& nd = tree[root_id-1];
  nd.id = root_id;
  nd.left = doit(pl1, pr1, ml1, mr1);
  nd.right = doit(pl2, pr2, ml2, mr2);
  return root_id;
}

vector<int> ret(0);

void post(int root){
  node& nd = tree[root-1];
  if(nd.left > 0) post(nd.left);
  if(nd.right > 0) post(nd.right);
  ret.push_back(nd.id);
}

int main(){
  int n;
  cin >> n;
  pre.resize(n);
  mid.resize(n);
  ipre.resize(n+1);
  imid.resize(n+1);
  tree.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> pre[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> mid[i];
  }
  for (int i = 0; i < n; i++) {
    ipre[pre[i]] = i;
    imid[mid[i]] = i;
  }
  int root_id = doit(0, n, 0, n);
  post(root_id);
  for (int i = 0; i < n-1; i++) {
    cout << ret[i] << " ";
  }
  cout << ret.back() << endl;

  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
int main() {
	
    int n,k,i;
    cin>>n>>k;
    int a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
 
    vector<bool> dp(k+1);
 
    //dp[i]=true if the first player to move wins and i stones left
 
    for(i=0;i<=k;i++)
    {
        for(auto x:a)
        {
            if(x<=i&&!dp[i-x]) {
            dp[i]=true;
            break;
            }
        }
    }
 
    if(dp[k])
    cout<<"First";
    else
    cout<<"Second";
       
    return 0;
}


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

int main() {
  int N, K; cin >> N >> K;
  
  int a = 1, b = 1;
  int ans = 1;
  for (int i=0; i < N; i++) {
    a = ans*2;
    b = ans+K;
    ans = min(a, b);
  }
  cout << ans << endl;
}

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

int main(){
    int n;
    cin>>n;
    double avg=0.0;
    int hoge;
    vector<int> x;
    rep(i,n){
        cin>>hoge;
        x.push_back(hoge);
        avg+=hoge;
    }
    avg = round(avg /n);
    // cout<<avg<<endl;

    int ans = 0;
    rep(i,n){
        ans += (x[i]-avg) * (x[i]-avg);
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    long long n;
    cin >> n;
    long long threesum = 0;
    threesum = 3*((n/3)*((n/3) + 1)/2);
    long long fivesum = 0;
    fivesum = 5*((n/5)*((n/5) + 1)/2);
    long long fifsum = 15*((n/15)*((n/15) + 1)/2);
    long long total = n*(n + 1)/2;
    cout << total - fivesum - threesum + fifsum << endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 100100100100100100;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;
 
int main () {
    
    int x,a; cin >>x>>a;

    if (x >= a) {
        cout << 10 << endl;
    } else {
        cout << 0 << endl;
    } 
    
    return 0;
}


 

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

int main(void) {
	int i;
	int N;
	int *a;
	int light;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	N = atoi(ch);

	a = (int *)calloc(N, sizeof(int));

	for(i = 0; i < N; i += 1){
		fgets(buf, sizeof(buf), stdin);
		ch = strtok(buf, " ");
		a[i] = atoi(ch);
	}
	light = 0;
	for(i = 1; i <= N; i += 1){
		light = a[light] - 1;
		if(light == 1) {
			break;
		}
	}
	if(light == 1) {
		printf("%d\n", i);
	} else {
		printf("-1\n");
	}

	free(a);
	return 0;
}


Measured memory_bytes: 2080
#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector <int> a;
    vector <int> :: iterator it,ip,ic,id;
    int k,n,i,m,d,s,sum=0,g;
    cin >> k >> n;
    for(i=0;i<n;i++)
    {
        cin >> m;
        m=m%k;
        if(a.empty())
        {
            d=0;
            s=0;
        }
        else
        {
            it=a.end();
            it--;
            d=m-*it;
            if(d>s)
            {
                s=d;
                g=m;
            }
        }
        a.push_back(m);
    }
    it=a.end();
    it--;
    ip=a.begin();
    d=k-*it+*ip;
    if(d>=s)
    {
        ip=a.begin();
        sum=0;
        ic=a.end();
        ic--;
        for(it=a.begin();ip!=ic;it++)
        {
            ip++;
            sum=sum+*ip-*it;
        }
    }
    else
    {
        sum=0;
        ip=find(a.begin(),a.end(),g);
        ic=ip;
        id=a.end();
        id--;
        for(it=ip;it!=id;it++)
        {
            ip++;
            sum=sum+*ip-*it;

        }
        ic--;
        for(it=ic;ic!=a.begin();it--)
        {
            ic--;
            sum=sum+*it-*ic;
        }
        sum=sum+k-*id+*a.begin();
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1400
/*********************************
*include
*********************************/
#include <stdio.h>

/*********************************
*define
*********************************/


/*********************************
*function
*********************************/
int main( void )
{
	int x;
	int y;
	char op;
	int answer;
	
	while( 1 ){
		scanf( "%d %c %d", &x, &op, &y );	
		
		if( '?' == op ) {
			break;
		}
		if( '+' == op ) {
			answer = x + y;
		}
		if( '-' == op ) {
			answer = x - y;
		}
		if( '*' == op ) {
			answer = x * y;
		}
		if( '/' == op ) {
			if( 0 != y ){
				answer = x / y;			
			}
		}
		printf( "%d\n", answer );
	}

	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< vector<pii> > graph;

const int INF = 1e9;

inline int match(int cur, int in, const string &s){
  string prv = s.substr(0,cur) + (char)(in+'0');
  rep(i,cur+1){
    int len = cur+1-i;
    if(s.substr(0,len) == prv.substr(i,len))return len;
  }
  return 0;
}

void dfs(int cur, vector<int> &vis, graph &g){
  if(vis[cur])return;
  vis[cur] = 1;
  for(pii e : g[cur])dfs(e.second, vis, g);
}

bool BellmanFord(int s, int V, vector<int> &d, const graph &g){
  d = vi(V,INF);
  d[s] = 0;
  rep(azu,V){
    bool f = false;
    rep(i,V)for(pii e : g[i]){
      if(d[i]<INF && d[e.second] > d[i] + e.first){
	d[e.second] = d[i] + e.first;
	f = true;
      }
    }
    if(!f)return true;
  }
  return false;
}

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

  int n,m,k,l;
  string pattern;
  while(cin >> n, n){
    vi col(n);
    rep(i,n)cin >> col[i], col[i]--;
    cin >> m;
    graph base(n);
    rep(i,m){
      int a,b,c;
      cin >> a >> b >> c; a--; b--;
      base[a].push_back(pii(c,b));
    }    
    cin >> k >> pattern;
    l = pattern.size();

    vector<vi> trans(l, vi(4,0));
    rep(i,l)rep(j,4){
      trans[i][j] = match(i,j+1,pattern);
    }

    int V = n*l;
    graph g(V), rg(V);
    rep(i,l)rep(j,n){
      for(pii e : base[j]){
	int to = e.second, nxt = trans[i][col[to]];
	if(nxt == l)continue;
	g[i*n+j].push_back(pii(e.first, nxt*n+to));
	rg[nxt*n+to].push_back(pii(e.first, i*n+j));
      }
    }

    if(trans[0][col[0]] == l){
      cout << "0 0" << endl;
      continue;
    }

    int S = trans[0][col[0]]*n;
    vi vis(V,0), rvis(V,0);
    dfs(S,vis,g);
    rep(i,l)dfs(i*n+n-1,rvis,rg);

    rep(i,V){
      if(vis[i]==0 || rvis[i]==0)g[i].clear();
      rep(j,g[i].size()){
	int to = g[i][j].second;
	if(vis[to]==0 || rvis[to]==0){
	  g[i].erase(g[i].begin()+j);
	  j--;
	}
      }
    }
    

    vi h;
    if(!BellmanFord(S, V, h, g)){
      cout << -1 << endl;
      continue;
    }

    vector< vi > d(V, vi(k,INF));
    d[S][0] = 0;
    priority_queue< pii, vector<pii>, greater<pii> > q;
    q.push(pii(0,S));

    while(q.size()){
      pii p = q.top(); q.pop();
      int v = p.second, c = p.first;

      for(pii e : g[v]){
	int nv = e.second, nc = c + e.first + h[v] - h[nv];
	bool f = true;
	rep(i,k){
	  if(d[nv][i] > nc){
	    if(f)q.push(pii(nc,nv)), f=false;
	    swap(d[nv][i],nc);
	  }
	}
      }
    }
	    
    vi can;
    rep(i,l)rep(j,k){
      if(d[i*n+n-1][j]!=INF){
	can.push_back(d[i*n+n-1][j] - h[S] + h[i*n+n-1]);
      }
    }
    sort(can.begin(),can.end());

    int ans = min((int)can.size(),k);
    long long sum = 0;
    rep(i,ans)sum += can[i];
    cout << ans << " " << sum << endl;
  }
}

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

int main() {
  int a,b;
  cin >> a>> b;
  int c = a * b; //cという文字を導入
  if (c % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

template<typename T> //最大公約数
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T> //最小公倍数
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}



//forthGraph, reverseGraph
vector<vector<int> > fG, rG;
vector<int> visited, order, group; 

void fDFS(int u){
    visited[u] = true;
    for (int i = 0; i < fG[u].size(); i++){
        int to = fG[u][i];
        if (!visited[to]){
            fDFS(to);
        }
    }
    order.push_back(u);
}

void rDFS(int u, int k){
    visited[u] = true;
    group[u] = k;
    for (int i = 0; i < rG[u].size(); i++){
        int to = rG[u][i];
        if (!visited[to]){
            rDFS(to, k);
        }
    }
}

int main(){
    int V, E, Q; cin >> V >> E;
    fG.resize(V); rG.resize(V);
    visited.assign(V, 0); order.clear(); group.assign(V, -1);

    for (int i = 0; i < E; i++){
        int s, t; cin >> s >> t;
        fG[s].push_back(t);
        rG[t].push_back(s);
    }

    //帰りがけ順を求める
    for (int i = 0; i < V; i++){
        if (!visited[i]){
            fDFS(i);
        }
    }

    //強連結成分分解
    reverse(order.begin(), order.end());
    visited.assign(V, 0);
    int k = 0;
    for (int i = 0; i < order.size(); i++){
        int now = order[i];
        if (!visited[now]){
            rDFS(now, k);
            k++;
        }
    }

    cin >> Q;
    vector<int> ans(0);

    for (int i = 0; i < Q; i++){
        int u, v; cin >> u >> v;
        if (group[u] == group[v]){
            ans.push_back(1);
        } else {
            ans.push_back(0);
        }
    }

    for (int i = 0; i < ans.size(); i++){
        cout << ans[i] << endl;
    }
}




Measured memory_bytes: 4728
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<cmath>
#include<cstdio>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
typedef pair<int, int> P;
// ConsoleApplication69.cpp : アプリケーションのエントリ ポイントを定義します。
//



int main() {
	ll i, j, k, l, m, n, sum, flag, cc, M, X, H, W, N, K,A,B,C;
	cin >> A>>B>>C;
	output(fmin(C,B/A));
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll N,K,H,W;
ll m;
string S,T;
ll d;
ll ans;
ll C[6][6];
ll A[200001];
ll M = 1000000007;
vector<ll> so;
ll ac,wa,tle,re;

int main() {
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A,A+N);
    int i=1;
    int j=0;
    while(i<=N-1){
        if(i%2 == 0){
            j++;
        }
        ans += A[N-j-1];
        i++;
    }
    cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;
LLi mod=1000000007;
vector<LLi> fac(1), facin(1);

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}
 
LLi modinv(LLi a) {
    LLi b = mod, u = 1, v = 0;
    while (b) {
        LLi t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}

//xCyを計算
LLi conb(LLi x, LLi y){
	if(x<y) cout<< "conb x<y" << x SP << y <<endl;
	return ((fac[x]*facin[y])%mod*facin[x-y])%mod;
}

int main(){

	LLi s, ans=0, lmt, ba, tmp;

	cin>> s;

	if(s<3){
		cout<< 0<<endl;
		return 0;
	}
	
	fac[0]=1;
	facin[0]=1;
	for(int i=1;i<=4010;i++){
		tmp=fac[i-1];
		tmp*=i;
		tmp=tmp%mod;
		fac.push_back(tmp);
		facin.push_back(modinv(tmp));
		//cout<< fac[i] << " " << facin[i] << " " << (fac[i]*facin[i])%mod <<endl;
	}

	lmt=s/3;

	for(LLi i=1;i<=lmt;i++) {
		ba=s-i*3;
		ans+=(conb(ba+i-1, ba)%mod);
		ans=ans%mod;
	}

	cout<< ans << endl;
 
	return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define endl '\n'  
typedef long long ll; 
typedef unsigned long long ull; 
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <mypair, vector<mypair>, greater<mypair> > min_heap;
const ll mod=1e9+7;
const ll inf=1e16;
const ll N=5e5+10;
vector<int>  v[N];
bool visited[N];
bool stk[N];
std::vector<int> topo;
bool dfs(int node)
{
	visited[node]=1;
	stk[node]=1;
	for(auto &i:v[node])
	{
		if(visited[i]==0 and dfs(i))
		{
			return 1;
		}
		else if(stk[i]) return 1;
	}
	stk[node]=0;
	topo.pb(node);
	return 0;
}

int main()
{
	boost;
	int n;
	cin>>n;
	map< pair<int,int>,int > index;
	int m=0;
	for(int i=1;i<n;i++) for(int j=i+1;j<=n;j++) index[mp(i,j)]=(m++);
	for(int i=1;i<=n;i++)
	{
		int prev;
		cin>>prev;
		for(int j=2;j<n;j++)
		{
			int x;
			cin>>x;
			v[index[mp(min(prev,i),max(prev,i))]].pb(index[mp(min(x,i),max(x,i))]);
			prev=x;
		}
	}
	n=m;
	for(int i=0;i<n;i++)
	{
		if(visited[i]==0)
		{
			if(dfs(i))
			{
				cout<<"-1";
				return 0;
			}
		}
	}
	reverse(all(topo));

	vector<int> dp(n,1),where(n);
	for(int i=0;i<n;i++) where[topo[i]]=i;
	for(auto &i:topo)
	{
		for(auto  &j: v[i])
		{
			dp[where[j]]=max(dp[where[i]]+1,dp[where[j]]);
		}
	}	
	cout<<*max_element(all(dp));

	return 0;
}


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

using namespace std;

int N;
int main() {
  	cin >> N;
    if(N/100 == 7 || N%100/10 == 7 || N%10 == 7){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3644
//Solution by Tima
#include <bits/stdc++.h>
 
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
 
using namespace std;    
const int N = int(3e5) + 12, mod = int(1e9)  + 7; 

int n,a[20], x[20][20], y[20][20];

int main () {
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		for(int j = 0; j < a[i]; j++){
			cin >> x[i][j] >> y[i][j];
			x[i][j]--;
		}
	}
	int ans = 0;
	for(int mask = 1; mask < (1<<n); mask++){
		int k = __builtin_popcount(mask);
		for(int i = 0; i < n; i++){
			if(mask & (1<<i)){
				for(int j = 0; j < a[i]; j++){
				    if(y[i][j] == 1){
				    	if(!(mask & (1<<x[i][j]))) k = 0;
				    }
				    else{
				    	if(mask & (1<<x[i][j])) k = 0;
				    }
				}
			}
		}
		ans = max(ans, k);
	}
	cout << ans;
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	int h[n];
	for(int i=0;i<n;i++){
		scanf("%d",h+i);
	}
	int ans=1;
	for(int i=1;i<n;i++){
		for(int j=i-1;j>=0;j--){
			if(h[j]>h[i]){
				break;
			}
			if(j==0){
				ans++;
			}
		}
	}
	printf("%d",ans);
}

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

int main(){
	int n;
	char a,b;
	map<char,char> list;
	map<char,char>::iterator it;
	while(1){
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>a>>b;
			list.insert(pair<char,char>(a,b));
		}
		cin>>n;
		for(int i=0;i<n;i++){
			cin>>a;
			it=list.find(a);
			if(it==list.end()){
				cout<<a;
			}else{
				cout<<(*it).second;
			}
		}
		cout<<endl;
		list.clear();
	}
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
double PI=3.1415926535897932384626;

void add_mod(int &a,int b)
{
	a+=b;
	if(a>=mod)
	{
		a-=mod;
	}
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
	string k;
	cin>>k;
	int d;
	cin>>d;
	vector< vector<int> >dp(d,vector<int>(2));
	dp[0][0]=1;
	for(int i=0;i<k.size();i++)
	{
		vector< vector<int> >temp(d,vector<int>(2));
		for(int sum=0;sum<d;sum++)
		{
			for(int st=0;st<2;st++)
			{
				for(int digit=0;digit<10;digit++)
				{
					if(digit>k[i]-'0' && st==0)
						break;
					add_mod(temp[(sum+digit)%d][st || (digit<k[i]-'0')],dp[sum][st]);
				}
			}
		}
		dp=temp;
	}
	ll ans=(dp[0][0]+dp[0][1])%mod;
	ans--;
	if(ans==-1)
	{
		ans=mod-1;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
typedef long long ll;
const int MOD = 1000000007;
#define PI 3.141592653589
using namespace std;

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
	// 数列ができたらスコア計算
	if (A.size() == n + 1) {
		int sumscore = 0;
		for (int i = 0; i < q; i++)
			if (A[b[i]] - A[a[i]] == c[i])
				sumscore += d[i];
		ans = max(ans, sumscore);
		return;
	}
	// 全通り数列生成
	A.push_back(A.back());
	while (A.back() <= m) {
		dfs(A);
		A.back()++;
	}
}

int main() {
	cin >> n >> m >> q;
	a.resize(q);
	b.resize(q);
	c.resize(q);
	d.resize(q);
	for (int i = 0; i < q; i++)
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	dfs(vector<int>(1, 1));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  string s;
  int x,y;
  cin >> s >> x >> y;
  vector<int> data;
  int n = s.size();
  int cnt = 0;
  bool first_flag = true;
  rep(i,n){
    if(s.at(i) == 'F'){
      if(first_flag){
        x--;
        continue;
      }
      cnt++;
      if(i == n-1){
        data.push_back(cnt);
      }
    }
    if(s.at(i) == 'T'){
      first_flag = false;
      data.push_back(cnt);
      cnt = 0;
    }
  }
  vector<int> xa(1,abs(x));
  vector<int> ya(1,abs(y));
  rep(i,data.size()){
    if(data.at(i) == 0) continue;
    
    if(i % 2 == 0) xa.push_back(data.at(i));
    else ya.push_back(data.at(i));
  }
  int xsum = 0;
  int ysum = 0;
  int xn = xa.size();
  int yn = ya.size();
  rep(i,xn) xsum += xa.at(i);
  rep(i,yn) ysum += ya.at(i);
  
  if(xsum % 2 != 0 || ysum % 2 != 0){
    cout << "No" << endl;
    return 0;
  }
  vector<vector<bool>> X(xn+1,vb(xsum/2 + 1,false));
  vector<vector<bool>> Y(yn+1,vb(ysum/2 + 1,false));
  X.at(0).at(0) = true;
  Y.at(0).at(0) = true;
  rep(i,xn){
    rep(j,xsum/2+1){
      if(j - xa.at(i) >= 0){
        X.at(i+1).at(j) = X.at(i).at(j) | X.at(i).at(j - xa.at(i));
      }else X.at(i+1).at(j) = X.at(i).at(j);
    }
  }
  rep(i,yn){
    rep(j,ysum/2+1){
      if(j - ya.at(i) >= 0){
        Y.at(i+1).at(j) = Y.at(i).at(j) | Y.at(i).at(j - ya.at(i));
      }else Y.at(i+1).at(j) = Y.at(i).at(j);
    }
  }
  
  //rep(i,data.size()) cout << data.at(i) << endl;
  //rep(i,xn) cout << xa.at(i) << endl;
  //rep(i,yn) cout << ya.at(i) << endl;
  //cout << data.size() << endl;
  
  if(X.at(xn).at(xsum/2) && Y.at(yn).at(ysum/2)) cout << "Yes" << endl;
  else cout << "No" << endl;
  

}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> x;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        x.push_back(a);
    }
    sort(x.begin(), x.end());
    int diff_min = INT_MAX;
    int min_idx = n - 1;
    int target = x[n-1] / 2;
    for (int i = 0; i < n; i++) {
        if (abs(target - x[i]) < diff_min) {
            diff_min = target - x[i];
            min_idx = i;
        } else if (n % 2 != 0 && abs((x[n-1]+1)/2 - x[i]) < diff_min) {
            diff_min = x[(n+1)/2]/2 - x[i];
            min_idx = i;
        }
    }
    cout << x[n - 1] << ' ' << x[min_idx] << endl;
    return 0;
}


Measured memory_bytes: 892
/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
#define sz(v) (int)v.size()
#define endl '\n'
const int mod = 1e9+7;
ll mul_inv(ll a,ll b = mod) {ll t1=a,t2=b,t3,v1=1,v2=0,v3;while(t2!=1){ll x=t1/t2;t3=t1-x*t2;v3=v1-x*v2;t1=t2,t2=t3;v1=v2,v2=v3;}return(v2+b)%b;}
const int N = 2e5+5;
int p[N];

int fin(int i){
    return p[i]==i ? i : p[i] = fin(p[i]);
}

void uni(int i,int j){
     
        int a = fin(i),b = fin(j);
        p[a] = b;

}
 
int32_t main(){
   
   speed_cubing
   
   
   int n;
   cin>>n;
   int m;
   cin>>m;

   for(int i=1;i<=n;i++)
      p[i] = i;

   for(int i=0;i<m;i++){
      
      int x,y;
      cin>>x>>y;
      uni(x,y);

   }

   map<int,int> mm;
   int maxi = 0;

   for(int i=1;i<=n;i++)
      mm[fin(i)]++;
  
    for(auto x:mm)
       maxi = max(maxi,x.ss);

    cout<<maxi;   


   return 0;
}


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

    using namespace std;
    typedef long long ll;
    # define M_PI  3.14159265358979323846
    const int MOD=1e9+7;

    void solve(){
        int n,k;
        cin>>n>>k;
        vector<int>a(n);
        for(int i=0;i<n;i++)
            cin>>a[i];
        sort(a.begin(),a.end());
        int total=0;
        for(int i=0;i<k;i++)
            total+=a[i];
        cout<<total;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int  INF =  1e9;
const ll LINF = 1e18;
const ll MOD = 1e9+7;
const int SIZE = 100;

template<class T>
inline T gcd(T a, T b){return b ? gcd(b, a % b) : a;}

template<class T>
inline T lcm(T a, T b){return a / gcd(a, b) * b;}
 
ll fac[SIZE], inv[SIZE], facinv[SIZE];
void make() {
	fac[0] = fac[1] = 1; inv[1] = 1; facinv[0] = facinv[1] = 1;
	for (ll i = 2; i < SIZE; i++) {
		fac[i] = (fac[i-1] * i) % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		facinv[i] = facinv[i-1] * inv[i] % MOD;
	}
}
ll combi(ll a, ll b) {
	if (a < b) return 0;
	return fac[a] * (facinv[b] * facinv[a-b] % MOD) % MOD;
}

int main() {
	ll n;
	ll ans = 1;
	scanf ("%lld", &n);
	string s1; cin >> s1;
	string s2; cin >> s2;
	vector<int> a;
	if (s1.length() == 1) {
		a.push_back(1);
	} else {
		for (ll i = 0; i < n-1; i++) {
			if (s1[i] == s1[i+1]) {
				a.push_back(2);
				i++;
			} else {
				a.push_back(1);
				if (i == (n-2)) {
					a.push_back(1);
				}
			}
		}
	}

	for (int i = 0; i < a.size(); i++) {
		if (i == 0) {
			if (a[i] == 1) ans *= 3;
			if (a[i] == 2) ans *= 6;
		} else {
			if (a[i-1] == 1) {
				if (a[i] == 1) ans *= 2;
				if (a[i] == 2) ans *= 2;
			} else {
				if (a[i] == 1) ans *= 1;
				if (a[i] == 2) ans *= 3;
			}
		}
		ans %= MOD;
	}
//	printf("%ld", a.size());
//	for (int i = 0; i < a.size(); i++) {
//		printf("%d ", a[i]);
//	}
//	printf("\n");
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int P = sc.nextInt();
		int Q = sc.nextInt();
		int R = sc.nextInt();
		if (R >= P && R >= Q)
			System.out.println(P + Q);
		else if (Q >= P && Q >= R)
			System.out.println(P + R);
		else
			System.out.println(Q + R);
		sc.close();
	}
}

Measured memory_bytes: 21716
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		execute5_3();
	}
	
	private static void execute5_3() {
		try (Scanner sc = new Scanner(System.in)) {
			int H = sc.nextInt()+1;
			int N = sc.nextInt();
			
			int[][] a = new int[N][2];
			int[] dp = new int[H];
			for(int i=0;i<N;i++) {
				int A = sc.nextInt();
				int B = sc.nextInt();
				a[i][0] = A;
				a[i][1] = B;
			}
			
			dp[0]=0;
			for(int i=1;i<H;i++) {
				dp[i] = Integer.MAX_VALUE;
			}
			for(int i =1;i<H;i++) {
				for(int x=0;x<N;x++) {
					int y=Math.max(0, i-a[x][0]);
					dp[i] = Math.min(dp[i],dp[y]+a[x][1]);
				}
			}
			
			
			System.out.println(dp[H-1]);
		}
	}
}

Measured memory_bytes: 27456
def convert(y, m, d):
    if m <= 2:
        m += 12
        y -= 1
    mjd = int(365.25*y) + (y//400) - (y//100) + int(30.59*(m-2)) + d - 678912
    return mjd
while 1:
    y1, m1, d1, y2, m2, d2 = map(int, input().split())
    if y1 == -1:
        break
    print(convert(y2, m2, d2) - convert(y1, m1, d1))



Measured memory_bytes: 5616
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	
	N := ScanInt(scanner)
	S := ScanText(scanner)
	
	ans := 0
	for i := 1; i < N; i++ {
	    a := S[:i]
	    b := S[i:]
	    
	    ma := make(map[rune]int)
	    for _, r := range a {
	        ma[r]++
	    }
	    
	    mb := make(map[rune]int)
	    for _, r := range b {
	        mb[r]++
	    }
	    
	    num := 0
	    for r := 'a'; r <= 'z'; r++ {
	        if ma[r] > 0 && mb[r] > 0 {
	            num++
	        }
	    }
	    ans = Max(ans, num)
	}
	fmt.Println(ans)
}

func ScanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func ScanFloat64(scanner *bufio.Scanner) float64 {
	scanner.Scan()
	f, e := strconv.ParseFloat(scanner.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func ScanText(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}
 

Measured memory_bytes: 768
#include <stdio.h>

int main(void){
   int n,high,high_p,i,total=0;

   scanf("%d",&n);
   int price[n];

   for(i=0;i<n;i++)
      scanf("%d",&price[i]);

   high=price[0]; high_p=0;
   for(i=1;i<n;i++)
      if(high<price[i]){
         high=price[i]; high_p=i;
      }

   for(i=0;i<n;i++){
      if(i==high_p) total+=price[i]/2;
      else total+=price[i];
   }

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

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var x int
	fmt.Scan(&x)
	m := 100
	var y int
	for {
		if m >= x {
			fmt.Println(y)
			break
		}
		m = int(float64(m) * 1.01)
		y++
	}
}


Measured memory_bytes: 1752
#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<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl
#define P pair<lint,lint>

int main() {
	lint H, W, K;
	cin >> H >> W >> K;
	vector<vector<char>>C(H, vector<char>(W));
	rep(i, H) {
		rep(j, W) {
			cin >> C[i][j];
		}
	}
	lint ans = 0;

	for (lint S = 0; S < 1 << H; S++) {
		//作成
		vector<lint>A;
		rep(i, H) {
			A.push_back(S >> i & 1);
		}
		for (lint S2 = 0; S2 < 1 << W; S2++) {
			//作成
			vector<lint>B;
			rep(j, W) {
				B.push_back(S2 >> j & 1);
			}
			vector<vector<char>>C2;
			C2 = C;
			rep(k, A.size()) {
				rep(l, W) {
					if (A[k] == 1) {
						C2[k][l] = '*';
					}
				}
			}
			rep(k, B.size()) {
				rep(l, H) {
					if (B[k] == 1) {
						C2[l][k] = '*';
					}
				}
			}
			lint cnt = 0;
			rep(k, H) {
				rep(l, W) {
					if (C2[k][l] == '#') {
						cnt++;
					}
				}
			}
			if (cnt == K) {
				ans++;
			}

		}

	}
	cout << ans << enld;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    const int MAX_V = 1000000;
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<int> cnt(MAX_V + 10, 0);
    sort(A.begin(), A.end());
    rep(i, A.size()) {
        if (i > 0 && A[i - 1] == A[i]) {
            cnt[A[i]]++;
            continue;
        }

        for (int b = A[i]; b <= MAX_V; b += A[i]) cnt[b]++;
    }

    int ans = 0;
    for(auto a: A) if (cnt[a] == 1) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 7932
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <stack>
#include <vector>
 
#define ll long long
#define ull unsigned long long
#define ld long double
 
#define gc (c = getchar())
#define gi(x) scanf("%d", &x)
#define gid(x, y) scanf("%d%d", &x, &y)
#define gll(x) scanf("%lld", &x)
#define glld(x, y) scanf("%lld%lld", &x, &y)
#define gllt(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define git(x, y, z) scanf("%d%d%d", &x, &y, &z)
 
#define pi(x) printf("%d\n", x)
#define pid(x, y) printf("%d %d\n", x, y)
#define pcs(ch, cs, x) printf("Case %s%d: %d\n", ch, cs, x)
#define pll(x) printf("%lld\n", x)
#define pllcs(ch, cs, x) printf("Case %s%d: %lld\n", ch, cs, x)
#define plld(x, y) printf("%lld %lld\n", x, y)
#define pllt(x, y, z) printf("%lld %lld %lld\n", x, y, z)
 
#define mp(x, y) std::make_pair(x, y)
#define fcs(x) while (x--)
#define dbg(x) std::cerr << #x << " " << x << std::endl
#define fi freopen("in.txt", "r", stdin)
#define fo freopen("out.txt", "w", stdout)
#define siz(x) (int)x.size()
#define rep(i, x, y) for (int i = x; i <= y; ++i)
#pragma GCC optimize(2)

int main(){
    std::string str;
    std::cin >> str;
    int len = str.length();
    int ret = 0;
    for(int i = 1; i <= len / 2; ++ i){
        if (str[i - 1] != str[len - i]){
            ret ++;
        }
    }
    std::cout << ret << std::endl;
}

Measured memory_bytes: 256
(defun digitsums (N &optional (sum 0))
  (if (zerop N) sum
    (multiple-value-bind (x y) (floor N 10)
      (digitsums x (+ sum y)))))

(defun solve (N)
  (if (zerop (mod N (digitsums N)))"Yes" "No"))

(princ (solve (read)))

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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

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

	int x;
  cin >> x;
  cout << (x ^ 1) << '\n';

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	ll n,k;
	cin>>n>>k;
	unordered_map<ll,ll> um;
	ll arr[n+1];
	REP(i,0,n){
		cin>>arr[i+1];
	}
	ll ct = 0;
	ll curr = 1;
	while(ct < k && (um.count(curr) == 0)){
		um[curr] = ct;
		curr = arr[curr];
		ct++;
	}
	if(ct == k){
		cout<<curr<<endl;
		return 0;
	}
	// cout<<curr<<endl;
	// cout<<ct-um[curr]<<endl;
	k -= um[curr];
	k = k % (ct-um[curr]);
	// cout<<k<<endl;

	// unordered_map<ll,ll> um1;
	ll c = 0;
	while(c < k){
		// um[curr] = 1;
		curr = arr[curr];
		c++;
	}
	cout<<curr<<endl;
	return 0;
}  


Measured memory_bytes: 11856