akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>


int main(int argc, char const *argv[]) {
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);
    if (A == B) {
        printf("%d\n", C);
    } else if (B == C) {
        printf("%d\n", A);
    } else {
        printf("%d\n", B);
    }
    return 0;
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**6)

N = int(input())
edges = [[] for _ in range(N)]

for _ in range(N-1):
    u, v, w = map(int, input().split())
    if w&1:
        edges[u-1].append((v-1, -1))
        edges[v-1].append((u-1, -1))
    else:
        edges[u-1].append((v-1, 1))
        edges[v-1].append((u-1, 1))

colors = [None] * N

def set_color(x, c):
    colors[x] = c
    for y, sgn in edges[x]:
        if colors[y] == None:
            set_color(y, c*sgn)

set_color(0, 1)
for z in colors:
    print((z+1)//2)


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

int main(){
    int D, G, p[11], c[11],t,k=1e9;
    cin >> D >> G;
    for(int i = 0; i < D; ++i){
        cin >> p[i] >> c[i];
    }
    rep(i,1<<D){
      int ans=0,num=0;
      rep(j,D){
        if(i&1<<j) ans +=100*(j+1)*p[j]+c[j],num+=p[j];
        else t=j;
      }
      for(int j=0;j<p[t]&&ans<G;j++) ans+=100*(t+1),num++;
      if(ans>=G) k=min(k,num);
    }
    cout << k << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,s,n) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;
int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{
  cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;
}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
const long long INF = 1000000;
//------------------------------------------------------------
ll n;
void solve()
{
    cin >> n;
    vector<ll> dp(n+1,INF);
    dp[0] = 0;

    vector<int> v;
    v.push_back(1);
    int num=1;
    rep(i,1,6) {num*=9;v.push_back(num);}
    num=1;
    rep(i,1,7) {num*=6;v.push_back(num);}

    rep(i,0,n) rep(j,0,v.size())
    {
      if(i+v[j]<=n) dp[i+v[j]]= min(dp[i+v[j]], dp[i]+1);
    }

    print(dp[n]);

    return;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000001
#define pi 3.141592653589793
#define pii pair<int , int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti set <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
int main()
{  
    FAST
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll a[n+1][n+1];
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=n;j++)
        {
            a[i][j]=0;

        }
    }
    a[1][1]=1;
    for(ll i=2;i<=n;i++)
    {
        if(s[i-2]=='<')
        {
            ll x=0;
            for(ll j=1;j<=i;j++)
            {
                a[i][j]=x;
                x+=a[i-1][j];
                x%=mod;
            }
        }
        else
        {
            ll x=0;
            for(ll j=i;j>0;j--)
            {
                x+=a[i-1][j];
                x%=mod;
                a[i][j]=x;
            }
        }
    }
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        ans+=a[n][i];
        ans%=mod;
    }
    cout<<ans;
}

Measured memory_bytes: 70784
n= int(input())
h= list(map(int, input().split()))
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2])
#print(dp)
print(dp[n-1])


Measured memory_bytes: 52208
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

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

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

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

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func mb2int(s string) int {
	b := []byte(s)
	var ans int
	e := 1
	for i := len(b) - 1; i >= 0; i-- {
		if b[i] == '1' {
			ans += e
		}
		e *= -2
	}
	return ans
}
func int2b(n int) string {
	var ans string
	if n == 0 {
		return "0"
	}
	for n > 0 {
		if n&1 == 1 {
			ans = "1" + ans
		} else {
			ans = "0" + ans
		}
		n /= 2
	}
	return ans
}

func display(s string) {
	printf("%5d %s\n", mb2int(s), s)
}

func solve(n int) int {
	if n < 2 {
		//println("solve(", n, ") returning", n)
		return n
	}

	i := 1
	x := 1
	for i < n {
		x *= 4
		i += x
		//println("solve(", n, ")", x)
	}

	//println("solve(", n, ")", x, n)
	if x == n {
		return x
	}
	if x < n {
		return x + solve(n-x)
	}
	return x + solveMinus(x-n)
}

func solveMinus(n int) int {
	if n < 3 {
		//println("solveMinus(", n, ") returning", 4-n)
		return 4 - n
	}

	i := 2
	x := 2
	for i < n {
		x *= 4
		i += x
		//println("solveMinus(", n, ")", x)
	}

	//println("solveMinus(", n, ")", x, n)
	if x == n {
		return x
	}
	if x < n {
		return x + solveMinus(n-x)
	}
	return x + solve(x-n)
}

func main() {
	defer stdout.Flush()

	n := readInt()
	var m int
	if n < 0 {
		m = solveMinus(-n)
	} else {
		m = solve(n)
	}
	println(int2b(m))
}


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

