akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>          // printf(), fprintf(), scanf()
#include <stdlib.h>         // exit()
#include <string.h>         // strlen(), strcpy()

#define QUE_SIZE 100000
#define L_STRINGS (11 * 100000)

typedef struct que_tbl
{
	const char* name;
	int time;
} que_t;

int que_in;
int que_out;
que_t queue[QUE_SIZE];
char strings[L_STRINGS];
int ix;

void
cleanup(int ecode)
{
	exit(ecode);
}

int
que_size()
{
	if (que_in >= que_out)
		return que_in - que_out;

	return que_in + QUE_SIZE - que_out;
}

void
que_push(que_t* que)
{
	queue[que_in].name = que->name;
	queue[que_in].time = que->time;
	que_in++;
	if (que_in >= QUE_SIZE)
		que_in = 0;

	if (que_in == que_out)
	{
		fprintf(stderr, "Queue area overflow. size:%d\n", QUE_SIZE);
		cleanup(1);
	}
}

void
que_pop()
{
	if (que_out != que_in)
	{
		que_out++;
		if (que_out >= QUE_SIZE)
			que_out = 0;
	}
}

void
que_front(que_t* que)
{
	que->name = queue[que_out].name;
	que->time = queue[que_out].time;
}

int
main(int argc, char** argv)
{
	char name[11];
	int time;
	que_t que;
	int q;
	int n, i;
	char* s;
	int t;

	ix = 0;
	que_in = 0;
	que_out = 0;

	scanf("%d %d", &n, &q);
	for (i = 0; i < n; ++i)
	{
		s = &strings[ix];
		scanf("%s %d", s, &t);
		ix += strlen(s) + 1;

		que.name = s;
		que.time = t;
		que_push(&que);
	}

	time = 0;
	while (que_size() > 0)
	{
		que_front(&que); que_pop();
		if (que.time <= q)
		{
			time += que.time;
			printf("%s %d\n", que.name, time);
		}
		else
		{
			que.time -= q;
			time += q;
			que_push(&que);
		}
	}

	return 0;
}

Measured memory_bytes: 2504
n, m = gets.chomp.split(' ').map(&:to_i)
wa = Array.new(1000000, 0)
ac = Array.new(1000000, false)
wanum = 0
acnum = 0
1.upto m do |index| 
  ary = gets.chomp.split(' ')
  targetSubject = ary[0].to_i
  targetResult = ary[1]
  next if ac[targetSubject]
  if targetResult == 'AC'
    ac[targetSubject] = true
    acnum += 1
    wanum += wa[targetSubject]
  else
    wa[targetSubject] += 1
  end
end

puts "#{acnum} #{wanum}"

Measured memory_bytes: 17404
/******

AUTHOR : RUDRANSH TRIPATHI, IIIT NAGPUR, CCID(rt24) & CFID(rsgt24)

MOTTO : Use criticism as fuel and you will never run out of energy.
        AIM : TO BECOME A BETTER CODER
        INTROSPECT + COURSE CORRECTIONS = CATALYST FOR SUCCESS
        Every moment is an opportunity to better yourself

*******/

#include<bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
const int MAX = 1e5 + 5;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define pb push_back
#define d(x) cout<<x<<"\n"

//basic mathematics
int gcd(int a, int b)
{
	if (a == 0)
		return b;
	return gcd(b % a, a);
}
int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}

