akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(int i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")




int main() {
	vector<ll> a, b;
	int N;
	cin >> N;
	REP(i, 0, N) {
		ll a_, b_;
		cin >> a_ >> b_;
		a.push_back(a_);
		b.push_back(b_);
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	if (N % 2 == 1) {
		PRI(b[N / 2] - a[N / 2] + 1);
	}
	else {
		PRI((b[N / 2 - 1] + b[N / 2]) - (a[N / 2 - 1] + a[N / 2]) + 1);
	}
	return 0;
}




Measured memory_bytes: 6552
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}
const MOD: usize = 1000000007;

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let l = it.next().unwrap();
    let mut dp0 = vec![0; l.len() + 1];
    let mut dp1 = vec![0; l.len() + 1];
    dp0[0] = 1;
    for (i, c) in l.chars().enumerate() {
        match c {
            '1' => {
                dp0[i + 1] = 2 * dp0[i] % MOD;
                dp1[i + 1] = (dp0[i] + dp1[i] * 3) % MOD;
            }
            '0' => {
                dp0[i + 1] = dp0[i];
                dp1[i + 1] = (dp1[i] * 3) % MOD;
            }
            _ => (),
        }
    }
    println!("{}", (dp0[l.len()] + dp1[l.len()]) % MOD);
}

fn test() {
    let mut f = fs::File::open("foo.txt").unwrap();
    let mut s = String::new();
    f.read_to_string(&mut s).unwrap();
    solve(&s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_main() {
        test();
    }
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll> > vvi;
typedef pair<ll, ll> pii;
const long long INF = 1LL << 58;
struct Edge
{
ll s,t, d;
};
typedef vector<vector<Edge> > Graph;
typedef vector<pii> vpii;
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;
}

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

signed main()
{
  int N,X;
  cin>>N>>X;
  vi a;
  a.resize(N);
  REP(i,N){
    cin>>a[i];
    a[i] = abs(a[i] - X);
  }
  sort(ALL(a));
  int ans = a[0];
  REP(i,N-1)
    ans=sk(ans,a[i+1]);
  cout<<ans<<endl;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string a,b;
	cin>>a;
	for(int i=0;i<a.size();i++){
		if(a[i]=='0'||a[i]=='1'){
			b+=a[i];
		}
		else if(a[i]=='B'&&b.size()!=0){
			b.erase(b.size()-1);
		}
	}
	cout<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();

		if(a + b + c >= 22) {
			System.out.println("bust");
		}else {
			System.out.println("win");
		}
	}
}

Measured memory_bytes: 21972
import sys
sys.setrecursionlimit(4100000)

N = int(input())
edges = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int,input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
C = list(map(int,input().split()))
C.sort(reverse = True)

D = [0] * N

def dfs(x, parent, index):
    D[x] = C[index]
    index += 1
    for u in edges[x]:
        if u != parent:
            index = dfs(u, x, index)
    return index

dfs(0, -1, 0)

print(sum(C[1:]))
print(*D)

Measured memory_bytes: 19996
R, G, B, N = map(int, input().split())

ans = 0

for i in range(N + 1):
    for j in range(N + 1):
        rg = R * i + G * j

        if rg <= N:
            if (N - rg) % B == 0:
                ans += 1

        else:
            break

print(ans)



Measured memory_bytes: 9024
N = int(input())
A = [[] for _ in range(N)]
for i in range(N):
  x, l = map(int, input().split())
  A[i] = [x + l, x - l]
A.sort()
for i in range(N):
  A[i][0], A[i][1] = A[i][1], A[i][0]
M = A[0][1]
cnt = 1
for i in range(1, N):
  if M <= A[i][0]:
    cnt += 1
    M = A[i][1]
print(cnt)

Measured memory_bytes: 20076
import java.util.Scanner;




public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

    	int a=sc.nextInt();
    	int b=sc.nextInt();

    	if(a<0 && b<0) {

    		if((b-a)%2==0) {
    			System.out.println("Negative");
    		}else {
    			System.out.println("Positive");
    		}

    	}else if(a<0 && b>=0) {
    		System.out.println("Zero");
    	}else if(a==0) {
    		System.out.println("Zero");
    	}else {
    		System.out.println("Positive");
    	}
    }


}



Measured memory_bytes: 21844
import java.util.*;

public class Main {
	static class Tree {
		public class Edge {
			int to, rev;

			public Edge(int to, int rev) {
				this.to = to;
				this.rev = rev;
			}
		}
		
		int V;
		ArrayList<ArrayList<Edge>> G;
		int root;
		int[] p;
		int[] depth;
		int[] childNum;
		
		public Tree(int[] a, int[] b) {
			this.V = a.length+1;
			p = new int[V];
			depth = new int[V];
			childNum = new int[V];
			
			G = new ArrayList<ArrayList<Edge>>();
			for(int i=0; i<V; i++) {
				G.add(new ArrayList<Edge>());
			}
			
			for(int i=0; i<V-1; i++) {
				G.get(a[i]).add(new Edge(b[i], G.get(b[i]).size()));
				G.get(b[i]).add(new Edge(a[i], G.get(a[i]).size()-1));
			}
			setRoot(0);
		}
		
