akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(vec, s) vec.find(s) != vec.end()
#define Set_union(A, B, res) set_union(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_intersection(A, B, res) set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_difference(A, B, res) set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_symmetric_difference(A, B, res) set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));

struct UnionFind {
	vector<int> par;
	int group_count;

	UnionFind(int N) {
		par = vector<int>(N, -1);
		group_count = N;
	}

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

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

	void unite(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (par[x] > par[y]) swap(x, y);
			par[x] += par[y];
			par[y] = x;
			group_count--;
		}
	}

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

	int max_size() {
		return -(*min_element(All(par)));
	}
};

int main() {
	int N, M;
	cin >> N >> M;
	vector<P> edge(M);
	int a, b;
	Rep(i, M) {
		cin >> a >> b;
		edge[i] = make_pair(a - 1, b - 1);
	}
	int ans = 0;
	Rep(i, M) {
		UnionFind UF(N);
		Rep(j, M) {
			if (j == i) continue;
			UF.unite(edge[j].first, edge[j].second);
		}
		if (UF.group_count > 1) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>

int main(void){
    int n, m, l0 = 1, r0, l, r, i;
    scanf("%d %d", &n, &m);
    r0 = n;
    for(i = 1; i <= m; i++){
        scanf("%d %d", &l, &r);
        if(l0 < l){
            l0 = l;
        }
        if(r < r0){
            r0 = r;
        }
    }
    if(r0 - l0 + 1 > 0){
        printf("%d", r0 - l0 + 1);
    }else{
        printf("0");
    }
    return 0;
}

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

using namespace std;

void outStr(vector<int>& ary) {

	string aryStr = "";
	for (int i = 0; i < ary.size() ; i++)
	{
		aryStr = aryStr + to_string(ary[i]);
		if (i < ary.size() - 1) aryStr = aryStr + " ";
	}

	cout << aryStr << endl;
	return;
}

int main() {

	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	outStr(A);

	int v = 0;; int j = 0;
	for (int i = 1; i < N;i++) {
		v = A[i];
		j = i - 1;

		while (j >= 0 && A[j] > v)
		{
			A[j + 1] = A[j];
			j--;
			
		}
		A[j + 1] = v;

		outStr(A);
	}

	return 0;
}



Measured memory_bytes: 3220
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
typedef long long ll;
map<int, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	int c = 1, d = 1;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		c *= 3;
		if (a[i] % 2 == 0) d *= 2;
	}
	cout << c - d << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N,M;cin>>N>>M;
  vector< pair<ll,ll> > p(N);
  rep(i,N) cin>>p[i].first>>p[i].second;

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

  priority_queue<ll> que;
  ll ans = 0, cnt = 0;
  repn(i,M){
    while(i == p[cnt].first){
      que.push(p[cnt].second);
      cnt++;
    }
    if(que.empty()) continue;
    ans += que.top();
    que.pop();
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2936
import sys
from itertools import accumulate

# functions used
r = lambda: sys.stdin.readline().strip() #single: int(r()), line: map(int, r().split())
R = lambda: list(map(int, r().split())) # line: R(), lines: [R() for _ in range(n)]
Rmap = lambda: map(int, r().split())
# set inputs
N, C = R()
STC = [R() for _ in range(N)]
#  0.5sec as one unit
tbl = [[0]*(2*(10**5)+5) for _ in range(C)]

for s, t, c in STC:
    c -= 1
    # if we can record the programms continuously (ver1)
    if tbl[c][2*s] != 0:
        tbl[c][2*s] += 1
        tbl[c][2*t] -= 1
    # if we can record the programms continuously (ver2)
    elif tbl[c][2*t-1] != 0:
        tbl[c][2*t-1] -= 1
        tbl[c][2*s-1] += 1
    # else:
    else:
        tbl[c][2*s-1] = 1
        tbl[c][2*t] = -1

tbl2 = [list(accumulate(a)) for a in tbl]
for i in range(200002):
     for j in range(C):
         if tbl2[j][i]>1:
          	tbl2[j][i]=1

ans = max([sum(x) for x in zip(*tbl2)])
print(ans)

# tmp = [sum(x) for x in zip(*tbl2)]

# res = 0
# for i in range(200002):
#     cc = 0
#     for j in range(C):
#         if tbl2[j][i]:
#             cc += 1
#     res = max(res, cc)
# print(res)


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

bool contains(long top, int target) {
    while (top > 0) {
        if (top % 10 == target)
            return true;
        top /= 10;
    }
    return false;
}

int solve(long n) {
    queue<int> que;
    que.push(0);
    int count = 0;
    while (true) {
        long top = que.front();
        que.pop();
        if (top > n)
            return count;
        if (contains(top, 3) && contains(top, 5) && contains(top, 7))
            count++;
        top *= 10;
        que.push(top + 3);
        que.push(top + 5);
        que.push(top + 7);
    }
}

int main() {
    long n;
    cin >> n;
    cout << solve(n) << endl;
    return 0;
}


Measured memory_bytes: 640
S1,S2,S3 =map(str,input())
if S1 == "R"and S2 == "R" and S3 =="S":
  print(2)
elif S1 == "R" and S2 == "R" and S3=="R":
    print(3)
elif S1 == "S" and S2 == "R" and S3=="R":
    print(2)
elif S1=="S"and  S2=="S"and S3=="S":
    print(0)
else:
    print(1)

Measured memory_bytes: 8968
n,x = map(int,(input().split()))
aa = list(map(int,input().split()))
sum_aa = sum(aa)

for i in range(n-1):
  tmp = aa[i+1] + aa[i]
  tmp = tmp - x #食べないといけない量
  if tmp > 0:
    sa = aa[i+1] - tmp
    if sa >= 0 :
      aa[i+1] -= tmp
    else:
      sa2 = tmp - aa[i+1]
      aa[i+1] = 0
      aa[i] -= sa2 
      
print(sum_aa - sum(aa))

Measured memory_bytes: 14540
n=int(input())
d=[]
ans=[[]for i in range(n)]
for i in range(n):
  d.append(list(input().split()))
for i in range(n):
  ans[i].append(d[i][0])
  j=int(d[i][1])
  ans[i].append(-j)
  ans[i].append(i)
ans.sort()

for i in range(n):
  print(ans[i][2]+1)

Measured memory_bytes: 3064
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x1: i32,
        y1: i32,
        x2: i32,
        y2: i32,
    }
    let v = (-(y2 - y1), x2 -x1);
    let x3 = x2 + v.0;
    let y3 = y2 + v.1;

    let v = (-(y3 - y2), x3 -x2);
    let x4 = x3 + v.0;
    let y4 = y3 + v.1;
    println!("{} {} {} {}", x3, y3, x4, y4);
}

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

