akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll m, n; cin >> m >> n;
	vector<vector<double>> p(m, vector<double>(n));
	REP(i, m) REP(j, n) cin >> p[i][j];

	// dp[?????????????????° % 2][????´???£???????????????][????????????] = ??????
	vector<vvd> dp(2, vvd(m, vd(1ll << m, 0)));
	// win_max_p[??????????????????????????????????????°][????????§?????? | ????????????] = ????????????????´???£??????????????????
	vvd win_max_p(n, vd(1ll << m, 0));
	REP(i, 1ll << m) REP(j, m) dp[n % 2][j][i & ~(1ll << j)] = 1;

	for (ll i = n - 1; i >= 0; --i) for (ll j = (1ll << m) - 1; j >= 0; --j) {
		REP(k, m) if ((j & (1ll << k)) == 0) {
			dp[i % 2][k][j] =
				win_max_p[i][j | (1ll << k)] * (1 - p[k][i])
				+ dp[(i + 1) % 2][k][j] * p[k][i];
			win_max_p[i][j] = max(win_max_p[i][j], dp[i % 2][k][j]);
		}
	}
	cout << win_max_p[0][0] << endl;

	return 0;
}

Measured memory_bytes: 28328
using static System.Console;

namespace ABC171
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            SolveA();
        }

        static void SolveA()
        {
            WriteLine(char.IsUpper(ReadLine().ToCharArray()[0]) ? "A" : "a");
        }
    }
}

Measured memory_bytes: 25788
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N)
	for i := range A {
		fmt.Scan(&A[i])
	}
	sort.Ints(A)
	count := 0
	prev := -1
	for _, v := range A {
		if prev != v {
			count++
		}
		prev = v
	}
	if N == count {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 5632
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define INF 1<<29

using namespace std;

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

char joi[(int)1e6+5];
int num[(int)1e6+5];

int main()
{
//	cut here before submit 
//	freopen ("testcase.joi5", "r", stdin );
	memset (joi, 0, sizeof (joi ) );
	memset (num, 0, sizeof (num ) );

	string str = "";
	cin >> str;
	int n = str.length();
	int m = 0;
	joi[m] = str[0];
	num[m] = 1;
	for (int i = 1; i < n; i++ ){
		if (str[i] == str[i-1] ){
			num[m]++;
		}else{
			++m;
			joi[m] = str[i];
			num[m] = 1;
		} // end if
	} // end for
	int res = 0;
	rep (j, m - 1 ){
		if (joi[j] == 'J' && joi[j+1] == 'O' && joi[j+2] == 'I' ){
			int curr = min (num[j], num[j+2] );
			if (curr >= num[j+1] )
				res = max (res, num[j+1] );
		} // end if
	} // end rep
	printf ("%d\n", res );
		
	return 0;
}

Measured memory_bytes: 6944
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <math.h>
#include <queue>
#define ll long long
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define mp make_pair
#define forn(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
    int x;
    scanf("%d",&x);
    while(true)
    {
        bool flag=true;
        for(int i=2;i<sqrt(x);i++)
        {
//            printf("%d %d\n",i,x);
            if(x%i==0)
            {
                flag=false;
                break;
            }
        }
        if(flag)break;
        x++;
//        printf("%d\n",x);
    }
    printf("%d\n",x);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
	ll n, tsum, asum;
	cin >> n;
	cin >> tsum >> asum;
	for (int i = 1; i < n; i++) {
		ll t, a;
		cin >> t >> a;
		if (tsum % t == 0 && asum % a == 0 && tsum / t == asum / a)continue;
		ll k, tt, aa;
		k = max(tsum / t, asum / a);
		tt = t * k; aa = a * k;
		while (tt < tsum || aa < asum) {
			tt += t;
			aa += a;
		}
		tsum = tt; asum = aa;
	}
	cout << tsum + asum << endl;
	return 0;
}


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

int main() {
  string s="";
  cin>>s;
  int ans=0;
  
  if(s=="SSS"){
    ans=0;
  }else if(s=="RSS"||s=="SRS"||s=="SSR"||s=="RSR"){
    ans=1;
  }else if(s=="RRS"||s=="SRR"){
    ans=2;
  }
  if(s=="RRR"){
    ans=3;
  }
  cout<<ans;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 5e5 + 5;
ll a, b, c, d;

void solve(){
    cin >> a >> b >> c >> d;
    bool tak = true;
    while(a > 0){
        if(c <= 0){
            cout << "Yes" << endl;
            return;
        }
        if(tak)
            c -= b;
        else
            a -= d;
        tak = !tak;
    }
    cout << "No" << endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

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


int main()
{
	unsigned long n, d;
	cin >> n >> d;

	long long x, y;

	int i;
	int ans = 0;
	for(i = 0; n > i; i++){
		cin >> x >> y;
		if(d >= sqrt(x * x + y * y) )
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
 
const ll MOD=1000000007;
 
ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}
 
ll pow1(ll a,ll b,ll p){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}
 
int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}
 
ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}
 
ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}
 
ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}
 