		public void setRoot(int root) {
			this.root = root;
			setRoot(root, -1);
		}
		public void setRoot(int cur, int parent) {
			p[cur] = parent;
			if(parent!=-1)
				depth[cur] = depth[parent]+1;
			childNum[cur] = 1;
			for(int i=0; i<G.get(cur).size(); i++) {
				int next = G.get(cur).get(i).to;
				if(next!=parent) {
					setRoot(next, cur);
					childNum[cur] += childNum[next];
				}
			}
		}
		
		public int getDepth(int idx) {
			return depth[idx];
		}
		
		public int getAncesstor(int idx, int x) {
			while(x>0) {
				idx = p[idx];
				x--;
			}
			return idx;
		}
		
		public int countChild(int idx) {
			return childNum[idx];
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] a = new int[N-1];
		int[] b = new int[N-1];
		for(int i=0; i<N-1; i++) {
			a[i] = sc.nextInt()-1;
			b[i] = sc.nextInt()-1;
		}
		Tree t = new Tree(a, b);
		
		int depth = t.getDepth(N-1);
		int whiteRoot = t.getAncesstor(N-1, (depth-1)/2);

		System.out.println(t.countChild(whiteRoot)>=(N+1)/2 ? "Snuke" : "Fennec");
		
		sc.close();
	}
}


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

using namespace std;

int main()
{
    int n, m, com[1001];
    vector<int> card;
    vector<int> shu;

    card.push_back(0);
    shu.push_back(0);

    cin >> n >> m;

    for (int i = 1; i <= 2 * n; i++) {
        card.push_back(i);
    }

    for (int i = 0; i < m; i++) cin >> com[i];

    for (int i = 0; i < m; i++) {
        if (com[i] == 0) {
            for (int j = 1; j <= n; j++) {
                shu.push_back(card[j]);
                shu.push_back(card[j+n]);
            }
        }
        else {
            for (int k = com[i]+1; k <= 2 * n; k++) {
                shu.push_back(card[k]);
            }

            for (int k = 1; k <= com[i]; k++) {
                shu.push_back(card[k]);
            }
        }
        card = shu;
        shu.erase(shu.begin() + 1, shu.end());
    }

    for (int i = 1; i <= 2 * n; i++) {
        cout << card[i] << endl;
    }
}



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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

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

  cout << n*n << endl;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)

typedef pair< int, int > pii;
typedef pair< pii, pii > ppii;

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
int n, x[20020], y[20020], visit[20020][2];
char dir[20020];
pii pos[40040], ids[40040];

int xadd(int i) { return dir[i] == 'x' ? 1 : 0; }
int yadd(int i) { return dir[i] == 'y' ? 1 : 0; }

bool rec(int i, int j, int v, vector< pii >& upd) {
	bool res = 1;
	
	if (visit[i][j] < 0) {
		visit[i][j] = v;
		visit[i][j^1] = v^1;
		upd.push_back(pii(i,j));
		upd.push_back(pii(i,j^1));
		
		int nx1 = x[i] + (j ? xadd(i) : 0), ny1 = y[i] + (j ? yadd(i) : 0);
		int nx2 = x[i] + (j ? 0 : xadd(i)), ny2 = y[i] + (j ? 0 : yadd(i));
		for_(d,0,4) {
			pii nxp1(nx1 + dx[d], ny1 + dy[d]);
			if (binary_search(pos, pos + 2*n, nxp1)) {
				int k = lower_bound(pos, pos + 2*n, nxp1) - pos;
				if (ids[k].second != i) res &= rec(ids[k].second, ids[k].first, v, upd);
			}
			
			pii nxp2(nx2 + dx[d], ny2 + dy[d]);
			if (binary_search(pos, pos + 2*n, nxp2)) {
				int k = lower_bound(pos, pos + 2*n, nxp2) - pos;
				if (ids[k].second != i) res &= rec(ids[k].second, ids[k].first, v^1, upd);
			}			
		}
	} else {
		res = (visit[i][j] == v);
	}
	
	return res;
}

int main() {
	while (scanf("%d", &n), n) {
		vector< ppii > vp;
		
		for_(i,0,n) {
			scanf("%d %d %c", &x[i], &y[i], &dir[i]);
			vp.push_back(ppii(pii(x[i], y[i]), pii(0, i)));
			vp.push_back(ppii(pii(x[i] + xadd(i), y[i] + yadd(i)), pii(1, i)));
		}
		
		sort(vp.begin(), vp.end());
		
		for_(i,0,2*n) {
			pos[i] = vp[i].first;
			ids[i] = vp[i].second;
		}
		
		memset(visit, -1, sizeof(visit));
		
		bool ok = 1;
		for_(i,0,n && ok) {
			if (visit[i][0] < 0) {
				vector< pii > upd;
				if (!rec(i, 0, 0, upd)) {
					int u_size = (int)upd.size();
					for_(j,0,u_size) visit[upd[j].first][upd[j].second] = -1;
					ok = rec(i, 0, 1, upd);
				}
			}
		}
		cout << (ok ? "Yes" : "No") << endl;
	}
	
	return 0;
}

