akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#define N 200005
using namespace __gnu_pbds;
const int mod = 1e9 + 7;
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
LL z = 1;
int read(){
	int x, f = 1;
	char ch;
	while(ch = getchar(), ch < '0' || ch > '9') if(ch == '-') f = -1;
	x = ch - '0';
	while(ch = getchar(), ch >= '0' && ch <= '9') x = x * 10 + ch - 48;
	return x * f;
}
int ksm(int a, int b, int p){
	int s = 1;
	while(b){
		if(b & 1) s = z * s * a % p;
		a = z * a * a % p;
		b >>= 1;
	}
	return s;
}

int maxn = N - 5, fac[N], inv[N];
int C(int n, int m){
	return z * fac[n] * inv[m] % mod * inv[n - m] % mod; 
}
int main(){
	int i, j, a, b, n, m, c, d, ans, sum = 0;
	for(fac[0] = i = 1; i <= maxn; i++) fac[i] = z * fac[i - 1] * i % mod;
	inv[maxn] = ksm(fac[maxn], mod - 2, mod);
	for(i = maxn - 1; i >= 0; i--) inv[i] = z * inv[i + 1] * (i + 1) % mod;
	scanf("%d%d%d%d", &n, &m, &c, &d);
	ans = C(n + m - 2, n - 1);
	for(i = 1; i <= d; i++){
		a = n - c;
		b = i - 1;
		j = C(a + b, a);
		j = (j - sum) % mod;
		sum = (sum + j) % mod;
		j = z * j * C(c - 1 + m - i, c - 1) % mod;
		//printf("%d %d\n", i, j);
		ans = (ans - j) % mod;
	}
	ans = (ans + mod) % mod;
	printf("%d", ans);
	return 0;
}


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

int main()
{
    int N,four=0,two=0,sonota=0;
    bool yatta = false;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a.at(i);
    }
    //sort(a.begin(), a.end());

    //an.at(0) = a.at(0);
    /*for (int i = 1; i < N; i++)
    {
        for (int j = 1; j < N;j++)
        {
            if(tta.at(j)==true)
            {
                continue;
            }
            else if((an.at(i-1)*a.at(j))%4==0)
            {
                an.at(i) = a.at(j);
                tta.at(j) = true;
                break;
            }
        }
    }*/
    for (int i = 0; i < N;i++)
    {
        if(a.at(i)%4==0)
        {
            four++;
        }else if(a.at(i)%2==0)
        {
            two++;
        }else
        {
            sonota++;
            //cout << sonota << endl;
        }
    }

    if(sonota<=four+1 && two==0)
    {
        yatta = true;
    }
    else if(sonota<=four && two>=1)
    {
        yatta = true;
    }

    if(yatta==true)
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 640
#include<cstdio>
#include<string>
#include<vector>
#include<iostream>

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

using namespace std;

class dice{
	int a[6];
public:
	dice(){}
	dice(int t,int l,int f,int r,int b,int d){
		a[0]=t; a[1]=l; a[2]=f;
		a[3]=r; a[4]=b; a[5]=d;
	}
	bool operator==(const dice &D)const{
		rep(i,6) if(a[i]!=D.a[i]) return false;
		return true;
	}
	bool operator!=(const dice &D)const{ return !(D==*this); }
	int operator[](int i)const{ return a[i]; }
	int &operator[](int i){ return a[i]; }
	void rotx(){ int tmp=a[0]; a[0]=a[4]; a[4]=a[5]; a[5]=a[2]; a[2]=tmp; }
	void roty(){ int tmp=a[0]; a[0]=a[1]; a[1]=a[5]; a[5]=a[3]; a[3]=tmp; }
	void rotz(){ int tmp=a[1]; a[1]=a[4]; a[4]=a[3]; a[3]=a[2]; a[2]=tmp; }
};

vector<dice> get_all(dice D){
	vector<dice> res;
	rep(i,6){
		rep(j,4){
			res.push_back(D);
			D.rotz();
		}
		if(i%2==0) D.rotx();
		else       D.roty();
	}
	return res;
}

struct node{
	int y,x,id; // y, x, dice direction
};

