akhauriyash/Code-Regression huggingface dataset:
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)
        self.size = [1] * (n + 1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            if self.same_check(x, y) != True:
                self.size[y] += self.size[x]
                self.size[x] = 0
            self.par[x] = y
        else:
            if self.same_check(x, y) != True:
               self.size[x] += self.size[y]
               self.size[y] = 0
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
               self.rank[x] += 1

    def siz(self, x):
        x = self.find(x)
        return self.size[x]


N, M = list(map(int, input().split()))
l = [[] for i in range(M)]
uf = UnionFind(N)

for i in range(N):
    kl = list(map(int, input().split()))
    K = kl[0]
    for j in range(1, K + 1):
        l[kl[j] - 1].append(i + 1)

for i in range(M):
    for j in range(len(l[i]) - 1):
        uf.union(l[i][0], l[i][1 + j])

if uf.siz(1) == N:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 19736
n, x = map(int, input().split())
ls = list(map(int, input().split()))

ans = 0
m = x

ls.sort()

for i in range(n):
    x = x - ls[i]
    if x >= 0:
        ans += 1
    else:
        break

if m > sum(ls):
    print(ans - 1)
else:
    print(ans)

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

using namespace std;
using ll = long long;

#ifdef ABHI
  #include "../debug.h"
  #define _GLIBCXX_DEBUG
#else
  #define debug(...) 42
  #define cerr if(0) cout
#endif

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<vector<pair<int, int>>> g(n);
  for(int i = 0; i < n - 1; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    w %= 2;
    g[--u].emplace_back(--v, w);
    g[v].emplace_back(u, w);
  }
  vector<int> mark(n, -1);
  int c = 0;
  function<void(int, int, int d)> dfs = [&](int u, int p, int d) {
    if(d == c) mark[u] = c;
    for(auto x: g[u]) if (x.first != p) {
      dfs(x.first, u, (x.second + d) % 2);
    }
  };
  dfs(0, -1, 0);
  for(int i = 0; i < n; ++i) if (mark[i] == -1) {
    c = 1;
    dfs(i, -1, 1);
  }
  debug(mark);
  for(int x: mark) {
    assert(x != -1);
    cout << x << '\n';
  }
  return 0;
}


Measured memory_bytes: 9984
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=9e18;
typedef pair<int,int> P;
ll power(ll a,ll b){
	ll sum=1;
	for (; b; b>>=1){
		if (b&1)	sum=1ll*sum*a%MOD;
		a=1ll*a*a%MOD;
	}
	return sum;
}
ll calc(ll n,ll x){
	ll sum=1;
	for (ll i=n; i>=n-x+1; i--)	
		sum=sum*i%MOD;
	for (ll i=1; i<=x; i++)
        //MODの世界では、Xで割ることとX^(MOD-2)で掛けることが等価
		sum=sum*power(i,MOD-2)%MOD;
	return sum;
}
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll x,y,n,m,ans;
  cin >> x >> y;
  if((x+y)%3!=0) {
    cout << 0 << endl;
    return 0;
  }
  n=(2*y-x)/3,m=(2*x-y)/3;
  if (n < 0 || m < 0) {
	cout << 0 << endl;
    return 0;
  }
  ans=calc(n+m,m);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>
