akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)9e18);
const int ninf=((int)-9e18);
const int mod=1000000007;

using namespace std;

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","w",stdout);
    //FILE *fptr2=freopen("out.txt","w",stdout);


    string a,b;
    cin>>a>>b;

    int ans=pinf;


    for(int i=0;i<=a.size()-b.size();i++)
    {
        string s=a.substr(i,b.size());

        int c=0;
        loop(j,0,b.size())
        {
            if(s[j]!=b[j])
            {
                c++;
            }
        }
        ans=min(ans,c);
    }

    cout<<ans;



    return 0;
}


Measured memory_bytes: 3660
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';
	return !f?x:-x;
}

const int N=200+19;
const int p=998244353;

struct Point{
	int x,y;
	bool operator < (const Point &B) const{
		return x<B.x||x==B.x&&y<B.y;
	}
} P[N],Pt;
typedef Point Vector;

ll cal[N][N];
int dp[N][N],val[N][N],val2[N][N],pw2[N];
int n,ans;

Vector operator - (Point A,Point B){
	return (Vector){
		A.x-B.x,A.y-B.y
	};
}
ll cross(Vector A,Vector B){
	return 1ll*A.x*B.y-1ll*A.y*B.x;
}
bool cmp(Point A,Point B){
	return cross(A-Pt,B-Pt)>0;
}

void Work(vector<Point> V){
	int n=V.size();
	memset(dp,0,sizeof(dp));
	memset(val,0,sizeof(val));
	memset(val2,0,sizeof(val2));
	sort(V.begin()+1,V.end(),cmp);
	For(i,1,n) For(j,1,n) cal[i][j]=cross(V[i]-V[0],V[j]-V[0]);
	For(i,1,n) For(j,i+1,n){
		For(k,1,n) if (k!=i&&k!=j&&cal[i][k]>=0&&cross(V[j]-V[i],V[k]-V[i])>=0){
			ll tmp=cal[k][j];
			if (tmp>0) val[i][j]++;
			lf (tmp==0) val2[i][j]++;
		}
		val[i][j]=pw2[val[i][j]];
		val2[i][j]=pw2[val2[i][j]];
	}
	For(i,1,n) dp[0][i]=1;
	For(i,0,n) For(j,i+1,n) if (dp[i][j]){
		For(k,j+1,n) if (cross(V[j]-V[i],V[k]-V[j])>0){
			dp[j][k]=(dp[j][k]+1ll*val[j][k]*dp[i][j])%p;
		}
	}
	For(i,1,n) For(j,i+1,n)
		if (cross(V[j]-V[i],V[0]-V[j])>0){
			ans=(ans+1ll*val2[i][j]*dp[i][j])%p;
		}
}