Measured memory_bytes: 7308
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define yes "Yes\n"
#define no "No\n"
//int m,n;
int i,j,k,l,x;
//int a,b,c,d,e,f,g;
//int sum,total;
//long long int ;
//float ;
//double ;
//char a[101],b[101],s[101],t[101],u[101];
int main(void){
    scanf("%d",&x);
    printf("%d\n",(x / 500) * 1000 + ((x % 500) / 5) * 5);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch BannedK | diff BannedK.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address BannedK.cpp && ./a.out

/*
 
 3/22/2020
 
 5:21-
 
 */

const int MAX_N=1e6+1;
int A[MAX_N];
int N;

LL com(LL x) { return x*(x-1)/2; }
void solve() {
  map<int,LL> cnt;
  LL tot=0;
  REP(i,N) cnt[A[i]]++;
  FORR(kvp,cnt) {
    tot+=com(kvp.second);
  }
  
  REP(i,N) {
    int a=A[i];
    LL res=tot;
    res-=com(cnt[a]);
    res+=com(cnt[a]-1);
    cout<<res<<endl;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) cin>>A[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 11392
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

vector<int> a[100000];
int b[100001];
int c[100001];
int d[100001];
void search(int p,int q,int r,int s){
	b[p] = q;
	d[p] = s + 1;
	for (int i = 0; i < a[p].size(); i++){
		if (b[a[p][i]] == q&&d[a[p][i]]==s+1){
			c[q] = 1;
		}
		if (b[a[p][i]] == 0){
			search(a[p][i], q, p,(s+1)%2);
		}
	}
}

int main(void){

for (int i = 0; i < 100001; i++){
	b[i] = 0;
	c[i] = 0;
	d[i] = 0;
}
int k;
long long s;
int p, q;
long long n, m;
long long x, y, z;
	s = 0;
	q = 0;
	x = 0;
	y = 0;
	z = 0;
	s = 0;
	scanf("%lld %lld", &n,&m);
	for (int i = 0; i < m; i++){
		scanf("%d %d", &p,&q);
		p--;
		q--;
		a[p].push_back(q);
		a[q].push_back(p);
	}
	z = 0;
	k = 1;
	for (int i = 0; i < n; i++){
		if (b[i] == 0){
			if (a[i].size() != 0){
				search(i, k, i,0);
				if (c[k] == 0)y++;
				else x++;
				k++;
			}
			else{
				z++;
			}
		}
	}
	s = n*n;
	s = s - ((n-z)*(n-z));
	s = (y*y) + s;
	s = ((x + y)*(x + y)) + s;
   printf("%lld\n",s);

	return 0;
}


Measured memory_bytes: 12544
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    string s, t; cin >> s >> t;

    rep(i, n) {
        cout << s[i] << t[i];
    }
    cout << endl;
}


Measured memory_bytes: 888
count = [0 for _ in range(ord("a"), ord("z") + 1)]
while True:
    try:
        for c in list(input().lower()):
            if "a" <= c <= "z":
                count[ord(c) - ord("a")] += 1
    except EOFError:
        break
for i, n in enumerate(count):
    print("{ch} : {cnt}".format(ch = chr(ord("a") + i), cnt = n))




Measured memory_bytes: 5568
N, C = gets.split.map(&:to_i)
D = C.times.map{ gets.split.map(&:to_i) }
M = N.times.map{ gets.split.map(&:to_i).map{|v|v - 1} }
S = Array.new(3){Array.new(C, 0)}

N.times do |i|
  N.times do |j|
    S[(i + j + 2) % 3][M[i][j]] += 1
  end
end

T = Array.new(3){ Array.new(C, 0) }
3.times do |mod|
  C.times do |to|
    T[mod][to] = C.times.inject(0){|s,from| s + S[mod][from] * D[from][to] }
  end
end

puts C.times.to_a.permutation(3).map{|to0,to1,to2| T[0][to0] + T[1][to1] + T[2][to2] }.min



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

using namespace std;

#define int int64_t
#define all(x) begin(x), end(x)
#define rall(x) x.rbegin(), x.rend()


void fail() {
    cout << -1 << endl;
    exit(0);
}

vector<vector<int>> construct(int n, string s) {
    vector<vector<int>> g(n);
    s.resize(n);
    vector<int> siz;
    for(int i = 1; i <= n; i++) {
        if(s[i - 1] == '1') {
            siz.push_back(i);
        }
    }
    reverse(all(siz));
    int k = siz.size();
    int sz = k;
    for(int i = 0; i < k; i++) {
        if(i) {
            g[i - 1].push_back(i);
        }
        int need = siz[i] - (i + 1 == k ? 0 : siz[i + 1]) - 1;
        for(int j = 0; j < need; j++) {
            g[i].push_back(sz++);
        }
    }
    return g;
}

signed main() {
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    if(s.back() != '0' || s[0] != '1') {
        fail();
    }
    s.pop_back();
    if(s != string(rall(s))) {
        fail();
    }
    int t = 1;
    for(int i = 1; 2 * i <= n; i++) {
        if(s[i - 1] == '1') {
            t = i;
        }
    }
    auto A = construct(t, s);
    auto B = construct(n - t, s);
    for(size_t v = 0; v < A.size(); v++) {
        for(auto u: A[v]) {
            cout << u + 1 << ' ' << v + 1 << endl;
        }
    }
    cout << 1 << ' ' << A.size() + 1 << endl;
    for(size_t v = 0; v < B.size(); v++) {
        for(auto u: B[v]) {
            cout << u + 1 + t << ' ' << v + 1 + t << endl;
        }
    }
    
}


Measured memory_bytes: 7488
n = int(input())
xl = list(map(int,input().split()))

bl = []

for i in range(n-1):
    bl.append(xl[i+1] - xl[i])

import itertools
bl_ac = list(itertools.accumulate(bl))

MOD = 10**9 + 7
N = 10**5

fact = [1]*(N+1)
rfact = [1]*(N+1)
r = 1
for i in range(1, N+1):
  fact[i] = r = r * i % MOD
rfact[N] = r = pow(fact[N], MOD-2, MOD)
for i in range(N, 0, -1):
  rfact[i-1] = r = r * i % MOD

# nPk (mod MOD) を求める
def perm(n, k):
  return fact[n] * rfact[n-k] % MOD

# nCk (mod MOD) を求める
def comb(n, k):
  return fact[n] * rfact[k] * rfact[n-k] % MOD

ans = 0
p = 1
c = 1
for i in range(n-1):
    ans += bl[i] * perm(n-1, n-2-i) * c
    ans %= MOD
    c *= i + 2
    c += p
    c %= MOD
    p *= i + 2
    p %= MOD

print(ans)

Measured memory_bytes: 22956
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        int beforeT = 0;
        int beforeX = 0;
        int beforeY = 0;
        for (int i = 0; i < n; i++)
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            int t = int.Parse(words[0]);
            int x = int.Parse(words[1]);
            int y = int.Parse(words[2]);
            int time = t - beforeT;
            int distance = Math.Abs(x - beforeX) + Math.Abs(y - beforeY);
            if (distance > t)
            {
                Console.WriteLine("No");
                return;
            }
            if ((time % 2) != (distance % 2))
            {
                Console.WriteLine("No");
                return;
            }
            beforeT = t;
            beforeX = x;
            beforeY = y;
        }

        Console.WriteLine("Yes");
    }
}