//modular arithmetic
int powermod(int x, int y, int p)
{
	int res = 1;

	x = x % p;

	if (x == 0) return 0;

	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

//Prime numbers till n precomputation - range query
int prefix[MAX + 1];

void buildPrefix()
{
	bool prime[MAX + 1];
	memset(prime, true, sizeof(prime));

	for (int p = 2; p * p <= MAX; p++) {
		if (prime[p] == true) {
			for (int i = p * 2; i <= MAX; i += p)
				prime[i] = false;
		}
	}
	prefix[0] = prefix[1] = 0;
	for (int p = 2; p <= MAX; p++) {
		prefix[p] = prefix[p - 1];
		if (prime[p])
			prefix[p]++;
	}
}

int query(int L, int R)
{
	return prefix[R] - prefix[L - 1];
}


//Find all paths from a to b in an undirected graph
vector<int> g[MAX];
int visited[MAX];
//count of all the paths from 1 to n;

void dfs(int visited[MAX], int u, int v, vector<int> path)
{
	visited[u] = 1;
	if (u == v)
	{
		for (int i = 0; i < path.size(); i++)
		{
			cout << path[i] << " ";
		}
		cout << "\n";
	}
	else
	{
		for (int i = 0; i < g[u].size(); i++)
		{
			int y = g[u][i];

			if (visited[y] == 0)
			{
				visited[y] = 1;
				path.pb(y);
				dfs(visited, y, v, path);
				path.pop_back();
			}

		}
	}

	visited[u] = 0;

}


void solve()
{
	int d,t,s;
	cin>>d>>t>>s;
	
	int x=s*t;
	if(x>=d)
	{
	    cout<<"Yes"<<"\n";
	}
	else
	cout<<"No"<<"\n";
		
}

int32_t main(void)
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 5984
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N, cnt = 0, ans = 0, tmp = 0;
    int K;
    cin >> N >> K;
    if(N % K != 0)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long x,a,b,c,ans=0;
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++)
        for(int j=0;j<=b;j++)
            for(int z=0;z<=c;z++)
            {
                int k=i*500+j*100+z*50;
                if(k==x)ans++;
            }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a, b, c, d;
    scanf("%d %d", &a, &b);
    if (1 <= a && b <= 100) {
        c = a * b;
        d = (a * 2) + (b * 2); 
        printf("%d %d\n", c, d);
    }
    return 0;
}

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

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

    int ans = -1;

    vector<int> s(M);
    vector<int> c(M);
    rep(i, M){
        cin >> s.at(i) >> c.at(i);
    }

    if (N == 1){
        for (int i = 0; i < 10; i++){
            int judge = 0;
            for (int j = 0; j < M; j++){
                if (s.at(j) == 1 && c.at(j) == i){
                    continue;
                } else {
                    judge = 1;
                    break;
                }
            }
            if (judge == 0){
                ans = i;
                break;
            }
        }


        
    } else if (N == 2){
        for (int i = 10; i < 100; i++){
            int judge = 0;
            for (int j = 0; j < M; j++){
                if (s.at(j) == 2 && c.at(j) == i%10){
                    continue;
                } else if (s.at(j) == 1 && c.at(j) == i/10) {
                    continue;
                } else {
                    judge = 1;
                    break;
                }
            }
            if (judge == 0){
                ans = i;
                break;
            }
        }
    } else {
        for (int i = 100; i < 1000; i++){
            int judge = 0;
            for (int j = 0; j < M; j++){
                if (s.at(j) == 3 && c.at(j) == (i%100)%10){
                    continue;
                } else if (s.at(j) == 2 && c.at(j) == (i%100)/10) {
                    continue;
                } else if (s.at(j) == 1 && c.at(j) == i/100){
                    continue;
                } else {
                    judge = 1;
                    break;
                }
            }
            if (judge == 0){
                ans = i;
                break;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,n,s) 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 printpair(vector<pair<ll, ll>> vp)
{
  cout<<'['<<endl;
  rep(i,0,vp.size())
  {
    pair<ll, ll> p=vp[i];
    cout<<'{'<<p.first<<','<<p.second<<'}'<<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 = 1e12;
//------------------------------------------------------------
ll N,M;
struct edge {ll to, cost;};
vector<vector<edge>> G(1e5+1, vector<edge>());

void solve()
{
    cin >> N;

    rep(i,0,N-1)
    {
      ll u,v,w;
      cin >> u>>v>>w;
      --u; --v;
      G[u].push_back({v, w%2});
      G[v].push_back({u, w%2});
    }

    ll root=0;
    rep(i,0,N) if(G[i].size()==1) root=i;

    queue<pair<ll,ll>> q;
    vector<ll> ans(N);
    vector<bool> used(N);
    ans[root]=0;
    q.push({root, 0});
    used[root]=true;

    while (!q.empty())
    {
      pair<ll, ll> p = q.front(); q.pop();
      int id=p.first; int col=p.second;
      rep(i,0,G[id].size())
      {
        ll to = G[id][i].to; ll cost = G[id][i].cost;
        if(used[to]) continue;
        used[to]=true;
        q.push({to, (col+cost)%2});
        ans[to]=(col+cost)%2;
      }
    }

    rep(i,0,N) print(ans[i]);

    return;
}



Measured memory_bytes: 8704
# https://atcoder.jp/contests/abc104/tasks/abc104_d
# in
# ????C?????B??????A???????
# out
# 979596887
# in
# ABCBC
# 3

MOD = (10**9) + 7
str = gets.chomp
# n文字目までの'a'の組み合わせの数
dp_a = 0
# n文字目までの'ab'の組み合わせの数
dp_ab = 0
# n文字目までの'abc'の組み合わせの数
dp_abc = 0

dp_none = 1

a = 'A'
b = 'B'
c = 'C'
str.chars.each.with_index(1) do |s, n|
  case s
  when a
    dp_a = (dp_a + dp_none)%MOD
  when b
    dp_ab = (dp_ab + dp_a)%MOD
  when c
    dp_abc = (dp_abc + dp_ab)%MOD
  else
    dp_abc = (dp_abc * 3 + dp_ab)%MOD
    dp_ab = (dp_ab * 3 + dp_a)%MOD
    dp_a = (dp_a * 3 + dp_none)%MOD
    dp_none = (dp_none * 3)%MOD
  end
end

p dp_abc

Measured memory_bytes: 6908
my $N = 4;
my $s = <STDIN>;

my ($n, $m) = (0,0);

my ($a, $b) = (substr($s,0,2),substr($s,2,2));
$a = $a + 0;
$b = $b + 0;

my $ans;

if ($a + 0 >= 1 && $a + 0 <= 12){$n = $n + 1;}
if ($b + 0 >= 1 && $b + 0 <= 12){$m = $m + 1;}

if($m == 0 && $n == 0){$ans = "NA";}
elsif($m == 0 && $n == 1){$ans = "MMYY";}
elsif($m == 1 && $n == 0){$ans = "YYMM";}
elsif($m == 1 && $n == 1){$ans = "AMBIGUOUS";}

print "$ans\n";


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const int N = 3e2+6;
const int mod = 1e9+7;
const int inf = 1e8;
int g[N][N];
int edg[N*10][3];
void solve(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            g[i][j] = inf;
        }
        g[i][i] = 0;
    }
    for(int i=0;i<m;i++){
        int x,y,z;
        cin>>x>>y>>z;
        edg[i][0] = x;
        edg[i][1] = y;
        edg[i][2] = z;
        g[x][y] = g[y][x] = z;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                g[k][j] = min(g[k][j],g[k][i]+g[i][j]);
            }
        }
    }

    int ans = 0;
    for(int i=0;i<m;i++){
        int x,y,z;
        x = edg[i][0];
        y = edg[i][1];
        z = edg[i][2];
        int shrt = 1;
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){

                if(g[j][k]==int(g[j][x]+z+g[y][k]))shrt = 0;
                if(g[j][k]==int(g[j][y]+z+g[x][k]))shrt = 0;
            }
        }
        ans+=shrt;
    }
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int god(int x,int y){

if( y == 0 ) return x; 
else return god(y,x%y);
}