int main(){
	pw2[0]=1;
	For(i,1,N) pw2[i]=2ll*pw2[i-1]%p;
	n=IN();
	For(i,1,n+1) P[i]=(Point){IN(),IN()};
	sort(P+1,P+n+1);
	For(i,1,n+1){
		Pt=P[i];
		vector<Point> V;
		For(j,i,n+1) V.pb(P[j]);
		Work(V);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1152
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

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

	int N,A;
	cin >> N >> A;
	cout << (N%500<=A ?"Yes":"No") << endl;
	return 0;
}


Measured memory_bytes: 256
# A - Kenken Race
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n,a,b,c,d=nl()
s=si()

ans=''
if c<d:
    for i in range(a,d-1):
        if s[i:i+2]=='##':
            ans='No'
            print(ans)
            exit()
    ans='Yes'
    print(ans)
elif c>d:
    for i in range(a-1,c-1):
        if s[i:i+2]=='##':
            ans='No'
            print(ans)
            exit()
    for i in range(b-2,d-1):
        if s[i:i+3]=='...':
            ans='Yes'
            print(ans)
            exit()
    ans='No'
    print(ans)


Measured memory_bytes: 3572
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const int MOD = 1e9+7;
//}}}

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

ll digit(ll num){
  int res = 0;
  while(num){
    num /= 10;
    res++;
  }
  return res;
}

int main(){
  ll N;
  cin >> N;

  int num = 1;
  rep(i, 1, 100001){
    if(i * i > N) break;
    if(N % i == 0) num = i;
  }
  ll ans = max(digit(num), digit(N / num));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define MAX_N 200000
ll n,k=0;
ll a[MAX_N],b[MAX_N],v[MAX_N];
bool used[MAX_N];
vector<P> G[MAX_N];
void dfs(ll ve,ll c){
  ll cnt=(c+1)%k;
  used[ve]=true;
  for(int i=0;i<G[ve].size();i++){
    if(c!=-1&&v[G[ve][i].second]==c){
      continue;
    }
    if(!used[G[ve][i].first]){
      v[G[ve][i].second]=cnt;
      dfs(G[ve][i].first,cnt);
      cnt = (cnt+1)%k;
    }
  }
}
signed main(){
  cin >> n;
  fill(v,v+n-1,-1);
  fill(used,used+n-1,false);
  queue<P> que;
  for(int i=0;i<n-1;i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    G[a[i]].push_back(P(b[i],i));
    G[b[i]].push_back(P(a[i],i));
  }
  for(int i=0;i<n-1;i++){
    k = max(k,(ll)G[i].size());
  }
  dfs(0,-1);
  cout << k<<endl;
  for(int i=0;i<n-1;i++){
    cout << v[i]+1<<endl;
  }
}


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

int main() {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  int wakeUp = 60*h1+m1;
  int goToBed = 60*h2+m2;

  cout << goToBed - wakeUp -k << endl;

  return 0;
}

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

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define For(i, a) for (int i=0; i<a; i++)
#define FORR(i,a,b) for (int i = a; i >= b; i--)
#define Forr(i,a) for (int i = a; i >= 0; i--)

#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__)
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args)
{cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }

void solve(){
  int d,t,s; cin >> d >> t >> s;
  if((d+0.0)/s <= t){
    cout << "Yes\n";
  }
  else cout << "No\n";

}

int32_t main(){
  ios_base:: sync_with_stdio(false);
  cin.tie(0);
  int t=1;
  for(int tt=1;tt<=t;tt++){
    solve();
  }
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    int full=0;
    for(int i=0; i<n; i++){
        cin >> h.at(i);
        full += h.at(i);
    }
    int count=0;
    int total=0;
    while(total<full){
        int l,r;
        l=0;r=n;
        for(int i=0; i<n; i++){
            if(h.at(i) >0){
                l = i;
                break;
            }
        }
        for(int i=l; i<n; i++){
            if(h.at(i) == 0){
                r=i;
                break;
            }
        }
        for(int i=l; i<r; i++){
            h.at(i)--;
        }
        total += r-l;
        count++; 
    }
    cout << count << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,n=1;
    cin>>a>>b;
    ll m=floor(log10(b))+1;
   for(int i=0;i<m;i++)
    n*=10;
   a*=n;
   a+=b;
   //cout<<a<<endl;
    if(sqrt(a)==(ll)sqrt(a))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

//main();
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 string s, t;
  cin >> s >> t;
  
  int count=0;
 
  int min_count=t.size();
 for(int k=0; k < s.size() - t.size() +1 ; k++){
  for(int i=0; i<t.size(); i++){
    if(s.at(i+k) != t.at(i)){
      count++;
    }
  }
   
    min_count= min(min_count, count);
   count=0;
  }
   cout << min_count << endl;
 }
        


Measured memory_bytes: 3616
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
 
#(方針)　(x,y)をunion-findにいれて, P[i]とiの根が同じならスワップできる
N,M = map(int,input().split())
P = list(map(int,input().split()))
for i in range(N): 
  P[i] = P[i]-1
  
union = UnionFind(N)
for i in range(M):
  x,y = map(int,input().split())
  union.Unite(x-1,y-1)

ans = 0
for i in range(N):
  if(union.isSameGroup(P[i],i) == True): ans += 1 
print(ans)

Measured memory_bytes: 13812
n = int(input())
list_a = list(map(int, input().split()))

sum_a = sum(list_a)
mid_sum_a = sum_a / 2

sum_first = 0
i = 0
result = 0

while sum_first < mid_sum_a:
    sum_first += list_a[i]
    i += 1
if sum_first == mid_sum_a:
    result = 0
if sum_first - mid_sum_a <= mid_sum_a - (sum_first - list_a[i - 1]):
    result = (sum_first - mid_sum_a) * 2
else:
    result = (mid_sum_a - (sum_first - list_a[i - 1])) * 2
print(int(result))

Measured memory_bytes: 26220
#include <bits/stdc++.h>
#define N 200010
using namespace std;

inline int read()
{
	int 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;
}
int F1[N],F2[N],n,m;
int main()
{
	n=read(); m=read();
	F1[1]=1; F2[n]=1;
	for(int i=1;i<=m;i++)
	{
		int x=read(), y=read();
		if(x==1) F1[y]=1; if(y==1) F1[x]=1;
		if(y==n) F2[x]=1; if(x==n) F2[y]=1;
	}
	for(int i=1;i<=n;i++)
		if(F1[i]&F2[i])
		{
			puts("POSSIBLE");
			return 0;
		}
	puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    int P,Q,R;
    cin >> P >> Q >> R;
    vector<int> L(3);
    L[0]=P;
    L[1]=Q;
    L[2]=R;
    sort(L.begin(),L.end());
    cout << L[0]+L[1];
}

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

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

bool check[500][100005];

signed main() {
  int N;
  cin >> N;
  int k;
  for (int i = 1; i <= N + 10; i++) {
    int t = i * (i - 1) / 2;
    if (t > N) {
      cout << "No" << endl;
      return 0;
    }
    if (t == N) {
      k = i;
      break;
    }
  }

  int s = 0;
  for (int i = 0; i < k; i++) {
    const int len = k - 1 - i;
    for (int j = s; j < s + len; j++) {
      check[i][j] = true;
    }

    for (int j = 0; j < len; j++) {
      check[i + 1 + j][s + j] = true;
    }
    s = s + len;
  }
  cout << "Yes" << endl;
  cout << k << endl;
  for (int i = 0; i < k; i++) {
    int cnt = 0;
    for (int j = 0; j < N; j++)
      if (check[i][j]) cnt++;
    cout << cnt;
    for (int j = 0; j < N; j++) {
      if (check[i][j]) cout << " " << j + 1;
    }
    cout << endl;
  }
}


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

class BIT {
  int n;
  vector<int> v;
public:
  BIT(int n) : n(n), v(n + 1) {}
  void add(int i) {
    for (++i; i <= n; i += i & -i) {
      ++v[i];
    }
  }
  int get(int r) {
    int sum = 0;
    for (; r > 0; r -= r & -r) {
      sum += v[r];
    }
    return sum;
  }
};

const long mod = 998244353;
struct Point {
  int x;
  int y;
  bool operator<(const Point& p) const {
    return x < p.x || x == p.x && y < p.y;
  }
};

int n;
Point ps[200000];
long bin[200001];

long corner() {
  BIT bit(n);
  sort(ps, ps + n);
  
  long sum = 0;
  for (int i = 0; i < n; ++i) {
    int j = ps[i].y;
    int cnt = bit.get(j);
    sum = (sum + bin[cnt]) % mod;
    bit.add(j);
  }
  return sum;
}

void compress() {
  map<int, int> mx;
  map<int, int> my;
  for (int i = 0; i < n; ++i) {
    int s = mx.size();
    int t = my.size();
    mx[ps[i].x];
    my[ps[i].y];
  }
  
  int cnt = 0;
  for (auto&& p : mx) p.second = cnt++;
  cnt = 0;
  for (auto&& p : my) p.second = cnt++;
  
  for (int i = 0; i < n; ++i) {
    ps[i].x = mx[ps[i].x];
    ps[i].y = my[ps[i].y];
  }
}

void pre() {
  bin[0] = 1;
  for (int i = 0; i < n; ++i) {
    bin[i + 1] = bin[i] * 2 % mod; 
  }
}

int main() {
  cin >> n;
  pre();
  
  for (int i = 0; i < n; ++i) cin >> ps[i].x >> ps[i].y; 
  compress();
  
  long sum = (n - 4 + mod) % mod * (bin[n] - 1) % mod;
  for (int k = 0; k < 4; ++k) {
    sum = (sum + corner()) % mod;
    for (int i = 0; i < n; ++i) {
      int x = ps[i].x;
      int y = ps[i].y;
      ps[i].x = (n - 1) - y;
      ps[i].y = x;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 22144
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
n=I()
lis=list(SI())
orig=0
for i in range(n):
    if lis[i]=="0":
        lis[i]=0
    else:
        lis[i]=1
orcount=sum(lis)
m1=0
m3=0
if orcount==1:
    for i in range(n):
        if lis[i]==1:
            m3=(m3+pow(2,n-i-1,orcount+1))
elif orcount>1:
    for i in range(n):
        if lis[i]==1:
            m1=(m1+pow(2,n-i-1,orcount-1))
            m3=(m3+pow(2,n-i-1,orcount+1))
        
        
m1=m1
m3=m3
#print(m1)
#print(m3)
#print(orig)
dp=[0 for i in range(n+1)]
dp[1]=1
for i in range(1,n):
    #u=count1(i+1)
    count=0
    j=0
    while pow(2,j)<=i+1:
        if ((i+1)>>j) %2==1:
            count+=1
        j+=1
    z=1
    dp[i+1]=z+dp[(i+1)%count]
#print(dp)
for i in range(n):
    if lis[i]==0:
        #num=orig+pow(2,n-i-1)
        pr=orcount+1
        num=m3+pow(2,n-i-1,pr)
    else:
        #num=orig-pow(2,n-i-1)
        pr=orcount-1
        if pr!=0:
            num=m1-pow(2,n-i-1,pr)
    #print(num,pr)
    if pr==0:
        print(0)
    else:
        print(1+dp[num%pr])


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

struct element_tag
{
    long long v;
    struct element_tag *prev;
    struct element_tag *next;
};
typedef struct element_tag element;

struct list_tag
{
    struct element_tag *first;
    struct element_tag *last;
};
typedef struct list_tag list;

void pushback(struct list_tag *l, long long x)
{
    if (l->first == NULL)
    {
        struct element_tag *t = malloc(sizeof(element));
        t->v = x;
        t->next = NULL;
        t->prev = NULL;
        l->first = t;
        l->last = t;
        return;
    }

    element *t = malloc(sizeof(element));
    t->v = x;
    l->last->next = t;
    t->prev = l->last;
    t->next = NULL;
    l->last = t;
}

void pushfront(list *l, long long x)
{
    if (l->first == NULL)
    {
        element *t = malloc(sizeof(element));
        t->v = x;
        t->next = NULL;
        t->prev = NULL;
        l->first = t;
        l->last = t;
        return;
    }

    element *t = malloc(sizeof(element));
    t->v = x;
    l->first->prev = t;
    t->next = l->first;
    t->prev = NULL;
    l->first = t;
}

void popback(list *l)
{
    if (l->first == NULL)
    {
        return;
    }

    if (l->last->prev == NULL)
    {
        free(l->last);
        l->first = NULL;
        l->last = NULL;
        return;
    }

    l->last->prev->next = NULL;
    element *t = l->last;
    l->last = t->prev;
    free(t);
}

void popfront(list *l)
{
    if (l->first == NULL)
    {
        return;
    }

    if (l->last->prev == NULL)
    {
        free(l->last);
        l->first = NULL;
        l->last = NULL;
        return;
    }

    l->first->next->prev = NULL;
    element *t = l->first;
    l->first = t->next;
    free(t);
}

void popall(list *l)
{
    while (1)
    {
        popback(l);
        if (l->first == NULL)
        {
            break;
        }
    }
}

int main(int argc, char const *argv[])
{
    //list ls;
    list ls = {NULL,NULL}; // ls に初期値を設定しました。
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        long long a;
        scanf("%lld", &a);
        if (i % 2 == 0)
        {
            pushback(&ls, a);
        }
        else
        {
            pushfront(&ls, a);
        }
    }

    if (n % 2 == 0)
    {
        while (1)
        {
            if (ls.first == NULL)
            {
                break;
            }
            //printf("%lld", ls.first->v);
            printf("%lld ", ls.first->v); // space を追加しました。
            popfront(&ls);
        }
    }
    else
    {
        while (1)
        {
            if (ls.first == NULL)
            {
                break;
            }
            //printf("%lld", ls.last->v);
            printf("%lld ", ls.last->v); // space を追加しました。first を last に変更しました。
            popback(&ls);
        }
    }

    printf("\n"); // 改行出力を追加しました。

    return 0;
}


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

    int x[100];
    int ans = 0;
    rep(i, n){
        cin >> x[i];
        if(x[i] > k/2){
            ans += abs(x[i] - k) * 2;
        }
        else{
            ans += x[i] * 2;
        }
    }
    cout << ans;
    
    return 0;
}

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

int main()
{
	int n, odd;
	cin >> n;
	if (n % 2 == 0)
		odd = n/2;
	else
		odd = (n/2)+1;
	double x = (double)odd / n;
	cout << setprecision(10) << fixed << x << endl;
	return 0;
}

Measured memory_bytes: 3756
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n=int(input())
a=[]
r=True
l=""
for i in range(0,n):
  w=input()
  if w in a:
    r=False
    break
  if l!="" and l!=w[0]:
    r=False
    break
  l=w[-1]
  a.append(w)
if r:
  print('Yes')
else:
  print('No')
    


Measured memory_bytes: 3060
n,k=map(int,input().split())
a=list(map(int,input().split()))
t=[[0]*n for i in range(60)]
for i in range(n):
    t[0][i]=a[i]-1
for i in range(1,60):
    for j in range(n):
        t[i][j]=t[i-1][t[i-1][j]]
now=0
for i in range(60):
    if k>>i&1:
        now=t[i][now]
print(now+1)

Measured memory_bytes: 175628
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
#define INF 10000000000

signed main() {
  int a, b;
  cin >> a >> b;
  int ans = INF;
  if (a <= b) ans = min(ans, b - a);
  if (-a <= b) ans = min(ans, b + a + 1);
  if (a <= -b) ans = min(ans, -b - a + 1);
  if (-a <= -b) ans = min(ans, -b + a + 2);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
ans = []
for i in range(h):
    if i%2==0:
        for j in range(w):
            if a[i][j]%2==1:
                if j==w-1:
                    if i<h-1:
                        a[i+1][j]+=1
                        ans.append([i+1,j+1,i+2,j+1])
                else:
                    a[i][j+1]+=1
                    ans.append([i+1,j+1,i+1,j+2])
    else:
        for j in range(w-1,-1,-1):
            if a[i][j]%2==1:
                if j==0:
                    if i<h-1:
                        a[i+1][j]+=1
                        ans.append([i+1,j+1,i+2,j+1])
                else:
                    a[i][j-1]+=1
                    ans.append([i+1,j+1,i+1,j])
print(len(ans))
for ans_ in ans:
    print(ans_[0],ans_[1],ans_[2],ans_[3])

Measured memory_bytes: 30292
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;



signed main() {
	int n, m; cin >> n >> m;
	if (n * 2 >= m) {
		cout << m/2 << endl;
	}
	else {
		int ans = n;
		m -= n * 2;
		ans += m / 4;
		cout << ans << endl;
	}
}

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

void swap(char *, char *);

int main(){
  int i, j, n;
  char **C, **cC, minj;

  scanf("%d", &n);

  C = (char **)malloc(sizeof(char *) * n);

  for(i=0; i<n; i++){
    C[i] = (char *)malloc(sizeof(char) * 2);
  }

  cC = (char **)malloc(sizeof(char *) * n);

  for(i=0; i<n; i++){
    cC[i] = (char *)malloc(sizeof(char) * 2);
  }
  
  for(i=0; i<n; i++){
    scanf("%s",C[i]);
    strcpy(cC[i], C[i]);
  }

  // BubbleSort
  for(i=0; i<n; i++){
    for(j=n-1; j>i; j--){
      if(atoi(&C[j][1]) < atoi(&C[j-1][1])){
	swap(C[j], C[j-1]);
      }
    }
  }

  for(i=0; i<n-1; i++){
      printf("%s ", C[i]);
    }

  printf("%s\n", C[i]);

  printf("Stable\n");

  // SelectionSort
  for(i=0; i<n; i++){
    minj = i;
    for(j=i; j<n; j++){
      if(cC[j][1] < cC[minj][1]){
	minj = j;
      }
    }
    swap(cC[i],cC[minj]);
  }

  for(i=0; i<n-1; i++){
      printf("%s ", cC[i]);
    }

  printf("%s\n", cC[i]);

  for(i=0; i<n; i++){
    if(cC[i][0] != C[i][0]){
      printf("Not stable\n");
      return 0;
    }
  }

  printf("Stable\n");

  return 0;

}

void swap(char *a, char *b){
  int i;
  char c;

  for(i=0; i<2; i++){
  c = a[i];
  a[i] = b[i];
  b[i] = c;
  }

}

Measured memory_bytes: 612
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#include <map>
#include <utility>
#define ll long long 
#define PI 3.14159265358979323846
#define INF 10000000000
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;

int main() {
	ll H, W, K, ans = 0;
	cin >> H >> W >> K;
	vector<vector<char>> c(H, vector<char>(W));
	rep(i, H) {
		rep(j, W) cin >> c[i][j];
	}
	for (ll bit = 0; bit < (1 << H); bit++) {
		vector<vector<char>> c1(H, vector<char>(W));
		rep(t, H) {
			rep(u, W) c1[t][u] = c[t][u];
		}
		for (ll i = 0; i < H; i++) {
			if (bit & (1 << i)) {
				rep(j, W) c1[i][j] = 'r';
			}
		}
			for (ll bit2 = 0; bit2 < (1 << W); bit2++) {
				vector<vector<char>> c2(H, vector<char>(W));
				ll con = 0;
				rep(c, H) {
					rep(v, W) c2[c][v] = c1[c][v];
				}
				for (ll x = 0; x < W; x++) {
					if (bit2 & (1 << x)) {
						rep(y, H) c2[y][x] = 'r';
					}
					
				}
				rep(q, H) {
					rep(w, W) {
						if (c2[q][w] == '#') con++;
					}
				}
				if (con == K) ans++;
				
			}
		
		
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>

int dp[50];

int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n-1) + fib(n-2);
}

int main() {
  int n;
  int i;

  for(i=0; i<50; i++)
    dp[i] = -1;

  scanf("%d", &n);
  printf("%d\n", fib(n));

  return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 5000001
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
int N;
int ans = -1;
vector<vector<int>> graph;
vector<vector<bool>> reached;


int main(){
    int N;
    cin >> N;
    int C[N],S[N],F[N];
    for(int i=0;i<N-1;i++){
        cin >> C[i] >> S[i] >> F[i];
    }
    for(int i=0;i<N-1;i++){
        int cnt = S[i]+C[i];
        for(int j=i+1;j<N-1;j++){
            if(cnt < S[j]){
                cnt = S[j];
            }
            if(cnt%F[j] == 0){
                cnt += C[j];
            }
            else{
                cnt += C[j]+(F[j]-cnt%F[j]);
            }
        }
        cout << cnt << endl;
    }
    cout << 0 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int in;
   int h, m, s;
   scanf("%d",&in);
   
   h =in/3600;
   in %=3600;
   
   m =in/60;
   in %=60;
   
   s = in;
   
   printf("%d:%d:%d\n",h,m,s);
   
}


Measured memory_bytes: 2048
n,k = map(int,input().split())
a = list(map(int,input().split()))
dp = [0]*(k+1)
for i in range(1,k+1):
  flg = 0
  for j in a:
    if i-j>=0:
      flg |= 1-dp[i-j]
  dp[i] = flg
if dp[k]:
  print("First")
else:
  print("Second")

Measured memory_bytes: 41980
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long



#if 0
const int MOD = ;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}

inline int inv(int x) {
    return lgput(x, MOD - 2);
}
#endif

#if 0
int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}
#endif

using namespace std;

const int MAXN = 5000;

ll dp[2][MAXN + 1];
ll mn[2][MAXN + 1];

int main() {
#if 0
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    int i, j, n, a, b;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n >> a >> b;
    vector <int> pos(n + 1);
    for(i = 1; i <= n; i++) {
        int x;
        cin >> x;
        pos[x] = i;
    }

    auto get = [&](int x, int y) {
        if(x == y) return 0;
        if(x < y) return a;
        return b;
    };

    const ll INF = 1e18;

    for(i = 1; i <= n; i++) {
        for(j = 0; j <= n; j++) {
            dp[i & 1][j] = INF;
            mn[i & 1][j] = INF;
        }
        for(j = 1; j <= n; j++) {
            dp[i & 1][j] = mn[1 - i & 1][j] + get(pos[i], j);
            mn[i & 1][j] = min(dp[i & 1][j], mn[i & 1][j - 1]);
        }
    }

    ll ans = INF;
    for(i = 1; i <= n; i++) {
        ans = min(ans, dp[n & 1][i]);
    }

    cout << ans;

    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int ans = 0;
  int N = 0;
  for(int i = 0; i < S.size(); i++){
    if(S.at(i) == 'A' || S.at(i) == 'C' || S.at(i)  == 'G' || S.at(i) == 'T'){
      N++;
      ans = max(ans , N);
    }
    else{
      N = 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>


using namespace std;

int main()
{
    int r , D , x;
    cin>>r>>D>>x;
    long long result = 0;
    for(int i=0 ; i<10 ; i++)
    {
        result = (r*x) - D;
        x = result;
        cout<<result<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <utility>
#include <algorithm>
#include <vector>
#include <stack>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, r, c, n, a, b, p, q;
  scanf("%lld%lld%lld", &r, &c, &n);
  vector< pair<ll, ll> > v;
  for(i = 0; i < n; ++i) {
    scanf("%lld%lld%lld%lld", &a, &b, &p, &q);
    if(((!a || a == r) || (!b || b == c)) && ((!p || p == r) || (!q || q == c))) {
      ll s, t;
      if(!a) s = b;
      else if(b == c) s = c + a;
      else if(a == r) s = r + c + c - b;
      else s = r + r + c + c - a;
      if(!p) t = q;
      else if(q == c) t = c + p;
      else if(p == r) t = r + c + c - q;
      else t = r + r + c + c - p;
      if(s > t) a = s, s = t, t = a;
      v.push_back({s, t});
    }
  }
  if(v.empty()) {
    printf("YES");
    return 0;
  }
  stack<ll> s;
  sort(v.begin(), v.end());
  for(i = 0; i < v.size(); ++i) {
    if(s.size()) {
      while(s.size() && v[i].first > s.top()) s.pop();
      if(s.size() && s.top() < v[i].second) {
        printf("NO");
        return 0;
      }
      s.push(v[i].second);
    } else s.push(v[i].second);
  }
  printf("YES");
  return 0;
}

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Go_ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=1e18+500;
const int sz=1e5+100;
vector<int> ad[sz];
int deg[sz];
int mx;
vector<pii> edge;
map<pii,int> mp;
void DFS(int p,int parent,int last)
{
     int col=1;
     for(auto xx: ad[p])
     {
         if(col==last) ++col;
         if(xx != parent){
             (p>xx) ? mp[{xx,p}]=col : mp[{p,xx}]=col;
             DFS(xx,p,col);
             ++col;
         }
     }
}
int main()
{
    Go_
    int a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    
    mx=0;
    cin>>n;
    for(i=1;i<n;i++){
        cin>>p>>q;
        ad[p].push_back(q),ad[q].push_back(p);
        ++deg[p],++deg[q];
        mx=max(mx,max(deg[p],deg[q]));
        if(p>q) swap(p,q);
        edge.push_back({p,q});
    }

    DFS(1,-1,0);
    cout<<mx<<endl;

    for(auto xx: edge){
        cout<<mp[{xx.f,xx.s}]<<endl;
    }

    
    

}

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

int main() {
	string id1, id2;
	cin >> id1 >> id2;

	for (int i = 0; i < id1.size(); i++) {

		if (id1.at(i) != id2.at(i)) {
			cout << "No" << endl;
			break;
		}

		else if (i - id1.size() == -1) {
			cout << "Yes" << endl;
		}
	}

}

Measured memory_bytes: 3592
#include<stdio.h>
int J[10001][10001],O[10001][10001],I[10001][10001];
int a[100001],b[100001],c[100001],d[100001];
char joi[1001][1001];
int main(void)
{
	int M,N,K,i,j,sumJ,sumO,sumI;
	scanf("%d%d%d",&M,&N,&K);
	for(i=1;i<=M;i++){
		for(j=1;j<=N;j++){
			scanf(" %c",&joi[i][j]);
		}
	}
	for(i=1;i<=M;i++){
		for(j=1;j<=N;j++){
			J[i][j]=0;
			O[i][j]=0;
			I[i][j]=0;
		}
	}
	for(i=1;i<=M;i++){
		for(j=1;j<=N;j++){
			if(joi[i][j]=='J'){
				J[i][j]++;
			}
			if(joi[i][j]=='O'){
				O[i][j]++;
			}
			if(joi[i][j]=='I'){
				I[i][j]++;
			}
			J[i][j+1]+=J[i][j];
			O[i][j+1]+=O[i][j];
			I[i][j+1]+=I[i][j];
		}
	}
	for(i=1;i<=N;i++){
		for(j=1;j<M;j++){
			J[j+1][i]+=J[j][i];
			O[j+1][i]+=O[j][i];
			I[j+1][i]+=I[j][i];
		}
	}
	for(i=1;i<=K;i++){
		scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
	}
	for(i=1;i<=K;i++){
		sumJ=0;
			sumJ+=J[c[i]][d[i]];
			sumJ-=J[a[i]-1][d[i]];
			sumJ-=J[c[i]][b[i]-1];
			sumJ+=J[a[i]-1][b[i]-1];
		sumO=0;
			sumO+=O[c[i]][d[i]];
			sumO-=O[a[i]-1][d[i]];
			sumO-=O[c[i]][b[i]-1];
			sumO+=O[a[i]-1][b[i]-1];
		sumI=0;
			sumI+=I[c[i]][d[i]];
			sumI-=I[a[i]-1][d[i]];
			sumI-=I[c[i]][b[i]-1];
			sumI+=I[a[i]-1][b[i]-1];
		printf("%d %d %d\n",sumJ,sumO,sumI);
	}
	return 0;
}

Measured memory_bytes: 28572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') { cout << "vowel" << endl; }
  else { cout << "consonant" << endl; }
}

Measured memory_bytes: 256
package main

import "fmt"

func main(){
  var a uint64
  var b uint64
  var x uint64
  var p uint64
  var q uint64
  var i uint64 = 0
  fmt.Scan(&a, &b, &x)
  if a % x == 0 {
    i = 1
  }
  p = b / x
  q = a / x
  fmt.Println(p-q+i)
}

Measured memory_bytes: 512
S = input()
Srev = S[::-1]
while True: 
  if Srev.startswith('maerd'):
    Srev = Srev[5::]
    continue
  elif Srev.startswith('remaerd'):
    Srev = Srev[7::]
    continue
  elif Srev.startswith('esare'):
    Srev = Srev[5::]
    continue
  elif Srev.startswith('resare'):
    Srev = Srev[6::]
    continue
  elif Srev == '':
    print('YES')
    break
  else:
    print('NO')
    break

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), K = sc.nextInt();
    int[] H = new int[N+2];
    for (int i = 0; i < N; i++) {
      H[i+1] = sc.nextInt();
    }
    H[0] = H[N+1] = 0;
    long INF = 300*(long)1e9;
    long[][] DP = new long[N+2][K+1];
    for (int k = 0; k <= K; k++) {
      DP[0][k] = 0;
    }
    for (int i = 1; i <= N+1; ++i) {
      for (int k = 0; k <= K; k++) {
        DP[i][k] = INF;
        for (int j = 0; j <= Math.min(i - 1, k); j++) {
          DP[i][k] = Math.min(DP[i][k], DP[i - j - 1][k - j] + Math.max(0, H[i] - H[i - j - 1]));
        }
      }
    }
    System.out.println(DP[N+1][K]);
  }
}


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

int main()
{
    int x,y,t;
    scanf("%d%d",&x,&y);
    if(x < y) std::swap(x,y);
    while(x % y != 0){
        x = x % y;
        std::swap(x,y);
    }
    printf("%d\n",y);
}

Measured memory_bytes: 2680
max1=gets.to_i
max2=-1
max3=-1
for i in 2..10 do
 a=gets.to_i
 if(a>max1)
  max3=max2
  max2=max1
  max1=a
 elsif(a>max2)
  max3=max2
  max2=a
 elsif(a>max3)
  max3=a
 end
end
print max1,"\n",max2,"\n",max3,"\n";

Measured memory_bytes: 6096
#include <iostream>
using namespace std;
 
int main() {
    int h,w,x,k;
    while(1){
        cin >> h >> w;
        k =0;
        if(h==0 && w==0)
            break;
        while(h > 0){
            x = w;
            while(x > 0){
                if(k%2 == 0)
                    cout <<"#";
                else
                    cout <<".";
                x--;
                k++;
            }
            cout <<endl;
            h--;
            if(w%2 ==0)
                k++;
        }
        cout <<endl;
    }
    return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main()
{
    ll A, B, K;
    cin >> A >> B >> K;
    ll count = 0;
    for (int i = max(A, B); i > 0; i--)
    {
        if (A % i == 0 && B % i == 0) {
            count++;
            if (count == K) {
                cout << i << endl;
                return 0;
            }

        }
    }
        return 0;
}



Measured memory_bytes: 256
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;

int N; double D,X;

inline int gi()
{
	char ch; int ret = 0,f = 1;
	do ch = getchar(); while (!(ch >= '0'&&ch <= '9')&&ch != '-');
	if (ch == '-') f = -1,ch = getchar();
	do ret = ret*10+ch-'0',ch = getchar(); while (ch >= '0'&&ch <= '9');
	return ret*f;
}

inline double calc(int n,double d,double x)
{
	if (n == 0) return 0;
	else return calc(n-1,(2*d+2*n*d+5*x)/(2*n),(2*x)/n+x)+d+(2*n-1)*x/2;
}

int main()
{
//	freopen("F.in","r",stdin);
//	freopen("F.out","w",stdout);
	N = gi(); D = gi(); X = gi();
	cout << fixed << setprecision(10) << calc(N,D,X) << endl;
	return 0;
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int flag = 1;
  while(n>0){
    int rem = n%10;
    n = n/10;
    if(rem==7){
      flag = 0;
      break;
}
  }
  if(flag == 0)
  cout<<"Yes";
  else
    cout<<"No";
  
  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}
ll com(ll n, ll r){
    ll res = 1;
    for(int k=1;k<=r;k++){
        res = res * (n-(k-1)) % MOD1;
        res = res * modinv(k, MOD1) % MOD1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,x,y,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld %lld",&x,&y);
  if((x+y)%3==0){
    n=2*y-x;
    n/=3;
    m=2*x-y;
    m/=3;
    if(n>=0&&m>=0)result = com(n+m,n);
  }
  printf("%lld",result);
  
  return 0;
}



Measured memory_bytes: 128
using System;
using System.Globalization;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization.Formatters;
using System.ComponentModel.DataAnnotations;

namespace atcoder1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            long n = long.Parse(input);
            string[] input2 = Console.ReadLine().Split(' ');
            long[] L = new long[n];
            long ans = 0;

            for(int i = 0; i < n; i++)
            {
                L[i] = long.Parse(input2[i]);
            }

            for(int i = 0; i < n; i++)
            {
                for(int j = 0; j < n; j++)
                {
                   for(int k = 0; k < n; k++)
                    {
                        if(L[i]<L[j] && L[j] < L[k])
                        {
                            if (L[i] == L[j]) continue;
                            if (L[j] == L[k]) continue;
                            if (L[k] == L[i]) continue;
                            long max = Math.Max(L[i],L[j]);
                            long max2 = Math.Max(L[j], L[k]);
                            long Himax = Math.Max(max, max2);
                            if (L[i] + L[j] + L[k] <= Himax * 2) continue;
                            ans++;
                        }
                    }
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27560
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<climits>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
using namespace std;

int main(void) {
	int n, x;
	cin >> n >> x;
	
	while (n != 0 || x != 0) {
		int count = 0;
		for (int i = 1; i <= n - 2; i++) {
			for (int j = i + 1; j <= n - 1; j++) {
				for (int k = j + 1; k <= n; k++) {
					if (i + j + k == x) {
						count++;
					}
				}
			}
		}
		cout << count << endl;
		cin >> n >> x;
	}
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    int ans = 0;
    while(ans < n){
        ans += 1000;
    }
    ans -= n;
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3624
// CODING BEAST
/*******************************************************************************************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define Precision(a) cout << fixed << setprecision(a)

using ll = long long;
#define INF
using vb = vector<bool>; using vc = vector<char>; using vd = vector<double>; using vi = vector<int>; using vvi = vector<vi>;
using vll = vector<ll>; using vvll = vector<vll>; using pi = pair<int, int>; using pll = pair<ll, ll>;
#define endl "\n"
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i = 0; i < n; i++)
#define repc(i,a,n) for(ll i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define pow2(x) (1ll<<(x))
#define Blazing_fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trav(a,v) for(auto &a:v)
int a[8] = { -1, -1, -1, 0, 0, 1, 1, 1};
int b[8] = { -1, 0, 1, -1, 1, -1, 0, 1};
inline ll power(ll x, ll y)
{
    ll temp;
    if ( y == 0)
        return 1;
    temp = power(x, y / 2) ;
    if (y % 2 == 0)
        return (temp * temp) ;
    else
        return (x * temp * temp) ;
}
bool sortbysec(pll & a, pll & b) {
    return (a.second < b.second);
}
/*
ll fact(ll n)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
        res = (res * i) ;
    return res;
}

ll ncr(ll n, ll r)
{
    return fact(n) / (fact(r) * fact(n - r));
}
bool isprime(ll n) {
    if (n <= 1) return false;
    if (n <= 3) return true;
    if ((n % 2 == 0) || (n % 3 == 0)) return false;
    for (ll i = 5; i * i <= n; i = i + 6)
        if ((n % i == 0) || (n % (i + 2) == 0)) return false;

    return true;
}*/
/*********************************************************************************************************************************************************/

signed main() {
    string s, t;
    cin >> s >> t;
    ll ma = INT_MAX;
    rep(i, s.size() - t.size() + 1) {
        string p = s.substr(i, t.size());
        // cout << p << endl;
        ll ans = 0;
        rep(x, p.size()) {
            if (p[x] != t[x]) {
                ans++;
            }
        }
        // cout << ans << endl;
        ma = min(ma, ans);
    }
    cout << ma << endl;

}



Measured memory_bytes: 3628
import itertools
n, m = map(int, input().split())
lst = [[] for _ in range(n)]
for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    lst[x].append(y)
    lst[y].append(x)

perms = list(itertools.permutations( [_ for _ in range(n)]))

ans = 0
flg = 0
for _ in perms:
    if _[0] == 0:
        visited = [0 for _ in range(n)]
        visited[0] = 1
        for i in range(n-1):
            st = _[i]
            ed = _[i+1]
            if ed in lst[st] and visited[ed] == 0:
                visited[ed] = 1
            else:
                pass
        if sum(visited) == n:
            ans += 1
    else:
        pass          
print(ans)

Measured memory_bytes: 8052