Measured memory_bytes: 15184
fn rotate(s: &[Vec<char>]) -> Vec<Vec<char>> {
    let n = s.len();
    let mut t = vec![vec!['.'; n]; n];
    for (i, s) in s.iter().enumerate() {
        for (j, c) in s.iter().enumerate() {
            t[j][n - 1 - i] = *c;
        }
    }
    t
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n: usize = s.trim().parse().unwrap();
    if n == 2 {
        println!("-1");
        return;
    }
    let mut s = vec![vec!['.'; n]; n];
    for c in "abcd".chars() {
        s[0][0] = c;
        s[0][1] = c;
        s = rotate(&s);
    }
    if n == 4 {
        for c in "efgh".chars() {
            s[1][0] = c;
            s[1][1] = c;
            s = rotate(&s);
        }
    } else {
        for c in "efgh".chars() {
            s[1][0] = c;
            s[2][0] = c;
            s = rotate(&s);
        }
        let mut x = 'x';
        let mut y = 'y';
        for i in 1..(n - 3) {
            s[i + 1][i] = x;
            s[i + 2][i] = x;
            s[i][i + 1] = y;
            s[i][i + 2] = y;
            std::mem::swap(&mut x, &mut y);
        }
    }
    let mut out = String::new();
    for s in s.into_iter() {
        for c in s.into_iter() {
            out.push(c);
        }
        out.push('\n');
    }
    print!("{}", out);
}

fn main() {
    run();
}


Measured memory_bytes: 12540
#include <iostream>
#include <cmath>
#include <utility>

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
#define mp make_pair
#define x first
#define y second

int main () {
	string t;
	cin>>t;
	int n=t.length();
	if(t[n-1]=='s'){
		t+="es";
	}
	else t+='s';
	cout<<t;



return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)
const long double PI = (acos(-1));