int main(){
int a,b;

scanf("%d%d",&a,&b);

if( a >= b ) printf("%d\n",god(a,b));
else  printf("%d\n",god(b,a));

return 0;
}

Measured memory_bytes: 592
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const r = Number(input);
const pi = 3.141;
const area = (Math.pow(r, 2) * Math.PI).toFixed(6);
const len = ((r*2) * Math.PI).toFixed(6);

console.log(area + ' ' + len);


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






int main() {
  int N;cin>>N;
  int cnt1=0;
  int cnt2=0;
  int cnt3=0;
  int cnt4=0;
  int cnt5=0;
  int cnt6=0;
  int cnt7=0;
  int cnt8=0;
  int cnt9=0;
  rep(i,N){
    int x;cin>>x;
    if(x<=399)cnt1=1;
    else if(x<=799)cnt2=1;
    else if(x<=1199)cnt3=1;
    else if(x<=1599)cnt4=1;
    else if(x<=1999)cnt5=1;
    else if(x<=2399)cnt6=1;
    else if(x<=2799)cnt7=1;
    else if(x<=3199)cnt8=1;
    else{
      cnt9++;
    }
  }
  int cnt=cnt1+cnt2+cnt3+cnt4+cnt5+cnt6+cnt7+cnt8;
  if(cnt==0){
    cout<< 1 <<" "<< cnt9 <<endl;
    return 0;
  }
  cout<< cnt <<" "<< cnt9+cnt <<endl;
  
  
}



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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

const int mod  = 100003;
const int maxn = 1e5+10;

int a[maxn][3];
int dp[maxn][4];

int solve(int n,int pla)
{
	if (dp[n][pla]!=-1)
		return dp[n][pla];
	for (int i=1;i<=3;i++)
	{
		for (int j=1;j<=3;j++)
		{
			if (j!=i)
				dp[n][i]=max(dp[n][i],solve(n-1,j));
		}
		dp[n][i]+=a[n][i];
	}
	return dp[n][pla];
}
void check(int n)
{
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=3;j++)
			cout<<setw(5)<<dp[i][j];
		cout<<endl;
	}
}
int main()
{
	int n;
	cin>>n;
	for (int i=1;i<=n;i++)
		cin>>a[i][1]>>a[i][2]>>a[i][3];
	for (int i=0;i<=n;i++)
		for (int j=1;j<=3;j++)
			dp[i][j]=-1;
	dp[1][1]=a[1][1];
	dp[1][2]=a[1][2];
	dp[1][3]=a[1][3];
	if (n==1)
		cout<<max(a[1][1],max(a[1][2],a[1][3]));
	else
	{
		solve(n,1);
		//check(n);
		int ans=-1;
		for (int i=1;i<=3;i++)
			ans=max(ans,dp[n][i]);
		cout<<ans;
	}
	return 0;
}


Measured memory_bytes: 14064
fn main() {
	let v: Vec<i32> = read_vec();
	if v[0]+v[1] == 15 {
		println!("+");
	} else if v[0]*v[1] == 15 {
		println!("*");
	} else {
		println!("x");
	}
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().split_whitespace().map(|e|
        e.parse().ok().unwrap()
    ).collect()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  if (s == "Sunny") cout << "Cloudy" << endl;
  if (s == "Cloudy") cout << "Rainy" << endl;
  if (s == "Rainy") cout << "Sunny" << endl;
   return 0;
}

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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  int ans;
  if(A>=B && A>=C){
    ans = 10 * A +B+C;
  }else if(B>=A && B>=C){
    ans = 10 * B +A+C;
  }else{
    ans = 10 * C +B+A;
  }
  cout << ans << endl; 
}

Measured memory_bytes: 256
def comb(n):
    return n*(n+1)//2

class UnionFind:
  def __init__(self, N):
    self.parent = [i for i in range(N)]
    self.rank = [0] * N
    self.count = 0
    self.size = [1] * N
    self.connection = 0

  def root(self, a):
    if self.parent[a] == a:
      return a
    else:
      self.parent[a] = self.root(self.parent[a])
      return self.parent[a]

  def is_same(self, a, b):
    return self.root(a) == self.root(b)

  def unite(self, a, b):
    ra = self.root(a)
    rb = self.root(b)
    if ra == rb:
      return
    self.connection -= (comb(self.size[ra]) + comb(self.size[rb]))
    self.connection += comb(self.size[ra] + self.size[rb])
    if self.rank[ra] < self.rank[rb]:
      self.size[rb] += self.size[ra]
      self.parent[ra] = rb
    else:
      self.size[ra] += self.size[rb]
      self.parent[rb] = ra
      if self.rank[ra] == self.rank[rb]:
        self.rank[ra] += 1
    self.count += 1

n, m = map(int, input().split())
uni = UnionFind(n)
remain = [comb(n-1)]
abl = []
for _ in range(m):
  a, b = map(int, input().split())
  abl.append((a-1, b-1))
for a, b in abl[::-1]:
  uni.unite(a, b)
  remain.append(remain[0] - uni.connection)
