akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn divisors(n: usize) -> Vec<usize> {
    let mut divisors = Vec::new();
    for i in 1..(f64::sqrt(n as f64) + 1e-9) as usize + 1 {
        if n % i == 0 {
            divisors.push(i);

            if i != n / i {
                divisors.push(n / i);
            }
        }
    }
    divisors.sort();
    divisors
}

fn check(n: usize, k: usize) -> bool {
    let mut n = n;
    while n > 1 {
        // println!("{} {}", n, k);
        if n % k == 0 {
            n = n / k;
        } else {
            n = n % k;
            break;
        }
    }
    return n == 1;
}

fn main() {
    let n: usize = read();
    let divisors1 = divisors(n);
    let divisors2 = divisors(n-1);
    // println!("{:?}", divisors1);
    // println!("{:?}", divisors2);

    let mut ans_vec = Vec::new();
    for divs in vec![divisors1, divisors2] {
        for k in divs {
            if k == 1 {
                continue;
            }
            if check(n, k) {
                ans_vec.push(k);
            }
        }
    }

    let uniq: HashSet<usize> = ans_vec.into_iter().collect();
    println!("{}", uniq.len());
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,r) for(auto& (i) : (r))

using namespace std;

struct Edge{
  	int src, dst;
    Edge(int s, int d) : src(s),dst(d){}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

bool augment(const Graph& g, int u, vector<int>& matchTo, vector<bool>& visited) {
  	if (u < 0) return true;
  	FOR(e, g[u]) if (!visited[e.dst]) {
    	visited[e.dst] = true;
    	if (augment(g, matchTo[e.dst], matchTo, visited)) {
      		matchTo[e.src] = e.dst;
      		matchTo[e.dst] = e.src;
      		return true;
    	}
  	}
  	return false;
}
int bipartiteMatching(const Graph& g, int L, Edges& matching) {
  const int n = g.size();
  vector<int> matchTo(n, -1);
  int match = 0;
  REP(u, L) {
    vector<bool> visited(n);
    if (augment(g, u, matchTo, visited)) ++match;
  }
  REP(u, L) if (matchTo[u] >= 0) // make explicit matching
    matching.push_back( Edge(u, matchTo[u]) );
  return match;
}

int gcd(int x, int y){
  if(x<y)return gcd(y,x);
  if(y==0)return x;
  return gcd(y,x%y);
}

int main() {
  while(1){
    int m,n;
    cin >> m >> n;
    if(!m) break;
    vector<int> b(m);
    vector<int> a(n);
    REP(i,m) cin >> b[i];
    REP(i,n) cin >> a[i];
    Graph g(n+m);
    REP(i,m)REP(j,n){
      if(gcd(b[i],a[j]) != 1){
        g[i].push_back(Edge(i, j+m));
      }
    }
    Edges e;
    cout << bipartiteMatching(g, m, e) << endl;
  }
  return 0;
}

Measured memory_bytes: 2660
import Data.Functor
import Control.Applicative

main::IO ()
main=mapM_ putStrLn qq

qq::[String]
qq=
  let list=(,) <$> [1..9] <*> [1..9] in
  map (\(x,y)->show x ++ 'x' : show y ++ '=' : show (x*y)) list

Measured memory_bytes: 3476
import bisect

def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    # divisors.sort()
    return divisors



N,M= map(int,input().split(" "))
divs = make_divisors(M)
divs.sort(reverse=True)
d = M//N
for i in divs:
    if i <= d:
        print(i)
        exit()

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

int main() {

    string S, T;
    cin >> S >> T;

    int ans = S.length();
    int ss = S.length();
    int st = T.length();
    rep(i, ss-st+1) {
        int tmp = 0;
        rep(j, st) {
            if (S[i+j] != T[j]) tmp++;
        }
        ans = min(tmp, ans);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <tuple>
using namespace std;
typedef long long ll;
int INF=1<<29;

class Unionfind{
public:
	vector<int> par;
	vector<int> size;

	Unionfind(int n){
		par=vector<int>(n);
		size=vector<int>(n,1);
		for(int i=0;i<n;i++) par[i]=i;
	}

	int root(int x){
		if(par[x]==x) return x;
		return par[x]=root(par[x]);
	}

	bool merge(int x,int y){
		x=root(x);
		y=root(y);
		if(par[x]==par[y]) return false;
		if(size[y]>size[x]) swap(x,y);
		par[y]=x;
		size[x]+=size[y];
		return true;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin>>N;
	vector<tuple<int,int,int>> tab(N);
	vector<int> cost;
	vector<pair<int,int>> d;
	for(int i=0;i<N;i++){
		cin>>get<0>(tab[i])>>get<1>(tab[i]);
		get<2>(tab[i])=i;
	}
	//x軸
	sort(tab.begin(),tab.end());
	for(int i=0;i<N-1;i++){
		d.push_back(make_pair( get<2>(tab[i]),get<2>(tab[i+1]) ));
		cost.push_back( min(abs(get<0>(tab[i])-get<0>(tab[i+1])) , abs(get<1>(tab[i])-get<1>(tab[i+1]))) );
	}

	//y軸
	for(int i=0;i<N;i++) swap(get<0>(tab[i]),get<1>(tab[i]));
	sort(tab.begin(),tab.end());
	for(int i=0;i<N;i++) swap(get<0>(tab[i]),get<1>(tab[i]));
	for(int i=0;i<N-1;i++){
		d.push_back(make_pair( get<2>(tab[i]),get<2>(tab[i+1]) ));
		cost.push_back( min(abs(get<0>(tab[i])-get<0>(tab[i+1])) , abs(get<1>(tab[i])-get<1>(tab[i+1]))) );
	}

	vector<tuple<int,int,int>> krus(d.size());
	for(int i=0;i<d.size();i++){
		krus[i]=make_tuple(cost[i],d[i].first,d[i].second);
	}

	Unionfind Uni(krus.size());
	sort(krus.begin(),krus.end());
	int res=0;
	for(int i=0;i<krus.size();i++){
		if(Uni.merge(get<1>(krus[i]),get<2>(krus[i]))) res+=get<0>(krus[i]);
		else continue;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 8432
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
ll minn(ll x, ll y){
    if(x<y)
        return x;
    return y;
}
ll maxx(ll x, ll y){
    if(x>y)
        return x;
    return y;
}
ll dp[109][100009],dpp[109][100009],a[109];
ll get(ll n, ll k){
    if(dpp[n][k]!=-1)
        return dpp[n][k];
    if(k==0)
        return dpp[n][0] = 1;
    dpp[n][k] =0;
    if(n!=0){
        for(int i=0;i<=a[n] && i<=k;i++){
            dpp[n][k] = ( dpp[n][k] + get(n-1, k-i) )%mod;
        }
    }
    return dpp[n][k]%mod;
}
int main() {
    ll n,k;
    cin>>n>>k;
    memset(dpp, -1, sizeof(dpp));
    // memset(dp, -1, sizeof(dp));
    for(int i=1;i<=n;i++)
        cin>>a[i];
    // cout<<get(n,k) - get(n,k-1);
    // cout<<get(n,k);
    // cout<<endl;
    // for(int i=0; i<=n;i++){
    //     for(int j=0; j<=k;j++)
    //         cout<<dpp[i][j]<<" ";
    //     cout<<endl;
    // }
    dp[0][0] =1;
    for(int i=0; i<=n;i++){
        for(int j=0; j<=k;j++){
            if(j==0 || i==0){
                dp[i][j]=1;
                continue;
            }
            dp[i][j] = (dp[i-1][j] + dp[i][j-1]);
            if(a[i]<j){
                dp[i][j] -= dp[i-1][j-a[i]-1];
            }
            dp[i][j]+=mod;
            dp[i][j]%=mod;
        }
    }
    cout<<(dp[n][k] - dp[n][k-1] + mod)%mod;
    // cout<<endl;
    // for(int i=0; i<=n;i++){
    //     for(int j=0; j<=k;j++)
    //         cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    string s1,s2;
    cin >> s1 >> s2;
    ll n1 = s1.size(), n2 = s2.size();
    vector<vector<ll>> dp(n1+1, vector<ll>(n2+1));
    for(i = 0;i <= n1;++i){
        dp.at(i).at(0) = i;
    }
    for(i = 0;i <= n2;++i){
        dp.at(0).at(i) = i;
    }
    for(i = 1;i <= n1;++i){
        for(j = 1;j <= n2;++j){
            if(s1.at(i-1) == s2.at(j-1)){
                dp.at(i).at(j) = min({dp.at(i-1).at(j-1), dp.at(i-1).at(j) + 1, dp.at(i).at(j-1) + 1});
            }else{
                dp.at(i).at(j) = min({dp.at(i-1).at(j-1), dp.at(i-1).at(j), dp.at(i).at(j-1)}) + 1;
            }
        }
    }
    cout << dp.at(n1).at(n2) << endl;
    return 0;
}


Measured memory_bytes: 10812
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
data = sorted(data) + [-1]
equ_count = []
cnt = 1
for i in range(0,N):
    if data[i] == data[i+1]:
        cnt += 1
    else:
        equ_count.append(cnt)
        cnt = 1
L = len(set(data))
if L <= K:
    ans = 0
else:
  ite = L - K - 1
  ans = 0
  for j in sorted(equ_count)[0:ite]:
    ans += j
print(ans)

Measured memory_bytes: 26888
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
from numba import njit


def EulerTour(graph, root=1):
    N = len(graph) - 1
    parent = [0] * (N + 1)
    stack = [-root, root]
    tour = []
    ind_L = [0] * (N + 1)
    ind_R = [0] * (N + 1)
    i = -1
    while stack:
        v = stack.pop()
        tour.append(v)
        i += 1
        if v > 0:
            ind_L[v] = i
            p = parent[v]
            for w in graph[v]:
                if w == p:
                    continue
                parent[w] = v
                stack.append(-w)
                stack.append(w)
        else:
            ind_R[-v] = i
    return tour, ind_L, ind_R, parent


N = int(readline())
graph = [[] for _ in range(N + 1)]
C = np.zeros(N + 1, np.int64)
C[1:] = np.array(readline().split(), np.int64)
m = map(int, read().split())
for a, b in zip(m, m):
    graph[a].append(b)
    graph[b].append(a)

tour, ind_L, ind_R, parent = map(lambda x: np.array(x, np.int64), EulerTour(graph))


@njit('i8[:](i8[:],i8[:],i8[:],i8[:],i8[:])', cache=True)
def main(C, tour, ind_L, ind_R, parent):
    N = len(C) - 1
    removed = np.zeros(N + 1, np.int64)
    answer = np.full_like(removed, N * (N + 1) // 2)
    memo = np.zeros_like(answer)
    for v in tour:
        if v > 0:
            memo[v] = removed[C[parent[v]]]
        else:
            v = -v
            removed[C[v]] += 1
            p = parent[v]
            x = (ind_R[v] - ind_L[v]) // 2 + 1  # subtree size
            x -= removed[C[p]] - memo[v]
            answer[C[p]] -= x * (x + 1) // 2
            removed[C[p]] += x
    for i, x in enumerate(removed):
        x = N - x
        answer[i] -= x * (x + 1) // 2
    return answer


answer = main(C, tour, ind_L, ind_R, parent)
print('\n'.join(answer[1:].astype(str)))


Measured memory_bytes: 198520
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
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; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

//--------------入力受け取る場所----------------------------------------------------
intl n,m;
intl a,b,c,d;
string s,t;

void input_var(){
    cin >> n >> m;
}
//-------------------------------------------------------------------------------

signed main(){
    cout << fixed << setprecision(10);
    input_var();
    cout << n * m << endl;
    return 0;
}

Measured memory_bytes: 3648
// D - Wizard in Maze
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

int main(){
	int H, W, sh, sw, eh, ew; cin>>H>>W>>sh>>sw>>eh>>ew; sh--, sw--, eh--, ew--;
	string S[H]; rp(i, 0, H) cin>>S[i];

	vector<vi> dst(H, vi(W, -1));
	deque<tuple<int, int, int>> dq; // <h, w, d>
	dq.emplace_front (sh, sw, 0);
	while(dq.size()){
		int h, w, d; tie(h, w, d) = dq.front(); dq.pop_front();
		if(h < 0 || H <= h || w < 0 || W <= w || dst[h][w] >= 0 || S[h][w] == '#') continue;
		dst[h][w] = d;
		rp(dh, -2, 3) rp(dw, -2, 3)
			if(dh*dh + dw*dw == 1) dq.emplace_front(h + dh, w + dw, d);
			else if(dh*dh + dw*dw > 1) dq.emplace_back(h + dh, w + dw, d+1);
	}

	cout<< dst[eh][ew] <<endl;
}


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

using namespace std;

int main() {
    int64_t A, B, C, K;
    cin >> A >> B >> C >> K;

    int64_t numOfA = 0, numOfB = 0, numOfC = 0;

    if (A >= K) {  // AがKより大きい場合
        numOfA = K;
    } else {  // AがKより小さい場合
        numOfA = A;
        K -= A;

        if (B >= K) {
            numOfB = K;
        } else {
            numOfB = B;
            K -= B;

            if (C >= K) {
                numOfC = K;
            } else {
                numOfC = C;
            }
        }
    }

    // cout << numOfA << " " << numOfB << " " << numOfC << " " << endl;

    int64_t ans = (1 * numOfA) + (0 * numOfB) + (-1 * numOfC);

    cout << ans << endl;

    return 0;
}

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

#define MAX_N 10000

int BIT(int C1,bool C2);
int MINUS(int C3);
int KAKE(int C4,int C5);
int PLUS(int C6,int C7);
string TSTRING(int C8);

string S,T;
int sum;
char U[4]="012";
int x[MAX_N];

int BIT(int C1,bool C2){
	if(C2==true){return C1;}
	return MINUS(C1);
}

int MINUS(int C3){
	return 2-C3;
}
int PLUS(int C4,int C5){
	return max(C4,C5);
}
int KAKE(int C6,int C7){
	return min(C6,C7);
}

string TSTRING(int C8)
{
	if(C8==0)
	{
		return "0";
	}
	if(C8==1)
	{
		return "1";
	}
	return "2";
}

int kaiseki2(string Z){
	int ans=3,ans2=3;
	bool ok=true;
	char op=' ';
	for(int i=0;i<Z.size();i++)
	{
		if(Z[i]=='-')
		{
			if(ok==true){ok=false;}
			else{ok=true;}
		}
		if(ans==3){
			if(Z[i]=='0')
			{
				ans=BIT(0,ok);
				ok=true;
			}
			if(Z[i]=='1')
			{
				ans=BIT(1,ok);
				ok=true;
			}
			if(Z[i]=='2')
			{
				ans=BIT(2,ok);
				ok=true;
			}
		}
		else{
			if(Z[i]=='0')
			{
				ans2=BIT(0,ok);
				ok=true;
			}
			if(Z[i]=='1')
			{
				ans2=BIT(1,ok);
				ok=true;
			}
			if(Z[i]=='2')
			{
				ans2=BIT(2,ok);
				ok=true;
			}
		}
		if(Z[i]=='+')
		{
			op='+';
		}
		if(Z[i]=='*')
		{
			op='*';
		}
	}
	if(op==' '){return ans;}
	if(op=='+'){return PLUS(ans,ans2);}
	return KAKE(ans,ans2);
}

int kaiseki(string V){
	while(V.size()>=2)
	{
		int s=0,maxn=0;
		string W="",X="";
		for(int i=0;i<V.size();i++)
		{
			if(V[i]=='(')
			{
				s++;
			}
			if(V[i]==')')
			{
				s--;
			}
			x[i]=s;
			maxn=max(s,maxn);
		}
		for(int i=0;i<V.size();i++)
		{
			if(x[i]==maxn)
			{
				if(V[i]!='(')
				{
					W+=V[i];
				}
				goto E;
			}
			if(i>=1)
			{
				if(x[i-1]==maxn)
				{
					X+=TSTRING((long long)kaiseki2(W));
					W="";
					goto E;
				}
			}
			X+=V[i];
E:;
		}
		V=X;
	}
	if(V=="2"){return 1;}
	return 0;
}

int main(){
	while(true){
		cin>>S;
		S='('+S+')';
		sum=0;
		if(S=="(.)"){break;}
		for(int i=0;i<3;i++)
		{
			for(int j=0;j<3;j++)
			{
				for(int k=0;k<3;k++)
				{
					T="";
					for(int l=0;l<S.size();l++)
					{
						if(S[l]=='P')
						{
							T+=U[i];
						}
						else if(S[l]=='Q')
						{
							T+=U[j];
						}
						else if(S[l]=='R')
						{
							T+=U[k];
						}
						else
						{
							T+=S[l];
						}
					}
					sum+=kaiseki(T);
				}
			}
		}
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 1208
def f(n):
    if n == 1:
        return 1
    return f(n - 1) * n


n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
l = list(range(1, n + 1))
a = 0
for i, x in enumerate(p[:-1]):
    a += l.index(x) * f(n - i - 1)
    l.remove(x)
b = 0
l = list(range(1, n + 1))
for i, x in enumerate(q[:-1]):
    b += l.index(x) * f(n - i - 1)
    l.remove(x)
print(abs(b - a))


Measured memory_bytes: 38484
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

set_random;

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , m , x , ans , k[MAXN] , p[MAXN];
vector<ll> s[MAXN];

int main() {
    fast_io;

    cin >> m >> n;
    for(ll i = 0 ; i < n ; i++){
        cin >> k[i];
        for(ll j = 0 ; j < k[i] ; j++){
            cin >> x;
            s[i].push_back(x - 1);
        }
    }
    for(ll i = 0 ; i < n ; i++) cin >> p[i];

    for(ll i = 0 ; i < (1 << m) ; i++){
        ll cnt = 0;
        for(ll j = 0 ; j < n ; j++){
            ll t = 0;
            for(ll k : s[j]){
                t ^= (((1 << k) & i) != 0);
            }
            cnt += (t == p[j]);
        }
        if(cnt == n)    ans++;
    }
    cout << ans << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 26880
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
int dp[100010];
int a[100],p;
void f()
{
    int ans=1;
    p=0;
    for(int i=1;i<=5;i++)
    {
        ans*=9;
        a[p++]=ans;
    }
    ans=1;
    for(int i=1;i<=6;i++)
    {
        ans*=6;
        a[p++]=ans;
    }
    a[p++]=1;
    sort(a,a+p);
}
int main()
{
    int i,t,j;
    f();
    while(scanf("%d",&t)==1)
    {
        for(i=1;i<=t;i++)
            dp[i]=INF;
        for(i=0;i<p;i++)
        {
            for(j=a[i];j<=t;j++)
                dp[j]=min(dp[j],dp[j-a[i]]+1);
        }
        printf("%d\n",dp[t]);
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
const lli M=998244353,N=3e3+5;
lli dp[N][N];

lli add(lli a, lli b)
{
	lli res = a + b;
	if(res >= M)
		return res - M;
	return res;
}
 
lli mul(lli a, lli b)
{
	lli  res = a * b;
	if(res >= M)
		return res % M;
	return res;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli n,s;
    cin>>n>>s;
    lli i,j,a[n+1];
    
    for(i=1;i<=n;i++) cin>>a[i];
    
    dp[0][0]=1;
    for(i=1;i<=n;i++)
    {
        for(j=0;j<=s;j++) dp[i][j]=mul(2LL, dp[i-1][j]);                                //for current value we can add it or not so we have 2 choice
        for(j=0;j<=s;j++) if(j+a[i]<=s) dp[i][j+a[i]]=add(dp[i][j+a[i]], dp[i-1][j]);   //if current value include in total sum
    }
    cout<<dp[n][s];
    return 0;
}

Measured memory_bytes: 74048
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  int n,m;
  cin>>n>>m;
  string s="No";
  if(n==m) s="Yes";
    cout<<s<<endl;
}


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

using namespace std;

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, l;
	cin >> n >> l;
	
	vector<string> v;
	for (int i = 0; i < n; i++) {
		string a;
		cin >> a;
		v.push_back(a);
	}
	
	sort(v.begin(), v.end());
	
	for (auto a : v) {
		cout << a;
	}
	cout << '\n';
	
    return 0;
}


Measured memory_bytes: 256
#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++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    int n; cin >> n;
    cout << "ABC" << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int rec(int,int);
 
int a[2000],n;
 
main(){
  int i,j,p,q;
  int m[2000];
   
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  } 
   
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  }
   
  for(i=0;i<q;i++){
    if(rec(0,m[i])==1)printf("yes\n");
    else printf("no\n");
     
  }
  return 0;
}
 
int rec(int i,int m){
  if(m == 0)return 1;
  if(i >= n)return 0;
  int response = rec(i + 1, m) || rec(i + 1, m - a[i]);
  return response;
}

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

int main()
{
	// Variable declaration
	int n;
	int input;
	int out[100];
	int i;

	// input n
	cin >> n;

	// n times loop
	for (i = 0; i < n; i++)
	{
		// input
		cin >> input;

		out[i] = input;
	}

	// n times loop
	for (i = 0; i < n; i++)
	{
		// output
		cout << out[n -1 - i];

		if (i == n - 1)
		{
			break;
		}
		// output " "
		cout << " ";
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
int N;
bool judge=false;
cin>>N;
for(int i=1;i<10;++i){
  if((N/i)<10 && N%i==0){
    judge=true;
    break;
  }
}
if(judge){
  cout<<"Yes"<<"\n";
}
else{
  cout<<"No"<<"\n";
}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define pb push_back
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll n; 
    double a, b, c = 0, ans;
    cin >> n;

    rep(i, n) {
        cin >> a;
        b = 1.0/a;
        c += b;
    }

    ans = 1.0/c;

    exout(ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define rlp(i,n) for(int i = int(n);i >= 0;i--)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
void _run(){
    int n,x,k;
    cin>>n>>x>>k;
    int ans =0;
    while(n){
        n-=min(x,n);
        ans+=k;
    }
    cout<<ans<<endl;
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int t=1;
    // scanf("%d",&t);
    while(t--)_run();
    
    return 0;
}

Measured memory_bytes: 3592
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);
            if (n == 0 && m == 0) break;
            var c = new int[m];
            for (int i = 0; i < m; i++) c[i] = int.Parse(Console.ReadLine().Trim());
            var dp = setDp(n, m, c);
            getAns(n, m, c, dp);
        }
    }
    static long[,] setDp(int n, int m, int[] c)
    {
        var dp = new long[n, 256];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < 256; j++)
                dp[i, j] = long.MaxValue;
        var x1 = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < m; i++)
        {
            var t = 128 + c[i];
            t = Max(t, 0);
            t = Min(t, 255);
            dp[0, t] = (x1 - t) * (x1 - t);
        }
        return dp;
    }
    static void getAns(int n, int m, int[] c, long[,] dp)
    {
        for (int i = 1; i < n; i++)
        {
            var x = int.Parse(Console.ReadLine().Trim());
            for (int j = 0; j < 256; j++)
                for (int k = 0; k < m; k++)
                {
                    var nx = j + c[k];
                    nx = Max(nx, 0);
                    nx = Min(nx, 255);
                    var def2 = (nx - x) * (nx - x);
                    if (dp[i - 1, j] != long.MaxValue) dp[i, nx] = Min(dp[i, nx], dp[i - 1, j] + def2);
                }
        }
        var ans = long.MaxValue;
        for (int i = 0; i < 256; i++)
        {
            if (dp[n-1, i] != long.MaxValue) ans = Min(ans, dp[n-1, i]);
        }
        Console.WriteLine(ans);
    }
}



Measured memory_bytes: 93356
#include<cstdio>
#include<iostream>
#include<map>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<cstdlib>
using namespace std;
typedef long long LL;
const LL mod = 1e9+7;
int main(){
	string a,b;
	cin >> a >> b;
	for(int i = 0;i < a.size();i++){
		printf("%c",a[i]);
		if(i<b.size())
		printf("%c",b[i]);
		}
	return 0;
	}


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

int main(){
	int N;
	vector<int> d;
	cin >> N;
	for (int i = 0; i < N; i++){
		int tmp;
		cin >> tmp;
		d.push_back(tmp);
	}

	long long sum = 0;
	for (int i = 0; i < N; i++){
		for (int j = i + 1; j < N; j++){
			sum += d[i] * d[j];
		}
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int ans[200001],x,n;
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	rep(i,n-1){
		cin>>x;
		x--;
		ans[x]++;
	}
	rep(i,n)
	cout<<ans[i]<<"\n";
	re 0;
}

Measured memory_bytes: 4436
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(' ').map { it.toInt() }
    val s = readLine()!!
    if (!s.slice(0 until a).all { it.isDigit() }) {
        println("No")
        return
    }
    if (s[a] != '-') {
        println("No")
        return
    }
    if (!s.slice(a + 1 until s.length).all { it.isDigit() }) {
        println("No")
        return
    }
    println("Yes")
}


Measured memory_bytes: 38304
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + 1 >= c) {
		cout << c + b;
	}
	else {
		cout << a + b + 1 + b;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int gcd(int x, int y){
  int r;
  while(1){
    r=x%y;
    if(r==0)break;
    x=y;
    y=r;
  }
  return y;
}


int main(){

  int x,y,m;

  scanf("%d %d",&x,&y);
  m=gcd(x,y);

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

Measured memory_bytes: 592
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

class Point
{
public:
	double x, y;
	Point(double x = 0, double y = 0) :x(x), y(y) {}

	Point operator + (Point p) { return Point(x + p.x, y + p.y); }
	Point operator - (Point p) { return Point(x - p.x, y - p.y); }
	Point operator * (double a) { return Point(a * x, a * y); }
	Point operator / (double b) { return Point(x / b, y / b); }
	friend istream& operator >> (istream & s, Point p) { s >> p.x >> p.y; }

	double dot(Point a, Point b) { return a.x* b.x + a.y * b.y; }
	double abs() { return sqrt(norm()); }
	double norm() { return x * x + y * y; }

	bool operator <(const Point & p)const { return x != p.x ? x < p.x : y < p.y; }
	bool operator == (const Point & p) const { return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS; }
};
typedef Point Vector;

struct Segment {
	Point p1, p2;
	Segment() {}
	Segment(Point p1, Point p2) :p1(p1), p2(p2) {}
};
typedef Segment Line;

double norm(Vector a) { return a.x* a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a)); }

double dot(Vector a, Vector b) { return a.x* b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x* b.y - a.y * b.x; }

Point getCrossPoint(Segment s1, Segment s2) {     

	Vector base = s2.p2 - s2.p1;
	double d1 = abs(cross(base, s1.p1 - s2.p1));
	double d2 = abs(cross(base, s1.p2 - s2.p1));
	double t = d1 / (d1 + d2);
	return s1.p1 + (s1.p2 - s1.p1) * t;
}


int main()
{
	int q;
	cin >> q;
	double x0, y0, x1, y1, x2, y2, x3, y3;
	while (q--)
	{
		cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		Segment s1 = Segment(Point(x0, y0), Point(x1, y1)), s2 = Segment(Point(x2, y2), Point(x3, y3));
		printf("%.8lf %.8lf\n", getCrossPoint(s1,s2).x, getCrossPoint(s1, s2).y);
	}
	return 0;
}


Measured memory_bytes: 3292
#include <iostream>
#include <string.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <sstream>
using namespace std;
string mast(int i){
	stringstream s;
	s<<i;
	return s.str();
}
int main(){
	int a,b;
	cin>>a>>b;
	int cnt=0;
	for(int i=a;i<=b;i++){
		string s=mast(i);
		string s1=s;
		reverse(s1.begin(),s1.end());
		if(s1==s) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
let [|n; m|] = stdin.ReadLine().Split() |> Array.map int
let a, s = stdin.ReadLine().Split() |> Array.map int |> fun x -> x, Array.sum x |> float
if ((a |> Array.filter (float >> fun x -> x >= s / (4. * (float m))) |> Array.length) < m) then "No" else "Yes"
|> printfn "%s"

Measured memory_bytes: 14044
import sys

def main():
    h, w, m = map(int,input().split())
    bomb = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(m)]
    x = [0] * h
    y = [0] * w

    for h,w in bomb:
        x[h] +=1
        y[w] +=1

    maxX = max(x)
    maxY = max(y)

    r = [h for h,x in enumerate(x) if x == maxX]
    c = [w for w,y in enumerate(y) if y == maxY]

    bomb = set(bomb)
    
    for ri in r:
        for ci in c:
            if (ri,ci) not in bomb:
                print(maxX + maxY)
                sys.exit()
    print(maxX + maxY -1)
    
main()


Measured memory_bytes: 90136
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;

public class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());
        String[] line = br.readLine().split(" ", 0);
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = Integer.parseInt(line[i]);
        }

        partition(nums, 0,n - 1);
    }

    static void printArray(int[] a, int index) {
        for (int i = 0; i < a.length; i++) {
            if (i == index) {
                System.out.print('[');
                System.out.print(a[i]);
                System.out.print(']');
            } else {
                System.out.print(a[i]);
            }

            if (i != a.length - 1) {
                System.out.print(' ');
            }
        }
        System.out.println();
    }

    static int[] swap(int[] a, int i1, int i2) {
        int tmp = a[i1];
        a[i1] = a[i2];
        a[i2] = tmp;
        return a;
    }

    static void partition(int[] a, int p, int r) {
        int val = a[r];
        int i = p - 1;
        for (int j = p; j < r; j++) {
            if (a[j] <= val) {
                i++;
                a = swap(a, i, j);
            }
        }
        a = swap(a, i + 1, r);
        printArray(a, i + 1);
        return;
    }
}




Measured memory_bytes: 58392
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n;
void find(int x)
{
	if(x<=26)
	{
		printf("%c",(char)(x-1+'a'));
		return;
	}
	find((x-1)/26);
	printf("%c",(char)((x-1)%26+'a'));
}
signed main()
{
	scanf("%lld",&n);
	find(n);
    return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#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 INF 1e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;

int main(){
 int n; cin>>n;
 vector<int> A(n);
 int b;
 ll ans=0;
 REP(i,n){
     int a;
     cin>>a;
    A[i]=a-i-1;
 }
 sort(ALL(A));


if(n%2==0)b=A[n/2-1];
else b=A[((n+1)/2)-1];

REP(i,n){
  ans+=abs(A[i]-b);
}
cout<<ans<<endl;
}

Measured memory_bytes: 1024
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    cin >> a;
    sort(all(a));
    int ans = 0;
    forn (i, 0, n) {
        forn (j, i + 1, n) {
            forn (k, j + 1, n) {
                if (a[i] != a[j] &&
                    a[j] != a[k] &&
                    a[k] != a[i] &&a[k] < a[i] + a[j])
                    ++ans;
            }
        }
    }
    cout << ans;
    return 0;
}

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

template<typename T>
T gcd(T a, T b) {
    if(a < b) {
        return gcd(b, a);
    }

    T c;
    while(c = a % b) {
        a = b;
        b = c;
    }
    return b;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

using namespace std;

int main(void) {
    long long a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
}

Measured memory_bytes: 256
n = int(input())
s = input()

ans = 0
for num in range(1000):
    num_s = str(num).zfill(3)
    
    s_index_0 = s.find(num_s[0])
    if s_index_0 == -1 :
        continue
    s_index_1 = s.find(num_s[1],s_index_0+1)
    if s_index_1 == -1 :
        continue

    s_index_2 = s.find(num_s[2],s_index_1+1)
    if s_index_2 == -1:
        continue

    ans +=1 

        
    
print(ans)


Measured memory_bytes: 3188
import java.util.Arrays;
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[] d = new int[n];
		for(int i=0; i<n; i++){
			d[i] = sc.nextInt();
		}
		Arrays.sort(d);

		if(n%2 != 0){
			System.out.println(0);
		}else{
			if(d[(n/2)-1]==d[n/2]){
				System.out.println(0);
			}else{
				System.out.println(d[n/2]-d[(n/2)-1]);
			}
		}

		sc.close();

	}

}