int main()
{
	int n,s;
	while(cin>>n>>s,n)
	{
		int ans=0,comb=(1<<n)-1;
		while(comb<1<<10)
		{
			int tmp=0;
			for (int i = 0; i < 10; ++i)
			{
				if(comb>>i&1) tmp+=i;
			}
			if(tmp==s) ans++;
			int x=comb&-comb,y=comb+x;
			comb=((comb&~y)/x>>1)|y;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstdio>
using namespace std;

#define int long long
#define INF 1e18

signed main() {
    int n, m, x; cin >> n >> m >> x;
    vector<int> vec(n, 0);
    for(int i = 0; i < m; i++) {
        int a; cin >> a;
        vec[a] = 1;
    }

    int tmp1 = 0;
    for(int i = 0; i < x; i++) tmp1 += vec[i];

    int tmp2 = 0;
    for(int i = x; i < n; i++) tmp2 += vec[i];

    cout << min(tmp1, tmp2) << endl;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>


int main(){
	//入力機構
	size_t N;
	std::vector<int> A;//1,000,000,000はintの範囲内,10,000個用意しても1000MBは超えない
	std::cin>>N;
	A.reserve(N);
	for(size_t i=0;i<N;i++){
		int a;
		std::cin>>a;
		A.push_back(a);
	}
	//処理機構
	int ans=0;//ans<=N*36でintの範囲内
	//Aのすべての数値が合計何回2で割り切れるかという問題に帰着可能
	for(size_t i=0;i<N;i++){
		//1回のforループにつき、A[i]<=1,000,000,000=10^9<16^9=2^36より、36回まで処理が行われる
		while(A[i]%2==0){
			ans++;
			A[i]/=2;
		}
	}

	//出力機構
	std::cout<<ans<<std::endl;

	return 0;
}


Measured memory_bytes: 256
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

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

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

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

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion


int main()
{
	int n, m; cin >> n >> m;
	vector<ll> res(m + 1);
	res[m] = (ll)n*(n - 1) / 2;
	vector<pair<int,int>> bridge(m);
	rep(i, m)
	{
		int a, b; cin >> a >> b;
		--a, --b;
		bridge[i] = make_pair(a, b);
	}
	UnionFind uf(n);
	rrep(i, m)
	{
		int a = bridge[i].first;
		int b = bridge[i].second;
		if (uf.issame(a, b))
		{
			res[i] = res[i + 1];
			continue;
		}
		ll tmp = (ll)uf.size(a)*uf.size(b);
		res[i] = res[i + 1] - tmp;
		uf.merge(a, b);
	}
	for (int i = 1; i <= m; ++i)cout << res[i] << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>

#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)
#define MAXSILVER 49*50
#define INF pow(10,16)

using namespace std;
typedef struct Node{
	vector<long> edges_to;//移動可能先
	vector<long> edge_costs;//移動に必要な銀貨
	vector<long> edge_times;//移動にかかる時間
	long exchange_rate;
	long exchange_time;
	
	
}Node_t;

typedef struct Status{
	long city_number;
	long silver;//所持している銀貨
	long time;//スタート時点からの経過時間

	bool operator > (const Status &st1) const {
		return st1.time > time;
	}
	bool operator < (const Status &st1) const {
		return st1.time < time;
	}
}Status_t;

int main(){
	int i,j;
	long N,M,S;
	priority_queue<Status_t> q; 
	vector<vector<long> > dp(51,vector<long>(MAXSILVER+1, INF));//経過時間(都市，残銀貨)

	cin >> N >> M >> S;
	S = min(S,(long)MAXSILVER);
	vector<Node_t> nodes(N+1);

	myfor(i,M){
		long u,v,a,b;
		cin >> u >> v >> a >> b;
		nodes[u].edges_to.push_back(v);
		nodes[u].edge_costs.push_back(a);
		nodes[u].edge_times.push_back(b);
		nodes[v].edges_to.push_back(u);
		nodes[v].edge_costs.push_back(a);
		nodes[v].edge_times.push_back(b);
	}
	myforFL(i,1,N+1){
		long c,d;
		cin >> c >> d;
		nodes[i].exchange_rate = c;
		nodes[i].exchange_time = d;
	}

	dp[1][S] = 0;
	Status_t status1 = {1,S,0};
	q.push(status1);
	while(!q.empty()){
		status1 = q.top();
		q.pop();
		long c,s,t;
		c = status1.city_number;
		s = status1.silver;
		t = status1.time;
		
		if(dp[c][s] < t)continue;
		
		long charged_s = s + nodes[c].exchange_rate;
		
		if(charged_s <= MAXSILVER){
			if(dp[c][charged_s] > t + nodes[c].exchange_time){
				dp[c][charged_s] = t + nodes[c].exchange_time;
				q.push((Status_t){c,charged_s,t + nodes[c].exchange_time});
			}
		}
		
		long n = nodes[c].edges_to.size();
		
		myfor(i,n){
			long move_to = nodes[c].edges_to[i];
			long move_cost = nodes[c].edge_costs[i];
			long move_time = nodes[c].edge_times[i];
			if(s >= move_cost){
				if(dp[move_to][s - move_cost] > t + move_time){
					dp[move_to][s - move_cost] = t + move_time;
					q.push((Status_t){move_to,s - move_cost,t + move_time});
				}
			}
		}
	}

	myforFL(i,2,N+1){
		long ans = INF;
		myfor(j,MAXSILVER+1){
			ans = min(ans,dp[i][j]);
		}
		cout << ans << endl;
	}
	return 0;

}

Measured memory_bytes: 6928
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, M, S;
vector<pair<int,int>> E[50];
int A[101], B[101], C[50], D[50];
ll dist[50][3010];
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
bool vis[50][3010];
ll ans[50];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M >> S;
    chmin(S, 3000);
	rep(i, 0, M) {
		int u, v; cin >> u >> v; u--; v--;
		cin >> A[i] >> B[i];
		E[u].push_back({ v, i });
		E[v].push_back({ u, i });
	}
	rep(i, 0, N) cin >> C[i] >> D[i];

    rep(i, 0, N) rep(s, 0, 3001) dist[i][s] = infl;
    rep(i, 0, N) rep(s, 0, 3001) vis[i][s] = false;
    rep(i, 0, N) ans[i] = infl;

    min_priority_queue<pair<ll, int>> que;

    dist[0][S] = 0;
    que.push({ 0, 0 * 5010 + S });

    while (!que.empty()) {
        auto q = que.top(); que.pop();

        ll cst = q.first;
        int cu = q.second / 5010;
        int s = q.second % 5010;

        if (vis[cu][s]) continue;
        vis[cu][s] = true;

        chmin(ans[cu], cst);

        fore(p, E[cu]) {
            int to = p.first;
            int i = p.second;
            if (s < A[i]) continue;

            ll cst2 = cst + B[i];
            if (chmin(dist[to][s - A[i]], cst2)) que.push({ dist[to][s - A[i]], to * 5010 + s - A[i] });
        }

        ll cst2 = cst + D[cu];
        int s2 = min(3000, s + C[cu]);
        if (chmin(dist[cu][s2], cst2)) que.push({ dist[cu][s2], cu * 5010 + s2 });
    }

    rep(i, 1, N) printf("%lld\n", ans[i]);
}







Measured memory_bytes: 6620
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>

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

using namespace std;

const int INF = 100000000;

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

  vector<int> p = vector<int>(n);

  REP(i,n){
    cin >> p[i];
  }

  sort(p.begin(),p.end());
  int ans =0;
  REP(i,n-1){
    ans += p[i];
  }
  ans += p[n-1]/2;

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

Measured memory_bytes: 256
N = int(input())
S = list(input())
ans = []
characters = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
for s in S:
    pos = characters.index(s)
    p = pos + N
    if p < 26:
        ans.append(characters[p])
    else:
        ans.append(characters[p-26])
        
print("".join(ans))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std; 

int main(){
    string s;
    cin >> s;

    if(s[s.size()-1] == 's'){
        s += "es";
    }
    else {
        s += "s";
    }

    cout << s << endl;
	
	return 0;
}

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

int main(){
    int dp[5][4001] = {};
    for(int i = 0; i <= 1000; i++)  dp[1][i] = 1;
    for(int i = 1; i < 3; i++){
        for(int j = 0; j <= 1000*i; j++){
            for(int k = 0; k <= 1000*i; k++){
                dp[i*2][j+k] += dp[i][j]*dp[i][k];
            }
        }
    }

    int n;
    while(cin >> n) cout << dp[4][n] << endl;
    
    return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

char a[1111][1111];
int n,m; 

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = (1e9 + 7);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}

bool valid(int x, int y)
{
	return (x>=0&&x<n&&y>=0&&y<m&&a[x][y]=='.');
}

int dp[1111][1111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>a[i][j];
		}
	}
	dp[0][0]=1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(a[i][j]=='#') continue;
			if(valid(i,j-1)) dp[i][j]=add(dp[i][j],dp[i][j-1]);
			if(valid(i-1,j)) dp[i][j]=add(dp[i][j],dp[i-1][j]);
		}
	}
	cout<<dp[n-1][m-1]<<'\n';
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
const int MOD = 1000000007;

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> ar(m, vector<int>(12));
    rep(i,m){
        cin >> ar[i][0];
        rep(j,ar[i][0]){
            cin >> ar[i][j+2];
        }
    }
    rep(i,m){
        cin >> ar[i][1];
    }
    int ans = 0;
    vector<int> bit(n+1);
    rep(i,1<<n){
        bool t = true;
        rep(j,n){
            bit[j+1] = i>>j & 1;
        }
        rep(k,m){
            int a = 0;
            rep(l,ar[k][0]){
                a += bit[ar[k][l+2]];
            }
            if (a % 2 != ar[k][1]){
                t = false;
                break;
            }
        }
        if (t) ans++;
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  for(int i = 0; i < N; i++) cin >> V[i];
  vector<int> C(N);
  for(int i = 0; i < N; i++) cin >> C[i];
  
  vector<int> A = {};
  for(int i = 0; i < N; i++) {
      int s = V[i] - C[i];
      if (s > 0) A.push_back(s);
  }
  
  int j = A.size();
  if (j != 0) {
      int S = 0;
      for(int i = 0; i < A.size(); i++) S += A[i];
      cout << S << endl;
  }
  else {
      cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int a=0;
	int b=0;
	int c=0;
	int temp;
	
	printf("");
	scanf("%d %d %d",&a,&b,&c);
	
	while(1){
		if(a>=1 && a<=10000 && b>=1 && b<=10000 && c>=1 && c<=10000){
			break;
		}else{
			printf("");
			scanf("%d %d %d",&a,&b,&c);
			continue;
		}	
	}
	if(a>b){
		temp=a;
		a=b;
		b=temp;
	}
	
	if(a>c){
		temp=a;
		a=c;
		c=temp;
	}
	
	if(b>c){
		temp=b;
		b=c;
		c=temp;
	}
	
	printf("%d %d %d\n",a,b,c);
	
	return 0;
	
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;
typedef vector<pair<int, int>> vp;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int N, M; cin >> N >> M;
	vector<vp> c(100001);
	rep(i, M) {
		int p, y; cin >> p >> y;
		c[p].push_back(make_pair(y, i));
	}

	vp ans(100001);
	rep(i, N + 1) {
		sort(all(c[i]));
		rep(j, c[i].size()) ans[c[i][j].second] = make_pair(i, j + 1);
	}

	rep(i, M) printf("%06d%06d\n", ans[i].first, ans[i].second);
}


Measured memory_bytes: 7808
#include<numeric>
#include<iostream>

using namespace std;

int main()
{
	int s[4],t[4];
	for(int i=0;i<4;i++)	cin>>s[i];
	for(int i=0;i<4;i++)	cin>>t[i];
	s[0]=accumulate(s,s+4,0);
	t[0]=accumulate(t,t+4,0);
	cout<<(s[0]<t[0]?t[0]:s[0])<<endl;
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int D = in.nextInt();
		int N = in.nextInt();
	
		
		if(D==0) {
			if(N==100) {
				System.out.print(N+1);
			}else {
				System.out.print(N);
			}
		}else if(D==1) {
			if(N==100) {
				System.out.print(100*(N+1));
			}else {
				System.out.print(100*N);
			}
		}else if(D==2) {
			if(N==100) {
				System.out.print(100*100*(N+1));
			}else {
				System.out.print(100*100*N);
			}
		}
		in.close();
		
	}
}

Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x=sc.nextInt();
		int s=x%60;
		int mm=x/60;
		int m=mm%60;
		int h=mm/60;
		System.out.println(h+":"+m+":"+s);
	}
}