for r in reversed(remain[:-1]):
  print(r)

Measured memory_bytes: 24912
#include <iostream>

 

using namespace std;

 

int main()
{
    int i, ans, a, b, c;
    
    cin >> a >> b >> c;
    ans = 0;
    
    for(i=a; i<=b; i++)
    {
        if( c % i == 0 )
       ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3116
#include<stdio.h>

int main(void)
{
 
int n,a,b;
 
scanf("%d%d%d",&n,&a,&b);
 
if(a*n<b)
{
 printf("%d",a*n);
}
 
else
{
 printf("%d",b);
}
 
return 0;
 
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    
    string S;
    cin >> S;
    
    int cnt = 0;
    for(int i = 0; i < S.size(); i++) if(S[i] == 'o') cnt++;
    
    int ans = 700 + (100 * cnt);
    cout << ans << endl;
    
}


Measured memory_bytes: 3152
#include<stdio.h>

int main(){
	double a,b,unyou[100][5],syoki,max;
	int i,j,k,m,nen,n;
	
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%lf%d%d",&syoki,&nen,&n);
//		printf("i %d\n",i);
		for(j=0;j<n;j++){
			scanf("%lf%lf%lf",&unyou[j][0],&unyou[j][1],&unyou[j][2]);
			a=syoki;
			b=0;
//			printf("j %d\n",j);
			switch(int(unyou[j][0])){
			case 0:
				for(k=0;k<nen;k++){
//					printf("k %d nen %d\n",k,nen);
					b+=int(a*unyou[j][1]);
					a=a-unyou[j][2];
				}
				unyou[j][3]=a+b;
//				printf("%d %lf\n",j,unyou[j][3]);
				break;
			case 1:
				for(k=0;k<nen;k++){
//					printf("k %d nen %d\n",k,nen);
					b=int(a*unyou[j][1]);
					a=a-unyou[j][2]+b;
				}
				unyou[j][3]=a;
//				printf("%d %lf\n",j,unyou[j][3]);
				break;
			}
		}
		
		
		max=0;
		for(j=0;j<n;j++){
			if(max<unyou[j][3]){
				max=unyou[j][3];
			}
		}
		printf("%.0f\n",max);
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N),B(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i) >> B.at(i);}
  
  vector<int> C(N);
  for(int i=0;i<N;i++){
    if(A.at(i) == B.at(i)){C.at(i) = 1;}
    else{C.at(i) = 0;}
  }
  
  int ans = 0;
  int count = 0;
  
  for( int i=0;i<N;i++){
    if(C.at(i)==1){
      count ++;
      if(count > ans){ans = count;}
                  }
  
    else{count = 0;}
  }

  if(ans >=3){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
    
    
}


Measured memory_bytes: 3624
maxn = 2 * (10**5)

n , k , l = map(int, input().split())

par = [[0] * (n+1) for _ in range(2)]
rank = [[0] * (n+1) for _ in range(2)]

#初期化
for i in range(n+1):
    par[0][i] = i
    rank[0][i] = 0
    par[1][i] = i
    rank[1][i] = 0

#判定(一番上野根を求める)
def find(num,x):
    if par[num][x] == x:
        return x
    else:
        par[num][x] = find(num,par[num][x])
        return par[num][x]
    
#結合
def unite(num , x , y):
    rx = find(num,x)
    ry = find(num,y)
    
    if rx == ry:
        return
    
    if rank[num][rx] < rank[num][ry]:
        par[num][rx] = ry
    elif rank[num][rx] > rank[num][ry]:
        par[num][ry] = rx
    else:
        par[num][ry] = x
        rank[num][rx] += 1
        

for i in range(k):
    p,q = map(int, input().split())
    unite(0,p,q)
        
for i in range(l):
    r,s = map(int, input().split())
    unite(1,r,s)
    
pairs = [(find(0,i),find(1,i)) for i in range(1,n+1)]
from collections import Counter
pairc = Counter(pairs)
ans = [pairc[pair] for pair in pairs]

print(*ans)

Measured memory_bytes: 123964
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x,a,b;
    
    cin>>x>>a>>b;
    
    if(a>=b) cout<<"delicious"<<endl;
    else if(b-a<=x) cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,ans;
int main()
{
	char ch[5],ch1[5];
	scanf("%s %s",ch,ch1);
	if(ch[0]==ch1[2]&&ch[1]==ch1[1]&&ch[2]==ch1[0])
        printf("YES\n");
    else
        printf("NO\n");
	return 0;
}

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

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll N,L;
    cin >> N >> L;
    ll mi=llabs(L);
    ll sum=0;
    for(int i=1;i<=N;i++){
        if(llabs(mi)>llabs(L+i-1)) mi=L+i-1;
        sum+=L+i-1;
    }
    cout << sum-mi << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int N, K;
long long nCk[100005];
long long mod = 1e9+7;

// a^n mod を計算する                                                           
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  res %=mod;
  return res;
}

// a^{-1} mod を計算する                                                        
long long modinv(long long a, long long mod) {
  return modpow(a, mod - 2, mod);
}


void init(){
  nCk[K-1]=1;
  for (int i=K; i<100005; i++){
    nCk[i] = ((nCk[i-1]*(long long)i)%mod)*modinv((long long)i-K+1, mod);
    nCk[i]%=mod;
  }
  return;
}