ll binom1(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}
 
ll damage(string s){
  ll i,ret=0,cnt=0;
  for(i=0;i<s.size();i++){
    if(s[i]=='A'){
      cnt++;
      ret+=cnt;
    }else{
      cnt=0;
    }
  }
  return ret;
}

int n;

int f(int v,int w){
  if(v>w)return f((v+n-2)/n,w);
  if(v<w)return f(v,(w+n-2)/n);
  return v;
}

int main(){
  int i,j,k,l,cnt=0;
  int q;
  cin>>n>>q;
  int v[q],w[q];
  for(i=0;i<q;i++)cin>>v[i]>>w[i];
  if(n==1){
    for(i=0;i<q;i++)cout<<min(v[i],w[i])<<endl;
    return 0;
  }
  for(i=0;i<q;i++)cout<<f(v[i],w[i])<<endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define UNIQUE(v) do{ (v).erase( unique(begin(v), end(v)), end(v) ); } while(0)

namespace std {
	template<class S, class T> pair<S, T> operator + (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first + b.first, a.second + b.second);}
	template<class S, class T> pair<S, T> operator - (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first - b.first, a.second - b.second);}
	template<class S, class T> pair<S, T>& operator += (pair<S, T> &a, const pair<S, T> &other) {return a = a + other;}
	template<class S, class T> pair<S, T>& operator -= (pair<S, T> &a, const pair<S, T> &other) {return a = a - other;}
	template<class S, class T> ostream& operator << (ostream& ost, pair<S, T> p) {ost << "(" << p.first << ", " << p.second << ")";return ost;}
	template<class T> ostream& print_iterable_container(ostream& ost, T& container) {
		for (auto&& iter = begin(container); iter != end(container); ++iter) ost << (iter == begin(container) ? " [ " : ", ") << (*iter);
		return ost << " ]";
	}
#	define APPLY_PRINT_ITERABLE_CONTAINER(container_type)\
	template<class T> ostream& operator << (ostream& ost, container_type<T>& container) {\
		return print_iterable_container(ost, container);\
	}
	APPLY_PRINT_ITERABLE_CONTAINER(vector);
	APPLY_PRINT_ITERABLE_CONTAINER(list);
	APPLY_PRINT_ITERABLE_CONTAINER(deque);
}

template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

using ld = long double;

template<class T> using VV = vector<vector<T> >;
template<class T> using maxPQ = priority_queue<T>;
template<class T> using minPQ = priority_queue<T, vector<T>, greater<T> >;
template<class T, class U> using uomap = unordered_map<T, U>;
template<class T> using uoset = unordered_set<T>;

const ll INF = 1001001001;
const ll INFll = (ll)INF * INF;
const ll MOD = 1000000007;
const ll MOD_FFT = 998244353;
const ld EPS = 1e-15;

//function<void(int,int)> tensi_no_3p=[&](int v,int d){
//};

int main() {
	ios_base::sync_with_stdio(false);
	string S; cin >> S;
	ll ans = 0;
	int ca = 0, cbc = 0;
	S += "B";
	rep(i, S.size()) {
		if (S[i] == 'A') {
			ca++;
		}
		else if (S[i] == 'B' && S[i + 1] == 'C') {
			cbc++;
			i++;
			ans += ca;
		}
		else {
			ca = 0;
			cbc = 0;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 720
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n];
        int even = 0;
        int four = 0;
        int odd = 0;
        for(int i = 0; i < n; i++){
            a[i] = scanner.nextInt();
            if(a[i] % 4 == 0){
                four++;
            }else if(a[i] % 2 == 0){
                even++;
            }else if(a[i] % 2 == 1){
                odd++;
            }
        }
        //System.out.println(" even : " + even + " four : " + four + " odd : " + odd);
        if((four >= odd-1 && even == 0) || (four >= odd && even % 2 == 1) || (four == odd && even%2 == 0)){
            System.out.println("Yes");
            return;
        }else{
            System.out.println("No");
            return;
        }
    }
}

Measured memory_bytes: 48288
import java.util.*;
public class Main {
	static int pass = 0;
	static int a[][];
	static int N;
	static int M;
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();
		a = new int[M][2];
		for(int i = 0; i < M; i++) {
			a[i][0] = sc.nextInt() - 1;
			a[i][1] = sc.nextInt() - 1;		}
		String str = "";
		for(int i = 1; i < N; i++) {
			str += i;
		}
		permutation(str, "0");
		System.out.println(pass);
	}
	
	public static void permutation(String q, String ans){
	    if(q.length() <= 1) {
	    	String str = ans + q;
	    	boolean flag = true;
	        for(int i = 0; i < str.length() - 1; i++) {
	        	int num1 = Integer.parseInt(str.substring(i, i + 1));
	        	int num2 = Integer.parseInt(str.substring(i + 1, i + 2));
	        	boolean f = false;
	        	for(int j = 0; j < M; j++) {
	        		if(a[j][0] == num1 && a[j][1] == num2) {
	        			f = true;
	        		} else if(a[j][0] == num2 && a[j][1] == num1) {
	        			f = true;
	        		}
	        	}
	        	if(!f) {
	        		flag = false;
	        	}
	        }
	        if(flag) pass++;
	    } else {
	        for (int i = 0; i < q.length(); i++) {
	            permutation(q.substring(0, i) + q.substring(i + 1), ans + q.charAt(i));
	        }
	    }
	}
}