Measured memory_bytes: 51184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll a,b;cin>>a>>b;
    REP(i,1,1000000){
        if(i*8/100==a&&i*10/100==b){
            out(i);
            return 0;
        }
    }
    out(-1);
}

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

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

int main(){

  int n;
  cin >> n;

  vector<int> t;
  vector<int> x;
  vector<int> y;

  bool flag = true;

  t.push_back(0);
  x.push_back(0);
  y.push_back(0);

  REP(i,n){
    int t1,x1,y1;
    cin >> t1 >> x1 >> y1;
    t.push_back(t1);
    x.push_back(x1);
    y.push_back(y1);
  }

  int t_t,t_x,t_y;

  REP(i,n){
    // if(t[i] >= x[i]+y[i]){
      // if(i==0){
      //   if((x[i]+y[i])%2 == t[i]%2){
      //     if(i<n-1){
      //       t_t = t[i+1]-t[i];
      //       t_x = abs(x[i+1]-x[i]);
      //       t_y = abs(y[i+1]-y[i]);
      //     }
      //     continue;
      //   } else {
      //     flag = false;
      //     break;
      //   }
      // } else {
    t_t = t[i+1]-t[i];
    t_x = abs(x[i+1]-x[i]);
    t_y = abs(y[i+1]-y[i]);
    if(t_t >= t_x+t_y){
      if((t_x+t_y)%2 == t_t%2){
        // if(i<n-1){
          //   t_t = t[i+1]-t[i];
          //   t_x = abs(x[i+1]-x[i]);
          //   t_y = abs(y[i+1]-y[i]);
          // }
        continue;
      } else {
        flag = false;
        break;
      }
      // }
    } else {
      flag = false;
      break;
    }
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

int main(){
    string S;
    cin >> S;
    string koyomi;
    if (string("2019/04/30").compare(S) >= 0){
        koyomi = "Heisei";
    } else {
        koyomi = "TBD";
    }
    cout <<  koyomi << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>
#include <map>
#include <utility>
#include <numeric>
#include <set>
#include <map>

#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 INF 999999999
#define atcoder 1e9+7

using namespace std;

int main() {

	set<string>s;
	string s1, s2;
	int n;

	cin >> n;

	REP(i, n) {
		cin >> s1 >> s2;
		if (s1 == "insert")
			s.insert(s2);
		else if (s1 == "find") {
			if (s.find(s2) != s.end())cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 32552
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace B_ABC170
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            int x= s[0];
            int y = s[1];
            for(int i =0;i<=x;i++){
                if(2 * i + 4 * (x-i) == y){
                    WriteLine("Yes");
                    return;
                }
            }
            WriteLine("No");
            return;
            
        }
    }
}


Measured memory_bytes: 28020
n, q = gets.chomp.split(" ").map(&:to_i)
instractions = []

n.times do
  instractions << gets.chomp.split(" ")
end

instractions_fin = []

time = 0
while true do
  a = instractions.first[1].to_i - q
  if a <= 0
    time += instractions.first[1].to_i
    instractions_fin << [instractions.first[0], time]
    instractions.shift
  else
    b = instractions.shift
    b[1] = b[1].to_i - q
    instractions << b
    time += q
  end
  if instractions.empty?
    break
  end
end

instractions_fin.each do |i|
  puts i.join(" ")
end


Measured memory_bytes: 22304
#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define SQR(X)  ( (X)*(X) )
#define CUBE(X) ( (X)*(X)*(X) )
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;
 
 
void reader(int& a){scanf("%d",&a);}
void reader(double& a){scanf("%lf",&a);}
void reader(char& a){scanf(" %c",&a);}
void reader(char a[]){scanf("%s",a);}
void reader(ll &a){scanf("%lld",&a);}
void reader(ull &a){scanf("%llu",&a);}
// void reader(string& a){cin >> a;};
template<class T,class U> void reader(T& t,U& u){reader(t); reader(u);}
template<class T,class U,class V> void reader(T& t,U& u,V& v){reader(t); reader(u); reader(v);}
 
void writer(int a,char c) {printf("%d",a); putchar(c);}
void writer(ll a,char c) {printf("%lld",a); putchar(c);}
void writer(double a,char c) {printf("%.20lf",a); putchar(c);}
void writer(char a[]) {printf("%s",a);};
void writer(char a[],char c) {printf("%s",a);putchar(c);};
void writer(char a,char c) {putchar(a); putchar(c);};
template<class T>void writerLn(T t){writer(t,'\n');}
template<class T,class U>void writerLn(T t,U u){writer(t,' ');writer(u,'\n');}
template<class T,class U,class V> void writerLn(T t,U u,V v){writer(t,' ');writer(u,' ');writer(v,'\n');}
template<class T> void writerArr(T x[], int n){int i;if(!n){putchar('\n');return;}rep(i,n-1) writer(x[i],' ');writer(x[n-1],'\n');}
template<class T> void writerVec(vector<T> x){int n=x.size();int i;if(!n){putchar('\n');return;}rep(i,n-1) writer(x[i],' ');writer(x[n-1],'\n');}
 

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
// #define int ll
 
int n;
bool test = 0;
vector< pair<int,int> > route;

//............................
#define MAX 30
char a[MAX][MAX];
int h,w;
int ans;
void print() {
  rep(i,h) writerArr(a[i],w);
}
void dfs(int y,int x,int cnt) {
  char c;
  if (test) {
	cin >> c;
	a[y][x] = 'x'; 
	print();
	a[y][x] = '0';
  } 
  if(cnt > ans) return ;
  rep(i,4) {
	int ny = y + dy[i];
	int nx = x + dx[i];
	if (ny < 0 || h <= ny) continue;
	if (nx < 0 || w <= nx) continue;
	if (a[ny][nx] == '1') continue;
	while (1) {
	  if (ny < 0 || h <= ny) break;
	  if (nx < 0 || w <= nx) break;
	  if (a[ny][nx] == 'G') {
		if (cnt < ans) ans = cnt;
		break;
	  }
	  if (a[ny][nx] == '1') {
		a[ny][nx] = '0';
		dfs(ny-dy[i],nx-dx[i],cnt+1);
		a[ny][nx] = '1';
		break;
	  }
	  ny += dy[i];
	  nx += dx[i];
	}
  }
}

signed main(int argc, char *argv[]){
  if (argc > 1) test = atoi(argv[1]);
  int i,j,k,l;
  while(1) {
	cin >> w >> h;
	if (h == 0) return 0; 
	ans = 11;
	rep(i,h) rep(j,w) reader(a[i][j]);
	int sy,sx;
	rep(i,h) rep(j,w) {
	  if(a[i][j] == '2') {
		sy = i;
		sx = j;
	  }
	}
	rep(i,h) rep(j,w) {
	  if(a[i][j] == '3') {
		a[i][j] = 'G';
	  }
	}
	dfs(sy,sx,1);
	if(ans == 11) puts("-1");
	else cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3144