akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

using ll = long long int ;

const int MAXN=52,MAXM=20;
vector<int> graph[MAXN];

int N,M;
ll dp[1<<MAXM][MAXN];
int depth[MAXN],p[MAXN],mark[MAXN];

void DFS(int cur,int parent,int d=0){
    // printf("%d %d\n",cur,d);
    p[cur]=parent;
    depth[cur]=d;
    for(auto adj:graph[cur]){
        if (adj==parent) continue;
        // puts("OK");
        DFS(adj,cur,d+1);
    }
}

void LCA(int a,int b,int m){
    if (depth[b]>depth[a]) swap(a,b);

    while(depth[a]>depth[b]) {
        mark[a]|=m;
        a=p[a];
    }

    while(a!=b) {
        // printf("%d %d\n",a,b);
        mark[a]|=m;
        mark[b]|=m;
        a=p[a];
        b=p[b];
    }

}

int main(){
    scanf("%d",&N);
    for(int i=0;i<N-1;i++){
        int u,v;
        scanf("%d%d",&u,&v);

        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    DFS(1,1);   

    scanf("%d",&M);
    for(int i=0;i<M;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        LCA(u,v,1<<i);
    }

    dp[0][1]=1;
    for(int e=2;e<=N;e++){
        for(int i=0;i<(1<<M);i++){
            dp[i|mark[e]][e]+=dp[i][e-1];
            dp[i][e]+=dp[i][e-1];
        }
    }

    // for(int i=2;i<=N;i++) printf("%x\n",mark[i]);

    printf("%lld\n",dp[(1<<M)-1][N]);

    return 0;
}

Measured memory_bytes: 429192
import java.util.Scanner;
        
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        
        int max = 0;
        for (int i = 0; i < k; i++) {
            if (i < a) {
                max += 1;
            } else if (i < a + b){
            } else {
                max += -1;
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 35652
n = int(input())
*A, = map(int, input().split())
a, b, c = A.count(1), A.count(2), A.count(3)
DP = [[[0.0 for k in range(n+1)] for j in range(n+1)] for i in range(n+1)]
for k in range(c+1):
    for j in range(b+c-k+1):
        for i in range(a+b+c-j-k+1):
            if i+j+k == 0:
                continue
            tmp = n
            if i > 0:
                tmp += DP[i-1][j][k]*i
            if j > 0:
                tmp += DP[i+1][j-1][k]*j
            if k > 0:
                tmp += DP[i][j+1][k-1]*k
            DP[i][j][k] = tmp/(i+j+k)
print(DP[a][b][c])


Measured memory_bytes: 258824
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int n, a, b;
  readf("%s %s %s\n", &n, &a, &b);
  int res;
  foreach (i; 1..n+1) {
    int sum;
    auto j = i;
    while (j) {
      sum += j % 10;
      j /= 10;
    }
    if (a <= sum && sum <= b) {
      res += i;
    }
  }

  res.writeln;
}


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

using namespace std;

int main() {
  int A, B, res = 0;
  cin >> A >> B;
  for (int i = A; i <= B; i++) {
    int i_1 = i % 10, i_10 = (i / 10) % 10;
    int i_1000 = (i / 1000) % 10, i_10000 = (i / 10000) % 10;
    if ((i_1 == i_10000) && (i_1000 == i_10)) res += 1;
  }
  cout << res;
}

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

const int MOD = 1e9 + 7;
const int MAX = 2e5 + 10;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 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) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    COMinit();
    ll n, a, b; cin >> n >> a >> b;
    ll coma = finv[a];
    for (int i = n - a + 1; i <= n; i++) {
        coma *= i;
        coma %= MOD;
    }
    ll comb = finv[b];
    for (int i = n - b + 1; i <= n; i++) {
        comb *= i;
        comb %= MOD;
    }
    ll ans = modpow(2, n) - 1;
    ans = (ans - coma - comb + MOD * 2) % MOD;
    cout << ans << endl;
}


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

typedef long long lli;

int main()
{
    lli n, x, y;
    cin>>n>>x>>y;

    lli arr[n+5][n+5];
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            arr[i][j] = abs(i-j);
        }
    }

    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            arr[i][j] = min(arr[i][j], 1 + arr[i][x] + arr[y][j]);
            arr[i][j] = min(arr[i][j], 1 + arr[i][y] + arr[x][j]);
        }
    }

    lli brr[n+5];
    for(int i = 0; i <= n; i++)
        brr[i] = 0;

    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= i-1; j++)
        {
            brr[arr[i][j]]++;
        }
    }
    for(int i = 1; i <= n-1; i++)
        cout<<brr[i]<<endl;
}



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

int main(){
        int a,b,c;
        string ans;
        cin >> a >> b >> c;
        if(a+b == c || a == b+c || b == c+a) ans = "Yes";
        else ans = "No";
        cout << ans << endl;
        return 0;
}


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

using namespace std;

typedef long long ll;

ll P = 1e9+7;
vector<ll> dp(2000003, -1);


ll factorial(ll n){
    if(dp[n] != -1){
        return dp[n];
    }
    return (n * factorial(n-1)) % P;
}