Measured memory_bytes: 29524
#!/usr/bin/env python
#-*- coding:utf-8 -*-

import sys
import math

railroad = []
outCar = []

for data in sys.stdin:
    data = int(data)
    if data != 0:
        railroad.append(data)
    else:
        outCar.append(railroad.pop())

for data in outCar:
    print(data)

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

int main() {
    int x, y, tmp;

    for ( ;; ) {
        cin >> x >> y;

        if ( x == 0  && y == 0 ) break;

        if ( x > y ) {
            tmp = x;
            x = y;
            y = tmp;
        }

        cout << x << " " << y << endl;
    }

    return 0;
}

Measured memory_bytes: 3004
import itertools
import copy
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
l = copy.deepcopy(p)
l.sort()
cnt = 0
p_c = 0
q_c = 0
p = tuple(p)
q = tuple(q)
for i in itertools.permutations(l):
    if i==p:
        p_c = cnt
    if i==q:
        q_c = cnt
    cnt+=1
print(abs(p_c-q_c))

Measured memory_bytes: 3696
#include <iostream>
#include <queue>
#define INF 1e+9
using namespace std;

int main(){
	int n;
	while(cin >> n,n){
		int a[2][101] = {},d[2][100];
		for(int i = 0;i < n;i++){
			d[0][i] = INF;
			d[1][i] = INF;
		}
		for(int i = 0;i < n;i++) cin >> a[0][i];
		for(int i = 0;i < n;i++) cin >> a[1][i];
		queue<int> que;
		que.push(0);
		que.push(n);
		for(int dist = 0;;dist++){
			int siz = que.size();
			if(!siz) break;
			for(int i = 0;i < siz;i++){
				int v = que.front();que.pop();
				int edge = v / n;
				v %= n;
				if(a[edge][v] == 1){
					while(a[edge][v] == 1) v++;
					v--;
				}
				if(d[edge][v] != INF) continue;
				d[edge][v] = dist;
				for(int j = 0;j < 3;j++){
					int to = v + j;
					if(to >= n) break;
					if(a[(edge + 1) % 2][to] == 2){
						while(a[(edge + 1) % 2][to] == 2) to--;
					}
					else if(a[(edge + 1) % 2][to] == 1){
						while(a[(edge + 1) % 2][to] == 1) to++;
						to--;
					}
					if(d[(edge + 1) % 2][to] == INF){
						que.push((edge + 1) % 2 * n + to);
					}
				}
			}
		}
		if(d[0][n - 1] == INF && d[1][n - 1] == INF) cout << "NA" << endl;
		else cout << min(d[0][n - 1],d[1][n - 1]) << endl;
	}
	return 0;
}

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

typedef long long ll;
#define mod 1000000007

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

void solve() {
    int n;
    cin>>n;
    ll ans = 0, cnt = 0;
    for(int i = 1; i < n; i++){
        int n1 = n - i;
        cnt = 0;
        for(int j = 1; j*j <= n1; j++){
            if(j*j == n1 && n1%j == 0){
                cnt += 1;
                continue;
            }
            if(n1%j == 0){
                cnt += 2;
            }
        }
        ans += cnt;
    }
    cout<<ans<<"\n";
}
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    // pre();
    while (t--)
        solve();

    return 0;
}

Measured memory_bytes: 3636
#coding: utf-8
l = []
for i in range(5):
    a = int(input())
    l.append(a)
k = int(input())
cnt = 0
for i in range(len(l)):
    for j in range(i+1, len(l)):
        if abs(l[i] - l[j]) > k:
            cnt += 1
print("Yay!" if cnt == 0 else ":(")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#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++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main(){
  int X;
  cin >> X;
  if(X==3)
    cout << "YES" << endl;
  else if(X==5)
    cout << "YES" << endl;
  else if(X==7)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define DAY_MAX (24*60*60)

int train_num[DAY_MAX+1];