int main(){
  scanf("%d", &N);
  scanf("%d", &K);
  std::vector<long long> A(N);
  for (int i=0; i<N; i++){
    scanf("%lld", &A[i]);
  }
  std::sort(A.begin(), A.end());
  long long ansM = 0;
  long long ansP = 0;
  init();
  for (int i=0; i<N; i++){
    if (N-i-1<K-1) break;
    //printf("i=%d, %lld\n", i, A[i]*nCk[N-i-1]);
    ansM += (A[i]*nCk[N-i-1])%mod;
    ansM %= mod;
  }
  for (int i=N-1; i>=0; i--){
    if (i<K-1) break;
    //printf("i=%d, %lld\n", i, A[i]*nCk[i]);
    ansP += (A[i]*nCk[i])%mod;
    ansP %= mod;
  }
  //printf("ansM=%lld, ansP=%lld\n", ansM, ansP);
  long long ans = ansP-ansM;
  while (ans<0){
    ans+=mod;
  }
  ans%=mod;
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

using real = double;
real EPS = 1e-10;
struct Point {
    real x, y;
    Point& operator+=(const Point a) { x += a.x; y += a.y;  return *this; }
    Point& operator-=(const Point a) { x -= a.x; y -= a.y;  return *this; }
    Point& operator*=(const real k) { x *= k; y *= k;  return *this; }
    Point& operator/=(const real k) { x /= k; y /= k;  return *this; }
    Point operator+(const Point a) const {return Point(*this) += a; }
    Point operator-(const Point a) const {return Point(*this) -= a; }
    Point operator*(const real k) const {return Point(*this) *= k; }
    Point operator/(const real k) const {return Point(*this) /= k; }
    bool operator<(const Point &a) const { return (x != a.x ? x < a.x : y < a.y); }
    explicit Point(real a = 0, real b = 0) : x(a), y(b) {};
};

istream& operator>> (istream& s, Point& P){
    s >> P.x >> P.y;
    return s;
}

inline real dot(Point a, Point b){ return a.x*b.x + a.y*b.y; }
inline real cross(Point a, Point b){ return a.x*b.y - a.y*b.x; }
inline real abs(Point a){ return sqrt(dot(a, a)); }

static constexpr int COUNTER_CLOCKWISE = 1;
static constexpr int CLOCKWISE = -1;
static constexpr int ONLINE_BACK = 2;
static constexpr int ONLINE_FRONT = -2;
static constexpr int ON_SEGMENT = 0;

int ccw(Point a, Point b, Point c){
    b -= a; c -= a;
    if(cross(b, c) > EPS) return COUNTER_CLOCKWISE;
    if(cross(b, c) < -EPS) return CLOCKWISE;
    if(dot(b, c) < 0) return ONLINE_BACK;
    if(abs(b) < abs(c)) return ONLINE_FRONT;
    return ON_SEGMENT;
}
struct Segment {
    Point a, b;
    Segment(Point x, Point y) : a(x), b(y) {};
};

double distance(Segment l, Point c){
    if(dot(l.b-l.a, c-l.a) < EPS) return abs(c-l.a);
    if(dot(l.a-l.b, c-l.b) < EPS) return abs(c-l.b);
    return abs(cross(l.b-l.a, c-l.a)) / abs(l.a-l.b);
}

bool intersect(Segment l1, Segment l2){
    return (ccw(l1.a, l1.b, l2.a)*ccw(l1.a, l1.b, l2.b) <= 0 &&
            ccw(l2.a, l2.b, l1.a)*ccw(l2.a, l2.b, l1.b) <= 0);
}

Point crossPoint(Segment l1, Segment l2){
    real d1 = abs(cross(l1.b-l1.a, l2.b-l2.a));
    real d2 = abs(cross(l1.b-l1.a, l1.b-l2.a));
    if(d1 < EPS && d2 < EPS) return l2.a;
    return l2.a+(l2.b-l2.a)*d2/d1;
}

Point project(Segment s, Point p){
    Point Q = s.b-s.a;
    return s.a + Q*(dot(p-s.a, Q) / dot(Q, Q));
}

Point refrect(Segment s, Point p){
    Point Q = project(s, p);
    return Q*2-p;
}

bool isOrthogonal(Segment s, Segment t){
    return fabs(dot(s.b-s.a, t.b-t.a)) < EPS;
}

bool isparallel(Segment s, Segment t){
    return fabs(cross(s.b-s.a, t.b-t.a)) < EPS;
}


int main() {
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        Point a, b, c, d;
        cin >> a >> b >> c >> d;
        Segment s(a, b), t(c, d);
        cout << intersect(s, t) << "\n";
    }
    return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define N 5005
using namespace std;
typedef long long ll;
ll n,h[N],p[N],tmp[N],ans,nn,tot,dp[N];
struct Node{
	int first,second;
	bool operator < (const Node &other){
		return first+second<other.first+other.second;
	}
};
Node a[N];
int main() 
{
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++){
		scanf("%lld%lld",&a[i].first,&a[i].second);dp[i]=1000000000000000000;
	}sort(a+1,a+1+n);
	for(ll i=1;i<=n;i++){
		for(ll j=n;j>=1;j--){
			if(dp[j-1]<=a[i].first)dp[j]=min(dp[j],dp[j-1]+a[i].second);
		}
	}for(ll j=n;j>=1;j--){
		if(dp[j]<1000000000000000000){
			printf("%lld",j);return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3860
# include <bits/stdc++.h>
# define ll long long
# define pb push_back
# define fi first
# define se second
# define mp make_pair
# define gcd(m,n)  __gcd(m, n)
# define pr_double(x) cout << fixed << setprecision(10) << x
using namespace std;

int main() {
  string s,t;
  cin>>s>>t;
  ll ans = INT_MAX;
  for(ll i=0;i<s.size()-t.size()+1;i++)
  {
      ll k = i; ll c=0;
      for(ll j=0;j<t.size();j++)
      {
          if(s[k]!=t[j]) c++;
          k++;
      }
      ans=min(ans,c);
  }
  cout<<ans<<endl;
}


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

using namespace std;

struct Point
{
    int x_, y_;
    Point() : x_(0), y_(0){}
    Point(const int &x, const int &y) : x_(x), y_(y){}
    Point(const Point &pt)
    {
        x_ = pt.x_;
        y_ = pt.y_;

    }
    void setPoint(const int &x, const int &y)
    {
        x_ = x;
        y_ = y;
    }

};

void updateJewelMap(bool jewel_map[21][21], Point &current_position, const char &direction, const int &step)
{
    for(int i = 0; i < step; i++)
    {
        switch(direction)
        {
        case 'N':
            current_position.y_++;
            break;
        case 'S':
            current_position.y_--;
            break;
        case 'E':
            current_position.x_++;
            break;
        case 'W':
            current_position.x_--;
            break;
        }
        jewel_map[current_position.y_][current_position.x_] = false;
    }
}

bool isGetAllJewel(const bool jewel_map[21][21], const int &width, const int &height)
{
    for(int h = 0; h < height; h++)
    {
        for(int w = 0; w < width; w++)
        {
            if(jewel_map[h][w]){ return false; }
        }
    }
    return true;
}

int main()
{
    bool jewel_map[21][21];
    Point initial_position(10, 10);

    int num_jewel = 0;
    int num_order = 0;

    while(true)
    {
        cin >> num_jewel;
        if(num_jewel == 0){ break; }

        //Initialize jewel map
        for(int h = 0; h < 21; h++)
        {
            for(int w = 0; w < 21; w++)
            {
                jewel_map[h][w] = false;
            }
        }

        //Map jewel positions
        int x, y;
        for(int i = 0; i < num_jewel; i++)
        {
            cin >> x >> y;
            jewel_map[y][x] = true;
        }

        //Set & execute orders
        cin >> num_order;
        char direction;
        int step;
        Point current_position(initial_position);
        jewel_map[current_position.y_][current_position.x_] = false;
        for(int i = 0; i < num_order; i++)
        {
            cin >> direction >> step;
            updateJewelMap(jewel_map, current_position, direction, step); //update jewel_map
        }

        if(isGetAllJewel(jewel_map, 21, 21)){ cout << "Yes" << endl; }
        else                                { cout << "No" << endl; }

    }


    return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls x << 1
#define rs x << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
using namespace std;
const db pi = acos(-1.0);
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}

const int N = 2e5 + 10;
const int INF = 1e9 + 7;
struct Edge
{
    int to, val, next;
}e[N * 4];

int n, m, cnt;
int head[N], ans[N], vis[N];
set<int> st[N];

void ins(int u, int v, int w)
{
	e[++ cnt].next = head[u];
	e[cnt].to = v;
	e[cnt].val = w;
	head[u] = cnt;
}

void insert(int u, int v, int w)
{
	ins(u, v, w);
	ins(v, u, w);;
}

int main()
{
    cnt = 0;
    n = read();
	m = read();
	rep(i, 1, m)
    {
        int p, q, c;
        p = read();
        q = read();
        c = read();
        insert(p, q, c);
    }
    rep(i, 1, n) ans[i] = INF;
    priority_queue<pii> Q;
    Q.push(mp(0, 1));
    int cnt = 0;
    ans[1] = 0;
    while(!Q.empty())
    {
        int dis = -Q.top().X;
        int x = Q.top().Y;
        Q.pop();
        if(dis > ans[x]) continue;
        for(int i = head[x]; i; i = e[i].next)
        {
            int to = e[i].to;
            int c = e[i].val;
            int d = dis + (!st[x].count(c));
            if(d < ans[to])
            {
                ans[to] = d;
                st[to].clear();
                st[to].insert(c);
                Q.push(mp(-d, to));
            }
            else if(d == ans[to]) st[to].insert(c);
        }
    }
    if(ans[n] == INF) puts("-1");
    else printf("%d\n", ans[n]);
    return 0;
}


Measured memory_bytes: 28408
#include<iostream>
using namespace std;
int main(){
int N;
  cin>>N;
  int d[N];
  for ( int i=0; i<N; i++) cin>>d[i];
  int sum=0;
  for (int i=0; i<N; i++) sum+=d[i];
  int cheer=0;
  for (int i=0; i<N; i++){
    cheer+=d[i]*(sum-d[i]);}
  cout<<cheer/2<<endl;
}
    

Measured memory_bytes: 256
fun main(args: Array<String>?): Unit {
    repeat(readLine()!!.trim().toInt()) {
        var current = Coordinate(0, 0)
        var max = current
        while (true) {
            val (dx, dy) = readLine()!!.trim().split(' ').map(String::toInt)
            if (dx == 0 && dy == 0) break
            current += Coordinate(dx, dy)
            if (current.norm2() > max.norm2() || (current.norm2() == max.norm2() && current.x > max.x)){
                max = current
            }
        }
        println("${max.x} ${max.y}")
    }
}

data class Coordinate(val x: Int, val y: Int) {
    operator fun plus(that: Coordinate): Coordinate = Coordinate(x + that.x, y + that.y)
    operator fun minus(that: Coordinate): Coordinate = Coordinate(x - that.x, y - that.y)
    fun norm2(): Int = x * x + y * y
}


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

using namespace std;

using Tree = vector<vector<int>>;

void dfs(Tree &tree, int v, vector<int> &results, int p = -1, int dist = 0) {
  results[v] = dist;
  for (auto neighbor : tree[v]) {
    if (neighbor != p) {
      dfs(tree, neighbor, results, v, dist + 1);
    }
  }
}

int main(int argc, const char *argv[]) {
  int n, u, v;
  cin >> n >> u >> v;
  u--;
  v--;

  Tree tree(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }

  vector<int> u_dists(n), v_dists(n);
  dfs(tree, u, u_dists);
  dfs(tree, v, v_dists);

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (u_dists[i] < v_dists[i]) {
      ans = max(ans, v_dists[i]);
    }
  }

  cout << ans - 1 << '\n';
  return 0;
}

Measured memory_bytes: 12928
#include<bits/stdc++.h>
using namespace std;
pair<int,int> pii;
vector<int> vec;
#define LL long long
int main()
{
  LL n,fl=0;
  LL h[100005];
  cin>>n;
  for(LL i=0; i<n; i++){
    cin>>h[i];
  }

  for(int i=n-1; i>0; i--){
    if(h[i-1]>h[i]){
      if(h[i-1]-1<=h[i]){
	h[i-1]--;
      }else{
	fl=1;
      }
    }
  }


  if(fl)cout<<"No"<<'\n';
  else cout<<"Yes"<<'\n';

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long FINV(int n){
    if (n < 0) return 0;
    return finv[n];
}

int main() {
    // 前処理
    COMinit();

    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    rep(i,n){
        if(i > k)break;
        ll tmp = COM(n,i) * COM(n-1, n-1-i) % MOD;
        ans = (ans + tmp) % MOD;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
const int INF = 100100100;
using namespace std;

int main()
{
  char X, Y;
  cin >> X >> Y;

  if(X<Y) cout << "<" << endl;
  else if(X>Y) cout << ">" << endl;
  else cout << "=" << endl;
}

Measured memory_bytes: 256
program name
    implicit none
    integer(8):: n, i, cnt
    integer(8),allocatable:: a(:)

    read*, n
    allocate(a(n))
    read*, a(:)

    cnt = 0
    do i=1,n
        if (a(i) < 0) then
            cnt=cnt+1
            a(i) = -a(i)
        end if
    end do


    if (mod(cnt,2_8) == 0_8) then
        print*, sum(a)
    else
        print*, sum(a) - 2*minval(a)
    end if
end program name

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  //vector<int> a(n);  rep(i, 0, n) cin >> a.at(i);
  
  cout << (s.substr(0, 4) == "YAKI" ?"Yes" :"No") << "\n";
  
  //cout << fixed << setprecision(10) << n << "\n";

}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var w string
	fmt.Scan(&w)

	m := make(map[rune]int)
	for _, v := range w {
		m[v]++
	}

	for _, v := range m {
		if v%2 != 0 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


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

using namespace std;

int main()
{
	int rectangle_num =0, rhombus_num=0;
	
	int side1, side2, diagonal;
	while( scanf("%d,%d,%d", &side1, &side2, &diagonal) != EOF ){
		if(side2 > side1) swap(side1, side2);
		
		// 長方形の判定
		if( side1*side1 + side2*side2 == diagonal*diagonal){
			rectangle_num++;
		}else if( side1==side2){
			rhombus_num++;
		}
		
	}
	cout<<rectangle_num<<endl<<rhombus_num<<endl;
	
	return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
#include<bitset>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int MOD=1000000007;int inf=1000000007;
int n;
int a[3];
signed main(){
    cin>>n;
    rep(i,3)cin>>a[i];
    vector<int> l(n);
    rep(i,n)cin>>l[i];
    int max=0;
    max|=(1<<n*2);
    int min=inf;
    for(int bit=0;bit<max;bit++){
        vector<int> buf(3,0);
        int mp=0;
        for(int i=0;i<n*2;i+=2){
            int flag=0;
            if(bit&(1<<i))flag++;
            if(bit&(1<<(i+1)))flag+=2;
            if(flag==3){

            }
            else{
                buf[flag]+=l[i/2];
                mp+=10;
            }
            //cout<<flag<<endl;
        }
        bool flag=false;
        rep(i,3){
            if(buf[i]==0)flag=true;
        }
        if(flag)continue;
        rep(i,3){
            mp+=abs(buf[i]-a[i]);
        }
        mp-=30;
        if(mp<min)min=mp;
    }
    cout<<min<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static Scanner scan;

    public static void main(String[] args) {
        scan = new Scanner(System.in);
        System.out.println(comp(scan.nextInt() , scan.nextInt(), scan.nextInt()));
    }

    /**
     * 比較して結果を返します。
     */
    private static String comp(int a, int b, int c) {
        if (a < b && b < c) {
            return "Yes";
        } else {
            return "No";
        }
    }
}

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

const int N = 1e6 + 100;

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    long long a, av, b, bv, t;
    cin >> a >> av >> b >> bv >> t;
    if(bv >= av) {
        cout << "NO" << endl;
    }
    else {
        if(t * (av - bv) >= abs(a-b)) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3652
n, t = map(int, input().split())
ct = [list(map(int, input().split())) for _ in range(n)]
ans = []

for i in ct:
    if i[1] <= t:
        ans.append(i)

if not ans:
    print('TLE')
else:
    ans.sort(key=lambda x: x[0])
    print(ans[0][0])

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int gcd(int a, int b)
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int cd = 0;
    repi(i, n, 0)
    {
        int a;
        cin >> a;
        if (i > 0)
        {
            cd = gcd(cd, a);
        }
        else
        {
            cd = a;
        }
    }
    cout << cd << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h> /* for atof() */
#include<ctype.h>
#define NUMBER '0'
int getop(char []);
void push(double);
double pop(void);
double value[100];
int sp = 0;
char buf[100];
int bufp = 0;

int getch(void);
void ungetch(int);
main()
{
    int type;
    double op2;
    char s[100];
    while ((type = getop(s)) != EOF) {
        switch (type) {
            case NUMBER:
            push(atof(s));
            break;
            case '+':
            push(pop() + pop());
            break;
            case '*':
            push(pop() * pop());
            break;
            case '-':
            op2 = pop();
            push(pop() - op2);
            break; 
            case '\n':
            printf("%.8g\n", pop());
            break;
            default:
            break;
        }
    }
}
void push(double f)
{
    if(sp < 100)
        value[sp++]=f;
    else
        printf("error\n");
}

double pop(void)
{
    if(sp>0)
        return value[--sp];
    else
    {
        printf("error\n");
        return 0.0;
    }
}

int getop(char s[])
{
    int i,c;

    while((s[0] = c = getch()) == ' ' || c =='\t')
        ;
    s[1] = '\0';
    
    i = 0;
    if(!isdigit(c) && c!='.' && c!='-')
        return c;

    if(c=='-')
        if(isdigit(c=getch()) || c == '.')
            s[++i]=c;
        else
        {
            if(c!=EOF)
                ungetch(c);
            return '-';
        }
    
    if(isdigit(c))
        while(isdigit(s[++i] =c =getch()))
            ;

    if(c=='.')
        while(isdigit(s[++i] = c=getch()))
            ;
    
    s[i] = '\0';
    if(c!=EOF)
        ungetch(c);
    return NUMBER;
}


int getch(void)
{
    return (bufp > 0) ? buf[--bufp] : getchar();
}

void ungetch(int c)
{
    if(bufp >= 100)
        printf("error");
    else
        buf[bufp++] = c;
}



Measured memory_bytes: 2128
import itertools
N = int(input())
P = [int(i) for i in input().split()]
Q = [int(i) for i in input().split()]

for i, lst in enumerate(itertools.permutations(range(1, N+1))):
    if list(lst) == P:
        a = i
    if list(lst) == Q:
        b = i


print(abs(a-b))


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){
  
  string s;
  cin >> s;
  bool flag = false;
  if(s[0] == '7')flag = true;
  if(s[1] == '7')flag = true;
  if(s[2] == '7') flag = true;
  if(flag)cout << "Yes" << endl;
  else cout <<"No" << endl;


  return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define MAX 200

void initialize();
bool isEnpty();
bool isFull();
void push(int);
int pop();
int S[MAX];
int top;

int main(){
  int x, num1, num2;
  char s[100];

  initialize();

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
        num1=pop();
        num2=pop();
        push(num2+num1);

    } 
    
    else if ( s[0] == '-' ){
        num1=pop();
        num2=pop();
        push(num2-num1);
    } 
    
    else if ( s[0] == '*' ){
        num1=pop();
        num2=pop();
        push(num2*num1);
    } 
    
    else {
      x = atoi(s);
      push(x);
    }
  }

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

void initialize(){
    top=0;
}

bool isEnpty(){
    return top == 0;
}

bool isFull(){
    return top >= MAX;
}

void push(int x){
    if(isFull()){
        fprintf(stderr, "オーバーフロー\n");
        exit(0);
    }
    top++;
    S[top]=x;
}

int pop(){
    if(isFull()){
        fprintf(stderr, "アンダーフロー\n");
        exit(1);
    }
    top--;
    return S[top+1];
}


Measured memory_bytes: 2140
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#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 <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define T int t = 0; cin >> t; while(t--)
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef long double lld;
const ll mod = 1000007;
const int mx = 2e5 + 1;
const int inf = 1e6;

void input(){
   int A, B, M;
   cin >> A >> B >> M;
   map<int, int>refri, micro;
   int ans = INT_MAX;
   int re = INT_MAX, mi = INT_MAX;
   f(i, A){
       int x;
       cin >> x;
       refri[i] = x;
       re = min(re, x);
   }
   f(i, B){
       int x;
       cin >> x;
       micro[i] = x;
       mi = min(mi, x);
   }
   ans = re + mi;
   while(M--){
       int x, y, c;
       cin >> x >> y >>c;
       --x; --y;
       ans = min(ans, refri[x] + micro[y] - c);
   }
   cout << ans << endl;

}
int main(){
    input();
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> que;
    int a;
    rep(i, n) {
        cin >> a;
        que.push(a);
    }
    int tmp;
    while(m > 0) {
        tmp = que.top();
        que.pop();
        tmp /= 2;
        que.push(tmp);
        m--;
    }
    ll ans = 0;
    while(!que.empty()) {
        ans += que.top();
        que.pop();
    }

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

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  vector<int> res;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      res.push_back(a.at(i));
    } else {
      res.insert(res.begin(), a.at(i));
    }
  }
  if (n % 2 == 1) {
    reverse(res.begin(), res.end());
  }
  rep(i, n) {
    cout << res.at(i);
    if (i != n - 1) {
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3828