Measured memory_bytes: 26180
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long,int> P;
typedef long long ll;
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//配列Aを大きい順にソートし、同じ数が2個以上あるものだけを取り出す
//そのうち1番大きい数と2番目に大きい数を取り出し、長方形の2辺
//長さと個数（２以上）をペアに持つペア配列を作る
//正方形となるのはp.firstが最大のsecondが4以上のときのみ

int main() {
 int N;
 cin >> N;
 vector<ll> A(N);
 for(int i = 0;i<N;i++){
	 cin >> A[i];
 }
 sort(A.begin(),A.end());
 reverse(A.begin(),A.end());
 A.push_back(-1);

vector<P> p;
int c = 1;
 for(int i = 0;i<N;i++){
  if(A[i] == A[i+1]){
		c++;
	}
  if(A[i] != A[i+1]){
		if(c>=2){
			p.push_back(P(A[i],c));
		}
		c = 1;
	}
 }

 ll ans = 0;
 
 if(p.size() == 0) cout << 0 << endl;
 else{
 	if(p[0].second >= 4) ans = p[0].first * p[0].first;
 	else ans = p[0].first * p[1].first;

  cout << ans << endl;
 }
  
}


Measured memory_bytes: 2672
#include <bits/stdc++.h> 
using namespace std ; 
#define ll long long int 
#define pb push_back
#define ff first 
#define dobara(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define ss second 
#define S(x) scanf("%d",&x) 
#define SL(x) scanf("%lld",&x)
#define M 1000000007
#define sz(x) (int)x.size()
#define all(a) (a).begin(),(a).end()
#define N 2005 