int main(void) {
	int n,i;
	int h,m,s;
	int max;
	while(1) {
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<=DAY_MAX;i++)train_num[i]=0;
		for(i=0;i<n;i++) {
			scanf("%d:%d:%d",&h,&m,&s);
			train_num[h*60*60+m*60+s]++;
			scanf("%d:%d:%d",&h,&m,&s);
			train_num[h*60*60+m*60+s]--;
		}
		max=0;
		for(i=1;i<=DAY_MAX;i++) {
			train_num[i]+=train_num[i-1];
			if(train_num[i]>max)max=train_num[i];
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 752
import java.util.Scanner;

public class Main {
	public	static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine();
		int n = 0;
		while(true) {
			String s = sc.next();
			 if(s.contains("END_OF_TEXT")){
				System.out.println(n);
				break;
			}
			s = s.toLowerCase( );
			if(s.equals(w)){
				n += 1;
			}
		}
	}
}




Measured memory_bytes: 26196
using System;

public class Program {

        public static void Main(string[] args) {

            var input = Console.ReadLine().Split(' ');
            var A = long.Parse(input[0]);
            var B = long.Parse(input[1]);
            var K = long.Parse(input[2]);

            if (K <= A) {

                Console.WriteLine("{0} {1}", A - K, B);

            } else if (A < K && K < A + B) {

                Console.WriteLine("{0} {1}", 0, B - (K - A));

            } else if (A + B <= K) {

                Console.WriteLine("0 0");

            }

        }

    }

Measured memory_bytes: 13140
use std::io::*;

fn main() {
    let stdin = stdin();
    let mut handle = stdin.lock();
    let a: u64 = read(&mut handle);
    let b: u64 = read(&mut handle);
    let m: u64 = read(&mut handle);
    let mut a_vec: Vec<u64> = Vec::new();
    for _ in 0..a as u64 {
        a_vec.push(read(&mut handle));
    }
    let mut b_vec: Vec<u64> = Vec::new();
    for _ in 0..b as u64 {
        b_vec.push(read(&mut handle));
    }
    let mut x_y_c: Vec<(u64, u64, u64)> = Vec::new();
    for _ in 0..m as u64 {
        x_y_c.push({
            let x = read(&mut handle);
            let y = read(&mut handle);
            let c = read(&mut handle);
            (x, y, c)
        });
    }

    let mut total: u64 = *a_vec.iter().min().unwrap() + *b_vec.iter().min().unwrap();
    // if a > 1 {
    //     for i in 1..a_vec.len() {
    //         if a_vec.get(result_pair.0 as usize).unwrap() > a_vec.get(i).unwrap() {
    //             result_pair.0 = *a_vec.get(i).unwrap();
    //         }
    //     }
    // }
    // if b > 1 {
    //     for i in 1..b_vec.len() {
    //         if b_vec.get(result_pair.1 as usize).unwrap() > b_vec.get(i).unwrap() {
    //             result_pair.1 = *b_vec.get(i).unwrap();
    //         }
    //     }
    // }

    for (xi, yi, c) in x_y_c {
        if total > a_vec.get(xi as usize - 1).unwrap() + b_vec.get(yi as usize - 1).unwrap() - c {
            total = a_vec.get(xi as usize - 1).unwrap() + b_vec.get(yi as usize - 1).unwrap() - c;
        }
    }

    println!("{}", total);
}

fn read(handle: &mut StdinLock) -> u64 {
    handle
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .fold(0, |acc, x| (x as u8 - b'0') as u64 + acc * 10)
}


Measured memory_bytes: 11360
program main
implicit None
	integer(8)::n,m,i
	integer(8),allocatable::x(:),y(:)
	
	read*,n,m
	
	allocate(x(m),y(m-1))
	
	read*,x
	
	if(n >= m)then
		print "(i0)",0
		stop
	endif
	
	call h1(x,m)
	
	do i = 1,m-1
		y(i) = x(i+1)-x(i)
	enddo
	
	call h1(y,m-1)
	
	if (n > 1)then
		print "(i0)",sum(y)-sum(y(m-n+1:m-1))
		else
		print "(i0)",sum(y)
	endif
end program main

subroutine h1(a,n)
implicit None
	integer(8)::a(n),x
	integer(8)::n,i,ie,i0,i1,i2
	
	do i = n/2,1,-1
		x = a(i);ie = n + 1; i0 = i; i1 = i0 * 2
		do while(i1 < ie)
			i2 = i1 + 1
			if(i2 < ie .and. a(i1) < a(i2)) i1 = i2
			if(a(i1) > x)then
				a(i0) = a(i1);a(i1) = x
				else
				exit
			endif
			i0 = i1;i1 = i0 *2
		enddo
	enddo
	do ie = n,2,-1
		x = a(ie)
		a(ie) = a(1)
		a(1) = x
		i0 =1;i1 =2
		do while(i1 <ie)
			i2 = i1 +1
			if(i2 < ie .and. a(i1) < a(i2)) i1 = i2
			if(a(i1) > x)then
				a(i0) = a(i1);a(i1) = x
				else
				exit
			endif
			i0 = i1;i1 = i0 *2
		enddo
	enddo
end subroutine h1


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s == "ABC")
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;
}

