akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LL long long
using namespace std;

int n;
LL ans, a[200005];

int main()
{
	scanf("%d", &n);
	for(int i=1; i<=n; i++) scanf("%lld", &a[i]), a[i]-=i;
	sort(a+1, a+n+1);
	LL t=a[(n+1)/2];
	for(int i=1; i<=n; i++)
	{
		if(a[i]-t<0) ans+=t-a[i];
		else ans+=a[i]-t;
	}
	printf("%lld\n", ans);
} 

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]


def solve():
    s = input()
    t = 'keyence'
    n = len(s)
    
    for i in range(n):
        for j in range(n - i):
            x = (s[:i] + s[i+j:])
            if x == t:
                print("YES")
                return



    print("NO")


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()

"""

"""



Measured memory_bytes: 9324
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        int res = Integer.MAX_VALUE;
        for(int i = 0; i <= s.length - t.length; i++){
            int idx = i;
            int count = 0;
            for(int j = 0; j < t.length;j++){
                if(s[idx++] != t[j])
                    count++;
            }
            res = Math.min(count, res);
        }
            System.out.println(res);
    }
}

Measured memory_bytes: 35588
package main
import . "fmt"
// github.com/EndlessCheng/codeforces-go
func main() {
	c,n,s:=map[string]int{},0,""
	for Scan(&n); n>0; n-- {
		Scan(&s)
		c[s]++
	}
	for _, s := range []string{"AC","WA","TLE","RE"} {
		Println(s,"x",c[s])
	}
}


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

int main(){
  string a, b;
  cin >> a >> b;
  
  if ( a.size() > b.size() ){
    cout << "GREATER" << endl;
  }else if ( a.size() < b.size() ){
    cout << "LESS" << endl;
  }else{
    for ( int i = 0; i < a.size();i++ ){
      if ( a[i] > b[i] ){
        cout << "GREATER" << endl;
        return 0;
      }else if ( a[i] < b[i] ){
        cout << "LESS" << endl;
        return 0;
      }
    }
    cout << "EQUAL" << endl;
  }
}

Measured memory_bytes: 256
/*input
RRR

*/ 
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 
#include <algorithm>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
#define endl "\n"
#define trav(a,x) for(auto &a:x)
#define bits(n) __builtin_popcount(n)
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp); 
void ipgraph(int m);
//void dfs(int u, int par);
const int mod = 1000000007;
const int N = 1000000001;
const int MAX = pow(10,5)+5;
 

//standard input and output template
template<typename... T>
void in(T&... args) {
    ((cin >> args), ...);
}

template<typename... T>
void out(T&&... args) {
    ((cout << args << " "), ...);
}

template<typename... T>
void outl(T&&... args) {
    ((cout << args << endl), ...);
}


int fast_exp(int base, int exp) {
    int res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base)%mod;
       base=(base*base)%mod;
       exp/=2;
    }
    return res%mod;
}



int32_t main() {
  IOS;

  string s;cin>>s;
  int n = 3;
  //sort(s.begin(),s.end());

  if(s[0]==s[1] && s[1]==s[2] && s[0]=='R')cout<<3<<endl;
  else if(s[0]==s[1] && s[0]=='R')cout<<2<<endl;
  else if(s[1]==s[2] && s[1]=='R')cout<<2<<endl;
  else if((s[0]=='R' || s[1]=='R' || s[2]=='R'))cout<<1<<endl;
  else cout<<0<<endl;
  return 0;
}

Measured memory_bytes: 3604
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();

void main()
{
    auto stack = DList!long();
    auto s = sread();
    long cnt;
    foreach(e; s)
    {
        if(stack.empty || stack.back == e)
        {
            stack.insertBack(e);
        }
        else
        {
            cnt += 2;
            stack.removeBack();
        }
    }
    cnt.writeln();
}


Measured memory_bytes: 5656
#include <bits/stdc++.h>
#define N 3001
using namespace std;
int w,h;
int dx[]={0,1,0,-1};//^>v<
int dy[]={-1,0,1,0};
vector<int> X,Y,d;
map<int,int> x,y;
int mp[N][N];

int compless(vector<int> A,map<int,int> &M){
  sort(A.begin(),A.end());
  int c=0;
  for(int i=0;i<A.size();i++)if(!M.count(A[i]))M[A[i]]=c++;
  return c;
}

int calc(int y,int x){
  vector<vector<bool> > used(h,vector<bool>(w,0));
  int res=0;
  while(1){
    res++;
    int i=mp[y][x];
    used[y][x]=1;
    while(1){
      y+=dy[i],x+=dx[i];
      if(y<0||x<0||x>=w||y>=h)return res;
      if(mp[y][x]!=-1&&!used[y][x])break;
    }
  }
  assert(0);
}