int main(){
	int a, b, n, time, route, min=1001;
	cin >> n >> time;
	while(n--){
		cin >> a >> b;
		if(b<=time && a<min){
			min = a;
		}
	}
	if(min<1001){
		cout << min << endl;
	}else{
		cout << "TLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int dp[31] ={1,2,4},step;
int main(){
  for(int i=3;i<31;i++){
    dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
  }
  while(cin>>step,step){
    cout<<(dp[step-1])/3650+1<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
 
using namespace std;
 
struct P{int c,r;};
struct State{
  int t,pos, remain;
  bool operator < (const State& st) const {
    return t > st.t;
  }
};
 
const int MAX = 5001;
const int INF = (1<<25);
int T[MAX][MAX];
vector<int> Edge[MAX];
P price[MAX];
int N,K;
 
void input(){
  scanf("%d %d",&N,&K);
  for(int i = 0; i < N; i++) scanf("%d %d",&price[i].c, &price[i].r);
  for(int i = 0; i < K; i++){
    int a,b;
    scanf("%d %d",&a, &b);
    a--;b--;
    Edge[a].push_back(b);
    Edge[b].push_back(a);
  }
}
 
int solve(){
  memset(T, -1, sizeof(T));
  T[0][0] = 0;
  priority_queue<State> Q;
  Q.push((State){0,0,0});
  while(!Q.empty()){
    const State now = Q.top();
    Q.pop();
     
    if(now.t > T[now.pos][now.remain]) continue;
    
    if(now.pos == N-1) return now.t;
    if(now.remain > 0){
      for(int i = 0; i < (int)Edge[now.pos].size(); i++){
    State nex = now;
    nex.pos = Edge[now.pos][i];
    nex.remain--;
     
    if(T[nex.pos][nex.remain] == -1 || T[nex.pos][nex.remain] > nex.t){
      T[nex.pos][nex.remain] = nex.t;
      Q.push(nex);
    }
      }
    }
 
    if(T[now.pos][price[now.pos].r] == -1 || T[now.pos][price[now.pos].r] > now.t+price[now.pos].c){
      T[now.pos][price[now.pos].r] = now.t+price[now.pos].c;
      Q.push((State){now.t+price[now.pos].c, now.pos, price[now.pos].r});
    }
  }
  return INF;
}
 
int main(){
 
  input();
  printf("%d\n",solve());
  return 0;
}

Measured memory_bytes: 99400
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353


ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll n,l;
    cin>>n>>l;
    vector <ll> a(n);
    for (ll i = 0; i < n; i++){
        a[i] = l+i;
    }
    ll s = 0;
    for(ll i =0; i < n; i++){
        s += a[i];
    }
    ll ans = 1e9;
    for (ll i =0; i < n; i++){
        ll t = s-a[i];
        if(abs(t-s) < abs(ans-s))ans = t;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

int main(){
  int l, r;
  cin >> l >> r;
  if(l / 2019 < r / 2019){
    cout << 0 << endl;
    return 0;
  }
  l %= 2019, r %= 2019;
  int m = 1 << 30;
  for(int i = l; i < r; ++i){
    for(int j = i + 1; j <= r; ++j){
      m = min(m, i * j % 2019);
    }
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vs = vector<string>;
using vvs = vector<vs>;
using pli = pair<long long, int>;
using vpli = vector<pli>;

int main() {
  ll N, cnt = 0, flg = 0;
  string S;
  cin >> N >> S;
  
  for (int i = 0; i < N; i++) {
    if (flg == 0) {
      if (S.at(i) == 'A') flg = 1;
    }
    else if (flg == 1) {
      if (S.at(i) == 'B') flg = 2;
      else if (S.at(i) == 'A') flg = 1;
      else flg = 0;
    }
    else if (flg == 2) {
      if (S.at(i) == 'C') cnt++;
      flg = 0;
    }
  }
  
  cout << cnt << endl;
  
}

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

using namespace std; 

const int N=205,M=20005,inf=1e9;
int S,T,h[N],nxt[M],to[M],flow[M],cnt=1,qu[N],ql,qr,d[N];
void addedge(int u,int v,int c1,int c2){
	to[++cnt]=v,nxt[cnt]=h[u],h[u]=cnt,flow[cnt]=c1;
	to[++cnt]=u,nxt[cnt]=h[v],h[v]=cnt,flow[cnt]=c2;
}
bool bfs(){
	for(int i=S;i<=T;i++)d[i]=-1;
	d[S]=0,qu[ql=qr=1]=S;
	while(ql<=qr){
		int u=qu[ql++];
		for(int i=h[u],v;i;i=nxt[i])if(d[v=to[i]]==-1&&flow[i])d[v]=d[u]+1,qu[++qr]=v;
		if(d[T]!=-1)break;
	}
	return d[T]!=-1;
}
int dfs(int u,int mf){
	if(u==T)return mf;
	int r=0,p;
	for(int i=h[u],v;i;i=nxt[i])if(d[v=to[i]]==d[u]+1&&flow[i])
		p=dfs(v,min(mf,flow[i])),flow[i]-=p,flow[i^1]+=p,r+=p,mf-=p; 
	return r;
}
int dinic(){
	int r=0;
	while(bfs())
		r+=dfs(S,inf);
	return r;
}

int n,m;
char ch[N][N]; 

int main(){
	scanf("%d%d",&n,&m);
	S=0,T=n+m+1;
	for(int i=1;i<=n;i++)scanf("%s",ch[i]+1);
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)
		switch(ch[i][j]){
			case '.': break;
			case 'o': addedge(i,j+n,1,1); break;
			case 'S': addedge(S,i,inf,0),addedge(S,j+n,inf,0); break;
			case 'T': addedge(i,T,inf,0),addedge(j+n,T,inf,0); break;
		}
	int cur=dinic();
	if(cur>=inf)
		puts("-1");
	else
		printf("%d\n",cur);
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
    char a[100], b[100], c[100];
    int i, j, flag1, flag2;

    flag1 = flag2 = 0;

    scanf("%s %s %s", a, b, c);

    i = 0;
    while (a[i] != '\0') i++;
    if (a[i - 1] == b[0]) flag1 = 1;

    i = 0;
    while (b[i] != '\0') i++;
    if (b[i - 1] == c[0]) flag2 = 1;

    if (flag1 + flag2 == 2) printf("YES\n");
    else printf("NO\n");

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1000000007; // 10000000000000007ll;

const double eps = 1e-8;

const i64 MAXN = 300004;

i64 n;
i64 a[MAXN];
unordered_map<i64, i64> b;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);


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

    for (i64 i = 0; i < n; i++) {
        if (b[a[i]]) {
            cout << "NO" << endl;
            return 0;
        }
        b[a[i]]++;
    }
    cout << "YES" << endl;


    return 0;
}

Measured memory_bytes: 9288
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

if a <= 40:
    a = 40
if b <= 40:
    b = 40
if c<= 40:
    c = 40
if d <= 40:
    d = 40
if e <= 40:
    e = 40
    
sum = a+b+c+d+e
ave = int(sum/5)
print(ave)


Measured memory_bytes: 5588
import math
L = int(input())
r = int(math.log2(L))

res = []
for i in range(1, r+1):
    res.append([i, i+1, 0])
    res.append([i, i+1, 2**(i-1)])

for t in range(r, 0, -1):
    if L >= 2**r + 2**(t-1):
        L -= 2**(t-1)
        res.append([t, r+1, L])

print(r+1, len(res))
for i in range(len(res)):
    print(res[i][0], res[i][1], res[i][2])


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

using namespace std;

stack<int> s;
int main() {
    string S;
    
    while(cin >> S) {
        if(S[0] == '+') {
            int a = s.top();
            s.pop();
            int b = s.top();
            s.pop();
            s.push(a+b);
        }
        else if(S[0] == '-') {
            int a = s.top();
            s.pop();
            int b = s.top();
            s.pop();
            s.push(b-a);
        }
        else if(S[0] == '*') {
            int a = s.top();
            s.pop();
            int b = s.top();
            s.pop();
            s.push(a*b);
        }
        else {
            s.push(atoi(S.c_str()));
        }
    }
    printf("%d\n", s.top());
    
    return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

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

    int N; cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));
    int ans = N, cnt = 0, even = 0;
    rep(i, N) {
        if (i + 1 < N && A[i] == A[i+1]) {
            cnt++;
        } else {
            if (cnt) ans -= cnt;
            if ((cnt + 1) % 2 == 0) even++;
            cnt = 0;
        }
    }
    if (even % 2) ans--;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
def mul(mx1, mx2):
    n = len(mx1)
    m = len(mx1[0])
    l = len(mx2[0])
    ans = [[None] * l for _ in range(n)]

    for i in range(n):
        for j in range(l):
            _e = 0
            for k in range(m):
                _e += mx1[i][k] * mx2[k][j]
            ans[i][j] = _e

    return ans


n, m, l = [int(i) for i in input().strip().split()]

mx1 = []
mx2 = []

for _ in range(n):
    mx1.append([int(i) for i in input().strip().split()])

for _ in range(m):
    mx2.append([int(i) for i in input().strip().split()])

ans = mul(mx1, mx2)

for row in ans:
    print(" ".join([str(i) for i in row]))


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

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), std::greater<int>());
    int sum_a = 0;
    int sum_b = 0;
    for (int i = 0; i < N; i++)
    {
        if (i % 2 == 0)
        {
            sum_a += a[i];
        }
        else
        {
            sum_b += a[i];
        }
    }
    cout << sum_a - sum_b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
using namespace std;
long long a[100009] = { 0 };
int main() {
	long long n, i, j, t;
	cin >> n;
	for (i = 1; i <= 9; i++) {
		a[i] = i;
	}
	j = 10;
	for (i = 1; i < 100005; i++) {
		t = a[i];
		if (t % 10 != 0) {
			a[j] = t * 10 + t % 10 - 1;
			j++;
		}
		a[j] = t * 10 + t % 10;
		j++;
		if (t % 10 != 9) {
			a[j] = t * 10 + t % 10 + 1;
			j++;
		}
		if (j > 100003)break;
	}
	cout << a[n] << endl;
	return 0;
}

Measured memory_bytes: 1024
import sys

input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    m = [0]*N
    for _ in range(M):
        a, b = map(int, input().split())
        m[a-1] += 1
        m[b-1] += 1
    for i in range(N):
        print(m[i])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
)

var out = bufio.NewWriter(os.Stdout)

func next() string {
	var s string
	fmt.Scan(&s)
	return s
}

func main() {
	defer out.Flush()

	s := next()
	t := next()

	pos := [128][]int{}

	for i, e := range s {
		pos[e] = append(pos[e], i)
	}

	var ans int64 = 0
	cur := -1

	gogo := func(next int) {
		if next <= cur {
			ans += int64(len(s) - cur + next)
		} else {
			ans += int64(next - cur)
		}
		cur = next % len(s)
	}

	f := func(e int32) {
		var nxt int
		if pos[e][len(pos[e])-1] <= cur {
			nxt = pos[e][0]
		} else {
			lb := 0
			ub := len(pos[e]) - 1
			for lb != ub {
				mid := (lb + ub) / 2
				if pos[e][mid] > cur {
					ub = mid
				} else {
					lb = mid + 1
				}
			}
			nxt = pos[e][lb]
		}
		gogo(nxt)
	}

	for _, e := range t {
		if len(pos[e]) == 0 {
			fmt.Fprintln(out, -1)
			return
		}
		f(e)

	}
	fmt.Fprintln(out, ans)

}


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

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

struct edge {
    ll to, cost;
};

int main() {
    ll N;
    cin >> N;
    vector<edge> G[N];
    for (int i = 0; i < N - 1; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        G[a].push_back(edge{b, c});
        G[b].push_back(edge{a, c});
    }

    ll Q, K;
    cin >> Q >> K;
    K--;

    priority_queue<P, vector<P>, greater<P>> que;
    vector<ll> d(N, 1000000000000000000);
    d[K] = 0;
    que.push(P(0, K));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }

    for (int i = 0; i < Q; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << d[x] + d[y] << endl;
    }

    return 0;
}

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