Measured memory_bytes: 3652
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 1e5 + 20 ;
int n , m , cnt[N] ;
bool mark[N] ;

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

	cin >> n >> m ;

	for (int i = 0 ; i < n ; i ++) cnt[i] = 1 ;
	mark[0] = 1 ;

	while (m --) {
		int x , y ;
		cin >> x >> y ;
		x -- , y -- ;

		mark[y] |= mark[x] ;
		cnt[x] -- , cnt[y] ++ ;
		if (!cnt[x]) mark[x] = 0 ;
	}

	int ans = 0 ;
	for (int i = 0 ; i < n ; i ++) ans += mark[i] ;
	cout << ans << '\n' ;
}


Measured memory_bytes: 768
#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(){
  string s,t;
  int cnt=0;
  cin >> s >> t;
  rep(i,s.size()){
    if(s[i]!=t[i])cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
  
  long long  i,N,c;
  cin >> N;
  long long  a[N];
  for(i=0;i<N;i++){
    cin >> a[i];
  }
  long long  max = 0;
  long long max1 = 0;
  for(i=0;i<N;i++){
    if(max < a[i]){
      max = a[i];
      c = i;
    }
  }
  a[c] = 0;
  for(i=0;i<N;i++){
    if(max1 < a[i]){
      max1 = a[i];
    }
  }
  
  for(i=0;i<N;i++){
    if(i == c){
      cout << max1 << endl;
    }
    else{
      cout << max << endl;
    }
    
  }
  
  return 0;
}

Measured memory_bytes: 3200
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

ll d_sum(ll n){
  str s = to_string(n);
  ll ans = 0;
  REP(i,s.length()){
    ans += s[i]-'0';
  }
  return ans;
}