int main(){
	int h,w; cin>>h>>w;
	string B[12];
	rep(y,h) cin>>B[y];
	string label[6];
	rep(i,6) cin>>label[i];
	int sx,sy,gx,gy; cin>>sy>>sx>>gy>>gx; sx--; sy--; gx--; gy--;

	vector<dice> S=get_all(dice(0,1,2,3,4,5));
	vector< pair<node,node> > E;
	rep(y,h) rep(x,w) rep(id,24) {
		// y--
		if(y>0 && (B[y][x]=='+' || B[y][x]=='|' || B[y][x]=='^')){
			dice D=S[id];
			D.rotx(); D.rotx(); D.rotx();
			int id2;
			for(id2=0;D!=S[id2];id2++);
			E.push_back(make_pair((node){y,x,id},(node){y-1,x,id2}));
		}
		// y++
		if(y+1<h && (B[y][x]=='+' || B[y][x]=='|' || B[y][x]=='v')){
			dice D=S[id];
			D.rotx();
			int id2;
			for(id2=0;D!=S[id2];id2++);
			E.push_back(make_pair((node){y,x,id},(node){y+1,x,id2}));
		}
		// x--
		if(x>0 && (B[y][x]=='+' || B[y][x]=='-' || B[y][x]=='<')){
			dice D=S[id];
			D.roty(); D.roty(); D.roty();
			int id2;
			for(id2=0;D!=S[id2];id2++);
			E.push_back(make_pair((node){y,x,id},(node){y,x-1,id2}));
		}
		// x++
		if(x+1<w && (B[y][x]=='+' || B[y][x]=='-' || B[y][x]=='>')){
			dice D=S[id];
			D.roty();
			int id2;
			for(id2=0;D!=S[id2];id2++);
			E.push_back(make_pair((node){y,x,id},(node){y,x+1,id2}));
		}
	}

	int s_id;
	for(s_id=0;S[s_id][0]!=0||S[s_id][4]!=1;s_id++);

	// Bellman-Ford
	string d[12][12][24];
	rep(y,h) rep(x,w) rep(id,24) d[y][x][id]="no";
	rep(id,24) d[gy][gx][id]=label[S[id][0]];

	rep(t,24*h*w+1){
		bool changed=false;
		rep(i,E.size()){
			const node &u=E[i].first,&v=E[i].second;
			string &d_u=d[u.y][u.x][u.id];
			string &d_v=d[v.y][v.x][v.id];
			if(d_v=="no") continue;

			string d2=label[S[u.id][0]]+d_v;
			if(d_u=="no" || d_u>d2){
				d_u=d2;
				changed=true;
				// if(t==h*w*24 && u.y==sy && u.x==sx && u.id==s_id){
				if(t>h*w*4 && u.y==sy && u.x==sx && u.id==s_id){ // h*w*24 まで見ると TLE するので嘘っぽい上界で適当に打ち切る
					cout<<"infinite"<<endl;
					return 0;
				}
			}
		}
		if(!changed) break;
	}

	cout<<d[sy][sx][s_id]<<endl;

	return 0;
}

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

int main()
{
  string s,t;
  cin >> s>>t;
  int a,b;
  cin >>a>>b;
  string u;
  cin >>u;
  if (u==s) a--;
  else if(u==t) b--;
  cout <<a <<" "<<b<<endl;
  
}

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

#define INF 1 << 29
#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;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int n,m;
int graph[8][8] = {{0}};
ll sum = 0;
bool visited[8] = {false};
void dfs(int now,bool visited[],int graph[8][8]){
  bool flag = true;
  REP(i,n){
    flag &= visited[i];
  }
  if(flag){
    sum++;
    return;
  }
  REP(i,n){
    if(graph[now][i] == 0) continue;
    if(visited[i]) continue;
    bool tmp = visited[i];
    visited[i] = true;
    graph[now][i]--;
    graph[i][now]--;
    dfs(i,visited,graph);
    visited[i] = tmp;
    graph[now][i]++;
    graph[i][now]++;
  }
  return;
}