ll dp[N][N] , n , m , cum[N][N] ;
vector<ll> a , b ; 



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

   for(int i=0;i<n;i++){
   	  ll x ; 
   	  cin>>x ; 
   	  a.pb(x) ; 
   }
   for(int i=0;i<m;i++){
   	   ll x ;
   	   cin>>x ; 
   	   b.pb(x) ; 
   }
   
   ll ans = 0 ; 

   for(int l=n-1;l>=0;l--){
   	 for(int r=m-1;r>=0;r--){
        ll curr = 0 ; 
        /*for(int i=l+1;i<n;i++){
        	for(int j=r+1;j<n;j++){
        		curr += dp[i][j] ;
        	}
        }*/
        
        if(a[l] == b[r])
        	dp[l][r] = (1 + cum[l + 1][r + 1])%M ;
        
        cum[l][r] = ((dp[l][r] + cum[l][r + 1])%M + (cum[l + 1][r] - cum[l + 1][r + 1] + M )%M )%M ;

        ans = (ans + dp[l][r])%M ;	 
   	 }
   }
   ans = (ans + 1)%M ;
   cout<<ans<<"\n" ;
}

Measured memory_bytes: 62848
N, K = map(int, input().split())

sum_p = 0
for i in range(1, N+1):
    if i >= K:
        sum_p += 1/N
    else:
        n_powers = 1
        while True:
            if i * (2 ** n_powers) >= K:
                break
            n_powers += 1
        sum_p += 1/N * 0.5 ** n_powers