int main(){
  ll n;
  cin >> n;
  if(n%d_sum(n)==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
const int mod = 1000000007;

int main() {

    int64_t D,G,fans=INF;
    cin>>D>>G;
    vector<tuple<int64_t,int64_t,int64_t>> A(10);
    for(int i=0; i<D; i++){
      cin>>get<0>(A[i])>>get<1>(A[i]);
      get<2>(A[i])=(i+1)*100*get<0>(A[i])+get<1>(A[i]);
    }
  for (int i = 1; i < (1 << D); i++) {
    bitset<10> s(i);
    int64_t sum=0,firstscore=-1,ans=0;
    for(int j=0;j<10;j++){
      if(s.test(j)){
        sum+=get<2>(A[j]);
        ans+=get<0>(A[j]);
        if(firstscore==-1)firstscore=9-j;}}
    if(sum>=G){//cout<<ans<<" "<<sum<<endl;
    if(sum-get<1>(A[9-firstscore])<G)fans=min(fans,ans);
    else{sum-=get<1>(A[9-firstscore]);//cout<<ans<<" "<<sum<<endl;
      if(((sum-G)/((9-firstscore+1)*100))>=get<0>(A[9-firstscore]))ans-=get<0>(A[9-firstscore]);
      else ans-=((sum-G)/((9-firstscore+1)*100));
      fans=min(fans,ans);}
    }
}
    cout << fans << endl;
}



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

					using namespace std;
					typedef long long ll;
					
					int main()
					{
						int n;
						map<int, int> m;
						cin >> n;
						for(int i = 1; i < n; i++)
						{
							int x;
							cin >> x;
							m[x]++;
						}
						for(int i = 1; i <= n; i++)
							cout << m[i] << '\n';
					}

Measured memory_bytes: 13008
#include<stdio.h>

int main(void){
  int i,j,k;
  int prime[10000],sum[10000];
  int n;
  int ans;

  i = 1;
  k = 3;
  prime[0] = sum[0] = 2;
  while(i<10000){
    for(j=0;j<i;j++){
      if( !(k%prime[j]) )break;
    }
    if(j==i){
      prime[i] = k;
      sum[i] = sum[i-1]+k;
      i++;
    }
    k++;
  }

  while(1){
    scanf("%d",&n);
    if(!n)break;
    printf("%d\n",sum[n-1]);
  }

  return 0;
}

Measured memory_bytes: 0
using System;
class hoge
{
    static void Main()
    {
        string input = Console.ReadLine();
        int a = int.Parse(input.Split(' ')[0]);
        int b = int.Parse(input.Split(' ')[1]);
        int c = int.Parse(input.Split(' ')[2]);
        if (a < b & b < c)
        {
        Console.WriteLine("Yes");
        }else
        {
        Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 8792
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>

using namespace std;
 
template<class T> inline bool chmax(T& a, T b) {
	 if (a < b) {
	 	a = b; 
	 	return true;
	 } 
	 return false;
}
 
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
 
ll N, W, w[110], v[110];
ll DP[110][110000] = {};
 
int main() {
	cin >> N >> W;
	
	for(int i = 0; i < N; i++){
		cin >> w[i] >> v[i];
	}
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < W+1; j++){
			chmax(DP[i+1][j], DP[i][j]);
			if(j - w[i] >= 0) {
				chmax(DP[i+1][j], DP[i][j - w[i]] + v[i]);
			}
		}
	}
	cout << DP[N][W] << endl;
}

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

int main() {
	vector<int> v(4);
	cin >> v[0]>> v[1]>> v[2]>> v[3];
	sort(v.begin(),v.end());
	if(v[0]==1 &&v[1]==4 &&v[2]==7 &&v[3]==9){
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
    int i, j;
    char s[1000];
    scanf("%s%d", s, &i);
    for (j=0; j < strlen(s) ;j++) {
        if (j % i == 0) printf("%c", s[j]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}


int main(){
    int n,k ;
    cin >> n >> k ;
    int ans = 0 ;
    int x ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> x ;
        ans += min(x,k-x) *2 ;
    }
    cout << ans << endl ;
}

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

signed main(void)
{
	long long n, ans;
	cin >> n;
	ans = 0;
	for(int i = 1; i <= sqrt(n); i++)
	{
		if (n % i == 0)
		{
			if (n / i - i > 1)
				ans += n / i - 1;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  string s;cin>>s;
  bool b = true;

  REP(i,3){
    if(s[i]==s[i+1]){
      b = false;
    }
  }

  if(b){
    cout<<"Good"<<endl;
  }else{
    cout<<"Bad"<<endl;
  }

 

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<utility>
#include<functional>
#include<algorithm>
#include<queue>
#include<map>
#include<string>
#include<numeric>


#define FOR(i, a, b) for(int i=a; i<b; i++)
#define COUT(a) cout << a << endl;

using namespace std;
using Int = long long;
using P = pair<Int, Int>;


int main(){
    Int A[3];
    cin >> A[0] >> A[1] >> A[2];
    Int ans = 0;

    FOR(i, 0, 3){
        FOR(j, 0, 3){
            FOR(k, 0, 3){
                if (i == j || j == k || k == i){
                    continue;
                }
                ans = max(ans, A[i]*10+A[j] + A[k]);
            }
        }
    }

    COUT(ans);
    
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

int main()
{
    using namespace std;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    float t, x;
    cin >> t >> x;
    printf("%.5f\n", t/x);
    // cout << t/x << '\n';
    
    return 0;
}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int N = 200005;
const int MOD = 10005;

int ten[N], t[N], cnt[MOD];

int main() {

    FAST;

    int n, p;
    cin >> n >> p;
    string a;
    cin >> a;
    a = " " + a;
    if (p == 2 || p == 5) {
        intt ans = 0;
        for (int i = 1; i <= n; i ++) {
            if ((int(a[i]) - '0') % p == 0) {
                ans += i;
            }
        }
        cout << ans << '\n';
    }
    else {
        ten[0] = 1;
        for (int i = 1; i <= n; i ++) {
            ten[i] = (ten[i - 1] * 10) % p;
        }
        t[n] = 0;
        for (int i = n - 1; i >= 0; i --) {
            t[i] = (t[i + 1] + ten[n - i - 1] * (int(a[i + 1]) - '0')) % p;
        }
        for (int i = 0; i <= n; i ++) {
            cnt[t[i]] ++;
        }
        intt ans = 0;
        for (int i = 0; i < p; i ++) {
            ans += 1LL * cnt[i] * (cnt[i] - 1) / 2;
        }
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 2128
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>

typedef long long ll;

int main(int argc, char* argv[])
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll N;
  std::cin >> N;

  std::string ans;
  while (N != 0) {
    ll r = std::fabs(N % 2);
    N = (N - r)/ -2;
    ans += '0' + r;
  }

  if (ans.size() == 0) {
    std::cout << 0 << std::endl;
  } else {
    std::reverse(ans.begin(), ans.end());
    std::cout << ans << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


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

    ll a;
    cin >>a;
    cout << 3*a*a;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

using Graf_char=vector<vector<char>>;
using Graf_int=vector<vector<int>>;
#define MAX 10000000

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    rsort(a);
    ll point_a=0;ll point_b=0;
    rep(i,n){
        if(i%2==0){
            point_a+=a[i];
        }else{
            point_b+=a[i];
        }
    }
    cout << point_a-point_b << endl;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    string s;
    cin>>s;
    int n=s.length();
    int ans = 753;
    for(int i=0;i<n-2;i++){
        string t = s.substr(i,3);
        int x = stoi(t);
        if(abs(x-753)<ans){
            ans = abs(x-753);
        }
        //cout<<t<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
int main(void){
    int n,m;
    int x[1505],y[1505];    
    while(cin>>n>>m){
        if(n==0&&m==0) break;
        int ans = 0;
        map<int,int> mp;
        for(int i=0;i<n;i++){
            int s;
            cin>>s;
            x[i+1]=0;
            x[i+1] += x[i]+s;
        }
        for(int i=0;i<m;i++){
            int s;
            cin>>s;
            y[i+1]=0;
            y[i+1] = y[i]+s; 
        }
        for(int i=0;i<=n;i++){
            for(int j=0;j<i;j++){
                mp[x[i]-x[j]]++;
            }
        }
        for(int i=0;i<=m;i++){
            for(int j=0;j<i;j++){
                ans += mp[y[i]-y[j]];
            }
        }
        
        cout<<ans<<endl;
        
    }
    
}



Measured memory_bytes: 20844
#include<bits/stdc++.h>
using namespace std;
#define read(x) scanf("%d",&x)
#define write(x) printf("%d ",x)
const int N = 2e5;
int head[N+5],tot;
int d[N+5];
struct Edge
{
    int next;
    int to;
}edge[N*2+5];
inline void add(int from,int to)
{
    edge[++tot].next = head[from];
    edge[tot].to= to;
    head[from] = tot;
}
void dfs(int x,int fa){
    d[x] += d[fa];
    for(int i = head[x];~i;i = edge[i].next)
    {
        int y = edge[i].to;
        if(y!=fa) dfs(y,x);
    }
}
int main()
{
    memset(head,-1,sizeof(head));
    int n,m;
    read(n);read(m);
    int f,t;
    for(int i = 1;i<=n - 1;++i){
        read(f);
        read(t);
        add(f,t);
        add(t,f);
    }
    for(int i = 1;i<=m;++i){
      read(f);
      read(t);
      d[f] += t;
    }
    dfs(1,0);
    for(int i = 1;i<=n;++i)    write(d[i]);
}


Measured memory_bytes: 13312
#include <iostream>
#include <algorithm>

#define ll long long

using namespace std;

ll func1(ll h, ll w){
	if(h % 3 == 0|| w % 3 == 0){
		return 0;
	}
	return min(h, w);
}

ll func2(ll h, ll w){
	ll min_dif = h * w;
	if(w % 2 == 0){
		for (ll i = 1; i < h; ++i)
		{
			min_dif = min(abs(w * i - w / 2 * (h - i)), min_dif); 
		}
	}else{
		for (ll i = 1; i < h; ++i)
		{
			ll max_dif = max(abs( (w+1) / 2 * (h - i) - w / 2 * (h - i)) , max(abs(w * i - w / 2 * (h - i)), abs(w * i - (w+1) / 2 * (h - i))));
			min_dif = min(max_dif, min_dif);
		}
	}
	return min_dif;
}


int main(){
	ll h, w;
	cin >> h >> w;
	cout << min(min(func1(h, w), func2(h, w) ), func2(w, h) ) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a,b="                                                                                                               ",c="                                                                                                               ";
	cin>>a;
	for (int i=0;i<a.size()/2;i++)
	{
		b[i]=a[i];
		c[i]=a[i+a.size()/2+1];
	}
	if (b==c)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	string a[3];
	for (int i = 0; i < 3; ++i)
	{
		cin >> a[i];
	}
	sort(a, a + 3, greater<string>());
	cout << stoi(a[0] + a[1]) + stoi(a[2]) << endl;
	return 0;
}

Measured memory_bytes: 256
const val MIN_THRESHOLD = 60
const val HR_THRESHOLD  = 60 * 60

fun main(args: Array<String>){
    val input: Int = readLine()?.toInt() ?: return
    val hr  = translateToHr(input)
    val sec = translateToSec(input)
    val min = (input - (hr * HR_THRESHOLD)) / MIN_THRESHOLD
    println("$hr:$min:$sec")
}

fun translateToHr(seconds: Int): Int  = seconds / HR_THRESHOLD
fun translateToSec(seconds: Int): Int = seconds % MIN_THRESHOLD


Measured memory_bytes: 27148
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


int N;
constexpr int Nmax = 100000;
vector<plint> D;
vector<int> to[Nmax];

plint dfs(int now, int prev)
{
    lint d = 0, subtreesz = 1;
    for (auto nxt : to[now]) if (nxt != prev)
    {
        plint pa = dfs(nxt, now);
        d += pa.first + pa.second;
        subtreesz += pa.second;
    }
    return plint(d, subtreesz);
}

int main()
{
    cin >> N;
    D.resize(N);
    REP(i, N)
    {
        cin >> D[i].first;
        D[i].second = i;
    }

    sort(D.begin(), D.end());

    map<lint, vector<pint>> ma;

    IREP(i, N)
    {
        lint Dnow, id_now;
        tie(Dnow, id_now) = D[i];

        int stsz = 1;
        if (ma.count(Dnow))
        {
            for (auto pa : ma[Dnow])
            {
                to[id_now].push_back(pa.first);
                to[pa.first].push_back(id_now);
                stsz += pa.second;
            }
            ma.erase(Dnow);
        }
        ma[Dnow + 2 * stsz - N].push_back(pint(id_now, stsz));
    }

    vector<pint> res;
    REP(s, N) for (auto t : to[s]) if (s < t) res.push_back(pint(s, t));

    if (res.size() != N - 1 || dfs(D[0].second, -1).first != D[0].first) cout << -1 << endl, exit(0);
    for (auto pa : res) cout << pa.first + 1 << " " << pa.second + 1 << endl;
}


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

#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(ll i=n;i<=N;++i)
#define rap(i,n,N) for(ll i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>>>> " << #x << " -> " << x << endl;
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define piii pair<int,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl "\n"
const int MAX = 3e5+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 450;

ll tc,n,a,b,x,ans;

int main(){
//	cout<<fixed<<setprecision(15);
//    freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>tc;
    while(tc--){
    	cin>>n>>x;
    	ans = 0;
    	rep(i,2,n)ans+=127, x^=127;
    	cout<<ans+x<<endl;
	}
	return 0;
}

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


namespace atcorder2
{
    class Program
    {
        public static long Read()
        {

            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       
         public static long GCM(long x,long y)
        {
            if (x < y)  GCM(y, x);


            while (y > 0)
            {
                var z = y;
                y = x % y;
                x = z;
            }
            
            return x;
        }

        



        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var s = ReadLine();
            
            var c = "keyence";
           
            
         


            
            
            int j=0, k = 6;
            for ( j = 0; j < 7;j++)
            {
                if (s[j] != c[j]) break;           
            }
            for (int l = s.Length-1; l >=0&&k>=0; l--)
            {
                if (s[l] != c[k]) break;
                k--;
            }
            


            
            WriteLine(k-j<=-1 ? "YES" : "NO");
            

            






            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair< int, int >;
using edge = struct { int to; ll cost; };
vector<edge> g[100010];
ll depth[100010];

void dfs(int v, int p, ll d) {
    depth[v] = d;
    for (auto & e : g[v]) {
        if (e.to == p) continue;
        dfs(e.to, v, d + e.cost);
    }
}

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

    rep(i, n-1) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        g[a].push_back({b, c});
        g[b].push_back({a, c});
    }

    int q, k;
    cin >> q >> k;
    k--;

    dfs(k, -1, 0);
    rep(i, q) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << depth[x] + depth[y] << endl;
    }

}


Measured memory_bytes: 14336
#include<stdio.h>
#include<string.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(int a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
static inline int Max(int a,int b){return a>b?a:b;}
static inline int Min(int a,int b){return a<b?a:b;}
#define rep(i,n) FOR(i,0,n-1)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
const int INF=0x7f7f7f7f;
struct SqrtDecomposition
{
  int k,n,sqrtn=0,dat[500708],buk[709]={0},lazy[709]={0},lazyflag[709]={0};
  void init(int x)
  {
    n=x;
    while(sqrtn*sqrtn<=n){sqrtn++;}
    k=(n+sqrtn-1)/sqrtn;
    rep(i,n){dat[i]=i;}
  }
  void eval(int b)
  {
    if(!lazyflag[b]){return;}
    lazyflag[b]=0;
    FOR(i,sqrtn*b,sqrtn*(b+1)-1){dat[i]=lazy[b];}
  }
  //[l,r)
  void update(int l,int r,int x)
  {
    rep(b,k)
    {
      int p=sqrtn*b,q=sqrtn*(b+1);
      if(q<=l||r<=p){continue;}
      if(l<=p&&q<=r){buk[b]=p-x;lazyflag[b]=1;lazy[b]=x;}
      else
      {
        eval(b);
        FOR(i,Max(l,p),Min(r,q)-1){dat[i]=x;}
        buk[b]=INF;
        FOR(i,p,q-1){buk[b]=Min(buk[b],i-dat[i]);}
      }
    }
  }
  //[l,r)
  int query(int l,int r)
  {
    int ret=INF;
    rep(b,k)
    {
      int p=sqrtn*b,q=sqrtn*(b+1);
      if(q<=l||r<=p){continue;}
      if(l<=p&&q<=r){ret=Min(ret,buk[b]);}
      else{eval(b);FOR(i,Max(l,p),Min(r,q)-1){ret=Min(ret,i-dat[i]);}}
    }
    return ret;
  }
};
int main(void)
{
  int H=IN(),W=IN();
  SqrtDecomposition sd;sd.init(W);
  rep(i,H)
  {
    int l=IN()-1,r=IN(),u=-INF;
    if(l>0){int b=(l-1)/sd.sqrtn;sd.eval(b);u=sd.dat[l-1];}
    sd.update(l,r,u);
    int ans=sd.query(0,W);
    if(ans>=INF){ans=-1;}else{ans+=i+1;}
    OUT(ans);
  }
}

Measured memory_bytes: 2396