int main(){
  scanf("%d %d",&n,&m);
  REP(i,m){
    int a,b;
    scanf("%d %d",&a,&b);
    a--;b--;
    graph[a][b] = 1;
    graph[b][a] = 1;
  }
  visited[0] = true;
  dfs(0,visited,graph);
  printf("%lld\n",sum);
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);

	if (
		(a == b && b != c)
		|| (a == c && b != c)
		|| (b == c && a != b)
		) {
		printf("Yes\n");
	}

	else
		printf("No\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int num[1000005];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>num[i];
	int be;
	be  = 0;
	int ans = 0;
	for(int i=1;i<n;i++)
	{
		if(num[i] == i)
		{
			ans++;
			swap(num[i],num[i+1]);
		}
	}
	if(num[n] == n) ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
N = int(input())
inf = 10 ** 6
dp = [inf] * (N + 1)
dp[0] = 0
for i in range(N):
  if i + 1 <= N:
    dp[i + 1] = min(dp[i] + 1, dp[i + 1])
  for j in range(1, 8):
    if i + 6 ** j <= N:
      dp[i + 6 ** j] = min(dp[i] + 1, dp[i + 6 ** j])
  for j in range(1, 7):
    if i + 9 ** j <= N:
      dp[i + 9 ** j] = min(dp[i] + 1, dp[i + 9 ** j])
print(dp[N])

Measured memory_bytes: 3828
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

manzoku = 0
i_b = 100
for i in a:
    manzoku+=b[i-1]
    if i-1 == i_b:
        manzoku+=c[i-2]
    i_b = i

        
print(manzoku)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef double db;

void file_put() {
    freopen("filename.in", "r", stdin);
    freopen("filename.out", "w", stdout);
}

map<char,int> M; int n;
char st[10005];

int main() {
//    file_put();
    
    scanf("%s",st),n=strlen(st);
    rep(i,0,n) M[st[i]]++;
    if (M.count('W') && !M.count('E')) return 0*printf("No\n");
    if (M.count('E') && !M.count('W')) return 0*printf("No\n");
    if (M.count('N') && !M.count('S')) return 0*printf("No\n");
    if (M.count('S') && !M.count('N')) return 0*printf("No\n");
    printf("Yes\n");
    
	return 0;
}



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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1LL << 60;

//Write From this Line

int main()
{
	int n ;
	cin >> n ;
	vector<string>  s(n) ;
	vector<int> t(n);
	rep(i,n) cin >> s[i] >> t[i] ;
	string a ;
	cin >>  a ;
	bool flag = false; 
	int ans = 0 ;
	rep(i,n){
		if(flag){
			ans += t[i];
		}
		if(s[i] == a){
			flag = true; 
		}
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b,c=-1,d;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        if(c<a){
            c=a;
            d=b;
        }
    }
    cout <<c+d<<endl;
    return 0;
}


Measured memory_bytes: 256
var
	h,w,k,i,j:Longint;
	m:int64=1000000007;
	dp:array[0..100,0..7]of int64;
	p:array[0..7]of Longint=(1,1,2,3,5,8,13,21);
begin
	read(h,w,k);
	dp[0,0]:=1;
	for i:=0 to h-1 do for j:=0 to w-1 do begin
		if j>0 then dp[i+1,j-1]:=(dp[i+1,j-1]+dp[i,j]*p[j-1]*p[w-j-1])mod m;
		dp[i+1,j]:=(dp[i+1,j]+dp[i,j]*p[j]*p[w-j-1])mod m;
		if j<w-1 then dp[i+1,j+1]:=(dp[i+1,j+1]+dp[i,j]*p[j]*p[w-j-2])mod m;
	end;
	writeln(dp[h,k-1]);
end.

Measured memory_bytes: 128
#include <iostream>
    #include <string>
    #include <set>  
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
	#include <cassert>
    #include <iomanip>
    #include <sstream>
using namespace std;
long long X;
long long sum=0;
int main()
{
	cin>>X;
	int i=0;
	while(sum<X)
	{
		i++;
		sum+=i;
	}
	cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int  long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> pipii;
typedef priority_queue<int, vector<int>, greater<int>> minpq;
typedef priority_queue<int> maxpq;
const long double PI = 3.14159265358979323846264338327950;
const int mod = 1000000007;


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    vi arr(n);
    fo(i,n) cin>>arr[i];
    vi sideways(n-1);
    for(int i =0;i <  sideways.size();i++){
        sideways[i] = arr[i]^arr[i+1];
    }
    for(int i =1;i <  sideways.size();i=i+2){
        arr[0]^=sideways[i];
    }
    int an = arr[0];
    //deb(an);
    vi ans(n);
    ans[n-1]=an;
    for(int i = n-2;i>=0;i--){
        ans[i] = sideways[i]^an;
        an = ans[i];
       // deb(an);
    }
    tr(it,ans){
        cout<<*it<<" ";
    }


  


}


Measured memory_bytes: 7908
from collections import Counter
N=int(input())
A=sorted(list(map(int,input().split())))
c=Counter(A)
if 1 in A:
    if c[1]==1:
        print(1)
    else:
        print(0)
    exit()
n=max(A)
ans=[0]*(n+1)
for k,v in c.items():
    if v==1:
        ans[k]=1
for i in c.keys():
    t=i*2
    while t<=n:
        ans[t]=0
        t+=i
print(sum(ans))

Measured memory_bytes: 122532
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>

using namespace std;

using ll = long long;

#define int ll

int count_lts(ll x, ll k, vector<ll> const& v, int start, int last) {
  if (x <= k * v[start]) return 0;
  auto l = start, r = last;
  while (r - l > 1) {
    auto m = (l + r) / 2;
    ((k * v[m] < x) ? l : r) = m;
  }
  return r - start;
}

int count_les(ll x, ll k, vector<ll> const& v, int start, int last) {
  if (x < k * v[start]) return 0;
  auto l = start, r = last;
  while (r - l > 1) {
    auto m = (l + r) / 2;
    ((k * v[m] <= x) ? l : r) = m;
  }
  return r - start;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n, k;
  cin >> n >> k;
  vector<ll> poss, negs;
  ll zeros = 0;
  for (ll i = 0; i < n; i++) {
    ll a;
    cin >> a;
    if (a > 0)
      poss.push_back(a);
    else if (a == 0)
      zeros++;
    else
      negs.push_back(a);
  }
  sort(begin(poss), end(poss));
  sort(begin(negs), end(negs));
  ll nps = poss.size() * negs.size(),
     nzs = zeros * (poss.size() + negs.size()) + zeros * (zeros - 1) / 2;
  if (k <= nps) {
    ll l = -LLONG_MAX / 2, r = 0;
    while (r - l > 1) {
      ll m = (l + r) / 2;
      int le = 0, lt = 0;
      for_each(rbegin(poss), rend(poss), [&] (auto p) {
        le += count_les(m, p, negs, 0, negs.size());
        lt += count_lts(m, p, negs, 0, negs.size());
      });
      if (lt < k && k <= le) {
        l = m;
        break;
      }
      (le < k ? l : r) = m;
    }
    cout << l << endl;
  }
  else if (k <= nps + nzs) {
    cout << 0 << endl;
  }
  else {
    ll l = 0, r = LLONG_MAX / 2;
    int rest = k - nps - nzs;
    vector<ll> pneg(negs.size());
    for (int i = 0; i < negs.size(); i++)
      pneg[negs.size() - 1 - i] = -negs[i];
    while (r - l > 1) {
      ll m = (l + r) / 2;
      int le = 0, lt = 0;
      for (int i = 0; i < poss.size(); i++) {
        le += count_les(m, poss[i], poss, i + 1, poss.size());
        lt += count_lts(m, poss[i], poss, i + 1, poss.size());
      }
      for (int i = 0; i < pneg.size(); i++) {
        le += count_les(m, pneg[i], pneg, i + 1, pneg.size());
        lt += count_lts(m, pneg[i], pneg, i + 1, pneg.size());
      }
      if (lt < rest && rest <= le) {
        l = m;
        break;
      }
      (le < rest ? l : r) = m;
    }
    cout << l << endl;
  }
}


Measured memory_bytes: 3056
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int min = Math.min(a, b);
		int max = Math.max(a, b);
		if(min <= 0 && max >= 0 || min == 0 || max == 0) {
			System.out.println("Zero");
		} else {
			if(min <= 0 && max <= 0) {
				System.out.println(((Math.abs(max - min))) % 2 == 0 ? "Negative" : "Positive");
			} else {
				System.out.println("Positive");
			}
		}
	}
}