#include <fstream>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N, K;
    cin >> N >> K;
    vector<pair<ll, ll>> co;
    Rep (i, N) {
        ll x, y;
        char c;
        cin >> x >> y >> c;
        if (c == 'W') x += K;
        x %= 2*K;
        y %= 2*K;
        co.push_back(make_pair(x, y));
    }

    vector<vector<ll>> grid(2*K, vector<ll>(2*K, 0));

    Rep (i, N) {
        grid[co[i].first][co[i].second]++;
    }


    vector<vector<ll>> s(2*K+1, vector<ll>(2*K+1, 0));
    Rep (i, 2*K) Rep (j, 2*K) s[i+1][j+1] = s[i][j+1] + s[i+1][j] - s[i][j] + grid[i][j];


    ll ans = 0;
    Rep (i, K) Rep (j, K) {
        ll tmp = s[i+K][j+K] - s[i][j+K] - s[i+K][j] + s[i][j];
        tmp += s[i][j] - s[0][j] - s[i][0] + s[0][0];
        tmp += s[2*K][j] + s[i+K][0] - s[2*K][0] - s[i+K][j];
        tmp += s[i][2*K] + s[0][j+K] - s[i][j+K] - s[0][2*K];
        tmp += s[2*K][2*K] + s[i+K][j+K] - s[2*K][j+K] - s[i+K][2*K];
        chmax(ans, tmp);
        chmax(ans, N-tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 64496
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


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);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/


int main() {

	int a, b;
	cin >> a >> b;
	cout << (a + b) / 2 << endl;


	return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>
#include<map>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);



//名前の通り。　N個の独立した要素を併合するときに使用
class UnionFind {
public:
	vector<int>rank, parent;
	//初期化
	UnionFind(){}
	UnionFind(int size) {
		rank.resize(size, 0);
		parent.resize(size, 0);
		REP(i, size)parent[i] = i;
	}
	//木の根を求める
	int find(int x) {
		if (parent[x] == x)return x;
		else return parent[x] = find(parent[x]);
	}
	//xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (rank[x] < rank[y])
			parent[x] = y;
		else {
			parent[y] = x;
			if (rank[x] == rank[y])rank[x]++;
		}
	}
	//xとyが同じ集合に属するか否か
	bool same(int x, int y) {
		return (find(x) == find(y));
	}
	//parentの内容を出力
	void debug() {
		for (auto num : parent) {
			cout << num << " ";
		}
		cout << "more:" << endl;
		REP(i, parent.size()) {
			cout << find(i) << " ";

		}
		cout << endl << "more:" << endl;
		for (auto num : parent) {
			cout << num << " ";
		}
		cout << endl;
	}
};


//変数
int N, M;
vector<int> p;
vector<pair<int, int>> xy;

UnionFind uf;




//サブ関数
//入力
void input()
{
	int tmp, tmp2;
	cin >> N >> M;
	REP(i, N) {
		cin >> tmp;
		tmp--;
		p.push_back(tmp);
	}
	
	uf = UnionFind(N);
	REP(i, M) {
		cin >> tmp >> tmp2;
		tmp--;
		tmp2--;
		uf.unite(tmp, tmp2);
	}
}


//計算
void calc()
{
	map<int, vector<int>> par2p, par2uf;


	REP(i, N) {
		int par = uf.find(i);

		auto itr2p = par2p.find(par);
		if (itr2p != par2p.end()) {
			par2p[par].push_back(p[i]);
		}
		else {
			par2p[par] = vector<int>(1, p[i]);
		}


		auto itr2uf = par2uf.find(par);
		if (itr2uf != par2uf.end()) {
			par2uf[par].push_back(i);
		}
		else {
			par2uf[par] = vector<int>(1, i);
		}
	}


	int ans = 0;
	//同じ親のやつがそろいました
	for (auto itr = par2p.begin(); itr != par2p.end(); ++itr) {
		int par = itr->first;
		vector<int> res;
		vector<int> p2 = par2p[par];
		vector<int> uf2 = par2uf[par];
		sort(p2.begin(), p2.end());
		sort(uf2.begin(), uf2.end());
		set_intersection(p2.begin(), p2.end(), uf2.begin(), uf2.end(), back_inserter(res));

		ans += res.size();
	}
	cout << ans << endl;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 23288
#include <stdio.h>
int main(){
  int a, b, ans;
  char op;
  while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op == '?')break;
    switch(op){
      case '+':ans = a + b;break;
      case '-':ans = a - b;break;
      case '*':ans = a * b;break;
      case '/':ans = a / b;break;
      default:break;
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1852
#include <string> 
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <math.h>
 
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
 
	int N,ans;
    ans = 1;
	cin >> N;
    vector<string> vec(N);
    for(int i=0;i<N;i++){
      cin >> vec.at(i);
    }
  
    sort(vec.begin(),vec.end());
  
    for(int i=0;i<N-1;i++){
      if(vec.at(i) != vec.at(i+1)){
        ans++;
      }
    }     
  
    cout << ans << "\n";
  
}

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

using namespace std;
using ll = long long;
const long long INF = 1LL << 60;


int main(){
    int n;
    cin >> n;
    vector<int> v(n+1);
    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j += i){
            v[j]++;
        }
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        ans += v[i] * (ll)i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 42308
#include <iostream>
using namespace std;
void ABC50(void);
void ABC52(void);
void ABC53(void);
void ABC54(void);
void ABC55(void);
void ABC56(void);
void ABC57(void);
void ABC58(void);
void ABC59(void);

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

void ABC56(void){
    char a,b;
    cin>>a>>b;
    if(a=='H')cout<<b<<endl;
    if(a=='D'&&b=='H'){cout<<'D'<<endl;}
    else if(a=='D')cout<<'H'<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a;
    int b;
    while(true){
        cin>>a>>b;
        if(a == 0 && b == 0)break;
        if(a < b){
            cout<<a<<" "<<b<<endl;
        }else if(a > b){
            cout<<b<<" "<<a<<endl;
        }else if(a == b){
            cout<<a<<" "<<b<<endl;
        }
    }
return 0;    
}



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

int n;
map<int, set<int>> ord;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n; i++){
		int x, y;
		cin >> x >> y;
		ord[x].insert(y);
	}
	int ans = 0;
	multiset<int, greater<int>> up, down;
	for(auto &i : ord)
		for(int j : i.second){
			up.insert(i.first + j);
			down.insert(i.first - j);
		}
	for(auto &i : ord)
		for(int j : i.second){
			ans = max(ans, *up.begin() - (i.first + j));
			ans = max(ans, *down.begin() - (i.first - j));
			up.erase(up.find(i.first + j));
			down.erase(down.find(i.first - j));
		}
	cout << ans << '\n';
	return 0;
}

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

