akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=(s);i<(t);++i)
#define per(i,s,t) for(int i=((t)-1);i>=s;--i)
#define repb(i,s,t) for(int i=(s);i<=(t);++i)
#define lepb(i,s,t) for(int i=(s);i>=(t);--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
#define mst(a,b) memset(a,b,sizeof(a))
#define dd(x) cout<<#x<<'='<<x<<' '
#define de(x) cout<<#x<<'='<<x<<'\n'
#define fi first
#define se second
#define sq(x) ((x)*(x))
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;

const int inf = 0x3f3f3f3f;
const ll inff = 4557430888798830399ll;
const db eps = 1e-10;
const db pi = acos(-1.0);
const ll mod = 1e9+7;



int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,k,a,b,o,s,G[700],cnt[700][700];
	ll z[700],dp[700][700];
	mst(z,0);z[0]=1;
	for(int i=2;i<=700;i+=2)z[i]=z[i-2]*(i-1)%mod;
	mst(G,0);s=0;
	cin>>n>>k;
	rep(i,0,k)
	{
		cin>>a>>b;
		G[a]=b;G[b]=a;
	}
	n*=2;k*=2;mst(dp,0);mst(cnt,0);
	repb(i,1,n)repb(j,i,n)cnt[i][j]=cnt[i][j-1]+(!G[j]);
	repb(i,1,n)repb(j,i,n)
	{
		o=1;repb(k,i,j)if(G[k]&&(G[k]<i||j<G[k]))o=0;
		if(!o)continue;
		dp[i][j]=z[cnt[i][j]];
		repb(k,i+1,j-1)(dp[i][j]-=dp[i][k]*z[cnt[k+1][j]]%mod)%=mod;
	}
	repb(i,1,n)repb(j,i,n)(s+=dp[i][j]*z[n-k-cnt[i][j]]%mod)%=mod;
	cout<<(s+mod)%mod<<endl;
}

Measured memory_bytes: 6016
#pragma GCC optimize "Ofast"
#pragma GCC optimize "unroll-loops"
#pragma GCC target "sse,sse2,sse3,sse4,abm,avx,mmx,popcnt,tune=native"
#include <bits/stdc++.h>
#define scan(x) do{while((x=getchar_unlocked())<'0'); for(x-='0'; '0'<=(_=getchar_unlocked()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define ll long long
#define MAXM 1010
#define MAXN 5010
#define INF 0x3f3f3f3f
#define min(a, b) (a) < (b) ? (a) : (b)
#define max(a, b) (a) < (b) ? (b) : (a)
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define f first
#define s second
#define mii map<int, int>
#define umii unordered_map<int, int>
#ifdef DEBUG
	#define D(x...) printf(x)
#else
	#define D(x...)
#endif
using namespace std;

int N;
vector<pii> vec;

int main (int argc, char const *argv[]) {
	#ifdef NOT_DMOJ
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif // NOT_DMOJ
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
cin >> N;
for (int i=1; i<=N; i++) {
int cnt = 0;
for (int j=1; j<=i; j++) {
if (i % j == 0) {
vec.pb(mp(i, ++cnt));
}
}
}
int ans = 0;
for (auto i : vec) {
if (i.f & 1 && i.s == 8) ans++;
}
cout << ans << "\n";
return 0;
}

/* 
 * Look for:
 * the exact constraints (multiple sets are too slow for n=10^6 :( ) 
 * special cases (n=1?)
 * overflow (ll vs int?)
 * array bounds
 */

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

int main(void){

    string ch;
    int count[26];
    for(int i=0;i<26;i++){
        count[i]=0;
    }
    while ( cin >> ch ){
        for(int i=0;i<ch.size();i++){
            if(97<=int(ch[i]) and int(ch[i])<=122) count[int(ch[i])-97]++;
            if(65<=int(ch[i]) and int(ch[i])<=90) count[int(ch[i])-65]++;
        }
    }
    for(int i=0;i<26;i++){
        cout << char(97+i) <<" : "<<count[i] << endl;
    }


    return 0;
}



Measured memory_bytes: 3216
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

long long int euclid_gcd(long long int a, long long int b){
  if(a%b == 0){
    return b;
  }
  else{
    return euclid_gcd(b, a%b);
  }
}

int main(){
  long long int A, B, C, D;
  scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
  std::cerr << A << " " << B << " " << C << " " << D << std::endl;
  
  long long int lcmCD = C*D/euclid_gcd(C, D);
  
  long long int tmpC = 0, tmpD = 0, tmpCD = 0;
  tmpC = B/C - (A-1)/C;
  tmpD = B/D - (A-(long long int)1)/D;
  tmpCD = B/lcmCD - (A-1)/lcmCD;
  
  std::cerr << B/C << " " << (A-1)/C << " " << lcmCD << " " << tmpC << " " << tmpD << " " << tmpCD << std::endl;
  
  std::cerr << "Answer:" << std::endl;
  std::cout << B-A+1 - tmpC - tmpD + tmpCD << std::endl;
  
  return 0;
}


Measured memory_bytes: 384
S = [
    (1, 2, 4, 3), # 0
    (0, 3, 5, 2), # 1
    (0, 1, 5, 4), # 2
    (0, 4, 5, 1), # 3
    (0, 2, 5, 3), # 4
    (1, 3, 4, 2), # 5
]