Measured memory_bytes: 35784
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,x=1,i;
	cin>>n;
	for(i=2;;i=i*2)
	{
		if(n!=1)
		{
		n=n/2;
		x=x+i;
		}
		else
		{
			break;
		}
	}	
	cout<<x<<endl;
}


Measured memory_bytes: 3580
function Main(input) {
  input = input.split(" ");
  var a = parseInt(input[0], 10);
  var b = parseInt(input[1], 10);
  var t = parseInt(input[2], 10);
  console.log('%d',Math.floor((t + 0.5) / a) * b);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<stdio.h>
int main(void)
{
	int n,m,max,i,j,sum,k,r[50],b[50],w[50];
	char s[50][51];
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		w[i]=0;
		b[i]=0;
		r[i]=0;
	}
	for(i=0;i<n;i++){
		scanf("%s",s[i]);
		for(j=0;j<m;j++){
			if(s[i][j]!='W'){
				w[i]++;
			}
			if(s[i][j]!='B'){
				b[i]++;
			}
			if(s[i][j]!='R'){
				r[i]++;
			}
		}
	}
	max=2501;
	for(i=0;i<n-2;i++){
		for(j=0;j<n-1;j++){
			sum=0;
			for(k=0;k<=i;k++){
				sum+=w[k];
			}
			for(k=i+1;k<=j;k++){
				sum+=b[k];
			}
			for(k=j+1;k<n;k++){
				sum+=r[k];
			}
			if(sum<max){
				max=sum;
			}
		}
	}
	printf("%d\n",max);
	return 0;
}


Measured memory_bytes: 2076
#include<bits/stdc++.h>
using namespace std;
long long M=1e9+7;
void solve(){
	int n;
	cin>>n;
	long long sum=0,ans=0,p;
	for(int i=0;i<n;i++){
		cin>>p;
		ans= (ans+(p*sum)%M)%M;
		sum=(sum+p)%M;
	}
	cout<<ans;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();

}

Measured memory_bytes: 3648
#include<stdio.h>
int main(void)
{
	int i,n;
	float f,s,y;
	while(scanf("%f",&s)!=EOF) {
		i=1;
		while(1)
		{
			n=5*i-5;
			y=n;
			f=2*9.8*y;
			if(s*s<=f) {
			printf("%d\n",i);
			break;
			}
			else {
				i++;
			}
		}
	}
	return 0;
}

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

int
main()
{
  int64_t X, K, D;
  cin >> X >> K >> D;

  lldiv_t divmod = lldiv(X, D);
  int64_t quot_abs = abs(divmod.quot);
  int64_t result;
  if (K < quot_abs) {
    result = X >= 0 ? X - D * K : X + D * K;
  } else {
    if ((K - quot_abs) % 2 == 0) {
      result = divmod.rem;
    } else {
      result = X >= 0 ? divmod.rem - D : divmod.rem + D;
    }
  }
  cout << abs(result) << endl;
  return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int n;cin >> n;
  vector<int> nums(n);
  rep_i(i, n){
    nums[i] = i + 1;
  }

  do {
    for (vector<int>::iterator i = nums.begin(); i != nums.end(); i++)
    {
      if(i == nums.begin()){
        cout << *i;
        continue;
      }
      cout << " " << *i;
    }
    cout << endl;
  }while(next_permutation(nums.begin(), nums.end()));

  // if(prev_permutation(nums.begin(), nums.end())){
  //   for (vector<int>::iterator i = nums.begin(); i != nums.end(); i++)
  //   {
  //     if(i == nums.begin()){
  //       cout << *i;
  //       continue;
  //     }
  //     cout << " " << *i;
  //   }
  //   cout << endl;
  // }
  // next_permutation(nums.begin(), nums.end());
  // for (vector<int>::iterator i = nums.begin(); i != nums.end(); i++)
  // {
  //   if(i == nums.begin()){
  //     cout << *i;
  //     continue;
  //   }
  //   cout << " " << *i;
  // }
  // cout << endl;
  // if(next_permutation(nums.begin(), nums.end())){
  //   for (vector<int>::iterator i = nums.begin(); i != nums.end(); i++)
  //   {
  //     if(i == nums.begin()){
  //       cout << *i;
  //       continue;
  //     }
  //     cout << " " << *i;
  //   }
  //   cout << endl;
  // }
}