print(sum_p)

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main(){
	int n, m, t, i, j, k, x;
	double c=1e9;
	scanf("%d%d%d", &n, &t, &m);
	for(i=1; i<=n; i++){
		scanf("%d", &x);
		if(fabs(t-x*0.006-m) < c){
			c = fabs(t-x*0.006-m);
			k = i;
		}
	}
	printf("%d\n", k);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        char arr[n][m];
        for(int i=0; i<n; i++)
            scanf("%s",arr[i]);

        int dir[8][2]= {{0,1},{0,-1},{1,0},{-1,0},{1,1},{-1,-1},{1,-1},{-1,1}};
        for(int a=0; a<n; a++)
            for(int b=0; b<m; b++)
                if(arr[a][b]=='.')
                    arr[a][b]='0';



        for(int a=0; a<n; a++)
            for(int b=0; b<m; b++)
            {
                if(arr[a][b]=='#')
                    for(int i=0; i<8; i++)
                    {
                        int tx,ty;
                        tx=a+dir[i][0];
                        ty=b+dir[i][1];
                        if(tx<0||tx>=n||ty<0||ty>=m)
                            continue;
                        if(arr[tx][ty]!='#')
                            arr[tx][ty]++;
                    }
            }
        for(int a=0; a<n; a++)
        {
            for(int b=0; b<m; b++)
                printf("%c",arr[a][b]);
            printf("\n");
        }


    }
    return 0;
}




Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main()
{
	char s[4],ss[7][4]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
	int i;
	scanf("%s",s);
	for(i=0;i<7;i++){
		if(strcmp(s,ss[i])==0){
			printf("%d\n",7-i);
		}
	}
	return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
long long f[120][4020], z;
int n, k, p = 1000000007;
int main() {
	cin >> n >> k;
	z = k * (k + 1) / 2 * n;
	for (int i = 1; i < n; i++) {
		z = z * (k + 1) % p;
	}
	f[n][0] = 1;
	for (int i = n; i > 0; i--) {
		for (int j = 0; j < 4010; j++) {
			if (f[i][j] == 0) {
				continue;
			}
			for (int l = 0; l <= k; l++) {
				if (l <= i) {
					f[i - 1][j + (j + l) / i] = (f[i - 1][j + (j + l) / i] + f[i][j]) % p;
				} else {
					f[i - 1][j] = (f[i - 1][j] + f[i][j]) % p;
				}
			}
		}
	}
	for (int i = 0; i < 4010; i++) {
		z = (z - i * f[0][i]) % p;
	}
	cout << (z + p) % p << endl;
	return 0;
}

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

typedef long long ll;

int N, A, B, C, D;
string S;

bool ok(int s, int e) {
    for (int i = s; i <= e-1; i++) {
        if (S[i] == '#' && S[i+1] == '#') return false;
    }
    return true;
}

int main() {
    cin >> N >> A >> B >> C >> D;
    cin >> S;
    S = '#' + S + '#';

    if (!ok(A, C) || !ok(B, D)) {
        cout << "No" << endl;
        return 0;
    }
    
    if (C > D) {
        bool flag = false;
        for (int i = B; i <= D; i++) {
            if (S[i-1] == '.' && S[i] == '.' && S[i+1] == '.') flag = true;
        }
        if (!flag) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i=0;i<K;i++){
        int d;
        cin >> d;
        for (int j=0;j<d;j++){
            int a;
            cin >> a;
            a--;
            A[a]++;
        }
    }
    int ans = 0;
    for (int i=0;i<N;i++){
        if (A[i]==0) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3628
#include <cstdio>
#include<iostream>

using namespace std;
   
int main(void){
  
	double xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2;

	while(cin>>xa1>>ya1>>xa2>>ya2>>xb1>>yb1>>xb2>>yb2){
		if(xa1<=xb2&&ya2>=yb1&&xa2>=xb1&&ya1<=yb2) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}

    return 0;
}

Measured memory_bytes: 1220
import heapq
N, M = map(int, input().split(' '))
prices = list(map(lambda x: x * (-1), map(int, input().split(' '))))

# 優先度付きキューに変換
heapq.heapify(prices)

for i in range(M):
    # 最大のものを半額にしてまたキューに突っ込む
    heapq.heappush(prices, ((heapq.heappop(prices) * (-1)) // 2) * -1)

print(sum(prices) * -1)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a, b) for (int i = (a); i < (b); i++ )

typedef pair<int,int> P;
typedef long long ll;

const int INF = 100000000;
const double PI=3.14159265358979323846;

int main () {
    double A,B,H,M;
    cin >> A >> B >> H >> M;

    double t,a,b,d,c;

    t = M+60.0*H;
    a = PI/360.0*t;
    b = PI/30.0*t;
    d = max(a-b,b-a);
    
    c = pow(A,2)+pow(B,2)-2.0*A*B*cos(d);
    c = pow(c,0.5);

    cout << fixed << setprecision(10) << c << endl;

}

Measured memory_bytes: 4376
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#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 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vll;
const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int x,y;cin>>x>>y;
    bool flag = true;
    if(y % 2 == 1)flag = false;
    if(x *2 > y || x * 4 < y)flag = false;
    cout<<(flag? "Yes":"No") << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define P pair<int,int>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define asort(x) sort(x.begin(),x.end())
 
int main() {
    int a,b;
  	cin >> a >> b;
    cout << a * b << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define INF 9000000000000000000
#define ff first
#define ss second
#define mod 1000000007
#define endl "\n"
#define BS binary_search

int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int tc=1;
    //cin>>tc;
    while(tc--){
        int n;cin>>n;
        int a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        vector<int> v;
        v.pb(a[0]);
        int prev=a[0];
        for(int i=1;i<n;i++){
            if(a[i]!=prev){
                v.pb(a[i]);
                prev=a[i];
            }
        }
        int ans=1000;
        for(int i=1;i<v.size();i++){
            if(v[i]>v[i-1]){
                ans+=(v[i]-v[i-1])*(ans/v[i-1]);
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 200005;

int n;
int a[MAXN];
int chk[MAXN];
	set<pi> s;

int main(){
	scanf("%d",&n);
	for(int i=0; i<n; i++) scanf("%d", &a[i]);
	sort(a, a + n);
	for(int i=0; i<n; i++) s.emplace(a[i], i);
	int ret = 0;
	for(int i=n-1; i>=0; i--){
		if(chk[i]) continue;
		int p = 1;
		while(p <= a[i]) p <<= 1;
		p -= a[i];
		auto l = s.lower_bound(pi(p, -1));
		if(l == s.end() || l->first != p) continue;
		if(l->second >= i) continue;
		chk[i] = chk[l->second] = 1;
		s.erase(l);
		ret++;
	}
	cout << ret << endl;
}


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

int main(){
    int n, q;
    vector<int> a;
    cin >> n >> q;
    a.resize(n);
    for(int i=0;i<n;++i) cin >> a[i];

    int64_t s[100001], s2[100000];
    s[n] = 0;
    for(int i=n-1;i>=0;--i) s[i] = a[i] + s[i+1];
    s2[0] = a[0]; s2[1] = a[1];
    for(int i=2;i<n;++i) s2[i] = s2[i-2] + a[i];

    for(int i=0;i<q;++i){
        int x;
        cin >> x;
        int al = 0, ar = n;
        while(ar-al > 1){
            int m = (ar+al) / 2;
            if(a[m] <= x) al = m;
            else ar = m;
        }
        if(ar < n && x - a[al] > a[ar] - x) ++al;
        if(al == n-1) --al;
        int t = n-1;
        while(t-al > 1){
            int m = (t+al) / 2;
            int l = -1, r = m;
            while(r-l > 1){
                int mm = (l+r) / 2;
                if(x-a[mm] <= a[m]-x) r = mm;
                else l = mm;
            }
            if(m-r+1 < n-m) al = m;
            else t = m;
        }
        int l = t - (n-t) - 1;

        int64_t ans = s[t];
        if(l >= 0) ans += s2[l];
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3712
#include<stdio.h>
#include<string.h>
#define M 1046527
#define NIL (-1)
#define L 14
char H[M][L];

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int fnd(char str[]){
  long long key, i, h;
  key = getKey(str);
  for ( i = 0;; i++){
    h = (h1(key)+i*h2(key))%M;
    if( strcmp(H[h],str) == 0 ) return 1;
    else if ( strlen(H[h]) == 0 ) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key, i, h;
  key = getKey(str);
  for ( i = 0; ; i++ ){
    h = (h1(key)+i*h2(key))%M;
    if( strcmp(H[h],str) == 0 ) return 1;
    else if ( strlen(H[h]) == 0 ){
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}
int main(){
  int g, n, h;
  char str[L], com[9];
  for ( g = 0; g < M; g++ ) H[g][0] = '\0';
  scanf("%d", &n);
  for ( g = 0; g < n; g++ ){
    scanf("%s %s", com, str);

    if ( com[0] == 'i' ){
      if (insert(str)){

      }
    } else {
      if (fnd(str) ){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }
  return 0;
}



Measured memory_bytes: 16080
// see https://github.com/LumaKernel/vimfiles/tree/master/snippets/cp-cpp/temp.snip
/// --- .lumrc Template {{{ ///
// #define DEBUG
// #define assert(...)
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = tuple<ll, ll>;
using P3 = tuple<ll, ll, ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using VP = vector<P>;
using VS = vector<string>;

#define omajinai ios::sync_with_stdio(false),cin.tie(0)

#define FOR(i,a,b) for(int i=int(a);i<int(b);++i)
#define FORI(i,a,b) for(int i=int(a);i<=int(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REPI(i,n) FORI(i,0,n)
#define RFOR(i,a,b) for(int i=int(b)-1;i>=int(a);--i)
#define RFORI(i,a,b) for(int i=int(b);i>=int(a);--i)
#define RREP(i,n) RFOR(i,0,n)
#define RREPI(i,n) RFORI(i,0,n)

#define ALL(a) begin(a),end(a)
#define UNIQUE(a) (a).erase(unique(ALL(a)),(a).end())
#define PB push_back
#define EACH(i,c) REP(i,(c).size())
#define REACH(i,c) RREP(i,(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))

#define BR cout<<"\n";

#ifdef DEBUG
#define dump(...) cerr<<"["<<__LINE__<< "] "<<#__VA_ARGS__<<" = "<<make_tuple(__VA_ARGS__)<<"\n";
#else
#define dump(...)
#endif

#define YES(x) cout<<((x)?"YES":"NO")<<"\n";
#define Yes(x) cout<<((x)?"Yes":"No")<<"\n";
#define yes(x) cout<<((x)?"yes":"no")<<"\n";

int __int_temp; ll __ll_temp; string __string_temp;
#define oini (omajinai, cin>>__int_temp, __int_temp)
#define oinl (omajinai, cin>>__ll_temp, __ll_temp)
#define oins (omajinai, cin>>__string_temp, __string_temp)
#define ini (cin>>__int_temp, __int_temp)
#define inl (cin>>__ll_temp, __ll_temp)
#define ins (cin>>__string_temp, __string_temp)

#define isInside(y,x) (0<=(y)&&(y)<h&&0<=(x)&&(x)<w)

#define fi(x) (get<0>(x))
#define se(x) (get<1>(x))
#define th(x) (get<2>(x))
#define fo(x) (get<3>(x))
#define fif(x) (get<4>(x))

template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '{'; EACH(i, v) o << v[i] << (i != (int)v.size()-1 ? ", " : ""); o << "}";  return o; }

template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":", ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }

template <typename T> inline void smax(T &a, T b) { a = a > b ? a : b; }
template <typename T> inline void smin(T &a, T b) { a = a < b ? a : b; }

template<typename T> inline int intlog2(T x);
template<> inline int intlog2(int x) { return x == 0 ? 0 : 32 - __builtin_clz(x); }
template<> inline int intlog2(ll x) { return x == 0 ? 0 : 64 - __builtin_clzll(x); }

constexpr double PI = acos(-1);

/// }}}--- ///

constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr int MOD = 1e9+7;

int main() {
  set<char> st;
  int n=ini;
  REP(i,n) {
    string s=ins;
    st.insert(s[0]);
  }
  cout << (st.size()==3 ? "Three" : "Four") <<endl;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int dp[1005];
void f(int k) {
    dp[0] = 0;
    for (int i = 1; i <= 100; i++) {
        set < int > s;
        for (int j = 1; j <= (i / k); j++) {
            s.insert(dp[i - j]);
        }
        dp[i] = 0;
        while (s.count(dp[i])) dp[i]++;
        //(3x+2) / 2 = a[i]
        // (3x)/2 + 1 = i
        // x = 2k -> 3k+1
        // x = 2k+1 -> 3k+2
        //(2x+1)
        // (k * x + (k - 1)) / (k - 1) = c
        //  (k - 1) * c + (k - 1) > k * x + (k - 1) >= (k - 1) * c
        if (i % k != 0) {
            int x = ((k - 1) * i) / k;
            cout << i << " " << dp[i] << " " << dp[x] << endl;
        }
//        cout << i << " " << dp[i] << endl;
    }
    // f(3n)=n
    //
}
ll get(ll n, ll k) {
    if (n % k == 0) return n / k;
    ll delta = (n + k - 1) / k;
    //n - delta * c > k * (n / k)
    ll lim = k * (n / k);
    ll at_most = (n - lim - 1) / delta;
    return get(n - delta * (at_most + 1), k);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    ll f = 0;
    for (int i = 1; i <= n; i++) {
        int a, b;
        cin >> a >> b;
        f ^= get(a, b);
    }
    cout << (f == 0 ? "Aoki" : "Takahashi");
    return 0;
}

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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            WriteLine(Pow(cin.ReadInt(), 2) - cin.ReadInt());
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
    }
}



Measured memory_bytes: 11220
from collections import deque
H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
S=[input() for _ in range(H)]
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1

P = [[float('inf')] * W for _ in range(H)]
a = [(1,0), (0,1), (-1,0), (0,-1)]
q=deque()
q.append((Ch,Cw,0))

while q:
  dq=deque()
  hh, ww, d = q.popleft()
  if type(P[hh][ww]) is int:
    continue
  dq.append((hh,ww))
  P[hh][ww]=d
  V=[]
  while dq:
    h, w = dq.popleft()
    V.append((h,w))
    for n in a:
      nh=h+n[0]
      nw=w+n[1]

      if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.' and type(P[nh][nw]) is float:
        P[nh][nw] = min(P[nh][nw], P[h][w])
        dq.append((nh,nw))

  for h,w in V:
    for x in range(-2, 3):
      for y in range(-2, 3):
        nh = h + x
        nw=w+y
        if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.' and type(P[nh][nw]) is float:
          q.append((nh,nw,d+1))

ans = P[Dh][Dw]
print(ans if type(ans) is int else -1)


Measured memory_bytes: 163576
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std ; 

typedef long long ll ; 

#define MOD 1000000007

void exgcd(ll a, ll b, ll& x, ll& y){
    if(!b){
        x = 1LL ; 
        y = 0 ; 
        return ;
    }
    exgcd(b, a%b, y, x) ; 
    y = y-(a/b)*x ; 
}
ll inv(ll a){
    ll x, y ; 
    exgcd(a, MOD, x, y) ; 
    return (x+MOD)%MOD ; 
}

ll prepro[311111] ; 
void init(){
    prepro[1] = 1 ; 
    for(int i = 2 ; i <= 300000 ; i++)
        prepro[i] = prepro[i-1]*i % MOD ; 
}

ll C(ll n, ll k){
    if(n == k)
        return 1 ; 
    if(k == 0)
        return 1 ; 
    return (prepro[n]*inv(prepro[n-k]) % MOD)*inv(prepro[k])%MOD ; 
}

int main()
{
    init() ;
    ll H, W, A, B ; 
    scanf("%lld%lld%lld%lld", &H, &W, &A, &B) ; 
    ll ans = C(H+W-2, H-1) ; 
    for(int i = 0 ; i != B ; i++){
        ll r = H-A-1 ; 
        ll c = i ;
        ll m = C(r+c, c)*C(A-1 + W-i-1, A-1) % MOD ; 
        ans = (ans+MOD - m)%MOD ; 
        //ans = (ans+MOD - C(r+c, c)) ; 
    }
    printf("%lld\n", ans) ; 
    return 0 ; 
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())
#define maxIndex(v) max_element(v.begin(), v.end()) - v.begin()
#define maxElement(v) *max_element(v.begin(), v.end())
#define minIndex(v) min_element(v.begin(), v.end()) - v.begin()
#define minElement(v) *min_element(v.begin(), v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;

int main()
{
  ll H, W, N; cin >> H >> W >> N;
  vector<vector<ll>> mtrx(H, vector<ll>(W));
  vector<ll> colors(N);
  rep(i, 0, N) cin >> colors[i];
  ll k = 0;
  rep(i, 0, H) {
  	if (i % 2 == 0) {
    	for (ll j = 0; j < W; j++) {
        	mtrx[i][j] = k + 1;
         	colors[k]--;
          	if (colors[k] == 0) k++;
        }
    } else {
	    for (ll j = W - 1; j >= 0; j--) {
        	mtrx[i][j] = k + 1;
         	colors[k]--;
          	if (colors[k] == 0) k++;
        }
    }
  }
  rep(i, 0, H) {
  	rep(j, 0, W) {
    	cout << mtrx[i][j] << " ";
    }
    cout << endl;
  }
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
    double max,min,now;
    scanf("%lf",&max);
    min=max;
    while(1) {
        if(scanf("%lf",&now)==-1)break;
        if(now<min)min=now;
        if(now>max)max=now;
    }
    printf("%f\n",max-min);
    return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
using namespace std;

int main() {
	int n; cin >> n;
	int flag = 0;
	int f[100][10] = {}; REP(i, n)REP(j, 10) { cin >> f[i][j];  }
	int p[100][11] = {}; REP(i, n)REP(j, 11) { cin >> p[i][j];}

	int sum = 0;
	int m_max=-1000000000;
	for (int i = 1; i < (1<<10); i++) {
		int p_max = 0;
		REP(j, n) {
			int count = 0;
			REP(k, 10) {
				if (f[j][k] && (i >> k & 1))count++;
			}
			p_max += p[j][count];
		}
		m_max = max(m_max, p_max);
	}

	cout << m_max << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 500005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n;
    cin >> n;
    int a[SIZE];
    for( int i = 0; i < n; ++i ) {
        cin >> a[i];

    }
    sort( a, a + n );
    int mi = n / 2;
    vector< int > v, w;
    v.pb( a[n / 2] );
    w.pb( a[n / 2] );
    int l = 0, r = n - 1;
    while( l < mi || r > mi ) {
        if( l == mi || r == mi ) {
            if( l == mi ) {
                v.pb( a[r] );
                --r;

            } else {
                v.pb( a[l] );
                ++l;

            }
        } else {
            v.pb( a[l] );
            v.pb( a[r] );
            ++l; --r;

        }
    }

    l = 0; r = n - 1;
    while( l < mi || r > mi ) {
        if( l == mi || r == mi ) {
            if( l == mi ) {
                w.pb( a[r] );
                --r;

            } else {
                w.pb( a[l] );
                ++l;

            }
        } else {
            w.pb( a[r] );
            w.pb( a[l] );
            ++l; --r;

        }
    }

    LL resv = 0, resw = 0;
    for( int i = 1; i < n; ++i ) {
        resv += abs( v[i] - v[i - 1] );
        resw += abs( w[i] - w[i - 1] );

    }

    cout << max( resv, resw ) << endl;
    return 0;
}



Measured memory_bytes: 1784