int main() {

	int n, m;
	cin >> n >> m;

	vector<int> x(m);
	rep(i, 0, m) cin >> x[i];
	vector<int> l(m - 1);

	if (n >= m) {
		cout << 0 << endl;
		return 0;
	}

	sort(x.begin(), x.end());
	
	rep(i, 0, m - 1) l[i] = x[i + 1] - x[i];

	sort(l.begin(), l.end());
	reverse(l.begin(), l.end());

	ll sum = 0;

	rep(i, 0, n - 1) sum += l[i];

	cout << x[m - 1] - x[0] - sum << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#define LEN 100005;

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[100005];
int head, tail, n;

void enqueue(P x){

  Q[tail]=x;
  
  tail=(tail+1)%LEN;
}

P dequeue(void){

  P x=Q[head];
  head=(head+1)%LEN;

  return x;
}

int min(int a, int b){

  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

int main(){

    int elaps=0,c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);

    for(i=1;i<=n;i++){
      scanf("%s",Q[i].name);
      scanf("%d",&Q[i].t);
    }
    head=1; tail=n+1;

    while(head!=tail){
      u=dequeue();
      c=min(q,u.t);
      u.t -= c;
      elaps+=c;
      if(u.t > 0) enqueue(u);
      else{
	printf("%s %d\n", u.name, elaps);
      }
    }

    return 0;
  }



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

bool isPrime(int a) {
  for(int i = 2; i < a; ++i) {
    if(a % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  for(int i = 11; i <= 55555; i += 5) {
    if(isPrime(i)) {
      n--;
      if(n == 0) {
        cout << i << endl;
        break;
      } else {
        cout << i << " ";
      }
    }
  }
  return 0;
}

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

int main() {
  int N, X, sum, a;
  cin >> N >> X;
  int count = N;
  vector<int> m(N);
  for(int i = 0; i < N; i++) {
    cin >> m.at(i);
    X = X - m.at(i);
  }
  sort(m.begin(), m.end());
  a = m.at(0);
  count += X / a;
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define	MIN(a,b,c)	min(min(a,b),c)
#define	MAX(a,b,c)	max(max(a,b),c)
#define ll          long long
#define itr         vector<int>::iterator
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
using namespace std;
vector<ll> v;
void pri(ll n)
{
    while (n%2 == 0)
    {
        v.push_back(2);
        n = n/2;
    }
    for (ll i = 3; i <= sqrt(n); i = i+2)
    {
        while (n%i == 0)
        {
            v.push_back(i);
            n = n/i;
        }
    }
    if (n > 2)
        v.push_back(n);        
}
int main(){
	ll n,p;cin>>n>>p;
	pri(p);map<ll,ll> f;
	for(ll i=0;i<v.size();i++){
		f[v[i]]++;
	}
	ll ans=1;
	for(auto u:f){
		if(u.S>=n){
			ans=ans*pow(u.F,u.S/n);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;
ll bigp = 1000000007;

ll get_num(string s, char c1, char c2, char c3){
    ll l = s.size();
    vector<vector<ll>> dp(3,vector<ll>(l+1));
    reps(i,1,l+1){
        dp[0][i] = dp[0][i-1];
        dp[1][i] = dp[1][i-1];
        dp[2][i] = dp[2][i-1];
        if(s[i-1]==c1){
            dp[0][i] = (dp[0][i-1] + 1)%bigp;
        }
        if(s[i-1]==c2){
            dp[1][i] = (dp[1][i-1] + dp[0][i-1])%bigp;            
        }
        if(s[i-1]==c3){
            dp[2][i] = (dp[2][i-1] + dp[1][i-1])%bigp;            
        }        
    }
    return dp[2][l];
}

ll powmod(ll n, ll m, ll p){
    if(m==0) return 1;
    if(m%2==0){
        ll t = powmod(n, m/2, p);
        return t*t % p;
    }
    return (n * powmod(n, m-1, p))%p;
}

int main()
{
    string s;
    cin >> s;
    ll l = s.size();
    ll ques_num = 0;
    rep(i,l){
        if(s[i]=='?'){ques_num++;}
    }
    ll ans = 0;
    ans =  (ans + get_num(s,'A','B','C') * powmod(3,ques_num,bigp))%bigp;
    if(ques_num >= 1){
        ans = (ans + get_num(s,'A','B','?') * powmod(3,ques_num-1,bigp))%bigp;
        ans = (ans + get_num(s,'A','?','C') * powmod(3,ques_num-1,bigp))%bigp;
        ans = (ans + get_num(s,'?','B','C') * powmod(3,ques_num-1,bigp))%bigp;
    }
    if(ques_num >= 2){
        ans = (ans + get_num(s,'A','?','?') * powmod(3,ques_num-2,bigp))%bigp;
        ans = (ans + get_num(s,'?','B','?') * powmod(3,ques_num-2,bigp))%bigp;
        ans = (ans + get_num(s,'?','?','C') * powmod(3,ques_num-2,bigp))%bigp;
    }
    if(ques_num >= 3){
        ans = (ans + get_num(s,'?','?','?') * powmod(3,ques_num-3,bigp))%bigp;
    }
    cout << ans;
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int main(){
	int a;
	int b;
	cin >> a >> b;
	int* c;
	c = new int[b];
	int d = 0;
	for (int i = 0;i < b;i++) {
		cin >> c[i];
		d += c[i];
	}
	if (a - d <= 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 640
n,a,b=map(int,input().split())
count=0
fcount=0
for s in input():
#    print(s,count,fcount)
    if s=="c":
        print("No")
    elif s=="a":
        if count<a+b:
            print("Yes")
            count+=1
        else:
            print("No")
    else:
        fcount+=1
        if count<a+b and fcount<=b:
            print("Yes")
            count+=1
        else:
            print("No")

Measured memory_bytes: 4244
n = gets.to_i
tree = Struct.new(:parent, :depth, :type, :children)
node = Array.new(n) {tree.new}
n.times do
  ar = gets.split.map(&:to_i)
  node[ar[0]].children = ar[2..-1]
  node[ar[0]].parent = -1
  node[ar[0]].type = "leaf"
end

node.each_with_index do |nd, i|
  nd.children.each {|child| node[child].parent = i}
  nd.type = "internal node" unless nd.children.empty?
end

root_index = 0
node.each_with_index {|nd, i| root_index = i if nd.parent == -1}
node[root_index].type = "root"

search = ->(index, depth) {
  node[index].depth = depth
  children = node[index].children
  return if children.empty?
  children.each {|child| search.(child, depth + 1)}
}
search.(root_index, 0)

node.each_with_index do |nd, i|
  puts "node #{i}: parent = #{nd.parent}, depth = #{nd.depth}, #{nd.type}, #{nd.children.inspect}"
end


Measured memory_bytes: 35668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

int main() {
    FAST_IO();
    int N; cin >> N;
    vector<int> P(N + 1);
    repp(i, 1, N) {
        int x; cin >> x;
        P[x] = i;
    }
    set<int> bigger;
    bigger.insert(0);
    bigger.insert(N + 1);
    ll ans = 0;
    for(int x = N; x >= 1; --x) {
        auto pos = bigger.lower_bound(P[x]);
        int R = *(pos);
        int RR;
        if(R == N + 1) RR = R;
        else {
            RR = *(++pos);
            --pos;
        }
        int L = *(--pos);
        int LL;
        if(L == 0) LL = L;
        else {
            LL = *(--pos);
        }
        ans += (ll)x * ((L - LL) * (R - P[x]) + (RR - R) * (P[x] - L));
        bigger.insert(P[x]);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 5376
#include <iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
	int R[MAX], n;
	
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> R[i];
		
	int maxv = R[1] - R[0];
	int minv = R[0];
	
	for(int i = 1; i < n; i++){
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	
	cout << maxv << endl;
	
	return 0;
}


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

int main() {
	int len[10];
	for (int i = 0; i < 10; i++) len[i] = 0;
	for (int i = 0; i < 3; i++) {
		int n;
		cin >> n;
		len[n - 1]++;
	}
	if (len[4] == 2 && len[6] == 1) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int a[2000000];
int main(){
	int n,m;cin>>n>>m;
	rep(i,m){
		scanf("%d",&a[i]);
		n-=a[i];
	}
	if(n<0)puts("-1");
	else cout<<n<<endl;
}

Measured memory_bytes: 3768
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007


template <class T>
void print(vector<T> arr)
{
	cout << "start printing the vector\n";
	for (auto u : arr)
		cout << u << " ";
	cout << "\n";
}

template <class T>
void print_mat(vector<vector<T>> a)
{
	cout << "start printing the matrix\n";
	for (auto v : a)
	{
		for (auto e : v)
		{
			cout << e << " ";
		}
		cout << "\n";
	}
}

/******************************************
* NUMBER THEORY ;) *
******************************************/



ll powermod(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	res %= mod;
	return res;
}
ll factmod(ll n)
{
	ll res = 1;
	while (n > 1)
	{
		res = (res * ((n / mod) % 2 ?  mod - 1 : 1)) % mod;
		for (ll i = 2; i <= n % mod; ++i)
			res = (res * i) % mod;
		n /= mod;
	}
	res %= mod;
	return res;
}



void solve()
{
	ll n, k;
	cin >> n >> k;
	vll arr(n);
	for (ll i = 0; i < n; i++)
		cin >> arr[i];

	vector<double> cumul = {0};
	double summ = 0;
	for (ll i = 0; i < n; i++)
	{
		summ += (1 + arr[i]) / 2.0;
		cumul.pb(summ);
	}
	double maxx = 0;
	for (ll i = 0; i + k <= n; i++)
	{
		maxx = max(cumul[i + k ] - cumul[i], maxx);
	}
	cout << fixed << setprecision(12) << maxx << "\n";
}

int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ll t;
	// cin>>t;
	// while(t--)
	// {
	solve();
	// }

	return 0;
}

Measured memory_bytes: 6892
def min(a, b)
  a < b ? a : b
end

n = gets.to_i
x = gets.chomp.split.map(&:to_i)
ans = 0xffffffff

1.upto(x.max) do |p|
  cnt = 0
  x.each do |xi|
    cnt += (xi - p) ** 2
  end
  ans = min(ans, cnt)
end

puts ans

Measured memory_bytes: 1788
using System;
using System.Linq;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class program{
  static void Main(string[] args){
    program p = new program();
    p.Run();
  }
  void Run(){
	int[] inp = Readint();
    int K = inp[0], X = inp[1];
    int st = Max(-1000000,X-K);
    int en = Min( 1000000,X+K);
    string res = "";
    for(int i = st+1; i < en ; i++){
      res += i.ToString() + " ";
    }
    WriteLine(res);
  }

  int[] Readint(){
    string[] s = ReadLine().Split();
    int[] res=new int[s.Length];
    Parallel.For(0,s.Length,i=>{
      res[i]=int.Parse(s[i]);
    });
    return res;
  }
}

Measured memory_bytes: 13652
#include <bits/stdc++.h>
#include <cstring>
#include <ctype.h>
#include<stdlib.h>

#define pi 2 * acos(0.00)
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl '\n'
#define nll '\0'
#define mx 1000007
#define bdyptb return 0;
#define testcase ll t,tt; cin>>tt; for(t=1;t<=tt;t++)
   
#define mod 142857

using namespace std;


struct level
{
    int a;
    int b;
};

bool acp(level lhs,level rhs)
{return lhs.a<rhs.a;}

int main()
{
    fastio;
    
    int x,n;
    cin>>x>>n;

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

    int mn=1000;
int ans=0,d;
    for(int i=-100; i<=250; i++)
    {
        int f=0;
        if(i>0)
        for(int j=0;j<n;j++)
        {
            if(i==p[j])
            {
                f=1;
                break;
            }       
        } 
        if(!f) 
        {
            d=abs(x-i);
            if(mn>d)
            {
                mn=d;
                ans=i;
            }
        }      
        
    }

    cout<<ans<<nl;
    
    
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int32_t main() {
    //ios::sync_with_stdio(false); cin.tie(nullptr);

	int a, b;
	cin >> a >> b;

	if (a <= 5) {
		cout << 0 << "\n";
	} else if (6 <= a and a <= 12) {
		cout << b / 2 << '\n';
	} else {
		cout << b << "\n";
	}

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		int ans = -1;
		for (int i = 1; i <= 2000; i++) {
			if(Math.floor((double)i*0.08)==a&&Math.floor((double)i*0.1)==b) {
				ans = i;
				break;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<cstring>
using namespace std;
int n,a,c=0x7fffffff;
int ass(int x){
	int s=0;
	while(x)
	  s+=x%10,
	  x/=10;
	return s;
}
int main(){
	scanf("%d",&n);
	for(a=1;a<=(n+1)/2;a++)
	  if(ass(a)+ass(n-a)<c)
		c=ass(a)+ass(n-a);
	printf("%d",c);
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;

int main(void) {

	int a = 0, c = 0;

	string s;

	cin >> s;

	for (int k = 0; k < s.size(); k++) {
		if (s.at(k) == 'A') {
			a++;
		}
		else if (a==1&&s.at(k) == 'C')c++;
		else a = 0;

//		printf("a=%d,c=%d\n", a, c);
	}

	if (c >= 1)cout << "Yes\n";
	else cout << "No\n";


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
#include <sstream>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

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

    ll n;

    cin >> n;

    ans = 1;
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        if (a % 2 == 0 && (a % 3 != 0 && a % 5 != 0)) ans = 0;
    }

    (ans) ? (cout << "APPROVED" << endl) : (cout << "DENIED" << endl);


}

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

typedef struct{
	int q, c;	
}Problem;

typedef long long	ll;
const int N = 1e5 + 10;
Problem problems[N];
const int S = 3;
ll dp[N][S][S];
bool used[N][S][S];
const int mod = 1e9 + 7;
string s;
int n;
int tot = 0;

ll fast_pow(ll n, ll x){
	if(x == 0LL){
		return 1LL;
	}
	
	if(x == 1LL){
		return n;
	}
	
	ll r = fast_pow(n, x / 2LL);
	r *= r;
	r %= mod;
	
	if(x & 1LL){
		r *= n;
	}
	
	r %= mod;
	
	return r;
}
ll solve(int i, int letter, int ques){
	if(letter >= S){
		return fast_pow(3LL, tot - ques);
	}
	
	if(i >= n){
		return 0LL;
	}
	
	char c = char('A' + letter);
	
	ll &ans = dp[i][letter][ques];
	
	if(used[i][letter][ques]){
		return ans;
	}
	
	used[i][letter][ques] = true;
	
	if(s[i] == c){
		ans = solve(i + 1, letter + 1, ques);
	}else if(s[i] == '?'){
		ans = solve(i + 1, letter + 1, ques + 1);
	}
	
	ans += solve(i + 1, letter, ques);
	ans %= mod;
	
	return ans;
}

int main() {
	cin >> s;
	n = s.length();
	
	for(int i = 0 ; i < n ; i++){
		if(s[i] == '?'){
			tot++;
		}
	}
	cout << solve(0, 0, 0) << endl;
	
	return 0;
}

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

struct P {
    string s;
    int p;
		int index;

    bool operator<(const P &another) const {
        if (s == another.s)
            return p > another.p;
        else
            return s < another.s;
    };
};

int main() {
	int N;
	cin >> N;
	vector<P> rest(N);
	rep(i,N){
		cin >> rest[i].s >> rest[i].p;
		rest[i].index = (i + 1);
	}
	sort(all(rest));
	rep(i,N){
		cout << rest[i].index << endl;
	}
}

Measured memory_bytes: 256
#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 a,b,k;
    vector<int> v;
    cin >> a >> b >> k;
    for(int i=1; i<=min(a, b); ++i){
        if(a%i == 0 && b%i == 0) v.push_back(i);
    }
    cout << v[v.size()-k] << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

 string f(string t) {
   string res;
    int n = t.size();
    char tmp = t[n-1]; 
    t.pop_back();
    res.push_back(tmp); 
    res = res + t;
    return res;
}
int main() {
  string s ,t;
  cin >> s >> t;
  if(s == t) {
    cout << "Yes" << endl;
    return 0;
  }
  bool b = false;
  int n = s.size();

  string tmp = s;
  rep(i, n-1) {
    tmp = f(tmp);
    if(tmp == t) b = true;
  }
  yorn(b);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	string s;
	cin>>s;
	rep(i,s.size()){
		if(s[i]==',')s[i]=' ';
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;


int main(){
    ll N, A, B; cin >> N >> A >> B;
    vector<ll> h(N);
    rep(i,N) cin >> h[i];

    ll extra_damage = A-B;

    ll ng = 0;
    ll ok = 1e9;
    
    while(abs(ok-ng)>1){
        ll mid = (ok+ng) / 2;
        auto f = [&](ll mid){
            ll damage = mid*B;
            ll count = 0;
            rep(i,N){
                ll rh = h[i] - damage;
                if (rh <= 0) continue;
                count += (rh+(extra_damage-1))/extra_damage;
            }
            
            return count <= mid; 
        };
        if(f(mid)) ok = mid;
        else ng = mid;
    }

    cout << ok << endl;
}

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

long long dp[1001][1001];

int main(void){
	int N,Ma,Mb;
	cin >> N >> Ma >> Mb;
	vector<int> a(N),b(N),c(N);
	for(int i=0;i<N;i++){
		cin >> a[i] >> b[i] >> c[i];
	}

	long long INF = 1e18;
	for(int i=0;i<=1000;i++)for(int j=0;j<=1000;j++)
		dp[i][j] = INF;

	dp[0][0] = 0;
	for(int k=0;k<N;k++){
		for(int i=1000;i>=0;i--){
			for(int j=1000;j>=0;j--){
				if(i-a[k] < 0 || j-b[k] < 0)continue;
				if(dp[i-a[k]][j-b[k]] == INF)continue;
				dp[i][j] = min(dp[i-a[k]][j-b[k]] + c[k],dp[i][j]);
			}
		}
	}

	long long ret = INF;
	for(int i=1;i<=100;i++){
		ret = min(ret,dp[Ma*i][Mb*i]);
	}
	if(ret == INF)cout << -1 << endl;
	else cout << ret << endl;

	return 0;
}

Measured memory_bytes: 8064
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=[[0,0] for i in range(48)]
lis[0]=[0,1]
sup=1
low=0
for i in range(1,48):
    #print(low,sup)
    lis[i][0]=low+(-2)**i
    lis[i][1]=sup+(-2)**i
    if i%2==1:
        low+=(-2)**i
    else:
        sup+=(-2)**i
#print(lis)
x=47
table=[0 for i in range(48)]
while x>0:
    if lis[x][0]<=n<=lis[x][1]:
        table[x]=1
        n-=(-2)**x
    x-=1
if n==1:
    table[0]=1
#print(table)
u=sum(table)
if u==0:
    print(0)
    sys.exit()
goal=[]
y=0
sm=0
while sm<u:
    if table[y]==1:
        sm+=1
    goal.append(table[y])
    y+=1
#print(goal)
print(''.join(list(map(str,list(reversed(goal))))))

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

int main() {
	int N;
	cin >> N;
	int A[N];
	for (int i = 0 ; i < N; i++) {
		cin >> A[i];
	}
	int temp, j;
	for (int i = 0; i < N; i++) {
		temp = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > temp) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = temp;
		for (int j = 0; j < N; j++) {
			if (j != N - 1) {
				cout << A[j] << " " << flush;
			}
			else {
				cout << A[j] << endl;
			}
		}

	}
	return 0;
}


Measured memory_bytes: 3036
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF32		INT32_MAX
#define	INF64		INT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

// main function
int main()
{
	ll N = 0;
	ll L = 0;
	ll ret = 0;

	cin >> N >> L;
	vector<ll> apple(N, 0);

	ll skip_idx = 0;
	ll min_abs = INT32_MAX;
	Rep(i, N) {
		apple[i] = L + i;
		if (abs(apple[i]) < min_abs) {
			min_abs = abs(apple[i]);
			skip_idx = i;
		}
	}

	Rep(j, N) {
		if (skip_idx == j) continue;
		ret += apple[j];
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<int> h(n), dp(n);
  rep(i, 0, n) cin >> h[i];

  dp[0] = 0;
  rep(i, 1, n) {
    if (i == 1)
      dp[i] = abs(h[i] - h[i - 1]);
    else
      dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]),
                  dp[i - 1] + abs(h[i] - h[i - 1]));
  }
  cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>

int x, a, b;

int main(){
    scanf("%d %d %d", &x, &a, &b);

    a = std::abs(x - a);
    b = std::abs(x - b);

    printf("%c\n", a < b ? 'A' : 'B');

    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read()
{
	int x,f=1;char c;
	while((c=getchar())<'0'||c>'9')if(c=='-')f=0;
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return f?x:0;
}
#define MN 200000
struct edge{int nx,t;}e[MN*3+5];
int n,h[MN+5],en=1,r[MN+5],u[MN*3+5],ans[MN+5];
inline void ins(int x,int y)
{
	e[++en]=(edge){h[x],y};h[x]=en;++r[x];
	e[++en]=(edge){h[y],x};h[y]=en;++r[y];
}
void dfs(int x)
{
	for(int i;i=h[x];)
	{
		h[x]=e[h[x]].nx;
		if(u[i])continue;
		if(x<=n&&e[i].t>n||x>n&&e[i].t<=n)++ans[x],--ans[e[i].t];
		u[i^1]=1;dfs(e[i].t);
	}
}
int main()
{
	n=read();
	for(int i=1;i<=n;++i)ins(read(),i);
	for(int i=1;i<=n;++i)ins(read()+n+1,i+n+1);
	for(int i=0;i<=n;++i)
	{
		if((r[i]^r[i+n+1])&1)return 0*puts("IMPOSSIBLE");
		if(r[i]&1)ins(i,i+n+1);
	}
	puts("POSSIBLE");
	dfs(0);
	for(int i=1;i<=n;++i)printf("%d ",ans[i]);
}

Measured memory_bytes: 19200
num = input()

def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)

if digitSum(num) % 9 == 0:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 75548