Measured memory_bytes: 3100
#include<iostream>
#include<string>
#define ll long long
using namespace std;
int main()
{
	//string  dog;
	//string pig;
	//getline(cin, dog);
	//getline(cin, pig);
	//string cat = pig.substr(0, pig.size() - 1);
	////cout << cat;
	//if (dog == cat)
	//	cout << "Yes";
	//else
	//	cout << "No";
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll ans = 0;
	while (k >0)
	{
		if (a > 0) {
			a -= 1;
			ans += 1;
			k -= 1;
			//cout << "a" << endl;
		}
		else if (b > 0) 
		{
			b -= 1;
			k -= 1;
			//cout << "b" << endl;
		}
		else if (c > 0)
		{
			c -= 1;
			ans -= 1;
			k -= 1;
			//cout << "c" << endl;
		}
		
	}
	cout << ans;
	
    return 0;
}



Measured memory_bytes: 3540
#include <iostream>
#include<algorithm>
using namespace std;
void pairsort(float a[], float b[], int n) 
{ 
    pair<float, float> pairt[n]; 
  
    // Storing the respective array 
    // elements in pairs. 
    for (int i = 0; i < n; i++)  
    { 
        pairt[i].first = a[i]; 
        pairt[i].second = b[i]; 
    } 
  
    // Sorting the pair array. 
    sort(pairt, pairt + n); 
      
    // Modifying original arrays 
    for (int i = 0; i < n; i++)  
    { 
        a[i] = pairt[i].first; 
        b[i] = pairt[i].second; 
    } 
} 
int main()
{
    int n,i;
    float t,a;
    scanf("%d",&n);
    scanf("%f%f",&t,&a);
    float b[n],c[n];
    for(i=0;i<n;i++)
    {
        scanf("%f",&b[i]);
        b[i]=t-((0.006)*b[i]);
        if((b[i]-a)>0)
        {
        b[i]=b[i]-a;
        c[i]=i+1;
        }
        else
        {
        b[i]=a-b[i];
        c[i]=i+1;
        }
    }
    pairsort(b,c,n);
    printf("%.0f",c[0]);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = str(input())

import itertools
ans=0

for num in range(1000):
	num=str(num).zfill(3)
	a0=S.find(str(num[0]))
	if a0>=0:
		S1=S[(a0+1):]
		a1=S1.find(str(num[1]))
		if a1>=0:
			S2=S1[(a1+1):]
			if str(num[2]) in S2:
				ans+=1

		



print(ans)





# 2darray [[0] * 4 for i in range(3)]

Measured memory_bytes: 9308
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	ll n;
	cin >> n;
	ll copy = n;
	int keta = 0;
	while(copy>0){
		copy /= 10;
		keta++;
	}
	int ans = 0;
	queue<string> que;
	que.push("7");
	que.push("5");
	que.push("3");
	while(1){
		string ss = que.front();
		que.pop();
		if((int)ss.size() > keta) break;
		set<char> sc;
		rep(i,ss.size()) sc.insert(ss[i]);
		if(sc.size() == 3 && atoi(ss.c_str()) <= n) ans ++;
		string s1 = "7", s2 = "5", s3 = "3";
		que.push(ss+s1); que.push(ss+s2); que.push(ss+s3);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int N;
  cin >> N;
  vector<int> PM(N);
  int sum = 0;
  rep(i, N) {
    cin >> PM.at(i);
    sum += PM.at(i);
  }
  int M;
  cin >> M;
  int P, X;
  rep(i, M) {
    cin >> P >> X;
    cout << sum - PM.at(P - 1) + X << endl;
  }
}

Measured memory_bytes: 3608
def main():
    x = int(input())
    if (x % 11) == 0:
        ans = (x // 11) * 2
    else:
        if x % 11 <= 6:
            ans = (x // 11) * 2 + 1
        else:
            ans = (x // 11) * 2 + 2
    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
     string s;
     cin >> s;
     if(s[2]==s[3]&&s[4]==s[5]){
         cout << "Yes" << endl;
     }else {
         cout << "No" << endl;
     }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int num[4];
	int n,i,j;
	int hit,blow;
	
	while(scanf("%d %d %d %d", &num[0], &num[1], &num[2], &num[3]) != EOF){
		hit = blow = 0;
		
		for(i = 0; i < 4; i++){
			scanf("%d", &n);
			if(num[i] == n)hit++;
			else {
				for(j = 0; j < 5; j++){
					if(num[j] == n){
						blow++;
						break;
					}
				}
			}
		}
		printf("%d %d\n", hit, blow);
	}
	
	return(0);
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

ll r,d,x;

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> r >> d >> x;

  for (int i = 0; i < 10; i++) {
    x = r * x - d;
    cout << x << endl;
  }

  return 0;
}


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

int main() {
	int N;cin>>N;
	vector<int>a(N);
	for(int i=0;i<N;i++)cin>>a[i];
	
	int cnt = 0;
	for(int i=0;i<N;i++)
	{
		if(a[i] == cnt+1)
		{
			cnt++;
		}
	}
	
	if(cnt==0)cout<<-1<<endl;
	else cout<<N-cnt<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define M 10000001
#define MAX 10000000000000010
#define mod 1000000007
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

ll fast_expo(ll base,ll p)
{
	ll ans = 1;
	while(p)
	{
		if(p&1)
		{
			ans = (ans*base)%mod;
		}
		base = (base*base)%mod;
		p/=2;
	}
	return ans;
}

int main()
{
	ll n,a,b;
	cin>>n>>a>>b;
	ll part1 = fast_expo(2,n);
	ll part2 = 1,part3 = 1,facta=1,factb=1,n1=n;
	for(ll i=1;i<=a;i++){
		part2 = (part2*n1)%mod;
		n1--;
		facta = (facta*i)%mod;
	}
	n1 = n;
	for(ll i=1;i<=b;i++){
		part3 = (part3*n1)%mod;
		factb = (factb*i)%mod;
		n1--;
	}
	part2 = (part2*fast_expo(facta,mod-2))%mod;
	part3 = (part3*fast_expo(factb,mod-2))%mod;
	part1 = (part1-part2-part3 + 2*mod)%mod;
	part1 = (part1-1+mod)%mod;
	cout<<part1<<endl;

	return 0;
}

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

#define all(v) (v).begin(), (v).end()
using namespace std;

struct info
{
    int type, value;

    info(){}

    info(int T, int V)
    {
        type = T, value = V;
    }

    const int operator<(info &A)
    {
        return (value < A.value);
    }
};

int main()
{
    int no_of_elements, no_of_choices;
    cin >> no_of_elements >> no_of_choices;

    vector <info> A(no_of_elements);
    for(int i = 0; i < no_of_elements; i++)
        cin >> A[i].type >> A[i].value;

    sort(all(A));
    reverse(all(A));

    vector <int> used(no_of_elements + 1, false);
    priority_queue <long long,vector<long long>, greater<long long> >Q;

    long long sum = 0, distinct_types = 0;
    for(int i = 0; i < no_of_choices; i++)
    {
        sum += A[i].value;

        if(!used[A[i].type])
        {
            used[A[i].type] = true;
            distinct_types++;
        }
        else
        {
            Q.push(A[i].value);
        }
    }
    sum += distinct_types*distinct_types;

    long long new_sum = sum;

    for(int i = no_of_choices; i < no_of_elements; i++)
    {
        if(used[A[i].type] || Q.size() == 0) continue;

        long long smallest = Q.top();

        new_sum += (A[i].value - smallest) + (distinct_types + 1)*(distinct_types + 1) - (distinct_types*distinct_types);

        Q.pop();

        distinct_types++;

        used[A[i].type] = true;


        sum = max(sum, new_sum);
    }

    cout << sum;
    return 0;
}


Measured memory_bytes: 2044
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,q;
	cin >> n >> q;
	string s;
	cin >> s;
	ll dp[n];
	dp[0]=0;
	rep(i,1,n){
		if(s[i]=='C' && s[i-1]=='A') dp[i]=dp[i-1]+1;
		else dp[i]=dp[i-1];
	}
	//rep(i,0,n) trace1(dp[i]);
	rep(i,0,q){
		ll l,r;
		cin >> l >> r;
		l--;r--;
		ll ans=dp[r];
		if(l>0) ans-=dp[l];
		//trace4(r,dp[r],l,dp[l-1]);
		cout << ans << "\n";
	}
	return 0;
}


Measured memory_bytes: 1872
using System;

public class Hello
{
    public static void Main()
    {
        var dset = 1;
        while (true)
        {
            var wmax = int.Parse(Console.ReadLine().Trim());
            if (wmax == 0) break;
            var n = int.Parse(Console.ReadLine().Trim());
            var vaL = new int[n + 1];
            var w = new int[n + 1];
            var dp = new int[n + 1, wmax + 1];
            DpSet(dp, vaL, w);
            for (int i = 0; i < n; i++)
                for (int j = 0; j <= wmax; j++)
                {
                    if (j < w[i]) dp[i + 1, j] = dp[i, j];
                    else dp[i + 1, j] = Math.Max(dp[i, j], dp[i, j - w[i]] + vaL[i]);
                }
            var answ = 0;
            for (int i = 0; i <= wmax; i++)
                if (dp[n, i] == dp[n, wmax]) { answ = i; break; }
            Console.WriteLine("Case {0}:", dset++);
            Console.WriteLine(dp[n, wmax]);
            Console.WriteLine(answ);
        }
    }
    public static void DpSet(int[,] dp, int[] vaL, int[] w)
    {
        for (int i = 0; i < vaL.Length - 1; i++)
        {
            string[] line2 = Console.ReadLine().Trim().Split(',');
            vaL[i] = int.Parse(line2[0]);
            w[i] = int.Parse(line2[1]);
        }
    }
}

Measured memory_bytes: 13336
def static_sushi(N: int, C: int, XV: list) -> int:
    Sv = [0] * (N+1)
    fr, fl = [0] * (N+1), [0] * (N+1)
    gr, gl = [0] * (N+1), [0] * (N+1)
    for i, (x, v) in enumerate(XV):
        Sv[i+1] = Sv[i] + v

        fl[i+1] = Sv[i+1] - x
        gl[i+1] = max(gl[i], fl[i+1])

        fr[i+1] = Sv[i+1] - 2*x
        gr[i+1] = max(gr[i], fr[i+1])

    max_cal = 0
    for ib, (xb, _) in enumerate(XV+[(C,0)]):
        cal_a1, cal_a2 = gr[ib], gl[ib]
        cal_b1, cal_b2 = Sv[N] - Sv[ib] - (C-xb), Sv[N] - Sv[ib] - 2*(C-xb)
        cal1, cal2 = cal_a1 + cal_b1, cal_a2 + cal_b2
        max_cal = max(max_cal, cal1, cal2)

    return max_cal


if __name__ == "__main__":
    N = 0
    N, C = map(int, input().split())
    XV = [tuple(map(int, input().split())) for _ in range(N)]
    ans = static_sushi(N, C, XV)
    print(ans)


Measured memory_bytes: 31656
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
#include <complex>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

typedef complex<double> Point;
Point p[300];

double sqr(double x){ return x*x; }

bool isok(Point& e, Point& q){
    return (sqr(e.real() - q.real()) + sqr(e.imag() - q.imag()) < 1.0);
}

/*
 Point(0,1)@¶É90xñ]
 Point(0,-1)@EÉ90xñ]
 */
int main(){
    int n,i,j,k, res;

    while( scanf("%d",&n), n ){
        res = 1;
        rep(i,n) cin >> p[i].real() >> p[i].imag();

        rep(i,n){
            REP(j,i+1,n){
                double dist = sqr(p[i].real() - p[j].real()) + sqr(p[i].imag() - p[j].imag());
                if( dist < 4.0 ){
                    dist /= 4.0; // (d/2)^2
                    double x = sqrt(1.0 - dist); // x
                    Point M((p[i].real() + p[j].real())/2.0, (p[i].imag() + p[j].imag())/2.0);

                    Point d = (p[i] - p[j])/abs(p[i] - p[j]);
                    Point e1 = M + d*Point(0,-1)*x;
                    Point e2 = M + d*Point(0,1)*x;

                    int cnt1 = 2, cnt2 = 2;

                    rep(k,n) if( i != k && j != k ){ // e1
                        if( isok(e1, p[k]) ) cnt1++;
                        if( isok(e2, p[k]) ) cnt2++;
                    }
                    res = max(res, max(cnt1,cnt2));
                }
            }
        }

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

Measured memory_bytes: 1004
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second

using namespace std;
  
bool compare(const pair<int,int> &a , const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 


int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   
   
   int x,n;
   cin>>x>>n;
  
   int temp , ans=0;
   
   bool check[102]={};
   
   for(int i=0;i<n;i++)
   {
       cin>>temp;
       
       check[temp]=true;
   }
   
   for(int i=0;i<=101;i++)
   {
       if(check[i]==false)
       {
           if(abs(i-x) < abs(ans - x))
           ans = i;
       }
   }
   
   cout<<ans<<endl;
   return 0;
}


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

#define ll long long
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define int long long
#define INF 1e9
#define pii pair<int,int>
#define pt(xx) cout << "\n" \
                    << xx << "\n"
#define debugv(x, n)               \
    cout << "\n"                   \
         << #x << ": ";            \
    rep(i, n) cout << x[i] << " "; \
    cout << endl
#define debug2d(x, m, n)            \
    cout << "\n"                    \
         << #x << " is: \n";        \
    for (int i = 0; i < m; ++i)     \
    {                               \
        for (int j = 0; j < n; ++j) \
        {                           \
            cout << x[i][j] << " "; \
        }                           \
        cout << endl;               \
    }
#define nl cout << endl

#define MOD 1000000007
int i, j, k, l, m;
int N, M, K, X;
int W, H, x, y;
int ans;


const int  GOLD=0;
const int  SILVER=1;
const int  BRONS=2;

vector<vector<pair<int,int>>> T(100002);

int ww;
int tb[100005] = {};
void dfs(int n, int state, int before){
    tb[n] = state;
    for (auto e: T[n]){
        if (e.first != before ) {
            dfs(e.first, ((state^(e.second%2))),n);
        }
    }

}

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

    cin>>N;
    
    int u,v,w;
    rep(i,N-1){
        cin>>u>>v>>w;
        --u;
        --v;

        T[u].push_back(make_pair(v,w));
        T[v].push_back(make_pair(u,w)); 
    }

    dfs(0,0,0);
    
    rep(i,N){
        cout<<tb[i]<<endl;
    }


return 0;
}

Measured memory_bytes: 10240
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

	vector<int> ships(n + 1, 0);
	for (int i = 0; i < m; i++) {
		cin >> a >> b;

		if (a == 1 || b == n) {
			ships[a]++;
			ships[b]++;
		}
	}

	ships[1] = 0;
	ships[n] = 0;
	bool ok = *max_element(ships.begin(), ships.end()) >= 2;

	cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}


Measured memory_bytes: 1024
#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 h, w;
  string s[26][26];
  cin >> h >> w;
  rep(i, h) rep(j, w) cin >> s[i][j];
  rep(i, h) rep(j, w) if (s[i][j] == "snuke") {
    printf("%c%d\n", j + 'A', i + 1);
  }
  return 0;
}

Measured memory_bytes: 3756
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
#define int long long int

void solve() {
  vector<int> v(5);

  for (int &x : v) {
    cin >> x;
  }

  int k;
  cin >> k;

  string ans;
  if (v.back() - v.front() > k) {
    ans = ":(";
  } else {
    ans = "Yay!";
  }

  cout << ans << endl;
}

signed main() {
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	int e1,e2,e3;
	int hisi = 0;
	int tyou = 0;
	char comma;

	while( cin >> e1 >> comma >> e2 >> comma >> e3 ){
		if( e1 == e2 ) hisi++;
		else if( e1 * e1 + e2 * e2 == e3 * e3 ) tyou++;
	}

	cout << tyou << endl;
	cout << hisi << endl;

	return 0;
}

Measured memory_bytes: 0
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn vs(a: &mut Vec<Vec<usize>>, n: usize, p1: usize, p2: usize, done: &mut Vec<bool>) -> bool {
    if done[p2 - 1] {
        a[p1 - 1].push(p2);
        done[p1 - 1] = true;
        return false;
    } else if let Some(p3) = a[p2 - 1].pop() {
        if p1 != p3 {
            done[p1 - 1] = true;
            a[p1 - 1].push(p2);
            return vs(a, n, p2, p3, done);
        }
        done[p1 - 1] = true;
        done[p2 - 1] = true;
        return true;
    }
    false
}

fn day(a: &mut Vec<Vec<usize>>, n: usize) -> u32 {
    let mut done: Vec<bool> = vec![false; n];
    let mut cnt: u32 = 0;
    for p1 in 1..(n + 1) {
        if done[p1 - 1] {
            continue;
        } else if let Some(p2) = a[p1 - 1].pop() {
            if vs(a, n, p1, p2, &mut done) {
                cnt += 1;
            }
        }
    }
    cnt
}

fn all(a: &mut Vec<Vec<usize>>, n: usize) -> i32 {
    let mut vs_cnt: u32 = 0;
    let mut day_cnt: i32 = 0;

    while vs_cnt < ((n * (n - 1)) / 2) as u32 {
        let tmp = day(a, n);
        if tmp == 0 {
            day_cnt = -1;
            break;
        } else {
            vs_cnt += tmp;
        }
        day_cnt += 1;
    }

    return day_cnt;
}

fn gcd(x: u64, y: u64) -> u64 {
    if x > y {
        gcd_sub(x, y)
    } else {
        gcd_sub(y, x)
    }
}

fn gcd_sub(x: u64, y: u64) -> u64 {
    let r = x % y;
    if r == 0 {
        y
    } else {
        gcd_sub(y, r)
    }
}

fn main() {
    let s: String = read();
    if s == "Sunny" {
        println!("Cloudy");
    } else if s == "Cloudy" {
        println!("Rainy");
    } else {
        println!("Sunny");
    }
}


Measured memory_bytes: 4352
import math
A, B, H, M = map(int, input().split())

theta_A = math.pi / 6 * (H + M / 60)
theta_B = math.pi / 30 * M
theta = abs(theta_A - theta_B)

if theta > math.pi:
  theta = 2 * math.pi - theta

L = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta))