void solve(long long N, long long D, long long X, std::vector<long long> A){
    auto ans=X;
    for(auto a: A){
        auto tmp=1;
        while(tmp <= D){
            ans++;
            tmp += a;
        }
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    long long X;
    scanf("%lld",&X);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, D, X, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
const int N=1e5+5;
int n,p[N],fa[N],sz[N],dep[N];long long d[N];
map<long long,int>Map;
bool cmp(int x,int y){
	return d[x]>d[y];
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%lld",&d[i]);
		Map[d[i]]=i;p[i]=i;sz[i]=1;
	}
	sort(p+1,p+n+1,cmp);
	for(int i=1;i<n;++i){
		int x=p[i];
		fa[x]=Map[d[x]-n+sz[x]+sz[x]];
		if(!fa[x]||fa[x]==x)return puts("-1"),0;
		sz[fa[x]]+=sz[x];
	}
	long long sum=0;
	for(int i=n-1;i;--i)dep[p[i]]=dep[fa[p[i]]]+1,sum+=dep[p[i]];
	if(sum!=d[p[n]])return puts("-1"),0;
	for(int i=1;i<n;++i)printf("%d %d\n",p[i],fa[p[i]]);
	return 0;
}


Measured memory_bytes: 9984
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int N = S.size();
  int64_t sum = 0;
  rep(i, N) { sum += (int64_t)(S[i] - '0'); }
  if (sum % 9 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main()
{
  ll a, b, c;
  cin >> a >> b >> c;
  if ((a*b*c)%2==0) {
    cout << "0" << endl;
    exit(0);
  }
  cout << min(a*b, min(b*c, c*a)) << endl;
  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 N = sc.nextInt();
		 int res = 0;
 		
if(N %2 ==0){
res = N;
} else {
res = N*2;
}

System.out.println(res);
}
}

Measured memory_bytes: 21588
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

using namespace std;

int main(){

    int ans=0;
    string s;
    cin>>s;
    int n=s.size();
    if(n%2==0){
        for(int i=0;i<n/2;i++){
            if(s[i]!=s[n-1-i]){
                ans++;
            }
        }
    }
    else{
        for(int i=0;i<(n-1)/2;i++){
            if(s[i]!=s[n-1-i]){
                ans++;
            }
        }
    }

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

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int h[N], i;
    int maxval = 0;
    for(i=0; i<N; ++i) {
        cin >> h[i];
        if(maxval < h[i]) maxval = h[i];
    }

    int min = 0, max = ceil((double)maxval/B)+1;
    int s = (max - 1 + min) / 2, x;
    double t = 0.0;

    // cout << "min = " << min << endl;
    // cout << "max = " << max << endl;
    // cout << "s = " << s << endl;
    // cout << "t = " << t << endl;

    while(max-min > 1) {
        for(i=0; i<N; ++i) {
            x = h[i] - B*s;
            if(x<0) x = 0;
            // cout << "x_" << i << " = " << x << endl;
            // cout << "ceil((double)x_" << i << "/(A-B) = ";
            // cout << ceil((double)x/(A-B)) << endl;
            t += ceil((double)x/(A-B));
        }
        if(t > s)
            min = s + 1;
        else
            max = s + 1;
        // cout << "min = " << min << endl;
        // cout << "max = " << max << endl;
        // cout << "s = " << s << endl;
        // cout << "t = " << t << endl;
        s = (max - 1 + min) / 2;
        t = 0;
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int ans=0;
  vector<int> a(2*n);
  for(int i=0;i<2*n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  for(int i=0;2*i<2*n;i++){
    ans+=a[2*i];
  }
  cout<<ans<<endl;
}

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

int main(void){
    string s;
    cin >> s;
    function<int(int,int)> OpFunc[] = {
        [](int a,int b)->int {return a+b;},
        [](int a,int b)->int {return a-b;}
    };
    for (size_t op1 = 0; op1 < 2; op1++)
    {
        for (size_t op2 = 0; op2 < 2; op2++)
        {
            for (size_t op3 = 0; op3 < 2; op3++)
            {
                if (OpFunc[op3](OpFunc[op2](OpFunc[op1](s[0]-'0',s[1]-'0'),s[2]-'0'),s[3]-'0')==7)
                {
                    cout << s[0] << (op1?'-':'+') << s[1] << (op2?'-':'+') << s[2] << (op3?'-':'+') << s[3] << "=7" << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
public class Main {
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
 try{
        String line = reader.readLine();
        int x = Integer.parseInt(line);
        System.out.println(""+(x*x*x));
    } catch (IOException e){
        System.out.println(e);
    } catch (NumberFormatException e){
        System.out.println("The input number can not be calcurated.");
    }
    }
}


Measured memory_bytes: 24184
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    int N;
    cin >> N;
    vector<int> h(N);
    REP(i, N) { cin >> h[i]; }
    for(int i = N - 2; 0 <= i; i--) {
        if(h[i] > h[i + 1]) {
            if(h[i] - h[i + 1] == 1) {
                h[i] = h[i + 1];
            } else {
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}
int fr[205];
int main()
{   init();
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++){
    int a;
    cin>>a;
    if(a%2==1&&i%2==1)ans++;}
    cout<<ans;
}


Measured memory_bytes: 3624
import itertools
import functools
import math
from collections import Counter

N,X,Y=map(int,input().split())

k=[]

for i in range(1,N):
    for j in range(i+1,N+1):
        chk = min(abs(j-i),abs(X-i)+abs(j-Y)+1)
        k.append(chk)

a=Counter(k)

for i in range(1,N):
    print(a[i])


Measured memory_bytes: 73384
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long ans = 1;
        long i = 1;
        while(h > 1){
            h = h / 2;
            i = i *2;
            ans = ans + i;

        }
        
        System.out.println(ans);
    }
}

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

int main() {
  int n,a,l;
  cin>>n>>a;
  l=n%500;
  if(l<=a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    let H = parseInt(arg[0].split(" ")[1]);

    let AB = arg.slice(1, N + 1).map(n=>n.split(" ").map(l=>parseInt(l)));
    
    AB.sort((a,b)=>b[0] - a[0]);
    
    let throwSum = 0;
    const strongest = AB[0][0];
    
    for(let i=0; i<N; i++) {
        if(AB[i][1] > strongest) {
            throwSum += AB[i][1];
        }
    }
    
    let cnt = 0;
    
    // while(H > throwSum) {
    //     H -= AB[0][0];
    //     cnt++;
    // }
    
    // console.log("cnt" + cnt);

    cnt += Math.ceil(((H - throwSum) / strongest));
    cnt = Math.max(0, cnt);
    
    H -= cnt * strongest;

    if(H <= 0) {
        console.log(cnt);
        return;
    } 

    AB.sort((a,b)=>b[1] - a[1]);
    
    for(let i=0; i<N; i++) {
        H -= AB[i][1];
        cnt++;
        
        if(H <= 0) break;
    }
    
    console.log(cnt);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  string s; std::cin >> s;
  int q; std::cin >> q;
  bool reversed = false;
  string head(q, '?'), back(q, '?');
  int hi = 0, bi = 0;
  rep(i, q) {
    int t; std::cin >> t;
    if (t == 1) reversed ^= 1;
    else {
      int f; std::cin >> f;
      char c; std::cin >> c;
      if (f == 1 && !reversed) head[hi++] = c;
      else if (f == 1) back[bi++] = c;
      else if (!reversed) back[bi++] = c;
      else head[hi++] = c;
    }
  }
  if (reversed) {
    drep(i, bi) std::cout << back[i];
    drep(i, s.size()) std::cout << s[i];
    std::cout << head.substr(0, hi) << "\n";
  } else {
    drep(i, hi) std::cout << head[i];
    std::cout << s;
    std::cout << back.substr(0, bi) << "\n";
  }
}


Measured memory_bytes: 1232
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
string s;
int dp[200000][13] ;
signed main() {
	cin >> s;
	int k = 1;
	dp[0][0] = 1;
	for (int i = 0; i < s.size(); i++) {
		char t = s[s.size() - i - 1];
		if (t == '?') {
			for (int j = 0; j < 13; j++) {
				for (int z = 0; z < 10; z++) {
					dp[i + 1][(j + z * k) % 13] = (dp[i + 1][(j + z * k) % 13] + dp[i][j]) % Mod;
				}
			}
		}
		else {
			int r = (int)(t - '0');
			for (int j = 0; j < 13; j++) {
				dp[i + 1][(j + k * r) % 13] = (dp[i + 1][(j + k * r) % 13] + dp[i][j]) % Mod;
			}
		}
		k *= 10;
		k %= 13;
	}
	cout << (dp[s.size()][5] + Mod) % Mod << endl;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
 
 string arr;
 const int  mod = 1e9+7;
long long dp[10005][101][2];
 
int d;
 
long long back(int in, long sum, bool flag  ){
	
 	if(in> arr.size()) {  if(sum%d==0) return 1; else return 0; }
 	
 	if(dp[in][sum][flag]!=-1)	return dp[in][sum][flag];
 	
 	 int limit = 9;
 	 if(!flag) limit=  arr[in-1]-'0';
 	
	long long res=0;
	
 	for(int i=0; i<=limit; ++i){
 	res+= (back(in+1, (sum+i)%d , flag || i<limit)%mod);		
 	res%=mod;
 	}
 	return dp[in][sum][flag] = res;
 }
 
 
 
int main() {
	

	cin>>arr;
	cin>>d;
	memset(dp, -1, sizeof dp);
	 
	 long long c= back(1,0,false);
	c-=1; c+=mod;
	 c%=mod;
	 cout<<  c <<'\n'; 
	return 0;
}


Measured memory_bytes: 20216
#include <bits/stdc++.h>
using namespace std;
#define _ << ' ' <<
using ll = long long;
using vi = vector<int>;
void view(const vector<int>& v){for(const auto& e : v)cout << e << " ";cout << endl;}

int main(){
	int i;
	int n, k;
	string s;
	cin >> n >> k >> s;
	s += 'x';
	vector<int> organ;
	char past = s[0];
	int count = 0;
	for(i=0; i<s.length(); ++i){
		if(past != s[i]) organ.push_back(count), count = 0;
		count ++;
		past = s[i];
	}
	for (int i=1; i<organ.size(); ++i)
		organ[i] += organ[i - 1];
	int humanState = (s[0] == '1');
	int maxHuman = 0;
	for(i=0; i<organ.size(); ++i){
    int humans;
    if(organ.size()<i+2*k+(humanState+i)%2){
      humans = organ[organ.size()-1] - (i? organ[i-1] : 0);
    }else{
      humans = organ[i+2*k-1+(humanState+i)%2] - (i? organ[i-1] : 0);
    }
		maxHuman = max(maxHuman, humans);
	}
	cout << maxHuman << endl;
	return 0;
}

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

Xa_max = (A + 1) / 0.08
Xa_min = (A) / 0.08

Xb_max = (B + 1) / 0.1
Xb_min = (B) / 0.1

# 範囲が被らない場合
if Xa_min >= Xb_max or Xb_min >= Xa_max:
    print(-1)
    exit()

if Xa_min >= Xb_min:
    ans = math.ceil(Xa_min)
    if ans >= Xb_max:
        print(-1)
        exit()
else:
    ans = math.ceil(Xb_min)
    if ans >= Xa_max:
        print(-1)
        exit()

print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        long c = Long.parseLong(sc.next());
        long k = Long.parseLong(sc.next());
        sc.close();

        // 主処理
        long result = 0;
        if (k <= a) {
            result = k;
        } else if (k <= a + b) {
            result = a;
        } else {
            long remain = k - (a + b);
            result = a - remain;
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 35684
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int a,b,k;
  scanf("%d%d%d",&a,&b,&k);
  int i;
  for(i=MAX(a,b);k>0;i--){
    if(a%i==0 && b%i==0){
      k--;
    }
  }
  printf("%d\n",i+1);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
n = int(input())

s = 0
for i in range(1,10**5):
  s += i
  if s >= n:
    t = i
    break

if s == n:
  for i in range(1,t+1):
    print (i)
else:
  for i in range(1,t+1):
    if i == s-n:
      continue
    print (i)
exit()

Measured memory_bytes: 9144
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

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

    int a, b, c;
    cin >> a >> b >> c;
    int rsl = min(c, b / a);
    cout << rsl << endl;

}


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

int main()
{   int n;
    cin>>n;
    ll arr[n];
    for (int i=0;i<n;i++){
        cin>>arr[i];
    }
    ll brr[n]={};
    brr[0]=0;
    brr[1]=abs(arr[1]-arr[0]);
    for (int i=2;i<n;i++){
        brr[i]=min(brr[i-1]+abs(arr[i]-arr[i-1]),brr[i-2]+abs(arr[i-2]-arr[i]));
    }
    cout<<brr[n-1]<<endl;
    
    return 0;
}


Measured memory_bytes: 5056
N,M=map(int,input().split())
SC=[input().split() for _ in range(M)]
ans=["0"]*N
for s,c in SC:
  if ans[int(s)-1]!="0" and ans[int(s)-1]!=c:
    print(-1)
    exit()
  if N>1 and int(s)==1 and c=="0":
    print(-1)
    exit()
  ans[int(s)-1]=c
if N>1 and ans[0]=="0":
  ans[0]="1"
print("".join(ans))

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

using namespace std;

int main() {
	vector <int> nums;
	int size = 0;
	int key = 0;

	cin >> size;
	for (int i = 0; i < size; i++) {
		cin >> key;
		nums.push_back(key);
	}
	for (int i = size-1; i >= 0; i--) {
		cout << nums[i];
		if (i != 0) {
			cout << ' ';
		}
	}
	cout << endl;
}



Measured memory_bytes: 3096
// D - Bouquet
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N,A,B;
ll MOD = 1000000007;

// a^n mod m を計算する(二分累乗法:O(logn))
ll modpow(ll a, ll n, ll m) {
	ll res = 1;
	while(n > 0){
		if(n & 1) res = res * a % m;
		a = a * a % m;
		n >>= 1;
	}
	return res;
}

// nCr mod m
ll nCr(ll n, ll r, ll m){
	ll ret = 1;
	for(ll i=0; i<r; ++i) ret = (ret * (n-i))%m * modpow(r-i,m-2,m) % m;
	return ret;
}

ll solve(){
	ll sum_nCr = modpow(2, N, MOD) - 1;
	ll nca = nCr(N, A, MOD);
	ll ncb = nCr(N, B, MOD);
	ll ans = (sum_nCr - (nca + ncb)%MOD)%MOD;
	if(ans < 0L) ans += MOD;
	return ans;
}

int main(){
	cin>>N>>A>>B;
	cout<< solve() <<endl;
}

Measured memory_bytes: 256
nm = [int(s) for s in input().split()]
ls = [0]*nm[0]
ac = [0]*nm[0]

for x in range(nm[1]):
  ps = [s for s in input().split()]
  p = int(ps[0])
  s = ps[1]
  if ac[p-1] == 0:
    if s == 'WA':
      ls[p-1] += 1
    else:
      ac[p-1] = 1
import numpy as np

print(' '.join(map(str,[sum(ac),np.dot(ac,ls)])))

Measured memory_bytes: 21344
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	string s;
	cin >> s;
	int n;
	cin >> n;
	rep(i, s.size()){
		if(i != (int)(s.size()-1)){
			if(s[i] != 'a' && n >= 'z' - s[i] + 1){
				n -= 'z' - s[i] + 1;
				s[i] = 'a';
			}
		}else{
			int temp = s[i];
			temp -= 'a';
			temp = (temp + n) % 26;
			temp += 'a';
			s[i] = temp;
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <set>
#define ll long long 
#include <string>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
#define mod 1000000007
using namespace std;
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
    double d,t,s;
    cin>>d>>t>>s;
    double ct=d/s;
    if (ct<=t)
    	cout<<"Yes"<<endl;
    else
    	cout<<"No"<<endl;
   


    	

}

	
		
	
	
	
	





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

int ctoi(const char c) {
  if(('0' <= c)&&(c <= '9')) return (c-'0');
  return -1;
}

int main() {
  vector<char> s(7, ' ');
  for (int i=0; i<7; i++) cin >> s.at(i);
  int Y=ctoi(s.at(0))*1000
    +ctoi(s.at(1))*100
    +ctoi(s.at(2))*10
    +ctoi(s.at(3));
  int M=ctoi(s.at(5))*10
    +ctoi(s.at(6));
  //int D=ctoi(s.at(8))*10
  //  +ctoi(s.at(9));
  int H=0;
  if (Y<2019) H=1;
  //else if (Y>2019) H=-1;
  //else if (M<=4) H=1;
  else if((Y=2019)&&(M<=4)) H=1;
  //else H=-1;
  if (H==1) cout <<"Heisei";
  else cout <<"TBD";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  if (n == 1) a == b ? dump(1) : dump(0);
  else if (a > b) dump(0);
  else {
    dump((n-2)*(b-a)+1);
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <map>
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<std::string> S(N);
  rep(i,N) std::cin >> S[i];

  std::map<std::string, int> m;
  rep(i,N) m[S[i]]++;

  int nmax = 0;
  for(auto&& n : m) nmax = std::max(nmax, n.second);

  for(auto&& n : m) if ( n.second == nmax ) std::cout << n.first << std::endl;

  return 0;
}


Measured memory_bytes: 25472