ll power(ll base, ll exp){
    ll ret = 1;
    while(exp > 0){
        if(exp % 2 == 0){
            base *= base;
            base %= P;
            exp /= 2;
        }
        else{
            ret *= base;
            ret %= P;
            exp -= 1;
        }
    }
    return ret;
}

ll inv(ll n){
    return power(n, P-2);
}

ll combi(ll r, ll c){
    ll ret = 1;
    ret *= factorial(r+c);
    ret %= P;
    ret *= inv(factorial(r));
    ret %= P;
    ret *= inv(factorial(c));
    ret %= P;
    return ret;
}

ll getAll(ll r, ll c){
    return (combi(r+1, c+1) + P - 1) % P;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 2;
    ll r1, r2, c1, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    ll ret = getAll(r2, c2);
    ret += (P-getAll(r1-1, c2));
    ret %= P;
    ret += (P-getAll(r2, c1-1));
    ret %= P;
    ret += getAll(r1-1, c1-1);
    ret %= P;
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 47104
import java.util.*;
import java.io.*;
import static java.lang.System.*;

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
      if (ptr < buflen) {
          return true;
      }else{
          ptr = 0;
          try {
              buflen = in.read(buffer);
          } catch (IOException e) {
              e.printStackTrace();
          }
          if (buflen <= 0) {
              return false;
          }
      }
      return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)) {
          sb.appendCodePoint(b);
          b = readByte();
      }
      return sb.toString();
  }
  public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
          minus = true;
          b = readByte();
      }
      if (b < '0' || '9' < b) {
          throw new NumberFormatException();
      }
      while(true){
          if ('0' <= b && b <= '9') {
              n *= 10;
              n += b - '0';
          }else if(b == -1 || !isPrintableChar(b)){
              return minus ? -n : n;
          }else{
              throw new NumberFormatException();
          }
          b = readByte();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int one = 1;
    int two = 0;
    char tmp = 'a';
    String S = sc.next();
    for(int i=1; i<4; i++){
      if(S.charAt(0) == S.charAt(i) ) one++;
      else tmp = S.charAt(i);
    }
    for(int i=1; i<4; i++){
      if(tmp == S.charAt(i) ) two++;
    }
    if(one == 2 && two == 2) out.println("Yes");
    else out.println("No");
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

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

int main() {
	int N;
	cin >> N;
	int seki[N];	//-1 is unchecked, 1 is male, 2 is female, 0 is no one
	for(int i=0; i<N; i++){
		seki[i]=-1;
	}
	cout << 0 << endl;
	string s;
	cin >> s;
	if(s=="Male"){seki[0]=1;}
	else if(s=="Female"){seki[0]=2;}
	else if(s=="Vacant"){seki[0]=0; return 0;}
	
	cout << N-1 << endl;
	cin >> s;
	if(s=="Male"){seki[N-1]=1;}
	else if(s=="Female"){seki[N-1]=2;}
	else if(s=="Vacant"){seki[N-1]=0; return 0;}
	
	
	int left,right;
	left=0; right=N-1;
	for(int i=0; i<17; i++){
		if((left+right+1)%2==1){	//even between two
			cout << (left+right)/2 << endl;
			cin >> s;
			if(s=="Male"){seki[(left+right)/2]=1;}
			else if(s=="Female"){seki[(left+right)/2]=2;}
			else if(s=="Vacant"){seki[(left+right)/2]=0; return 0;}
			
			if((right-(left+right)/2-1)%2==1){
				if(seki[left]!=seki[(left+right)/2]){
					right=(left+right)/2;
				}else{
					left=(left+right)/2;
				}
			}else{
				if(seki[left]==seki[(left+right)/2]){
					right=(left+right)/2;
				}else{
					left=(left+right)/2;
				}
			}
		}
		
		
		else if((left+right+1)%2==0){	//odd between two
			cout << (left+right)/2 << endl;
			cin >> s;
			if(s=="Male"){seki[(left+right)/2]=1;}
			else if(s=="Female"){seki[(left+right)/2]=2;}
			else if(s=="Vacant"){seki[(left+right)/2]=0; return 0;}
			
			if(seki[left]==seki[(left+right)/2]){
				if((right-(left+right)/2-1)%2==0){
					left=(left+right)/2;
				}else{
					right=(left+right)/2;
				}
			}else{
				if((right-(left+right)/2-1)%2==1){
					left=(left+right)/2;
				}else{
					right=(left+right)/2;
				}	
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n;
    cin>>n;int ans = 0;
    REP(i,n+1){
        if(((int)log10(i)+1)%2 == 1)ans++;
    }
    cout<<ans<<endl;return 0;
}


Measured memory_bytes: 512
class BIT:
  def __init__(self,n):
    self.n=n+1
    self.BIT=[0]*self.n
  def add(self,i,x):
    idx=i
    while idx<self.n:
      self.BIT[idx]+=x
      idx+=(idx&-idx)
  def _sum(self,i):
    ret=0
    idx=i
    while idx>0:
      ret+=self.BIT[idx]
      idx-=(idx&-idx)
    return ret
  def sum(self,l,r):
    return self._sum(r)-self._sum(l-1)
  def value(self,i):
    return self._sum(i)-self._sum(i-1)

n,k=map(int,input().split())
arr=[0]+[int(input()) for _ in range(n)]
for i in range(1,n+1):
  arr[i]+=arr[i-1]-k
s=set(arr)
key=sorted(list(s))
dic={}
for i in range(len(key)):
  dic[key[i]]=i+1
bit=BIT(len(key)+1)
ans=0
bit.add(dic[0],1)
for i in range(1,n+1):
  ans+=bit.sum(1,dic[arr[i]])
  bit.add(dic[arr[i]],1)
print(ans)

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

typedef long long ll;

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

	ll max_n = floor(sqrt(n));

	ll ans = n - 1;
	for (int i = 2; i <= max_n; i++) {
		if (n % i == 0) {
			ans = min(ans, (i + n / i - 2));
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int prime(int n)
{
	int i;
	for(i=n/2; i>=2; i--){
		if(n%i==0){
			return 1;
		}
	}
	return 0;
}

int main(void)
{
	int n,i,j,x,y,z=0;
	scanf("%d",&n);
	for(i=0; i<n; i++){
		for(j=2; z<n; j=j+2){
			x=j*5+1;	y=prime(x);
			if(y==0){
				z=z+1;
				printf("%d",x);
				if(z<n){
					printf(" ");
				}
			}
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstdint>
#include <algorithm>
#include <cmath>
#include <vector>
#include <unordered_map>


int main()
{
	uint64_t A, B, C;

	std::cin >> A >> B >> C;

	if (A + B + 2 * sqrtl(A * B) < C)
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}

	return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a, Ts... ts) {return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, C;
    cin >> N >> C;
    auto d = make_v<int>(C, C);
    auto c = make_v<int>(N, N);
    REP(i, C) REP(j, C) cin >> d[i][j];
    REP(i, N) REP(j, N) cin >> c[i][j];
    REP(i, N) REP(j, N) c[i][j]--;

    auto e = make_v<int>(3, C);
    REP(i, N) REP(j, N) REP(k, C)
    {
        e[(i+j)%3][k] += d[c[i][j]][k];
    }

    int ans = INF;
    REP(i, C) REP(j, C) REP(k, C)
    {
        if(i == j || j == k || i == k) continue;
        int sum = 0;
        int arr[] = {i, j, k};
        REP(l, 3) sum += e[l][arr[l]];
        ans = min(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define ios; ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef double db;
mt19937 rnd(random_device{}());
const int mod = 1e9 + 7;
const int N = 2e5 + 5;
const int M = 1e3 + 5;
const db pi = acos(-1.0);
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
inline ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
int n, m, k;
int f[N];

int main(){
    ios;
    rep(x,1,100) rep(y,1,100) rep(z,1,100){
        int res=x*x+y*y+z*z+x*y+y*z+z*x;
        if(res<=10000) f[res]++;
    }
    cin>>n;
    rep(i,1,n) cout<<f[i]<<"\n";
    return 0;
}

/*

*/
//
//                            _ooOoo_
//                           o8888888o
//                           88" . "88
//                           (| -_- |)
//                           O\  =  /O
//                        ____/`---'\____
//                      .'  \|     |//  `.
//                     /  \|||  :  |||//  \
//                    /  _||||| -:- |||||-  \
//                    |   | \  -  /// |   |
//                    | \_|  ''\---/''  |   |
//                    \  .-\__  `-`  ___/-. /
//                  ___`. .'  /--.--\  `. . __
//               ."" '<  `.___\_<|>_/___.'  >'"".
//              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//              \  \ `-.   \_ __\ /__ _/   .-` /  /
//         ======`-.____`-.___\_____/___.-`____.-'======
//                            `=---='
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                     佛祖保佑      永无BUG


Measured memory_bytes: 3664
/*
  AtCoder Beginner Contest 078
  B - ISU

  方針
    1人で座る場合、Y+2*Zの幅が必要である。
    2人目以降を追加する場合は、Y+Zの幅が必要になる。

  実装
    ans = (X - (Y + 2 * Z)) / (Y + Z) + 1
*/

#include<iostream>
using namespace std;

int X, Y, Z;

int main() {
  scanf("%d %d %d", &X, &Y, &Z);
  
  printf("%d\n", (X - (Y + 2 * Z)) / (Y + Z) + 1);
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int[] l = new int[N];
    for (int i = 0; i < N; i++) l[i] = scanner.nextInt();
    Arrays.sort(l);

    long count = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < i; j++) {
        int k = lowerBound(l, j, i, l[i] - l[j]);
        count += i - k;
      }
    }
    System.out.println(count);
  }

  public static int lowerBound(int[] a, int left, int right, int k) {
    while (right - left > 1) {
      int mid = (left + right) / 2;
      if (a[mid] > k) {
        right = mid;
      } else {
        left = mid;
      }
    }
    return right;
  }
}


Measured memory_bytes: 28576
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int main(){
	map<char,int> m;

	string s;
	cin >> s;
	rep(i,s.size()){
		m[s[i]]++;
	}

	vector<int> v;
	for(auto i : m){
		v.emplace_back(i.second);
	}
	sort(all(v), greater<int>());


	int len = s.size();
	while(true){
		rep(i,3){
			if(v[i] == 0){
				goto END;
			}else{
				v[i]--;
				len--;
			}
		}
	}
END:
	cout << (len == 0 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(void){
  int i,j,k;
  int n,x,s;
  while(scanf("%d %d\n",&n,&x),n>0||x>0){
      s=0;
      for(i=1;i<=n;i++){
          for(j=i+1;j<=n;j++){
              for(k=j+1;k<=n;k++){
                  if(i+j+k==x){
                      s++;
                  }
                  
              }
          }
      }
      printf("%d\n",s);
  }
  
  return 0;  
}


Measured memory_bytes: 2056
from collections import deque
import sys

input = sys.stdin.readline

n = int(input())

doubly_linked_list = deque()

for _ in range(n):
    command = input().split()
    if command[0] == "insert":
        doubly_linked_list.appendleft(command[1])
    elif command[0] == "delete":
        try:
            doubly_linked_list.remove(command[1])
        except:
            pass
    elif command[0] == "deleteFirst":
        doubly_linked_list.popleft()
    elif command[0] == "deleteLast":
        doubly_linked_list.pop()

print(" ".join(doubly_linked_list))
    



Measured memory_bytes: 69728
def solve():
    N, K = map(int, input().split())

    dic = {}
    for i in range(N):
        dic[i+1] = 0
        
    for i in range(K):
        dk = int(input())
        Ak = list(map(int, input().split()))
        for a in Ak:
            if a in dic:
                del dic[a]
    print(len(dic))

solve()

Measured memory_bytes: 9180
#include <iostream>

using namespace std;

int main()
{
    int h1, h2;
    int k1, k2;
    int a, b, c, d;
    cin>>h1>>h2>>k1>>k2>>a>>b>>c>>d;
    int h = h1*a + h2*b + h1/10*c + h2/20*d;
    int k = k1*a + k2*b + k1/10*c + k2/20*d;
    if (h>k)
        cout<<"hiroshi"<<endl;
    else if (h<k)
        cout<<"kenjiro"<<endl;
    else
        cout<<"even"<<endl;

}

Measured memory_bytes: 3100
import java.util.Scanner;

public class Main 
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		int i=0;
		while(in.hasNext())
		{
			int n=in.nextInt();
			if(n==0)
				return;
			switch(n)
			{
			case 1:
			{
				System.out.println("Case "+(++i)+":");
				System.out.println("  1");
				break;
			}
			case 2:
			{
				System.out.println("Case "+(++i)+":");
				System.out.println("  1  2");
				System.out.println("  3  4");
				break;
			}
			case 3: 
			{
				System.out.println("Case "+(++i)+":");
				System.out.println("  1  2  6");
				System.out.println("  3  5  7");
				System.out.println("  4  8  9");
				break;
			}
			case 4:
			{
				System.out.println("Case "+(++i)+":");
				System.out.println("  1  2  6  7");
				System.out.println("  3  5  8 13");
				System.out.println("  4  9 12 14");
				System.out.println(" 10 11 15 16");
				break;
			}
			case 5:
			{
				System.out.println("Case "+(++i)+":");
				System.out.println("  1  2  6  7 15");
				System.out.println("  3  5  8 14 16");
				System.out.println("  4  9 13 17 22");
				System.out.println(" 10 12 18 21 23");
				System.out.println(" 11 19 20 24 25");
				break;				
			}
			case 6:
			{
				System.out.println("Case "+(++i)+":");
				System.out.println("  1  2  6  7 15 16");
				System.out.println("  3  5  8 14 17 26");
				System.out.println("  4  9 13 18 25 27");
				System.out.println(" 10 12 19 24 28 33");
				System.out.println(" 11 20 23 29 32 34");
				System.out.println(" 21 22 30 31 35 36");
				break;
			}
			case 7:
			{
				System.out.println("Case "+(++i)+":");
				System.out.println("  1  2  6  7 15 16 28");
				System.out.println("  3  5  8 14 17 27 29");
				System.out.println("  4  9 13 18 26 30 39");
				System.out.println(" 10 12 19 25 31 38 40");
				System.out.println(" 11 20 24 32 37 41 46");
				System.out.println(" 21 23 33 36 42 45 47");
				System.out.println(" 22 34 35 43 44 48 49");
				break;
			}
			case 8:
			{
				System.out.println("Case "+(++i)+":");
				System.out.println("  1  2  6  7 15 16 28 29");
				System.out.println("  3  5  8 14 17 27 30 43");
				System.out.println("  4  9 13 18 26 31 42 44");
				System.out.println(" 10 12 19 25 32 41 45 54");
				System.out.println(" 11 20 24 33 40 46 53 55");
				System.out.println(" 21 23 34 39 47 52 56 61");
				System.out.println(" 22 35 38 48 51 57 60 62");
				System.out.println(" 36 37 49 50 58 59 63 64");
				break;
			}
			case 9:
			{
				System.out.println("Case "+(++i)+":");
				System.out.println("  1  2  6  7 15 16 28 29 45");
				System.out.println("  3  5  8 14 17 27 30 44 46");
				System.out.println("  4  9 13 18 26 31 43 47 60");
				System.out.println(" 10 12 19 25 32 42 48 59 61");
				System.out.println(" 11 20 24 33 41 49 58 62 71");
				System.out.println(" 21 23 34 40 50 57 63 70 72");
				System.out.println(" 22 35 39 51 56 64 69 73 78");
				System.out.println(" 36 38 52 55 65 68 74 77 79");
				System.out.println(" 37 53 54 66 67 75 76 80 81");
				break;
			}
			}
		}
	}
}

Measured memory_bytes: 12000
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod.m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}


int main(){
    ll n, d;
    cin >> n >> d;
    int ans = 0;
    rep(i,n){
        ll x, y;
        cin >> x >> y;
        if(x*x + y*y <= d*d){
            ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3596
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/


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

	if (b == c && c == 1) {
		cout << a * a << endl;
	} else {
		cout << ( a - ( b - 1 ) )*( a - ( c - 1 ) ) << endl;
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,x,y;
lol i[101];
lol sum[101];
lol dp[100][100001];
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    lol c,d=0,e=0,f=0,g=1,h=0;
    string s;
    cin >>a;
    b=sqrt(a);
    for(int n=b;n>0;n--){
	if(a%n==0){
	    g=n;
	    break;
	}
    }
    c=a/g;
    while(c>0){
	d++,c=c/10;
    }
    cout <<d<<'\n';
    return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int64_t sum = 3;
  int64_t l0 = 2;
  int64_t l1 = 1;
  if(n == 1) {
  	cout  << 1 << endl;    
  }
  else{
  for(int i = 2;  i <=n; i++) {
  	sum = l0 + l1;
    l0 = l1;
    l1 = sum;
  }
  cout << sum << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 3e2+10;
const int inf = 0x3f3f3f3f;
const ll MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
#define X first
#define Y second


int a[maxN];
int main() {
	int x;
	scanf("%d",&x);
	if(x%2 == 0)
	{
		int y = x/2;
		printf("%d\n",y);
	}
	else
	{
		int y = (x/2)+1;
		printf("%d\n",y);
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
#include<fstream>
using namespace std;
typedef long long LL;

int main(void)
{
	LL a,b,c,n;
	string s;
	cin >>a;
	cout <<3*(a*a)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int ord(ll a, ll b){
	int ret = 0;
	while(a % b == 0){
		ret++;
		a /= b;
	}
	return ret;
}

char s[20];
#define N 64
ll p[N][N] = {};
ll q[N][N] = {};

int main(){
	int n; scanf("%d", &n);
	ll m = 0;
	REP(i, n){
		scanf("%s", s);
		bool aft = false;
		int cnt = 0;
		int k = strlen(s);
		ll a = 0;
		REP(i, k){
			if(s[i] == '.'){
				aft = true;
			} else {
				a = a * 10 + (s[i] - '0');
				if(aft) cnt++;
			}
		}
		while(cnt < 9) cnt++, a *= 10;
		DEBUG("%13lld %d %d\n", a, ord(a, 2), ord(a, 5));
		p[ ord(a, 2) ][ ord(a, 5) ]++;
		if( ord(a, 10) >= 9 ) m++;
	}
	DEBUG("m = %lld\n", m);
	for(int i = N-1; i >= 0; i--){
		for(int j = N-1; j >= 0; j--){
			if(i + 1 == N || j + 1 == N)
				q[i][j] = p[i][j];
			else{
				q[i][j] = p[i][j] + q[i][j+1] + q[i+1][j] - q[i+1][j+1];
			}
		}
	}
	ll ans = 0;
	REP(i, N){
		REP(j, N){
			ans += p[i][j] * q[ max(18-i, 0) ][ max(18-j, 0) ];
			if(p[i][j])
				DEBUG("(%d, %d)=%lld => (%d, %d)=%lld\n", 
						i, j, p[i][j], max(18-i, 0), max(18-j, 0), 
						q[ max(18-i, 0) ][ max(18-j, 0) ]);
		}
	}
	ans = (ans - m)/2;
	printf("%lld\n", ans);
}




Measured memory_bytes: 3840
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
int gcd(int x,int y)
{
	if(y==0)
	{
		return x;
	}
	return gcd(y,x%y);
}
int main()
{
	int i,j,k,n,m,x,y;
	scanf("%d",&n);
	scanf("%d",&y);
	for(i=1;i<n;i++)
	{
		scanf("%d",&x);
		y=gcd(x,y);
	}
	printf("%d",y);
}


Measured memory_bytes: 256
q=int(input())
l=[list(map(int,input().split())) for i in range(q)]

def jud(i):
    #iの素数判定
    num=int(i**0.5)+1
    for k in range(2,num):
        if i%k==0:
            return 0
    return 1

s=[0]*(10**5+1)
for i in range(2,10**5+1):
    if i%2==0:
        s[i]=s[i-1]
    else:
        if jud(i)*jud((i+1)//2)==1:
            s[i]=s[i-1]+1
        else:
            s[i]=s[i-1]

for k,v in l:
    ans=s[v]-s[k-1]
    print(ans)


Measured memory_bytes: 30176
#include<iostream>
#include<numeric>
using namespace std;
int gcd(int a, int b) {
  if(a < b) return gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main(){
    int x,y;
    cin >> x >> y;
    int g = gcd(x,y);
    cout << x+y-g+1 << endl;
    return 0;
}


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

int main(void){
    char s[10];
    int i,length=0,length1=0;
    scanf("%s",s);
    for(i=0;i<10;i++){
        if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
            length1++;
            if(length<length1) length=length1;
        }else length1=0;
    }
    printf("%d",length);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

ll gcd(ll x, ll y){
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y){
  return x / gcd(x, y) * y;
}

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  ll l = lcm(c, d);
  ll r = (b / c) - ((a - 1) / c) + (b / d) - ((a - 1) / d) - ((b / l) - ((a - 1) / l));
  ll ans = (b - a + 1) - r;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 888
import sys
sys.setrecursionlimit(10**5)

N=int(input())
v=[[] for i in range(N)]
r=list()

def wps(s,d,u):
  c=1
  for i in range(len(v[d])):
    if v[d][i][0]!=s:
      c=c if u!=c else c+1
      v[d][i][1]=c
      wps(d,v[d][i][0],c)
      c+=1
    else:
      v[d][i][1]=u


for i in range(N-1):
  a,b=map(int,input().split())
  v[a-1].append([b-1,0,i])
  v[b-1].append([a-1,0,i])

wps(-1,0,-1)

m=0
for i in range(N):
  for j in range(len(v[i])):
    if i<v[i][j][0]:
      r.append(v[i][j])
  m=max(m,len(v[i]))

print(m)
r.sort(key=lambda x:x[2])
for e in r:
	print(e[1])


Measured memory_bytes: 77420
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <tuple>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <complex>
#include <bitset>
#include <numeric>
#include <random>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define SE second
#define FI first
#define DBG(a) cerr<<(a)<<endl;
#define dump(a) cerr<<#a <<' '<< a <<endl;
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;  typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
typedef pair<int,int>PI; typedef vector<int> VI;
const LL LINF=334ll<<53; const int INF=15<<26; const LL MOD=1E9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,cnt;cin >> h >>w;
    cnt=h+w-1;
    REP(i,h){
        char a;
        REP(j,w){
            cin >> a;
            if(a=='#')--cnt;
        }
    }
    if(!cnt)cout << "Possible"<<endl;
    else cout << "Impossible" <<endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
 
  int r,c,i,j,a[101][101];
 
 
  scanf("%d%d",&r,&c);
 
  for(i=0;i<=r;i++){
    for(j=0;j<=c;j++){
      a[i][j]=0;
    }
  }
   
  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      scanf("%d",&a[i][j]);
    }
  }
 
  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      
      a[i][c]+=a[i][j];
    }
  }
 
  for(i=0;i<=c;i++){
    for(j=0;j<r;j++){
      a[r][i]+=a[j][i];
    }
  }
 
  for(i=0;i<=r;i++){
    for(j=0;j<=c;j++){
      if(j==c) printf("%d",a[i][j]);
      else   printf("%d ",a[i][j]);
    }
    printf("\n");
  }
 
  return 0;
}


Measured memory_bytes: 2148
#abc127d
n,m=map(int,input().split())
a=list(map(int,input().split()))
l=[]
for i in range(m):
 bi,ci=map(int,input().split())
 l.append((ci,bi))
for i in range(n):
 l.append((a[i],1))
l=sorted(l,reverse=True)
r=n
res=0
for x in l:
 q=min(r,x[1])
 res+=q*x[0]
 r-=q
 if r==0:
  break
print(res)


Measured memory_bytes: 30444
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	static int[] parent, prenum, lowest;
	static int timer=0;
	static boolean[] visited;
	static int V;
	static boolean[][] G;
	static PriorityQueue<State> pq=new PriorityQueue<>();
	
	static class State implements Comparable<State>{
		int s, t;
		State(int s, int t){
			this.s=s;
			this.t=t;
		}
		public int compareTo(State p) {
			if(p.s==this.s) {
				return this.t-p.t;
			}
			return this.s-p.s;
		}
	}
	
	
	static void dfs(int current, int prev) {
		prenum[current]=lowest[current]=timer;
		timer++;
		visited[current]=true;
		int next=0;
		for(int i=0; i<V; i++) {
			if(G[current][i]) {
				next=i;
				if(!visited[next]) {
					parent[next]=current;
					dfs(next, current);
					lowest[current]=Math.min(lowest[current], lowest[next]);
				}
				else if(next != prev) {//currentからnextがbackedgeの時
					lowest[current]=Math.min(lowest[current], prenum[next]);
				}
			}
		}

	}

	static void art_point() {
		for(int i=0; i<V; i++) {
			visited[i]=false;
		}
		timer=1;
		dfs(0, -1);
//		for(int i=0; i<V; i++) {
//			System.out.println("prenum["+i+"]="+prenum[i]+" lowest["+i+"]="+lowest[i]);
//		}
		
		for(int i=1; i<V; i++) {
			int p=parent[i];
			if(prenum[p]<lowest[i]) {
				pq.add(new State(Math.min(p, i), Math.max(p, i)));
				//System.out.println(Math.min(i, p)+" "+Math.max(i, p));
			}
		}
		
		while(! pq.isEmpty()) {
			State p=pq.remove();
			System.out.println(p.s+" "+p.t);
		}
		
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			V=sc.nextInt();
			int E=sc.nextInt();
			parent=new int[V];
			prenum=new int[V];
			lowest=new int[V];
			visited=new boolean[V];
			G=new boolean[V][V];
			for(int i=0; i<E; i++) {
				int s=sc.nextInt();
				int t=sc.nextInt();
				G[s][t]=G[t][s]=true;
			}
			art_point();
			
		}
	}
}


Measured memory_bytes: 200760
n = int(input())
dpa = 0
dpb = 0
dpc = 0
for i in range(n):
    a,b,c = map(int,input().split())
    dpat,dpbt,dpct = dpa,dpb,dpc
    dpa = max(dpbt,dpct) + a
    dpb = max(dpct,dpat) + b
    dpc = max(dpat,dpbt) + c
print(max(dpa,dpb,dpc))


Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
   double w;
   while ( scanf("%lf", &w) != EOF ) {
      if ( w <= 48) printf("light fly\n");
      else if ( 48 < w && w <= 51 ) printf("fly\n");
      else if ( 51 < w && w <= 54 ) printf("bantam\n");
      else if ( 54 < w && w <= 57 ) printf("feather\n");
      else if ( 57 < w && w <= 60 ) printf("light\n");
      else if ( 60 < w && w <= 64 ) printf("light welter\n");
      else if ( 64 < w && w <= 69 ) printf("welter\n");
      else if ( 69 < w && w <= 75 ) printf("light middle\n");
      else if ( 75 < w && w <= 81 ) printf("middle\n");
      else if ( 81 < w && w <= 91 ) printf("light heavy\n");
      else printf("heavy\n");
   }
   return 0;
}

Measured memory_bytes: 1796
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	while(1){
		ll rr,ww,c,r;
		cin>>rr>>ww>>c>>r;
		if(rr==0)break;
		ll res = 0;
		if(c*ww-rr<=0){
			cout<<0<<endl;
			continue;
		}
		res = (c*ww-rr)/r;
		if( (c*ww-rr)%r != 0) res++;
		cout<<res<<endl;
	}
	

	return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define ALL(v) (v).begin(), (v).end()
#define PUTS(x) cout << (x) << endl;
#define PB push_back
#define MP make_pair
#define F first
#define S second
vector<Int> IntsIn(int n) {
    auto v = vector<Int>(0);
    for (int i = 0; i < n; i++) {
        Int a;
        cin >> a;
        v.push_back(a);
    }
    return v;
}

int main() {
    char a, b, c;
    cin >> a >> b >> c;
    auto s = set<char>();
    s.insert(a);
    s.insert(b);
    s.insert(c);
    puts(s.size() == 1 ? "No" : "Yes");
}

Measured memory_bytes: 256
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

f(X, N) :- N mod 2 =:= 0, X is N, !.
f(X, N) :- X is 2 * N.

main :-
	get_number(N),
    f(X, N),
    writeln(X).


Measured memory_bytes: 8164
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
typedef pair<int, int> PII;
typedef long long ll;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


int a, b;

int main() {

	cin >> a >> b;

	if (a >= 10 || b >= 10)cout << -1 << endl;
	else cout << a * b << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N;
	ll K;
	cin >> N >> K;
	vector<ll> A(N);
	for(int i=0; i<N; i++) cin >> A[i];

	vector<ll> Ap, An;
	int n_0 = 0;
	for(int i=0; i<N; i++){
		if(A[i]>0) Ap.push_back(A[i]);
		if(A[i]<0) An.push_back(A[i]);
		if(A[i]==0) n_0++;
	}
	sort(Ap.begin(), Ap.end());
	sort(An.begin(), An.end());

	if(K<=(ll)Ap.size()*An.size()) {
		ll lb = 0, ub = 1e18+5;
		while(ub-lb>1){
			ll med = (ub+lb)/2;

			ll cnt = 0;
			for(int i=0; i<An.size(); i++){
				auto j = lower_bound(Ap.begin(), Ap.end(), (med-An[i]-1)/(-An[i]));
				cnt += Ap.end() - j;
			}
			debug(med, cnt);

			if(cnt >= K){
				lb = med;
			} else {
				ub = med;
			}
		}
		cout << -lb << endl;
	} else if(K<=(ll)N*(N-1)/2-(ll)An.size()*(An.size()-1)/2-(ll)Ap.size()*(Ap.size()-1)/2){
		cout << 0 << endl;
	} else {
		ll l = K - ((ll)N*(N-1)/2 - (ll)An.size()*(An.size()-1)/2 - (ll)Ap.size()*(Ap.size()-1)/2);
		ll lb = 0, ub = 1e18+5;

		for(int i=0; i<An.size(); i++) An[i] = -An[i];
		sort(An.begin(), An.end());

		while(ub-lb>1){
			ll med = (ub+lb)/2;
			ll cnt = 0;
			for(int i=0; i<An.size(); i++){
				auto j = upper_bound(An.begin()+i+1, An.end(), med/An[i]);
				cnt += j - (An.begin()+i+1);
			}
			for(int i=0; i<Ap.size(); i++){
				auto j = upper_bound(Ap.begin()+i+1, Ap.end(), med/Ap[i]);
				cnt += j - (Ap.begin()+i+1);
			}

			if(cnt < l){
				lb = med;
			} else {
				ub = med;
			}
		}

		cout << ub << endl;
	}

	return 0;
}


Measured memory_bytes: 4084
// D - Practical Skill Test
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
// #define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()

int main(){
	int H,W,D; cin>>H>>W>>D;

	vector<tuple<int,int,int>> A(H*W+1);//<h,w,distance>

	rp(h,H){
		rp(w,W){
			int a; cin>>a;
			A[a] = make_tuple(h+1,w+1,0);
		}
	}

	up(pre,1,H*W,1){
		int now = pre + D;
		if(now>H*W) break;
		int hb,wb,d; tie(hb,wb,d)=A[pre];
		int ha,wa; tie(ha,wa,ignore)=A[now];
		d += abs(hb-ha) + abs(wb-wa);
		A[now] = make_tuple(ha,wa,d);
		// cout<<pre<<","<<now<<":";
		// cout<<"("<<hb<<","<<ha<<")"<<abs(hb-ha)<<"+";
		// cout<<"("<<wb<<","<<wa<<")"<<abs(wb-wa)<<"=";
		// cout<<abs(hb-ha)+abs(wb-wa)<<"\n";
	}

	// ot("\n---\n");
	// rp(i,A.size()){
	// 	int h,w,d;tie(h,w,d)=A[i];
	// 	cout<<i<<") "<<"("<<h<<","<<w<<","<<d<<")\n";
	// }ot("---\n");

	int Q; cin>>Q;
	rp(i,Q){
		int l,r; cin>>l>>r;
		int dl; tie(ignore,ignore,dl) = A[l];
		int dr; tie(ignore,ignore,dr) = A[r];
		cout<< dr-dl <<endl;
	}


}


Measured memory_bytes: 2176
#include <stdio.h>

#define MAX 500

int main(void){
	int w, h, t, p, d, c, x, y;
	int ans, dist, origin_x, origin_y;

	while(1){
		int kami[MAX][MAX]={0};

		scanf("%d %d %d %d", &w, &h, &t, &p);
		if(w==0 && h==0 && t==0 && p==0) break;
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				kami[i][j] = 1;//初期化
			}
		}

		origin_x = origin_y =0;
		for(int k=0; k<t; k++){
			scanf("%d %d",&d, &c);

			if(d == 1){
				dist = 1;
					for(int j=origin_x+c; j<origin_x+(2*c); j++){
						for(int i=origin_y; i<MAX; i++){
							if(j-dist >= 0)kami[i][j] += kami[i][j-dist];
					}
					dist += 2;
				}
				origin_x += c;
			} else{
				dist = 1;
				for(int i=origin_y+c; i<origin_y+(2*c); i++){
					for(int j=origin_x; j<MAX; j++){
						if(i-dist >= 0)kami[i][j] += kami[i-dist][j];
					}
					dist += 2;
				}
				origin_y += c;
			}


		}
		
		for(int k=0; k<p; k++){
			scanf("%d %d", &x, &y);
			printf("%d\n", kami[origin_y+y][x+origin_x]);
		}
	}

	return 0;
}


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

int main() {
	int N;
	cin >> N;

	int count = 0;
	int N_ken = N;
	while (N_ken > 0) {
		N_ken /= 10;
		count += 1;
	}
	
	if (count == 6) {
		cout << 90909 << endl;
	}
	else if (6>count && count >=5) {
		cout << N-9999+909 << endl;
	}
	else if (5 > count && count >= 4) {
		cout << 909 << endl;
	}
	else if (4 > count && count >= 3) {
		cout << N - 99 + 9 << endl;
	}
	else if (3 >count && count>=2) {
		cout << 9<< endl;
	}

	else if (2 > count) {
		cout << N <<endl;

	}
}



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

public class Main {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    static class DSU {
        int[] root;
        int[] rank;

        public DSU(int n) {
            root = new int[n];
            rank = new int[n];
            for(int i=0;i<n;i++) {
                root[i] = i;
            }
        }

        public int find(int x) {
            if(root[x] == x) {
                return x;
            }
            else {
                return find(root[x]);
            }
        }

        public void unite(int x, int y) {
            x = find(x);
            y = find(y);
            if(x == y) {
                return;
            }
            if(rank[x] < rank[y]) {
                root[x] = y;
            }
            else {
                root[y] = x;
                if(rank[x] == rank[y]) {
                    rank[x]++;
                }
            }
        }

        public boolean same(int x, int y) {
            return find(x) == find(y);
        }
    }

	public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        long a = sc.nextLong(), b = sc.nextLong(), c = sc.nextLong();

        if(a + b + 1 >= c) {
            pw.println(b + c);
        } else {
            pw.println(b + (a + b + 1));
        }

        pw.close();
    }
}

// a : untasty, a
// b : tasty, a
// c : tasty, p

Measured memory_bytes: 22612