int main() {
 int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b == c+d){
  cout << "Balanced" << endl;
  } else if(a+b > c+d){
  cout << "Left" << endl;
  } else{
  cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    X, Y, A, B, C = iim()
    P = list(iim())
    Q = list(iim())
    R = list(iim())

    P.sort(reverse=True)
    Q.sort(reverse=True)
    R.sort(reverse=True)

    p1 = [0]*(X+1)
    for i in range(X):
        p1[i+1] = p1[i] + P[i]
    q1 = [0]*(Y+1)
    for i in range(Y):
        q1[i+1] = q1[i] + Q[i]

    si = [X-1, Y-1]
    S = [P, Q]
    if P[si[0]] < Q[si[1]]:
        idx = 0
    else:
        idx = 1
    ans = 0
    swap = True
    for i in range(C):
        if S[idx][si[idx]] < R[i]:
            si[idx] -= 1
            ans += R[i]

            if si[idx] < 0:
                idx ^= 1
                if si[idx] <= 0:
                    break
                swap = False
            elif not swap:
                continue
            elif P[si[0]] < Q[si[1]]:
                idx = 0
            else:
                idx = 1
        else:
            break

    print(p1[si[0]+1] + q1[si[1]+1] + ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 24624
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

// 引数nの各桁の和を返す。
long long sumDigit(long long n){
    long long ret = 0;
    while(n > 0){ ret += n%10; n /= 10; }
    return ret;
}

int main(){
    Init();
    ll n; cin >> n;
    ll ans = INFLL;
    for(ll i=1; i<n; i++){
        ll j=n-i;
        chmin(ans, sumDigit(i)+sumDigit(j));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int h, w, k;

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

  cin >> h >> w >> k;

  vector<string> a(h);
  vector<vector<int>> b(h, vector<int>(w, 0));
  for (int i = 0; i < h; i++) {
    cin >> a[i];
  }

  int curr = 1;
  for (int i = 0; i < h; i++) {
    if (a[i].find("#") == a[i].npos) {
      continue;
    }

    bool fst = true;

    for (int j = 0; j < w; j++) {
      char c = a[i][j];
      if (c == '#') {
        if (fst) {
          fst = false;
        } else {
          curr++;
        }
      }
      b[i][j] = curr;
    }
    curr++;
  }

  for (int i = 0; i < h; i++) {
    if (b[i][0] != 0) {
      continue; // すでに処理済みの行はなにもしない
    }

    // 未処理の行を処理
    if (i == 0) {
      int targeti;
      for (int ii = i; ii < h; ii++) {
        if (b[ii][0] != 0) {
          targeti = ii;
          break;
        }
      }

      b[i] = b[targeti];
    } else {
      b[i] = b[i - 1];
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << (j ? " " : "") << b[i][j];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1280
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


# 入力
N, Q = map(int, input().split())
g = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    g[a].append(b)
    g[b].append(a)
point = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    p -= 1
    point[p] += x
ans = [0] * N
# 探索
def dfs(pre, now):
    # ansを更新
    ans[now] = ans[pre] + point[now]
    # 隣接頂点を探索
    for nxt in g[now]:
        if nxt == pre:
            continue
        dfs(now, nxt)
dfs(0, 0)
print(*ans)


Measured memory_bytes: 236928
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e14;
using Graph = vector<vector<int>>;

signed main(){
  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 r = 1000000000;
  int l = 0;
  while( r-l > 1 ){
    int mid = (r+l)/2;
    int cnt = 0;
    for( int i = 0; i < N; i++ ){
      int now = (A[i]+mid-1)/mid-1;
      cnt += now;
    }
    if( cnt <= K ) r = mid;
    else l = mid;
  }
  cout << r << endl;

}


Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    vector<string>a;
    for(ll i=0;i<n;i++){
        string x;
        cin >> x;
        a.push_back(x);
    }
    ll D[60][40]={};
    for(ll i=0;i<a.size();i++){
        ll b=0,k=0;//b:分子の整数、k:分母の指数
        for(ll j=0;j<a[i].size();j++){
            if(a[i][j]=='.'){
                k=a[i].size()-j-1;
                continue;
            }
            b*=10;
            b+=a[i][j]-'0';
        }
        ll t=0,f=0;//t:two,f:five
        ll copy=b;
        while(copy%2==0){
            t++;
            copy/=2;
        }
        copy=b;
        while(copy%5==0){
            f++;
            copy/=5;
        }
        //D[t-k][f-k]をインクリメントする
        //いい感じにするために+10する
        D[t-k+10][f-k+10]++;
    }
    ll ans=0;
    for(ll i=0;i<55;i++){
        for(ll j=0;j<30;j++){
            for(ll k=0;k<55;k++){
                for(ll l=0;l<30;l++){
                    if(i+k-20>=0 && j+l-20>=0 && !(i==k && j==l)){
                        ans+=D[i][j]*D[k][l];
                    }
                }
            }
        }
    }
    ans/=2;
    for(ll i=0;i<55;i++){
        for(ll j=0;j<30;j++){
            if(i-10>=0&&j-10>=0){
                ans+=D[i][j]*(D[i][j]-1)/2;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 11596
r,g,b,n = map(int,input().split())
cnt=0
s=[r,g,b]
s.sort()
for i in range(n//s[2]+1):
    if i*s[2]==n:
        cnt+=1
    else:
        for j in range((n-i*s[2])//s[1]+1):
            if n-i*s[2]==s[1]*j:
                cnt+=1
            else:
                if (n-i*s[2]-j*s[1]) % s[0] ==0:
                    cnt+=1
print(cnt)
 

Measured memory_bytes: 40556
r, g, b, n = gets.split.map(&:to_i)
g, b, r = [r, g, b].sort!

ans = 0

0.upto(n / r) do |x|
  0.upto((n - (r * x)) / g) do |y|
    balls = r * x + g * y
    rest = n - balls

    ans += 1 if rest % b == 0
  end
end

puts ans


Measured memory_bytes: 1788
residence = [0 for i in range(120)]
n = int(input())
count = 0
while count < n:
    b, f, r, v = map(int, input().split())
    residence[(b - 1) * 30 + (f - 1) * 10 + (r - 1)] += v
    count += 1
for i in range(120):
    if i != 0:
        if i % 10 == 0:
            print()
        if i % 30 == 0:
            print("#" * 20)  
    if i % 10 < 10:
        print(end=" ")
    print(residence[i], end="")
print()



Measured memory_bytes: 5632
/*
    JAI JAGANNATH!
*/
//@Author : zanj0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<lli>
#define mii             map<lli,lli>
#define pqb             priority_queue<lli>
#define pqs             priority_queue<lli,vi,greater<lli> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            lli x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> pbds;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

void zanj0()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}
void solve() {
	lli ret = 0;
	string s;
	string x;
	cin >> s >> x;
	lli n = s.size();
	for (lli i = 0; i < n; i++) {
		ret += s[i] != x[i];
	}
	cout << ret << endl;
}
int main()
{
	zanj0();
	solve();
	return 0;
}

Measured memory_bytes: 3860
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl;
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

ll mod= 1000000007;
struct mint {
	ll x;
	mint(ll x = 0) :x(x%mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
};
mint dp[1010][1010];
const int MAX = 10000;
const int MOD = mod;
ll fac[MAX], finv[MAX], inv[MAX];

void combinit() {
	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;
	}
}
ll comb(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;
}

int main() {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	combinit();
	fac[0] = 1;
	rep(i, 1, 1010) {
		fac[i] = i * fac[i - 1];
		fac[i] %= mod;
	}

	dp[a - 1][n] = 1;
	for (int i = a; i <= b; i++) {
		for (int j = 0; j <= n; j++) {
			dp[i][j] += dp[i - 1][j];
			mint p = 1;
			for (int k = 1; k <= d && j + k * i <= n; k++) {
				mint tmp = comb(j + k * i, i);
				p *= tmp;
				p *= inv[k];
				if (k >= c)dp[i][j] += p*dp[i-1][j+k*i];
			}
		}
	}
	puts(dp[b][0].x)

	return 0;
}


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

using namespace std;

int main(void) {
  
  string S;
  string T;
  cin >> S;
  cin >> T;

  int count = 0;
  int size = S.size();
  for (int i=0; i<size; i++) {
    if (S.at(i) != T.at(i)) {
      count++;
    }
  }
  cout << count << endl;

}


Measured memory_bytes: 3916
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	HashMap<List<Integer>, Integer> memo = new HashMap<>();

	private int rec(int i, int rest) {
		List<Integer> memoKey = Arrays.asList(i, rest);

		if (memo.containsKey(memoKey)) {
			return memo.get(memoKey);
		}

		int ans;
		if (rest == 0) {
			ans = 0;
		} else if (i == hiki.size()) {
			ans = Integer.MAX_VALUE >> 1;
		} else if (hiki.get(i) > rest) {
			ans = rec(i + 1, rest);
		} else {
			int a = 1 + rec(i, rest - hiki.get(i));
			int b = rec(i + 1, rest);
			ans = Math.min(a, b);
		}

		memo.put(memoKey, ans);
		return ans;

	}

	int N;
	ArrayList<Integer> hiki;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		N = sc.nextInt();

		hiki = new ArrayList<>();

		hiki.add(1);
		for (int i = 1; Math.pow(6, i) <= N; i++) {
			hiki.add((int) Math.pow(6, i));
		}
		for (int i = 1; Math.pow(9, i) <= N; i++) {
			hiki.add((int) Math.pow(9, i));
		}

		hiki.sort(Comparator.reverseOrder());
		System.err.println(hiki);
		out.println(rec(0, N));

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


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

int a[100005];
int dp[100005][50];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i = 1;i <= n;i++)
		scanf("%d",&a[i]);
	int L,Q;
	scanf("%d%d",&L,&Q);
	for(int i = 1;i <= n;i++)
	{
		int id = (int) (upper_bound(a+1,a+1+n,a[i]+L)-a-1);
		if(a[i] + L >= a[n])
			dp[i][0] = n;
		else
			dp[i][0] = id;
	}
	
	for(int i = 1;i <= 30; i++)
		for(int j = 1;j <= n; j++)
			dp[j][i] = dp [dp[j][i-1]][i-1];
	while(Q--)
	{
		int L,R;
		scanf("%d%d",&L,&R);
		if(R<L)
			swap(L,R);
		int ans = 1;
		for(int i=30;i>=0;i--)
		{
			if(dp[L][i] < R)
			{
				ans = ans + (1<<i);
				L = dp[L][i];
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 20736
/*0633　ぬいぐるみの整理
 ビットdp　８０点ぐらい
*/
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int dp[1<<21],ss[1<<21],s2[21][100001];
int main(void)
{
	int i,j,s[21],n,m,a[100000],x,k,mask[21],s1,wk,wk2;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)	scanf("%d",&a[i]);
	for(i=1;i<=m;i++)	s[i]=0;
	for(i=0;i<n;i++)	s[a[i]]++;
	for(i=0;i<(1<<m);i++)	{
		x=i;	ss[i]=0;	
		for(j=1;j<=m;j++)	{
			if(x%2==1)	ss[i]+=s[j];
			x=x/2;
		}
	}
	for(i=1;i<=m;i++)	{
		s2[i][0]=0;	wk=0;
		for(j=0;j<n;j++)	{
			if(a[j]==i)	{
				wk++;
			}
			s2[i][j+1]=wk;
		}
	}
//	for(i=1;i<=m;i++)	{
//		for(j=0;j<n;j++)	{
//			printf("%d ",s2[i][j]);
//		}
//		printf("\n");
//	}
	mask[1]=1;
	for(i=2;i<=m;i++)	mask[i]=mask[i-1]*2;
	for(i=0;i<(1<<m);i++)	dp[i]=n;
	dp[0]=0;
	for(i=0;i<(1<<m);i++)	{
		x=i;
		for(j=1;j<=m;j++)	{
			if((x&mask[j])==0)	{
				s1=s[j]-(s2[j][ss[i]+s[j]]-s2[j][ss[i]]);
//				printf(" %d %df s1=%d\n",i,j,s1);
				wk=i|mask[j];
				dp[wk]=min(dp[wk],dp[i]+s1);
			}
		}
	}
//	for(i=0;i<(1<<m);i++)	printf(" %d %d\n",i,dp[i]);
	printf("%d\n",dp[(1<<m)-1]);
	return 0;
}
		
				




Measured memory_bytes: 19000
import java.util.Scanner;

public class Main {
	
	static int[] dish = new int[5];
	static int[] last1 = new int[5];
	static String[] dishStr = new String[5];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(int i=0; i<5; i++) {
			dishStr[i] = (sc.nextLine());
			dish[i] = Integer.parseInt(dishStr[i]);
		}
		
		int lastDish = 0;
		int mini1 = 0;
		//最後に、下一桁の数値が一番小さいdishを頼む(0を除く)
		for(int i=0; i<5; i++) {
			last1[i] = Integer.parseInt(dishStr[i].substring(dishStr[i].length() -1 , dishStr[i].length()));
			if(i == 0) {
				mini1 = last1[i];
				continue;
			}
			if(!(last1[i] == 0) && last1[i] < mini1) {
				mini1 = last1[i];
				lastDish = i;
			}
		}
		
		int ans = 0;
		for(int i=0; i<5; i++) {
			if(i==lastDish) {
				ans += dish[i];
			} else {
				if(last1[i] == 0) {
					ans += dish[i] + last1[i];
				}else {
					ans += dish[i] + 10 - last1[i];
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
def dfs(n,k,a)
  return nil if n<0
  if k==K.size
    return n.zero? ? a : nil
  end
  c=S[K[k]]
  r1=dfs(n-K[k], k, a+[c])
  r2=dfs(n, k+1, a)
  return r2 unless r1
  return r1 unless r2
  return r1 if r2.size < r1.size
  return r2 if r1.size < r2.size
  r1.sort.reverse.to_s < r2.sort.reverse.to_s ? r2 : r1
end

B=[0,2,5,5,4,5,6,3,7,6]

N,M=gets.split.map(&:to_i)
A=gets.split.map(&:to_i)

S=Hash.new{|h,k|h[k]=0}
A.each do |a|
  S[B[a]]=[S[B[a]],a].max
end
K=S.keys.sort

n,r=N.divmod(K[0])
m=[10,n-1].min
n-=m
r+=K[0]*m
f=""
l=""
dfs(r,0,[]).sort.reverse.each do |c|
  S[K[0]]<c ? f+=c.to_s : l+=c.to_s
end
puts f + S[K[0]].to_s*n + l

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

using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<ll, ll>;

int m, d;
void input() {
    cin >> m >> d;
}

void calc() {
    int ans = 0;
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= d; j++) {
            int d1 = j % 10, d10 = j / 10;
            if (d1 >= 2 && d10 >= 2 && d1 * d10 == i) ++ans;
        }
    }
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    input();
    calc();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;

int main() {
	int A, B, N; cin >> N >> A >> B;
	if ((B - A) % 2 == 0) {
		cout << "Alice" << endl;
	}
	else {
		cout << "Borys" << endl;
	}
	return 0;
}

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

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define repd(i, a, b) for (int i=(a);i<(b);i++)
#define rep(i, n) repd(i,0,n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

using namespace std;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

/**
 * change minimum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMinimum(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * change maximum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMaximum(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template<typename T>
T output(T answer) {
    cout << answer << endl;
    return 0;
}

/** ----from here ---------------------------------------------------------- */

int main() {

    string S;
    cin >> S;
    int M = S.length();
    string inverse;

    for (int i = M - 1; i >= 0; --i) {
        inverse.push_back(S[i]);
    }
    // cout << inverse << endl;

    int j = 0;
    bool ans = false;
    while (j < M) {
        string five;
        string six;
        string seven;

        for (int k = j; k < j + 5; ++k) {
            five.push_back(inverse[k]);
        }
        for (int k = j; k < j + 6; ++k) {
            six.push_back(inverse[k]);
        }
        for (int k = j; k < j + 7; ++k) {
            seven.push_back(inverse[k]);
        }
//        cout<<five<<endl;
//        cout<<six<<endl;
        //cout<<seven<<endl;
        if (five == "maerd" || five == "esare") {
            j += 5;
            //cout<<"FIVE";
        } else if (six == "resare") {
            j += 6;
            //cout<<"six";
        } else if (seven == "remaerd") {
            j += 7;
        } else {
            break;
        }
        //cout<<j<<endl;
        if (j == M ) {
            ans = true;
            break;
        }
    }

    string a;
    if (ans) {
        a = "YES";
    } else {
        a = "NO";
    }


    cout << a << endl;
}

Measured memory_bytes: 640
# coding: utf-8
# Your code here!
N,A,B=map(int,input().split())

count=0

for h in range(2):
    for i in range(10):
        for j in range(10):
            for k in range(10):
                for l in range(10):
                
                    if h+i+j+k+l>B:
                        break
                    elif ((h+i+j+k+l)>=A and (10000*h+1000*i+100*j+10*k+l)<=N):
                        count+=10000*h+1000*i+100*j+10*k+l
                        

                    
print(count)                    
    


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, m;
    cin >> n >> m;
    m++;
    vector<int> v(m, 0);
    rep(i, n)
    {
        int k;
        cin >> k;
        rep(j, k)
        {
            int a;
            cin >> a;
            v[a]++;
        }
    }
    int ans = 0;
    rep(i, m) if (v[i] == n) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;

long long mod = 1e9+7;
vector<int> fact;
vector<int> factinv;

void initfact(int n) {
    fact.push_back(1);
    for (int i = 1; i < n+1; i++) {
        fact.push_back((fact.back()*static_cast<long long>(i))%mod);
    }
}

int sqr(int n) {
    return static_cast<long long>(n)*n%mod;
}

int bipow(int c, int n) {
    if (n == 0) {
        return 1;
    } else if(n == 1) {
        return c;
    } else if(n%2 == 0) {
        return sqr(bipow(c, n/2))%mod;
    } else {
        return (static_cast<long long>(c)*sqr(bipow(c, (n-1)/2)))%mod;
    }
}

void initfactinv() {
    factinv.push_back(bipow(fact.back(), mod-2));
    for (int i = fact.size()-1; i > 0; i--) {
        factinv.push_back((factinv.back()*static_cast<long long>(i))%mod);
    }
    reverse(factinv.begin(), factinv.end());
}

int C(int n, int m) {
    if (n < m) {
        return 0;
    }
    return (((static_cast<long long>(fact[n])*factinv[m])%mod)*factinv[n-m])%mod;
}

void solve(int n, vector<int> a) {
    vector<int> used(n, -1);
    int l, r, m;
    for (int i = 0; i < n+1; i++) {
        if (used[a[i]-1] != -1) {
            l = used[a[i]-1];
            r = i;
            break;
        }
        used[a[i]-1] = i;
    }
    m = r - l - 1;
    initfact(n+1);
    initfactinv();
    for (int i = 1; i < n+2; i++) {
        int ret = (C(n+1, i) - C(n+1-m-2, i-1) + mod)%mod;
        std::cout << ret << std::endl;
    }
}

int main() {
    struct timeval start,end;
    long long span;
    int n;

    gettimeofday(&start,NULL);

    std::cin >> n;
    vector<int> a(n+1);
    for (int i = 0; i < n+1; i++) {
        std::cin >> a[i];
    }
    solve(n, a);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 3320
#include <stdio.h>
#include <ctype.h>

int main(){
    char ch;
    
    while(1){
        
        scanf("%c", &ch);
        if ( ch == '\n' ) break;
        
        if(islower(ch)){
            ch = toupper(ch);
        }else if(isupper(ch)){
            ch = tolower(ch);
        }
        printf("%c", ch);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 524
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█
 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long lo;
typedef pair< int,int > PII;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
 
const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;
 
int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
multiset<int> st;
vector<int> v;
 
int main(void){
	scanf("%d",&n);
	FOR{
		scanf("%d",&a[i]);
	}
	//~ st.insert(inf)
	st.insert(a[1]);
	for(int i=2;i<=n;i++){
		//~ cout<<st.size()<<endl;
		auto it=st.begin();
		//~ it++;
		//~ cout<<*it<<endl;
		if(*it>=a[i]){st.insert(a[i]);continue;}
		it=st.lower_bound(a[i]);
		//~ auto it1=st.upper_bound(a[i]);
		//~ if(st.size()==1){
			//~ it--;
			//~ if(it==st.end()){
				//~ it--;
				//~ st.erase(it);
				//~ st.insert(*it);
				//~ continue;
			//~ }
			//~ else{
				//~ st.insert(a[i]);continue;
			//~ }
		//~ }
		it--;
		//~ if(it==){st.insert(a[i]);continue;}
		//~ if(*it>=a[i]){st.insert(a[i]);continue;}
		
		st.erase(it);
		st.insert(a[i]);
	}
	printf("%d\n",st.size());
	return 0;
}


Measured memory_bytes: 5376
import bisect
import math
def solve():
  n,k = (int(i) for i in input().split())
  bairitu = [1]
  for i in range(1,20):
    bairitu.append(2*bairitu[i-1])
  ans = 0
  kakuritu = 1/n
  for i in range(1,n+1):
    if i >= k:
      ans += kakuritu
    else:
      rest = math.ceil(k/i)
      place = bisect.bisect_left(bairitu,rest)
      ans += kakuritu *((1/2)**place)
  print(ans)
  
solve()


Measured memory_bytes: 3188
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

char str[100005];
ll dp[2][13];
int main(int argc, char* argv[])
{
    scanf("%s", str);
    int n=strlen(str);

    int prev=0, curr=1;
    int i,j,k;
    dp[prev][0]=1;
    for(i=0; i<n; i++) {
        for(k=0; k<13; k++) dp[curr][k]=0;
        if(str[i]=='?') {
            for(j=0; j<13; j++) {
                for(k=0; k<10; k++) {
                    dp[curr][j] = (dp[curr][j] + dp[prev][(j-k+13)*4%13])%MOD;
                }
            }
        }
        else {
            int add = str[i]-'0';
            for(j=0; j<13; j++) {
                dp[curr][j] = (dp[curr][j] + dp[prev][(j-add+13)*4%13])%MOD;
            }
        }
        swap(prev,curr);
    }
    printf("%lld\n", dp[prev][5]);

    return 0;
}


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

int main()
{
  int n;
  cin>>n;
  ll h[n],dp[n];
  for(int i=0;i<n;i++)
  {
    cin>>h[i];
    dp[i]=0;
  }
  dp[1]=abs(h[1]-h[0]);
  for(int i=2;i<n;i++)
  {
    dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
  }
  cout<<dp[n-1]<<"\n";
}

Measured memory_bytes: 1792
import java.awt.geom.*;
import java.io.*;
import java.util.*;

public class Main{
	double EPS = 1.0e-08;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int [][] data = new int[n][3];
			for(int i = 0; i < n; i++){
				for(int j = 0; j < 3; j++){
					data[i][j] = sc.nextInt();
				}
			}
			
			double best = 1 << 24;
			int ind = -1;
			for(int i = 0; i < n; i++){
				double now = 22.0 - ((double)(data[i][2]) / (data[i][1] * 0.01 * data[i][1] * 0.01));
				now = Math.abs(now);
				if(best > now){
					best = now;
					ind = i;
				}
			}
			System.out.println(data[ind][0]);
		}
	}
	
	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 29648
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int n;
gl(n);
int a[1005];
rep(i,1,n)cin>>a[i];
ll ans=1e18;

rep(kk,-300,300)
{
	ll s=0;
	rep(i,1,n)
	{
		s+=(kk-a[i])*(kk-a[i]);
	}
	ans=min(ans,s);
}
ol(ans);
return 0;
}


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

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


Measured memory_bytes: 3096
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int x=scan.nextInt();
        int a=scan.nextInt();
        int b=scan.nextInt();
        System.out.println(Math.abs(x-a)<Math.abs(x-b)?'A':'B');
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int k,x;
    cin >> k >> x;
    for(int i = x-k+1; i <= x+k-1; i++){
        cout << i << " ";
    }
    cout << endl;
    return 0;
}


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

#define int long long

using namespace std;

const int mod = 1e9 + 7;
int n, m;
char a[1005][1005];
int dp[1005][1005];

main(){
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			cin >> a[i][j];
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(a[i][j] == '.'){
				if(i == 1 && j == 1) dp[i][j] = 1;
				else{
					dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
					dp[i][j] %= mod;
				}
			}
		}
	}
	cout << dp[n][m] % mod;
}

Measured memory_bytes: 9088
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp1 {
    public class Class {
        static void Main(string[] args) {
            var X = RL<int>();
            var T1 = new TimeSpan(X[0], X[1], 0);
            var T2 = new TimeSpan(X[2], X[3], 0);
            var ans = ((T2 - T1).TotalMinutes) - X[4];
            Console.Write(ans);
        }

        static T[] RL<T>()where T :IComparable {
            if (typeof(T) == typeof(int)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
            }
            if (typeof(T) == typeof(long)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
            }
            if (typeof(T) == typeof(double)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(double.Parse).ToArray();
            }
            if (typeof(T) == typeof(decimal)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(decimal.Parse).ToArray();
            }
            return (T[])(object)Console.ReadLine().Trim().Split().ToArray();
        }
    }
}

Measured memory_bytes: 28380
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    string[] input = readln.split;
    int N = input[0].to!int;
    int T = input[1].to!int;
    int H = input[2].to!int;
    int L = input[3].to!int;
    int[] t = new int[N];
    int[] h = new int[N];
    foreach(int i; 0..N) {
        input = readln.split;
        t[i] = input[0].to!int;
        h[i] = input[1].to!int;
    }

    int i=-1;
    int x = 0; // 残金
    while(true) {
        i = (i+1)%N;
        if (t[i] > 0) {
            t[i]--; T++; x+=10;
        } else if (h[i] > 0) {
            h[i]--; H++; x+=100;
        } else {
            break;
        }
        if (T > L) break;
        if (x >= 90) {
            bool flg = false;
            for (int j = T; j>=0; j--) {
                if (x-90-10*j>=0 && (x-90-10*j)%100==0 && (x-90-10*j)/100<=H) {
                    x=0;
                    T-=j; H-=(x-90-10*j)/100;
                    t[i]+=j; h[i]+=(x-90-10*j)/100;
                    flg = true;
                    break;
                }
            }
            if (!flg) break;
        }
    }
    writeln(i+1);
}

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

int num = a.size();
int numb = b.size();

if(a.at(num-1) == b.at(0) && b.at(numb-1) == c.at(0)){
    cout << "YES" << endl;
}else{
    cout << "NO" << endl;
}


return 0;
}

Measured memory_bytes: 256
module Main where

import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    [ss, ts] <- replicateM 2 getLine
    let ss' = sort ss
    let ts' = sortBy (flip compare) ts
    if ss' < ts'
        then putStrLn "Yes"
        else putStrLn "No"

Measured memory_bytes: 508
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
using namespace std;

int main(){
  int n,m;
  string s,t;
  cin>>n>>m>>s>>t;
  long long int a,aa;
  bool out=false;
  aa=__gcd(n,m);
  a=aa*(n/aa)*(m/aa);
  for(int i=0;i<aa;i++){
    if(s[i*(n/aa)]!=t[i*(m/aa)]){
        out=true;
        break;
    }
  }
  if(out)
  cout<<-1<<endl;
  else
  cout<<a<<endl;
}


Measured memory_bytes: 512
def run_length_encoding(s):
    '''
    連長圧縮を行う
    s ... iterable object e.g. list, str 
    return
    ----------
    s_composed,s_num,s_idx
    それぞれ、圧縮後の文字列、その文字数、その文字が始まるidx
    '''
    s_composed = []
    s_sum = []
    s_idx = [0]
    pre = s[0]
    cnt = 1
    for i, ss in enumerate(s[1:], start=1):
        if pre == ss:
            cnt += 1
        else:
            s_sum.append(cnt)
            s_composed.append(pre)
            s_idx.append(i)
            cnt = 1
            pre = ss
    s_sum.append(cnt)
    s_composed.append(pre)
    # assert len(s_sum) == len(s_composed)
    return s_composed, s_sum, s_idx


import sys
read = sys.stdin.readline

S = read()[:-1]
ans = [0] * len(S)

S_comp, S_num, S_idx = run_length_encoding(S)
for i, (moji, num, idx) in enumerate(zip(S_comp, S_num, S_idx)):
    if moji == 'R':
        r = S_idx[i + 1]
        ans[r] += num // 2  # 奇数離れてるやつのカウント
        ans[r - 1] += num - num // 2  # 偶数離れてるやつのカウント
    elif moji == 'L':
        l = idx
        ans[l] += num - num // 2  # 偶数離れてるやつのカウント
        ans[l - 1] += num // 2


print(*ans)

Measured memory_bytes: 62448
import java.util.Scanner;
class Main{
	public static void main(String[]agrs){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		System.out.println(gcd(x,y));
	}
	static int gcd(int x, int y){
		if(y == 0){
			return x;
		}else{
			return gcd(y, x % y);
		}
	}
}

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

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

int main(void){
  
  int N,num=0,ans;
  cin >> N;
  while(1){
    if(N<=num)
      break;
    else
      num+=1000;
  }
  ans=num-N;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632