int main(){
  int n;
  cin>>n;
  X.resize(n),Y.resize(n),d.resize(n);
  for(int i=0;i<n;i++){
    char ch;
    cin>>X[i]>>Y[i]>>ch;
    if(ch=='^')d[i]=0;
    if(ch=='>')d[i]=1;
    if(ch=='v')d[i]=2;
    if(ch=='<')d[i]=3;
  }
  h=compless(Y,y);
  w=compless(X,x);
  
  memset(mp,-1,sizeof(mp));
  for(int i=0;i<X.size();i++)mp[y[Y[i]]][x[X[i]]]=d[i];
  int ans=1;
  for(int i=0;i<n;i++)ans=max(ans,calc(y[Y[i]],x[X[i]]));
  cout <<ans<<endl;

  return 0;
}

Measured memory_bytes: 38628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 123455, LG = 60;
ll n, m, k, A[N], P[N], R[LG][N];
int main()
{
    scanf("%lld", &n);
    for (int i = 0; i < n; i++)
        scanf("%lld", &A[i]), P[i] = i;
    scanf("%lld%lld", &m, &k);
    for (int i = 0; i < m; i++)
    {
        int a;
        scanf("%lld", &a);
        swap(P[a], P[a - 1]);
    }
    for (int i = 0; i < n; i++)
        R[0][i] = P[i];
    for (int j = 1; j < LG; j++)
        for (int i = 0; i < n; i++)
            R[j][i] = R[j - 1][R[j - 1][i]];
    printf("%lld\n", A[0]); ll nw = A[0];
    for (int i = 1; i < n; i++)
    {
        int id = i;
        for (int j = 0; j < LG; j++)
            if ((k >> j) & 1LL)
                id = R[j][id];
        nw += A[id] - A[id - 1];
        printf("%lld\n", nw);
    }
    return 0;
}

Measured memory_bytes: 60544
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int Num = (s.length())-1;//終わりのIndex
		int i,j;
		for(i = 0;i < Num;i++){
			char head = s.charAt(i);
			if(head == 'A'){
				break;
			}
		}
		for(j = Num;0 < j;j--){
			char tail = s.charAt(j);
			if(tail == 'Z'){
				break;
			}
		}
		j = j - i + 1;
		System.out.println(j);
	}
}

Measured memory_bytes: 14724
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         System.out.println(2*N*3.1415);
      }
   }

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

typedef long long ll;

int main()
{
	int n, a = 0;
	scanf("%d", &n);
	while (n-- > 1) {
		int m = n, c = 1;
		for (int i = 2; i*i <= m; ++i) {
			int b = 1;
			while (m%i==0) ++b, m /= i;
			c *= b;
		}
		if (m != 1) c <<= 1;
		a += c;
	}
	printf("%d\n", a);
}

Measured memory_bytes: 3860
#include <stdio.h>