print(L)

Measured memory_bytes: 9504
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let a = read::<String>().chars().collect::<Vec<char>>()[0];
    let b = read::<String>().chars().collect::<Vec<char>>()[0];
    if a < b {
        println!("<");
    } else if a == b {
        println!("=");
    } else {
        println!(">");
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
int main()
{
    int D,T,S;
    float x;
    scanf("%d %d %d",&D,&T,&S);
    x=(float)D/S;
    if(x<=T)
    {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define fi first
#define se second
#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()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,q;
  cin >> n >> q;
  string s;
  cin >> s;
  vi cnt(n,0);
  srep(i,1,n){
    if(s[i] == 'C' && s[i-1] == 'A') cnt[i]=1;
  }
  vi S(n+1,0);
  rep(i,n){
    S[i+1] += S[i]+cnt[i];
  }

  rep(i,q){
    int l,r;
    cin>>l>>r;
    cout<<S[r]-S[l]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    long long N,index=1,ally[1000]={1000};
    string ans_str = "";
    char ans_one_letter;

    cin >> N;
    
    for(int i=0;i<15;i++){
        ally[i]=-1;
    }
    
    for(int i=1;i<13;i++){
        N=N-1;
        ally[12-i]=N%26;
        if((N+1)/26<1) break;
        N=N/26;
    }
    

    int k=0;
    for(int j =0;j<13;j++){
        if(ally[j]!=-1){
            ans_one_letter = 'a' +ally[j];
            cout <<ans_one_letter;
            ans_str[k]=ans_one_letter;
            k++;
        }
        
    }
    
    cout << endl;;

    return 0;
}


Measured memory_bytes: 3588
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: u64,
    }
    let mut c = 0;
    for k in 1..=n {
        if k % 2 == 0 {
            continue;
        }
        if (1..=k).filter(|l| k % l == 0).count() == 8 {
            c += 1;
        };
    }
    println!("{}", c);
}


Measured memory_bytes: 2124
#include <iostream>
#include <vector>
using namespace std;
int main(){
    long long x;
    vector<char> y;
    cin>>x;
    while(x!=0){
        x--;
        y.push_back('a'+(x%26));
        x/=26;
    }
    for(int i=y.size()-1;i>=0;i--){
        cout<<y[i];
    }
}

Measured memory_bytes: 3100
N = int(input())
sp=[[0]*3 for i in range(N)]
for i in range(N):
    sp[i][0], sp[i][1] = input().split()
    sp[i][1] = int(sp[i][1])
    sp[i][2] = i+1

sp = sorted(sp, key=lambda x:x[1], reverse=True)
sp = sorted(sp, key=lambda x:x[0])
for i in sp:
    print (i[2])


Measured memory_bytes: 3064