*L, = map(int, input().split())
q = int(input())
for i in range(q):
    a, b = map(int, input().split())
    for i in range(6):
        if L[i] == a:
            for k in range(4):
                if L[S[i][k]] == b:
                    print(L[S[i][k-3]])



Measured memory_bytes: 5600
#!/usr/bin/python3

import sys
import math

def input():
    return sys.stdin.readline().rstrip('\n')

N = int(input())

# honest_claims[claimer] = a list of honest persons who claimee claims
honest_claims = [0 for _ in range(N)]
unkind_claims = [0 for _ in range(N)]

for i in range(N):
    A = int(input())
    for _ in range(1,A+1):
        j,claim = list(map(int, input().split()))
        if claim == 1:
            honest_claims[i] |= 1<<(j-1)
        else:
            unkind_claims[i] |= 1<<(j-1)

#print([bin(i) for i in honest_claims])
#print([bin(i) for i in unkind_claims])

def get_unkind_claim(honests):
    unkinds = 0
    i = 0
    for _ in range(N):
        if honests & 1 > 0:
            unkinds |= unkind_claims[i]
        honests = honests >> 1
        i += 1
    return unkinds

def get_honest_claim(honests):
    honest_claim = 0
    i = 0
    for _ in range(N):
        if honests & 1 > 0:
            honest_claim |= honest_claims[i]
        honests = honests >> 1
        i += 1
    return honest_claim

def count_1(honests):
    count = 0
    while(honests>0):
        if honests & 1 > 0:
            count += 1
        honests = honests >> 1
    return count

max_honests = 0

for honests in range(1,2**N):
    unkind_claim = get_unkind_claim(honests)
    honest_claim = get_honest_claim(honests)
    if unkind_claim & honests > 0:
        continue
    if (honest_claim | honests) > honests:
        continue
    else:
        max_honests = max(max_honests, count_1(honests))

print(max_honests)


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