int main(void)
{
    int H, W, i, j;

    while (1) {
        scanf("%d %d", &H, &W);
        if (H == 0 && W == 0) {
            break;
        }
        for (i = 0; i < H; i++) {
            for (j = 0; j < W; j++) {
                fputc('#', stdout);
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 576
#!/usr/bin/env python3
s = input()
t = input()
ls = len(s)
lt = len(t)
ans = 1000  # min
for i in range(ls - lt + 1):
    tmp_cnt = 0
    for j in range(lt):
        if s[i + j] != t[j]:
            tmp_cnt += 1
    ans = min(ans, tmp_cnt)
print(ans)


Measured memory_bytes: 9112
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
s = ""
S = input()
l = len(S)
S = list(S.zfill(10))
sum = 0
for i in range(2**(l-1)):
	i = list(str(format(i, "08b").zfill(9)))
	s = S[0]
	for j in range(len(i)):
		# print(S)
		# print(i)
		if i[j] == '1' and s != "": # 取り出す
			sum += int(s)
			s = S[j+1]
		else:
			s += S[j+1]
		# print(s)
	sum += int(s)
	# print(sum)
print(sum)

Measured memory_bytes: 3944
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

//For nCk
const int MAX = 5100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll n, k; cin >> n >> k;

    COMinit();

    ll ans = 0;
    for(ll i=0; i<=min(n-1, k); i++){
        ans += COM(n, i)%MOD * COM(n-1, i)%MOD;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


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

int main()
{
    int n,m;
    scanf("%d %d",&n,&m);

    if(n<0||n>100||m<0||m>100||n+m<2)  return 0;
    //if((m==0&&n==0)||(m==1&&n==0)||(n==1&&m==0))  printf("0");
      printf("%d",(n*(n-1)/2)+(m*(m-1)/2));
    //if((m==1||m==0)&&n!=1)  printf("%d",n*(n-1)/2);
    //if((n==1||n==0)&&m!=1)  printf("%d",m*(m-1)/2);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

template<class T> inline bool cmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool cmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll MAXN=1e5+5;
const ll MAXLG=__lg(MAXN)+2;

ll n;
bool a[30][30];
ll dp[1<<21];
ll solve(ll idx,ll state) {
    if (dp[state] != -1) {
        return dp[state];
    }

    dp[state] = 0;
    for (int i=0;i<n;i++) {
        if (a[idx][i] == 1 && (state&(1<<i))) {
            dp[state] = (dp[state] + solve(idx+1,state-(1<<i))) % MOD;
        }
    }

    return dp[state];
}
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n;
    REP (i,n) {
        REP (j,n) {
            cin >> a[i][j];
        }
    }

    MEM(dp,-1);
    dp[0] = 1;

    cout << solve(0,(1<<n) - 1) << endl;
    return 0;
}


Measured memory_bytes: 16640
var
k,s,o,i,j:longint;
begin
readln(k,s);
for i := 0 to k do
begin
for j := 0 to k do
begin
if (s-i-j<=k) and (s-i-j>=0) then o:=o+1;
end;
end;
writeln(o);
end.


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#define MN 110001
#define ll long long
using namespace std;

ll read_p,read_ca;
inline ll read(){
	read_p=0;read_ca=getchar();
	while (read_ca<'0'||read_ca>'9') read_ca=getchar();
	while (read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
	return read_p;
}
const int MOD=1e9+7;
int n,a[MN],b[MN],_a=0,_b=0,mla[MN],mlb[MN],da[MN],db[MN];
ll s[MN],A,B;
inline void M(int &x){while(x>=MOD)x-=MOD;while(x<=0)x+=MOD;}
inline int ask(int x,int v[]){int mmh=0;for(;x;x-=-x&x)M(mmh+=v[x]);return mmh;}
inline int cg(int x,int V,int v[]){M(V);for(;x<=n;x+=-x&x)M(v[x]+=V);}
int main(){
	register int i;
	n=read();A=read();B=read();
	for (i=1;i<=n;i++){
		s[i]=read();
		while (s[i]-s[_a+1]>=A) _a++;
		while (s[i]-s[_b+1]>=B) _b++;
		da[i]=_a;db[i]=_b;
	}
	mla[1]=1;mlb[1]=1;
	for (i=2;i<=n;i++)
	mla[i]=s[i]-s[i-1]>=A?mla[i-1]:i,mlb[i]=s[i]-s[i-1]>=B?mlb[i-1]:i;
	cg(1,1,a);
	cg(1,1,b);
	for (i=2;i<=n;i++){
		if (db[i]+1>=mla[i-1]) _b=ask(db[i]+1,a)-ask(mla[i-1]-1,a);
		if (da[i]+1>=mlb[i-1]) cg(i,ask(da[i]+1,b)-ask(mlb[i-1]-1,b),a);
		if (db[i]+1>=mla[i-1]) cg(i,_b,b);
	}
	printf("%d\n",((ask(n,a)-ask(mla[n]-1,a)+ask(n,b)-ask(mlb[n]-1,b))%MOD+MOD)%MOD);
}

Measured memory_bytes: 3328
import sys

h, w=(int(word) for word in input().split())
canvas=[["." for wi in range(w+2)] for hi in range(h+2)]
for hi in range(h):
    l=input()
    for wi in range(w):
        canvas[hi+1][wi+1]=l[wi]
ds=[(-1, 0), (1, 0), (0, -1), (0, 1)]
for hi in range(1, h+1):
    for wi in range(1, w+1):
        if canvas[hi][wi]==".": continue
        conts=False
        for d in ds:
            if canvas[hi+d[0]][wi+d[1]]=="#":
                conts=True
                break
        if not conts:
            print("No")
            sys.exit()
print("Yes")


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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int H, W, K;
string c[11];
signed main() {
    cin >> H >> W >> K;
    rep(i, H) { cin >> c[i]; }
    int ans = 0;
    rep(i, bit(H)) {
        rep(j, bit(W)) {
            int cnt = 0;
            rep(y, H) {
                rep(x, W) {
                    if (c[y][x] == '#' && !(i & bit(y)) && !(j & bit(x))) { cnt++; }
                }
            }
            if (cnt == K) { ans++; }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
TRANSPORTATION_COUNT = 5

people_count = int(input())
capacity_counts = [int(input()) for i in range(TRANSPORTATION_COUNT)]
result = people_count // min(capacity_counts)

if people_count % min(capacity_counts) > 0:
    result += TRANSPORTATION_COUNT
else:
    result += TRANSPORTATION_COUNT - 1
    
print(result)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
int main() {
	ll a, b;
	string s[110];
	cin >> a >> b;
	for (int i = 0; i < a; i++)cin >> s[i];
	for (int i = 0; i < b + 2; i++)cout << '#';
	cout << endl;
	for (int i = 0; i < a; i++)cout << '#' << s[i] << '#' << endl;
	for (int i = 0; i < b + 2; i++)cout << '#';
	cout << endl;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  int V[N], C[N];
  for (int i=0; i<N; i++){
    cin >> V[i];
  }
  for (int i=0; i<N; i++){
    cin >> C[i];
  }

  int sum = 0;
  for (int i=0; i<N; i++){
    if (V[i] - C[i] > 0){
      sum += V[i] - C[i];
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define f(a) for(a=0;a<=x;a++)
struct com{
    bool operator()(const vector<int>& v1,const vector<int>& v2){
        int s1=0,s2=0;
        for(int i=0;i<v1.size();i++)s1+=v1[i];
        for(int i=0;i<v2.size();i++)s2+=v2[i];
        return s1>s2;
    }
} com;
int main(){
    int n,x,m;
    cin>>n>>x>>m;
    vector<vector<int> >vec;
    int l[12],r[12],s[12],o[7];
    for(int i=0;i<m;i++){
        cin>>l[i]>>r[i]>>s[i];
    }
    f(o[0])f(o[1])f(o[2])f(o[3])f(o[4])f(o[5]){
        bool ok=true;
        for(int i=0;i<m;i++){
            int c=0;
            for(int j=l[i]-1;j<=r[i]-1;j++){
                c+=o[j];
            }
            if(c!=s[i]){
                ok=false;
                break;
            }
        }
        if(ok){
            vector<int>v;
            for(int i=0;i<n;i++){
                v.push_back(o[i]);
            }
            vec.push_back(v);
        }
    }
    if(vec.size()==0){
        cout<<-1<<endl;
        return 0;
    }
    sort(vec.begin(),vec.end(),com);
    for(int i=0;i<vec[0].size()-1;i++){
        cout<<vec[0][i]<<" ";
    }
    cout<<vec[0][vec[0].size()-1]<<endl;
}

Measured memory_bytes: 8200
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    string s, t;
    cin >> s >> t;
    vector<vector<int>> dp(s.size() + 1, vector<int> (t.size() + 1));
    for (int i = 0; i < s.size(); i++){
        for (int j = 0; j < t.size(); j++){
            if (s.at(i) == t.at(j)){
                dp.at(i + 1).at(j + 1) = dp.at(i).at(j) + 1;
            }
            else {
                if (dp.at(i + 1).at(j) > dp.at(i).at(j + 1)){
                    dp.at(i + 1).at(j + 1) = dp.at(i + 1).at(j);
                }
                else {
                    dp.at(i + 1).at(j + 1) = dp.at(i).at(j + 1);
                }
            }
        }
    }
    string ans = "";
    int i = s.size(), j = t.size();
    while (i != 0 || j != 0){
        if (i - 1 >= 0 && j - 1 >= 0 && dp.at(i).at(j) == dp.at(i - 1).at(j - 1) + 1 && s.at(i - 1) == t.at(j - 1)){
            i--;
            j--;
            ans += s.at(i);
        }
        else if (i - 1 >= 0 && dp.at(i).at(j) == dp.at(i - 1).at(j)){
            i--;
        }
        else if (j - 1 >= 0 && dp.at(i).at(j) == dp.at(i).at(j - 1)){
            j--;
        }
    }
    reverse(ALL(ans));
    cout << ans << endl;
}


Measured memory_bytes: 35584
n,k,*a=map(int,open(0).read().split())
a.sort()
p=a.pop
s=b=~k%2or p()
i=0
for _ in k//2*'_':
 x=a[i]*a[i+1]
 if x*b>a[-1]*a[-2]*b:s*=x;i+=2
 else:s*=p()*p()
 s%=10**9+7
print(s)

Measured memory_bytes: 111844
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
#define N 100010
using namespace std;
ll dp[N][2];
vector<int> graph[N];
ll dfs(int s, int p){
	dp[s][1] = 1;
	dp[s][0] = 1;
	for(auto to: graph[s]){
		if(to != p){
			dfs(to, s);
			dp[s][1] = (dp[s][1] * dp[to][0]) % MOD;
			dp[s][0] = (dp[s][0] * (dp[to][0] + dp[to][1])) % MOD;
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	for(int i = 0; i < n - 1; i++){
		int a, b;
		cin >> a >> b;
		graph[a - 1].pb(b - 1);
		graph[b - 1].pb(a - 1);
	}
	dfs(0, -1);
	cout << (dp[0][0] + dp[0][1]) % MOD << '\n';


}

Measured memory_bytes: 14208
#include<stdio.h>
int main()
{
    int a, b, mask=1;

    // line 1
    scanf("%d %d", &a, &b);
    // output
    if (a & mask && b & mask) {
        printf("Odd\n");
    }else{
        printf("Even\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main(){

  string s;
  cin >> s;
  auto f = s.find('A');
  auto l = s.find_last_of('Z');
  cout << l - f + 1 << endl;

  return 0;
}


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

int main() {
    string S;
    cin >> S;
    int N = S.length();
    int N_init = N;
    int i = 0;
    while (i < N - 1)
    {
        if ((S[i + 1] == '0' and S[i] == '1') or (S[i] == '0' and S[i + 1] == '1'))
        {
            S.erase(i,2);
            N = S.length();
            i--;
        }
        else
            i++;
    }
    cout << N_init - N;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  int x[4];
  int y[4];
  cin >> x[0] >> y[0] >> x[1] >> y[1];
  int dx = x[1] - x[0];
  int dy = y[1] - y[0];
  x[2] = x[1] - dy;
  y[2] = y[1] + dx;
  x[3] = x[0] - dy;
  y[3] = y[0] + dx;
  cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3] << endl;


  return 0;
}




//


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

const long long N = 1e3 + 17;
int a[N], sum, ans;

int main()
{
    int n;
    cin >> n;
    for(ll i = 0; i < n; i ++)
    {
        cin >> a[i];
        sum += a[i];
    }
    reverse(a, a+n);
    int par = sum;
    for(ll i = 0; i < n; i ++)
    {
        ans += a[i];
        par = min(par, abs(ans - (sum - ans)));
    }
    cout << par;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define N_MAX 10000

int isPrime(int x)
{
  int i;
  if (x <= 3) {
    return 1;
  } else if (x % 2 == 0) {
    return 0;
  } else {
    for (i = 3; i <= sqrt(x); i = i + 2) {
      if (x % i == 0) {
        return 0;
      }
    }
    return 1;
  }
}

int main(int argc, char *argv[])
{
  int i, j, n, x;
  int answer = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    answer = answer + isPrime(x);
  }
  printf("%d\n", answer);
  return 0;
}


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

"""
input:
0 0 2
2 0 2

output:
1.00000000 -1.73205080 1.00000000 1.73205080
"""

import sys
from math import sin, cos, atan2, acos


class Circle(object):
    __slots__ = ('centre', 'radius')

    def __init__(self, centre=float('inf'), radius=-1):
        self.centre = complex(centre)
        self.radius = float(radius)


def arg(p_vector):
    return atan2(p_vector.imag, p_vector.real)


def polar(a, r):
    return a * cos(r) + a * sin(r) * 1j


def get_circles_cross_points(c1, c2):
    centre_distance = abs(c1.centre - c2.centre)
    a = acos((pow(c1.radius, 2) + pow(centre_distance, 2) - pow(c2.radius, 2)) /
             (2 * c1.radius * centre_distance))
    t = arg(c2.centre - c1.centre)
    p1, p2 = c1.centre + polar(c1.radius, t + a), c1.centre + polar(c1.radius, t - a)

    if p1.real < p2.real:
        ans = (p1, p2)
    elif p1.real == p2.real:
        if p1.imag < p2.imag:
            ans = (p1, p2)
        else:
            ans = (p2, p1)
    else:
        ans = (p2, p1)
    return ans


def solve(_circle_info):
    for i, circle in enumerate(_circle_info):
        cx, cy, r = map(int, circle)
        circles[i].centre = cx + cy * 1j
        circles[i].radius = r

    cp1, cp2 = get_circles_cross_points(*circles)
    print('{0:.8f} {1:.8f} {2:.8f} {3:.8f}'.format(cp1.real, cp1.imag, cp2.real, cp2.imag))
    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    circle_info = map(lambda x: x.split(), _input)

    circles = [Circle() for _ in range(2)]
    solve(circle_info)

Measured memory_bytes: 8056
#include <bits/stdc++.h>
using namespace std;
#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 REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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; }

const long long INF = 1LL << 60;

string s, t;

int dp[3100][3100] = {0};

int main(){
  cin >> s >> t;
  int n = s.size();
  int m = t.size();

  rep(i, n){
    rep(j, m){
      if(s[i] == t[j]){
        chmax(dp[i+1][j+1], dp[i][j]+1);
      }
      else{
        chmax(dp[i+1][j+1], dp[i+1][j]);
        chmax(dp[i+1][j+1], dp[i][j+1]);
      }
    }
  }

  string res = "";
  int i = n, j = m;
  while(i>0 && j>0){
    if(dp[i][j] == dp[i-1][j]) i--;
    else if(dp[i][j] == dp[i][j-1]) j--;
    else{
      res = s[i-1] + res;
      i--, j--;
    }
  }

  cout << res << endl;

  return 0;
}


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

using namespace std;
mt19937_64 rng(58);

bool p(string s) {
    string t = "" + s;
    reverse(t.begin(), t.end());
    return t == s;
}

string sub(string s, int f, int t) {
    return s.substr(f - 1, (t - f + 1));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s;
    cin >> s;
    int n = s.length();
    bool ans = p(s) && p(sub(s, 1, (n - 1) / 2)) && p(sub(s, (n + 3) / 2, n));
    cout << (ans ? "Yes":"No") << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
#define dd(x) cout<<#x<<"="<<x<<" "
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;

const ll mod = 1000000007;
const int N = 2e5+6;
const int M = 2e6+6;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
ll n, m;
ll a[N], pre[N];
int main() {
	while(~scanf("%lld%lld", &n, &m)) {
		rep(i, 1, n + 1) scanf("%lld", a + i);
		sort(a + 1, a + n + 1);
		pre[0] = 0;
		rep(i, 1, n + 1) pre[i] = pre[i - 1] + a[i];
		ll l = 0, r = 1e18;
		ll cnt = 0, ret = 0;
		while(r - l > 1) {
			ll mid = r + l >> 1;
			cnt = 0, ret = 0;
			rep(i, 1, n + 1) {
				ll pos = lower_bound(a + 1, a + n + 1, mid - a[i]) - a;
				cnt += (n + 1 - pos);
				ret += pre[n] - pre[pos - 1] + (n + 1 - pos) * a[i];
			}
			(cnt >= m ? l : r) = mid;
		}
		printf("%lld\n", ret - (cnt - m) * l);
	}
    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<vector>
#include<algorithm>

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

using namespace std;

const int V_MAX=100000;

struct edge{ int v,id; };

int main(){
	int n,m; scanf("%d%d",&n,&m);
	static vector<edge> G[V_MAX],H[V_MAX];
	rep(i,m){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		G[u].push_back((edge){v,i});
		H[v].push_back((edge){u,i});
	}

	static int dp1[V_MAX];
	rep(u,n) rep(i,G[u].size()) {
		int v=G[u][i].v;
		dp1[v]=max(dp1[v],dp1[u]+1);
	}

	static int dp2[V_MAX];
	for(int u=n-1;u>=0;u--) rep(i,H[u].size()) {
		int v=H[u][i].v;
		dp2[v]=max(dp2[v],dp2[u]+1);
	}

	int L=*max_element(dp1,dp1+n);

	static int cnt[V_MAX],id[V_MAX];
	rep(u,n) rep(i,G[u].size()) {
		int v=G[u][i].v;
		if(dp1[u]+1+dp2[v]==L) cnt[dp1[u]]++, id[dp1[u]]=G[u][i].id;
	}

	vector<int> ans;
	rep(i,n) if(cnt[i]==1) ans.push_back(id[i]);
	sort(ans.begin(),ans.end());

	if(ans.empty()) puts("-1");
	rep(i,ans.size()) printf("%d\n",ans[i]+1);

	return 0;
}

Measured memory_bytes: 14024
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.datetime, std.bigint;

immutable inf = 10L^^16;
int n;
int[] a;

void main() {
    scan(n);
    a = readln.split.to!(int[]);

    auto p = new long[](n + 1);
    auto s = new long[](n + 1);

    iota(n).each!(i => p[i + 1] = p[i] + a[i]);
    iota(n).retro().each!(i => s[i] = s[i + 1] + a[i]);

    debug {
        writeln(p);
        writeln(s);
    }

    long ans = inf;

    foreach (i ; 1 .. n) {
        ans = min(ans, abs(p[i] - s[i]));
    }

    writeln(ans);
}

void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 11392
#include <iostream>
#include <vector>
using namespace std;
int main(){
  string s;cin>>s;
  vector<char> cont;
  for(int i = 0; s.size() >= i; i++){
    cont.push_back(s[i]);
    if(cont.size() >=2 && cont[cont.size()-1] == 'T' && cont[cont.size()-2] == 'S'){
      cont.pop_back();
      cont.pop_back();
    }
  }
  cout << cont.size()-1 << endl;
}

Measured memory_bytes: 772
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int s=0;
	if(a>=k)
	{
		s=k;
	}
	else if(a+b>=k)
	{
		s=a;
	}
	else 
	{
		s=a+a-k+b;
	}
	cout<<s;
	
}



Measured memory_bytes: 3676
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

string S = ""; 
string T = "";
map<char, char> swaps;
int vis[30];
int vis1[30];

int main() {
	cin >> S;
	cin >> T;
	for(int i = 0; i < S.size(); i++) {
		if(!vis[S[i] - 'a'] && !vis1[T[i] - 'a']) {
			swaps[S[i]] = T[i]; 
			vis[S[i] - 'a'] = 1;
			vis1[T[i] - 'a'] = 1;
		}
	}
	for(int i = 0; i < S.size(); i++) {
		S[i] = swaps[S[i]];
	}
	if(S == T) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 776
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int N, M, L;
//vv<pair<ll, int>> graph;
vv<ll> graph;

int main() {
    cin >> N >> M >> L;
    graph = vvec(N, N, LINF);
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        graph[a][b] = c;
        graph[b][a] = c;
    }

    rep(k, N) rep(i, N) rep(j, N) {
        graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
    }

    vv<int> cc = vvec(N, N, INF);
    vv<bool> a = vvec(N, N, false);
    rep(i, N) {
        rep(j, N) {
            if (graph[i][j] <= L) {
                a[i][j] = true;
                cc[i][j] = 1;
            }
        }
    }

    rep(i, N) {
        cc[i][i] = 0;
    }

    rep(k, N) rep(i, N) rep(j, N) {
        cc[i][j] = min(cc[i][j], cc[i][k] + cc[k][j]);
    }

    int Q;
    cin >> Q;
    vector<int> ans(Q);
    rep(i, Q) {
        int s, t;
        cin >> s >> t;
        s--; t--;

        ans[i] = cc[s][t];
    }

    for (int a : ans) {
        write(a >= INF ? -1 : a - 1);
    }
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,y;
  cin>>n>>y;
  for(int a=0;a<=n;a++){
    for(int b=0;b<=n-a;b++){
      int c=n-a-b;
      if(10000*a+5000*b+1000*c==y){
        cout<<a<<" "<<b<<" "<<c<<endl;
        return 0;
      }
    }
  }
  cout<<-1<<" "<<-1<<" "<<-1<<endl;
  return 0;
}

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

using namespace std;


int main () {

	ios_base::sync_with_stdio(false);  cin.tie(NULL); 

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

	if (a < b)
		swap (a, b);
	cout << (a < 10 ? a * b : -1) << '\n';



	return 0;
}





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

int main(){
    int N,H,W;cin>>N>>H>>W;
    int A[N],B[N];int count=0;
    for(int i=0;i<N;i++){
        cin>>A[i]>>B[i];
        if(A[i]>=H&&B[i]>=W){
            count++;
        }
    }cout<<count<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
#define size 12
int comp(int *c,int *d)
{
    return (*d-*c);
}
int main()
{
    int a[size],n,i,j,sum=0,t;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    //qsort(a,n,sizeof(int),comp);
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if(a[i]<a[j])
            {
                t=a[i];a[i]=a[j];a[j]=t;
            }
        }
    }
    for(i=1;i<n;i++)
    {
        sum+=a[i];
    }
    if(sum>a[0])printf("Yes");
    else printf("No");
}


Measured memory_bytes: 1712
#include <stdio.h>
#define MAX 11
//printf("1\n");

/*


 */

int main(){
    int i,tmp,a1=0,a2=0,a4=0,n;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        
        scanf("%d",&tmp);
        
        if(tmp%4==0){
            a4++;
        }else if(tmp%2==0){
            a2++;
        }else{
            a1++;
        }
    }
    
    if(a2>0){
        if(a1<=a4){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }else{
        if(a1<=a4+1){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
        
    }
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  int a, b, k;
  cin >> a >> b >> k;
  int cnt = 0,ans;
  for(int i=b; i>=1; i--){
    if(a%i==0 && b%i==0) cnt++;
    if(cnt==k){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
import java.util.*;


public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	class P{
		int d;
		int k;
		P(int d, int k){
			this.d=d;
			this.k=k;
		}
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();

		ArrayList<ArrayList<Integer>> ll = new ArrayList<>();
		for(int i=0; i<n; i++) {
			ll.add(new ArrayList<Integer>());
		}
		for(int i=0; i<n; i++) {
			int t = sc.nextInt();
			int d = sc.nextInt();
			ll.get(--t).add(d);
		}
		for(ArrayList<Integer> l : ll) {
			Collections.sort(l);
		}

		ArrayList<P> pl = new ArrayList<P>();
		for(ArrayList<Integer> l : ll) {
			for(int i=0; i<l.size(); i++) {
				int d = l.get(i);
				P p = new P(d, (i==l.size()-1) ? 1 : 0);
				pl.add(p);
			}
		}
		Collections.sort(pl, (p1, p2)->Integer.compare(p1.d, p2.d));

		int choose = 0;
		long sum = 0;
		long max = 0;
		int kind = 0;
		PriorityQueue<Integer> pq = new PriorityQueue<>();
		for(int i=pl.size()-1; i>=0; i--) {
			int d = pl.get(i).d;
			sum += d;
			kind += pl.get(i).k;
			choose++;
			if( pl.get(i).k==0) {
				pq.add(d);
			}
			if(choose > k) {
				choose--;
				if(pq.isEmpty()) break;
				sum -= pq.poll();
			}
			if(choose == k) {
				max = Math.max(max, sum + (long)kind*kind);
			}

		}
		System.out.println(max);
		sc.close();
	}


}


Measured memory_bytes: 102720
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class FIntervalsOnTree {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll n; cin >> n;
      ll edges = 0;
      rep(i, n-1) {
        ll a, b; cin >> a >> b;
        if (a > b) swap(a, b);
        edges += a * (n+1-b);
      }

      ll points = 0;
      ll all = n*(n+1)/2;
      for(ll i=1; i<=n; i++) {
        ll left = (i-1)*i/2;
        ll right = (n-i)*(n-i+1)/2;
        points += all - left - right;
      }

      cout << points - edges << endl;


    }
};

signed main() {
  FIntervalsOnTree solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize(3)
#if 0
date +%Y.%m.%d

solution will be written here.
#endif
#include <cstdio>
#include <cmath>
#include <vector>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;
typedef std::pair<int, int> par;
struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
} read;

const int maxn = 605;
int c[2][maxn][maxn];
int tot[2][maxn * maxn];
bool mark[2][maxn * maxn];
std::vector<par> v;
int n;

void dfs(int x, int y, int co, int o) {
	if(x < 0 or x >= n * 2 or y < 0 or y >= n * 2 or c[o][x][y] or
			(o == 1 and !mark[0][c[0][x][y]])) return;
	c[o][x][y] = co;
	++ tot[o][co];
	for(par p : v) {
		dfs(x - p.first, y - p.second, co ^ 1, o);
		dfs(x - p.first, y + p.second, co ^ 1, o);
		dfs(x + p.first, y - p.second, co ^ 1, o);
		dfs(x + p.first, y + p.second, co ^ 1, o);
	}
}

int main() {
	n = read;

	for(int o = 0; o < 2; o ++) {
		int dis = read;
		v.clear();
		for(int x = 0; x < n * 2 and x * x <= dis; x ++) {
			int y = int(sqrt(dis - x * x));
			if(x * x + y * y == dis)
				v.push_back(par(x, y));
		}

		int co = 0;
		for(int x = 0; x < n * 2; x ++)
			for(int y = 0; y < n * 2; y ++)
				if(!c[o][x][y]) {
					++ co;
					dfs(x, y, co << 1, o);
				}

		for(int i = 1; i <= co; i ++)
			if(tot[o][i << 1] > tot[o][i << 1 | 1])
				mark[o][i << 1] = 1;
			else
				mark[o][i << 1 | 1] = 1;
	}

	int need = n * n;
	for(int x = 0; x < n * 2; x ++)
		for(int y = 0; y < n * 2; y ++)
			if(mark[1][c[1][x][y]] and need) {
				printf("%d %d\n", x, y);
				-- need;
			}

	if(need) return 1;
}


Measured memory_bytes: 39680
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100001
#define rank dfasodfhdasoif
using namespace std;
vector<int> G[2][100001];

/*Union_Find_Tree
  O(a(n))<O(log(n))
*/

int par[MAX_N];
int rank[MAX_N];

void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    rank[i]=0;
  }
}

int find(int x){
  if(par[x]==x)return x;
  return par[x]=find(par[x]);
}

void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y)return;
  if(rank[x]<rank[y])par[x]=y;
  else{
    par[y]=x;
    if(rank[x]==rank[y])rank[x]++;
  }
}

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


int main(){
  int n,w,h,flg=0;
  cin>>n>>w>>h;
  init(n);
  
  for(int i=0;i<n;i++){
    int x,y;
    cin>>x>>y;
    if(x==1||y==1||x==w||y==h)flg=1;
    G[0][x].push_back(i);
    G[1][y].push_back(i);
  }
  
  for(int i=1;i<=h;i++)
    for(int j=1;j<G[1][i].size();j++)unite(G[1][i][j],G[1][i][j-1]);
  
  for(int i=1;i<=w;i++)
    for(int j=1;j<G[0][i].size();j++)unite(G[0][i][j],G[0][i][j-1]);

  int cnt=0,used[100001]={};
  for(int i=0;i<n;i++){
    par[i]=find(i);
    cnt+=!used[find(i)];
    used[find(i)]=1;
  }
  if(cnt==1)cout <<n-cnt<<endl;
  else cout <<n+(cnt-1)-flg<<endl;  
    return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define ASSERT(expr...) assert((expr))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
using ll = long long;

constexpr i64 INF = 1010000000000000017LL;

constexpr i64 MOD = 1000000007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

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

ll mod_pow_r(ll x, ll n) {
    if (x == 0) return 0;
    if (n == 0) return 1;

    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n /= 2;
    }
    return ret;
}

ll factorial(ll n) {
    ll ret = 1;
    REP(i, n) {
        ret *= (i + 1);
        ret %= MOD;
    }
    return ret;
}

ll combination(ll n, ll r) {
    if (n < 0 || n < r || r < 0) return 0;
    ll fn = factorial(n);
    ll fr = factorial(r);
    ll fn_r = factorial(n-r);

    ll d = (mod_pow(fr, MOD - 2) * mod_pow(fn_r, MOD - 2)) % MOD;
    ll u = fn % MOD;
    return u * d % MOD;
}

int x, y, z;

void solve() {
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;
}

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

Measured memory_bytes: 256
using System;

class Code_01
{

    public static void Main()
    {

        string Datas = Console.ReadLine();
        int N = int.Parse(Datas.Split(' ')[0]);
        int R = int.Parse(Datas.Split(' ')[1]);

        if (N >= 10)
        {
            Console.WriteLine(R);
        }
        else
        {
            int X = 100 * (10 - N);
            R += X;
            Console.WriteLine(R);
        }



    }


}



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

int main(){
  int N;
  cin >> N;
  int s=0,t=N;
  
  while(t>0){
    s+=t%10;
    t/=10;
  }
  
  if(N%s==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256