int main() {
    int N;
    cin >> N;
    bool frag = true;
    for(int i = 0; i < N; i++){
        char S;
        cin >> S;
        if (S == 'Y'){
            cout << "Four" << endl;
            frag = false;
            break;
        }
    }
    if (frag) {
        cout << "Three" << endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
int main(void)
{
  int N,i,j,x;long long K;
  i=scanf("%d %lld",&N,&K);
  int A[N]={0},here[N]={},town[N]={0};
  for(i=0;i<N;i++)here[i]=-scanf("%d",&A[i]);
  for(i=0,j=0;;i=A[i]-1,j++)if(here[i]<0)here[i]=j,town[j]=i;else{x=here[i];break;}
  if(K>=j)K=(K-x)%(x-j)+x;
  return printf("%d\n",town[K]+1),0;
}

Measured memory_bytes: 4076
//B - Tap Dance
#include <stdio.h>

int main(void){
    char s[100];
    int i;
    scanf("%s", s);
    for(i=0; s[i]!='\0'; i++){
        if(i%2==0 && s[i] == 'L'){
            printf("No\n");
            return 0;
        }
        if(i%2==1 && s[i] == 'R'){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


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

int main () {
	string str, command;
	cin >> str;

	int q, a, b;
	cin >> q;

	for (int i=0; i<q; i++) {
		cin >> command;
		cin >> a >> b;
		
		if (command == "replace") {
			string tmp;
			cin >> tmp;
			str.replace(a, b-a+1, tmp);
		} else if (command == "reverse") {
			for (int j=b; j>a; j--) {
				str.insert(str.begin()+j+1, str[a]);
				str.erase(str.begin()+a);
			}
		} else if (command == "print"){
			for (int j=a; j<=b; j++) {
				cout << str[j];
			}
			cout << endl;
		}
	}
  return 0;
}


Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
int main()
{
    /*vector <int> v(3);
    for(int i=0;i<3;i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    double a=(v[0]*v[1])/2;
    cout<<(int)a<<endl;*/
    double a,b;
    cin>>a>>b;
    /*if(b%a==0)
    {
        cout<<a+b<<endl;
        return 0;
    }
    else*/
        printf("%.10lf",a/b);
    return 0;
}


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

int main(){
    int N, K;
    cin >> N;
    cin >> K;
    vector<int> X(N);
    for (int i=0; i<N; i++){
        cin >> X[i];
    }
    // 動作はyごとに独立なのでx[i]それぞれについて考えれば良い
    int ans = 0;
    for (int x : X){
        ans += 2 * min(x, abs(K-x));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	cout << pow(n, 3) << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<math.h>

using namespace std;

#define INF 1000000007
int n;
int t[16][17];
int dp[1<<16][16];
int rec(int s, int u){
  // cout << s << " "<< u << endl;
  if(dp[s][u] != -1) return dp[s][u];
  int v = INF;
  int w = t[u][0];
  if(s == (1<<n)-1){
    return dp[s][u] = 0;
  }
  for(int i = 0; i < n; i++){
    if(s & (1<<i))w = min(w, t[u][i+1]);
  }
  for(int i = 0; i < n; i++){
    if( !(s & (1<<i)) ){
      v = min(v, rec(s | (1<<u), i) + w);
    }
  }
  return dp[s][u] = v;
}

int main(){
  while(cin >> n && n != 0){
    for(int i = 0; i < n ; i++){
      for(int j = 0; j <= n ; j++){
        cin >> t[i][j];
      }
    }
    int m = INF;
    for(int i = 0; i < (1<<n) ; i++){
      for(int j = 0; j < n; j++){
        dp[i][j] = -1;
      }
    }
    for(int k = 0; k < n; k++){
      m = min(m, rec(0,k));
    }
    cout << m << endl;
  }
}



Measured memory_bytes: 7184
#include <iostream>
#include <unordered_map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>

using namespace std;

// 約数
// たいして多くないので力ずくで取得
vector<int> divisors(int x) {
  vector<int> result;
  int sqr = floor(sqrt(x));
  for (int i = 1; i <= sqr; i++) {
    if (x % i == 0) {
      result.push_back(i);
      result.push_back(x/i);
    }
  }

  return result;
}

int main() {
  int n, k;
  cin >> n >> k;

  int as_sum = 0;
  vector<int> as(n);
  for (int i = 0; i < n; i++) {
    cin >> as[i];
    as_sum += as[i];
  }

  vector<int> as_sum_divisors = divisors(as_sum); // 候補になる数は、aの合計の約数のみ
  sort(as_sum_divisors.begin(), as_sum_divisors.end(), greater<int>()); // 候補が大きい順に調査する

  int result;
  for (const auto& divisor : as_sum_divisors) {
    // cout << "divisor: " << divisor << endl;
    vector<int> bs(n);
    int bs_sum = 0;
    for (int i = 0; i < n; i++) {
      bs[i] = as[i] % divisor; //候補で余る分を、操作でどうにかしなければいけない
      bs_sum += bs[i];
    }
    sort(bs.begin(), bs.end(), greater<int>());

    //操作は、余りを0にするか、divisorにするかどちらか
    //累計は変わらないので、余りが小さいほうを0にして、大きいほうはdivisorにするのが最小。

    int plus_b_count = bs_sum / divisor; // divisorにする数
    int plus_sum = 0;
    // cout << "plus_b_count: " << plus_b_count << endl;
    for (int i = 0; i < plus_b_count; i++) {
      // 大きいほうからdivisorにして、どんだけ変更したかを累積していく。+と-は同数なので、0にしたほうは考えなくていい
      plus_sum += divisor - bs[i];
    }
    // cout << "plus_sum: " << plus_sum << endl;

    if (plus_sum <= k) {
      // k以内の変更で収まったらそれが答え
      result = divisor;
      break;
    }
  }

  cout << result << endl;
  
  return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n;
double x[1002], y[1002], r[1002];

vector<pair<int, double>> vec[1002];
double dist[1002];

template<typename T> class RPQ : public PQ<T, vector<T>, greater<T>> { };
template<typename Cost> void dijkstra(int start, vector<pair<int, Cost>> g[], Cost dist[]) {
	RPQ<pair<Cost, int>> q;
	dist[start] = 0;
	q.emplace(dist[start], start);
	while(! q.empty()) {
		auto cp = q.top(); q.pop();
		int  p = cp.SE;
		Cost c = cp.FI;
		if(dist[p] != c) { continue; }
		for(auto && e : g[p]) {
			int  ep = e.FI;
			Cost ec = e.SE;
			if(setmin(dist[ep], dist[p] + ec)) { q.emplace(dist[ep], ep); }
		}
	}
	return;
}

int main() {
	double xs, ys, xt, yt;
	scanf("%lf%lf%lf%lf%d", &xs, &ys, &xt, &yt, &n);
	inc(i, n) { scanf("%lf%lf%lf", &x[i], &y[i], &r[i]); }
	x[n] = xs;
	y[n] = ys;
	r[n] = 0.0;
	x[n + 1] = xt;
	y[n + 1] = yt;
	r[n + 1] = 0.0;
	
	inc(i, n + 2) {
	inc(j, n + 2) {
		double d = max(sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j])) - r[i] - r[j], 0.0);
		vec[i].EB(j, d);
	}
	}
	
	inc(i, n + 2) { dist[i] = 4e9; }
	dijkstra<double>(n, vec, dist);
	
	printf("%.12f\n", dist[n + 1]);
	
	return 0;
}


Measured memory_bytes: 22404
import math
a,b,x=map(int,input().split())
if x>a*a*b/2:
  tmp=2*(a*a*b-x)/(a*a*a)
  print(math.degrees(math.atan(tmp)))
else:
  tmp=a*b*b/(2*x)
  print(math.degrees(math.atan(tmp)))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int input[] = new int[n];
		int sum = 0;

		for(int i = 0; i < n; i++){
			input[i] = sc.nextInt();
			sum += input[i];
		}

		int minDiff = Integer.MAX_VALUE;
		int sum2 = 0;

		for(int i = 0; i < n - 1; i++){
			sum2 += input[i];
			int tmpDiff = Math.abs(sum - sum2*2);

			minDiff = Math.min(tmpDiff, minDiff);
		}

		System.out.println(minDiff);
	}

}


Measured memory_bytes: 23764
<?php
$s = trim(fgets(STDIN));
$a = explode(" ", trim(fgets(STDIN)));
$n = 0;
for ($i = 0; $i < $s; $i++) {
    if ($i % 2 === 0 && $a[$i] % 2 === 1) {
        $n++;
    }
}
echo $n . "\n";


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

#define int long long
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    string ans = "";

    while(n > 0) {
        n--;
        ans += ('a' + ((n)%26));
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}



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

int main() {
	ll N;
	cin >> N;
	ll h, n, w = 0;
	for (h = 1; h <= 3500; h++) {
		for (n = 1; n <= 3500; n++) {
			ll a, b;
			a = 4 * h * n - N * h - N * n;
			b = N * h * n;
			if (a > 0 && b % a == 0) {
				w = b / a;
				break;
			}
		}
		if (w) {
			break;
		}
	}
	cout << h << ' ' << n << ' ' << w << endl;
	return 0;
}


Measured memory_bytes: 256
n= int(input())
def fact_m(n, modulus=10**9+7):
    ans=1
    if n <= modulus//2:
        for i in range(1,n+1):
            ans = (ans * i) % modulus   
    else:
        for i in range(1,modulus-n):
            ans = (ans * i) % modulus
        ans = modinv(ans, modulus)

        if n % 2 == 0:
            ans = -1*ans + modulus
    return ans % modulus
print(fact_m(n))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}

int main(){
	int k, s;
	cin >> k >> s;
	int cnt = 0;
	for(int x = 0; x <= k; x++){
		for(int y = 0; y <= k; y++){
			if(s - x - y <= k && s - x - y >= 0) cnt++;
		//cout << x << " " << y << " " << s-x-y << endl;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

vector<int> a[200010];
int buka[200010];

// void dfs(int v, int dep){
//     if (a[v].empty()) {
//         depth[v] = dep;
//         return;
//     }
//     for(auto nv : a[v]){
//         dfs(nv, dep - 1);
//     }
// }


int main(){
    int n;
    cin >> n;
    rep(i, n - 1){
        int c;
        cin >> c;
        a[c].push_back(i+2);
    }

    for(int i = n; i >= 1; i--){
        if (a[i].empty()) buka[i] = 0;
        else {
            int m = a[i].size();
            int tmp = m;
            buka[i] = m;
        }
    }

    rep(i, n) cout << buka[i+1] << endl;

    return 0;
}

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

using namespace std;

#define all(v)          v.begin(), v.end()
#define pb              push_back
#define sz(x)          (int) (x.size())
#define endl            "\n"
#define isOdd(n)       (n&1)
#define pow(n, m)      (ll)powl(n, m)
#define clr(x, val)     memset(x, val, sizeof(x))
#define EPS 1e-6

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, k; cin >> n >> k;
    int a[n];
    for(auto &i: a) cin >> i;
    int l = 0;
    for(int i = k; i < n; i++){
        cout << (a[i] > a[l++] ? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 4396
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int hoge[200];

int main() {
    int n;
    char s;
    cin >> n;
    REP(i,n) {
        cin >> s;
        hoge[s]++;
    }
    int cnt = 0;
    REP(i,200) {
        if (hoge[i]) cnt++;
    }
    if (cnt == 3) {
        cout << "Three" << endl;
    }
    if (cnt == 4) {
        cout << "Four" << endl;
    }
}


Measured memory_bytes: 384
using System;

class Program
{
    static void Main(string[] args)
    {
        var money = Convert.ToInt32(Console.ReadLine());
        var priceA = Convert.ToInt32(Console.ReadLine());
        var priceB = Convert.ToInt32(Console.ReadLine());

        Console.WriteLine(money - priceA - (money - priceA) / priceB * priceB);
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
    ll N;
    ll A;
    ll ans=1;
    cin>>N;
    rep(i,N){
        cin>>A;
        if(A==0)ans=0;
        else if(ans>1000000000000000000/A){
            ans=-1;
        }
        else if(ans!=-1)ans=ans*A;
    }
    if(ans<=1000000000000000000&&ans>=0)cout<<ans<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(void) {
	int N, x=0, max = 0;
	char S[101];
	scanf("%d %s", &N, &S);
	for (int i = 0; i < N; i++)
	{
		if (S[i] == 'I') { x++; }
		if (S[i] == 'D') { x--; }
		if (x > max) { max = x; }
	}
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3 = x2+y1-y2;
  int y3 = y2+x2-x1;
  int x4 = x1+y1-y2;
  int y4 = y1+x2-x1;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
import sys
mINF = -float('inf')
n,k = map(int, sys.stdin.readline().rstrip("\n").split())
p = [int(s)-1 for s in sys.stdin.readline().rstrip("\n").split()]
c = [int(s) for s in sys.stdin.readline().rstrip("\n").split()]
loop = []
for i in range(n):
    loop_costs = []
    lc = 0
    np = i
    while True:
        lc += c[p[np]]
        loop_costs.append(lc)
        np = p[np]
        if np == i:
            break
    loop.append(loop_costs)
ans = mINF
for i in range(n):
    loop_i = loop[i]
    if len(loop_i) < k:
        if loop_i[-1] > 0:
            q, mod = divmod(k, len(loop_i))
            if mod == 0:
                q = q - 1
                modmax = max(loop_i)
            else:
                modmax = max(loop_i[:mod])
            ans = max(ans,loop_i[-1]*q+modmax)
        else:
            ans = max(ans,max(loop_i))
    else:
        ans = max(ans,max(loop_i[:k]))
print(ans)

Measured memory_bytes: 280072
#pragma warning (disable :4996)
#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int N = 2e6 + 10;
int A[N], L[N], R[N];
ll ans;
ll merge(int A[], int le, int mid, int r) {
	ll cnt = 0;
	int n1 = mid - le, n2 = r - mid;
	for (int i = 0; i < n1; i++) L[i] = A[le + i];
	for (int i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1] = R[n2] = 2e9;
	int i = 0, j = 0;
	int ans = 0;
	for (int k = le; k < r; k++) {
		if (L[i] <= R[j]) { A[k] = L[i++]; }
		else { 
			A[k] = R[j++];
			cnt += n1 - i;
		}
	}
	return cnt;
}
ll mergesort(int A[], int le, int r) {
	if (le + 1 < r) {
		ll v1 = 0, v2 = 0, v3 = 0;
		int mid = (le + r) / 2;
		v1 = mergesort(A, le, mid);
		v2 = mergesort(A, mid, r);
		v3 = merge(A, le, mid, r);
		return v1 + v2 + v3;
	}
	return 0;
}

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &A[i]);
	ans=mergesort(A, 0, n);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4720
from collections import defaultdict
n=int(input())
num_dict=defaultdict(int)
a_sum=0
for a in map(int,input().split()):
    num_dict[a]+=1
    a_sum+=a
for i in range(int(input())):
    b,c=map(int,input().split())
    a_sum+=c*num_dict[b]-b*num_dict[b]
    num_dict[c]+=num_dict[b]
    num_dict[b]=0
    print(a_sum)


Measured memory_bytes: 22076
N = int(input())
S = input()
cnt = 0
num = 0

for i in S:
    if (i == 'A'
        and S[cnt+1] == 'B'
        and S[cnt+2] == 'C'):
        num += 1
        
    cnt += 1
    if cnt == N-2:
        break
        
print(num)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int A, B, N=4, mat[4][4];
int main(){
  int Lj4PdHRW, i, ind[4]={0,1,2,3}, j, k, ok=0;
  for(Lj4PdHRW=0;Lj4PdHRW<N-1;Lj4PdHRW++){
    rd(A);
    rd(B);
    A--;
    B--;
    mat[A][B] = mat[B][A] = 1;
  }
  do{
    for(i=1;i<N;i++){
      if(!mat[ind[i-1]][ind[i]]){
        break;
      }
    }
    if(i==N){
      ok = 1;
    }
  }
  while(next_permutation(ind,ind+N));
  if(ok){
    wt_L("YES");
    putchar_unlocked('\n');
  }
  else{
    wt_L("NO");
    putchar_unlocked('\n');
  }
  return 0;
}
// cLay varsion 20180730-1

// --- original code ---
// int N = 4, A, B;
// int mat[4][4];
// {
//   int i, j, k, ok = 0;
//   int ind[4] = {0,1,2,3};
// 
//   rep(N-1){
//     rd(A,B);
//     A--; B--;
//     mat[A][B] = mat[B][A] = 1;
//   }
// 
//   do{
//     rep(i,1,N) if(!mat[ind[i-1]][ind[i]]) break;
//     if(i==N) ok = 1;
//   }while(next_permutation(ind,ind+N));
// 
//   if(ok) wt("YES"); else wt("NO");
// }


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

using namespace std;

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

bool dp[100010][5][5][5];
char trace[100010][5][5][5];
string S[100010];

int main(){
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  dp[0][2][2][2] = true;
  REP(i, n){
    cin >> S[i];
    string& s = S[i];
    if(s[0] == 'A' && s[1] == 'B'){
      REP(j, 5) REP(k, 5) REP(l, 5) if(dp[i][j][k][l]){
        if(j > 0 && k < 4 && a + j - 1 - 2 >= 0){
          dp[i + 1][j - 1][k + 1][l] = true;
          trace[i][j - 1][k + 1][l] = 'B';
        }
        if(k > 0 && j < 4 && b + k - 1 - 2 >= 0){
          dp[i + 1][j + 1][k - 1][l] = true;
          trace[i][j + 1][k - 1][l] = 'A';
        }
      }
    }else if(s[0] == 'A' && s[1] == 'C'){
      REP(j, 5) REP(k, 5) REP(l, 5) if(dp[i][j][k][l]){
        if(j > 0 && l < 4 && a + j - 1 - 2 >= 0){
          dp[i + 1][j - 1][k][l + 1] = true;
          trace[i][j - 1][k][l + 1] = 'C';
        }
        if(l > 0 && j < 4 && c + l - 1 - 2 >= 0){
          dp[i + 1][j + 1][k][l - 1] = true;
          trace[i][j + 1][k][l - 1] = 'A';
        }
      }
    }else{
      REP(j, 5) REP(k, 5) REP(l, 5) if(dp[i][j][k][l]){
        if(k > 0 && l < 4 && b + k - 1 - 2 >= 0){
          dp[i + 1][j][k - 1][l + 1] = true;
          trace[i][j][k - 1][l + 1] = 'C';
        }
        if(l > 0 && k < 4 && c + l - 1 - 2 >= 0){
          dp[i + 1][j][k + 1][l - 1] = true;
          trace[i][j][k + 1][l - 1] = 'B';
        }
      }
    }
  }
  int d[3] = {-1};
  REP(j, 5) REP(k, 5) REP(l, 5){
    if(dp[n][j][k][l]){
      d[0] = j, d[1] = k, d[2] = l;
      break;
    }
  }
  if(d[0] == -1){
    cout << "No" << endl;
    return 0;
  }
  vector<char> r(n);
  REP(i, n){
    char v = trace[n - i - 1][d[0]][d[1]][d[2]];
    r[n - i - 1] = v;
    string& s = S[n - i - 1];
    --d[v - 'A'];
    ++d[s[0] + s[1] - v - 'A'];
  }
  cout << "Yes" << endl;
  REP(i, n){
    cout << r[i] << endl;
  }
  return 0;
}


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

using namespace std;

int A[100050];
int n,l,q;
int dp[100050][20];
int main(){
	//freopen("input.in","r",stdin);
	cin >> n;
	for(int i=1; i<=n; ++i) cin >> A[i];
	cin >> l;
	for(int i=1; i<=n; ++i) dp[i][0] = upper_bound(A+1,A+n+1,A[i]+l)-A-1;
	for(int k=1; k<=18; ++k){
		for(int i=1; i<=n; ++i){
			dp[i][k] = dp[dp[i][k-1]][k-1];
		}
	}
//	for(int k=0; k<=3; ++k){ for(int i=1; i<=n; ++i) printf("%d ", dp[i][k]); printf("\n"); }
	cin >> q;
	while(q--){
		int a, b; cin >> a >> b;
		if(a > b) swap(a,b);
		int ans = 0;
		while(a < b){
			int s=0,e=19,m;
			for(int k=0; k<=18; ++k) if(dp[a][k] < b) s=k;
			ans += (1<<s);
			a = dp[a][s];
		}
		cout << ans << "\n";
	}
}


Measured memory_bytes: 9088
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define INF 10000000000

ll a, b, c, n, m, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s;

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

    cin >> n;
    if(!(n % 10)){
        cout << 10 << endl;
        return 0;
    }else{
        while(n){
            ans += n % 10;
            n /= 10;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,X;
  cin>>N>>X;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  for(int i=0;i<N;i++){
    X-=vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int cnt = N + X/vec.at(0);
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  vector<int> ue(n+1, 0), shita(n+1, 0);
  partial_sum(ALL(a), ue.begin() + 1);
  REP(i, n) cin >> a[i];
  partial_sum(ALL(a), shita.begin() + 1);
  int ans = 0;
  REP(i, n) ans = max(ans, ue[i+1] - ue[0] + shita[n] - shita[i]);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;
#define ll long long
#define pb push_back
#define pp pair<long long,long long>
#define ppp pair<pair<long long,long long>,long long>
#define f firsta
#define s second
#define pd pair<double,long long>
int main() {
	ll t,n,i,j,k,l,m;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll p;
	t=1;
	//cin>>t;
	while (t--) {
		double d,s,t,c;
		cin>>d>>s>>t;
		c=d/s;
		if (c<=t)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	return 0;
}

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

int main() {
string N;
cin >> N[0] >> N[1] >> N[2];
int countf = 0, counts = 0;

for (int i = 0; i < 3; i++) {
	if (N[i] == '5') ++countf; 
	else if (N[i] == '7') ++counts; 
}

if (countf == 2 && counts ==1) cout << "YES" << endl;
else cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 3508
//============================================================================
// Name        : AOJ.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;
typedef long long ll;
int main(){

	int n,a;
	int e;

	cin>>n;
	cin>>a;

	if(n%500==0){
		cout<<"Yes"<<endl;
	}else if(n%500<=a){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	return 0;

}


Measured memory_bytes: 256
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for _ in range(D)]

last=[0]*26


for d in range(1,D+1):
    ans=[]
    for choice in range(1,27):
        ans_tmp=0
        ans_tmp+=s[d-1][choice-1]
        for i in range(26):
            if i+1==choice:
                continue
            ans_tmp-=c[i]*(d-last[i])*10
        ans.append((ans_tmp,choice))
    _,case=max(ans)
    last[case-1]=d
    print(case)



Measured memory_bytes: 9400
#include <cstdio>

using namespace std;

#define MAX 10000
#define NIL -1

struct Node { int parent, left, right;};

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u,int d) {
	if(u == NIL) return;
	D[u] = d;
	setDepth(T[u].left, d+1);
	setDepth(T[u].right,d+1);
}

int setHeight(int u) {
	int h1 = 0, h2 = 0;
	if(T[u].left != NIL)
		h1 = setHeight(T[u].left)  + 1;
	if(T[u].right != NIL)
		h2 = setHeight(T[u].right) + 1;
	return H[u] = (h1 > h2 ? h1 : h2);
}

// 接点 u の兄弟を返す
int getSibling(int u) {
	if( T[u].parent == NIL ) return NIL;
	if(T[T[u].parent].left != u && T[T[u].parent].left != NIL )
		return T[T[u].parent].left;
	if(T[T[u].parent].right != u && T[T[u].parent].right != NIL )
		return T[T[u].parent].right;
	return NIL;
}

void print(int u) {
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].parent);
	printf("sibling = %d, ",getSibling(u));
	int deg = 0;
	if(T[u].left  != NIL) deg++;
	if(T[u].right != NIL) deg++;
	printf("degree = %d, ",deg);
	printf("depth = %d, ",D[u]);
	printf("height = %d, ",H[u]);
	
	if(T[u].parent == NIL) {
		printf("root\n");
	} else if(T[u].left == NIL && T[u].right == NIL) {
		printf("leaf\n");
	} else {
		printf("internal node\n");
	}
}

int main(void) {
	int v, l, r, root = 0;
	scanf("%d",&n);
	for(int i=0;i<n;i++) T[i].parent = NIL;
	for(int i=0;i<n;i++) {
		scanf("%d %d %d",&v,&l,&r);
		T[v].left  = l;
		T[v].right = r;
		if(l != NIL) T[l].parent = v;
		if(r != NIL) T[r].parent = v;
	}
	
	for(int i=0; i<n; i++)
	if(T[i].parent == NIL) root = i;
	
	setDepth(root,0);
	setHeight(root);
	
	for(int i=0;i<n;i++) print(i);
	
	return 0;
}



Measured memory_bytes: 2712
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;

char toupper(char c){
    return (c - 0x20);
}

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

    cout << toupper(a[0]) << toupper(b[0]) << toupper(c[0]) << endl;

    return 0;
}


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


#define endl '\n'

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;


int solve(vector<int> &stones) {

    if(stones.size() == 2) {
        return abs(stones[0]-stones[1]);
    }
    
    vector<int> dp(stones.size(), 0);

    dp[0] = 0;
    dp[1] = abs(stones[0]-stones[1]);

    for(size_t i = 2; i < stones.size(); ++i) {
        dp[i] = min(dp[i-1]+abs(stones[i]-stones[i-1]),
        dp[i-2]+abs(stones[i]-stones[i-2]));
         
    }

    return dp[stones.size()-1];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, h_i;
    cin>>n;

    vector<int> stones;


    stones.reserve(n+1);

    for(int i = 0; i < n; ++i) {
        cin>>h_i;
        stones.push_back(h_i);
    }
    
    cout<<solve(stones)<<endl;

    return 0;
}

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

#define endl '\n'
#define int long long

const int N = 110, V = 1e5+9;
int cache[N][V], items[N][2], n, w;

int dp(int id, int val) {
	if(val == 0) 
		return 0;
	if(val < 0)
		return 1e15;
	if(id == n+1)
		return 1e15;
	int &ans = cache[id][val];
	if(ans != -1) 
		return ans;
	ans = min(dp(id+1, val), items[id][0] + dp(id+1, val-items[id][1]));
	return ans;
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	memset(cache, -1, sizeof cache);
	cin >> n >> w;
	for(int i = 1; i <= n; i ++) {
		for(int j = 0; j < 2; j ++) {
			cin >> items[i][j];
		}
	}
	int ans = 0;
	for(int i = 1; i <= V; i ++) {
		int temp = dp(1, i);
		if(temp <= w)
			ans = i;
	}
	cout << ans << endl;

	return 0;
}

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

int64_t gcd(int64_t a, int64_t b){
    if (b == 0){
        return a;
    }
    return gcd(b, a%b);
}

int64_t lcm(int64_t a, int64_t b){
    return a/gcd(a, b)*b;
}


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

    int64_t ans = 1;
    for (int i = 0; i<n; i++){
        int64_t x;
        cin >> x;
        ans = lcm(x, ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

ll dp[1010][20010];

void solve() {
    ll h, n; cin >> h >> n;
    vector<ll> a(n), b(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i <= n; ++i) {
        for (int j = 1; j < 20010; ++j) {
            dp[i][j] = INF;
        }
    }

    dp[0][0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 10010; ++j) {
            dp[i][j + a[i]] = min(dp[i][j + a[i]], dp[i][j] + b[i]);
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }
    ll ans = INF;
        for (int j = h; j < 20010; ++j) {
            ans = min(ans, dp[n][j]);
        }
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


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

using namespace std;

int main()
{
	int k, s;
	cin >> k >> s;
	vector<vector<int>> dp(4, vector<int>(s+1, 0));
	dp[0][0] = 1;
	for (int i = 1; i < 4; i++)
		for (int j = 0; j <= s; j++)
			for (int p = 0; p <= j && p <= k; p++)
				dp[i][j] += dp[i-1][j-p];
	cout << dp[3][s] << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  double a,b;
  double t=3.305785;
  cin>>a>>b;
  a*=b;
  cout<<(int)(a/t)<<".";
  a=fmod(a,t);
  for(int i=0;i<6;i++){
    a*=10;
    cout<<(int)(a/t);
    a=fmod(a,t);
  }
  cout<<endl;
  return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] m = new int[n];
		for(int i = 0 ; i<n ;i++) {
			m[i] = scn.nextInt();
		}
		Arrays.sort(m);
		double ans = m[0];
		for(int i = 1 ; i<n ;i++) {
			ans = (ans + m[i])/2;
		}
		System.out.println(ans);
		scn.close();
	}
}

Measured memory_bytes: 23124
#include<stdio.h>
int p[100005], count[100005];
int root(int n)
{
	if (p[n] != n)
		p[n] = root(p[n]);
	return p[n];
}
void uni(int x, int y)
{
	x = root(x);
	y = root(y);
	if (x != y)
	{
		p[x] = y;
		count[y] += count[x];
	}
	return;
}
int main()
{
	int n, m, k;
	scanf("%d %d %d", &n, &m, &k);
	int i;
	int a[100005], b[100005];
	for (i = 0; i < m; i++)
	{
		scanf("%d %d", &a[i], &b[i]);
		a[i]--;
		b[i]--;
	}
	int c[100005], d[100005];
	for (i = 0; i < k; i++)
	{
		scanf("%d %d", &c[i], &d[i]);
		c[i]--;
		d[i]--;
	}
	for (i = 0; i < n; i++)
	{
		p[i] = i;
		count[i] = 1;
	}
	for (i = 0; i < m; i++)
		uni(a[i], b[i]);
	int e[100005];
	for (i = 0; i < n; i++)
		e[i] = 1;
	for (i = 0; i < m; i++)
	{
		if (root(a[i]) == root(b[i]))
		{
			e[a[i]]++;
			e[b[i]]++;
		}
	}
	for (i = 0; i < k; i++)
	{
		if (root(c[i]) == root(d[i]))
		{
			e[c[i]]++;
			e[d[i]]++;
		}
	}
	for (i = 0; i < n - 1; i++)
		printf("%d ", count[root(i)] - e[i]);
	printf("%d\n", count[root(n - 1)] - e[i]);
	return 0;
}

Measured memory_bytes: 4096
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> s(n+1);
  s[0]=0;
  rep(i,n){
    s[i+1]=s[i]+a[i];
  }
  ll ans=1e18;
  for(int i=1;i<=n-1;i++){
    chmin(ans,abs(s[i]-(s[n]-s[i])));
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.List;
import java.util.Collection;
import java.util.Scanner;
import java.util.Queue;
import java.util.LinkedList;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author bcools
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            TaskD.Vertex[] vs = new TaskD.Vertex[n + 1];
            for (int i = 0; i < n - 1; ++i) {
                int a = in.nextInt();
                TaskD.Vertex va = (vs[a] == null) ? new TaskD.Vertex() : vs[a];
                va.index = a;
                int b = in.nextInt();
                TaskD.Vertex vb = (vs[b] == null) ? new TaskD.Vertex() : vs[b];
                vb.index = b;
                va.adj.add(vb);
                vb.adj.add(va);
                vs[a] = va;
                vs[b] = vb;
            }
            vs[1].visited = true;
            vs[1].bDist = 0;
            vs[1].isBlack = true;
            vs[n].visited = true;
            vs[n].wDist = 0;
            vs[n].isBlack = false;

            Queue<TaskD.Vertex> q = new LinkedList<>();
            q.add(vs[1]);
            q.add(vs[n]);
            int blackScore = 1;
            int whiteScore = 1;
            int checker = 0;
            while (!q.isEmpty()) {
                checker++;
                TaskD.Vertex v = q.remove();
                if ((v.isBlack && v.bDist > v.wDist) || (!v.isBlack && v.wDist > v.bDist))
                    continue;
                for (TaskD.Vertex a : v.adj) {
                    if (a.visited) continue;
                    a.visited = true;
                    a.isBlack = v.isBlack;
                    if (a.isBlack) blackScore++;
                    else whiteScore++;
                    q.add(a);
                }
            }
            System.err.println(checker);
            if (whiteScore >= blackScore) out.println("Snuke");
            else out.println("Fennec");
        }

        static class Vertex {
            int index;
            List<TaskD.Vertex> adj = new ArrayList<>();
            boolean visited = false;
            boolean isBlack = false;
            int bDist = Integer.MAX_VALUE;
            int wDist = Integer.MAX_VALUE;

        }

    }
}



Measured memory_bytes: 104904
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

class UnionFind {
private:
    int n;
    vector<int> a;
public:
    UnionFind(int n) : n(n), a(n, -1) {}
    int find(int x) { return a[x] < 0 ? x : (a[x] = find(a[x])); }
    bool same(int x, int y) { return find(x) == find(y); }
    bool same(ii& p) { return same(p.first, p.second); }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return false;
        if (a[x] > a[y]) swap(x, y);
        a[x] += a[y];
        a[y] = x;
        n--;
        return true;
    }
    bool unite(ii& p) { return unite(p.first, p.second); }
    int size() const { return n; }
    int size(int x) { return -a[find(x)]; }
};

int main() {
    int n, m;
    cin >> n >> m;

    vii vp;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        vp.push_back({ a, b });
    }

    int ans = 0;
    rep(i, m) {
        UnionFind uf(n);
        rep(j, m) {
            if (i == j) continue;
            uf.unite(vp[j]);
        }

        if (uf.size() != 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256