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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    ll N,K; cin >> N >> K;
    ll n = floor(sqrt(N)), t = N/n==n ? 2*n-1 : 2*n;
    VL sz(t, 1);
    VI v;
    REP(i,n) v.push_back(N/(i+1));
    if(N/n != n) v.push_back(N/(n+1));
    REP(i,t/2) sz[t-1-i] = v[i] - v[i+1];

    ll dp[K+1][t]; REP(i,K+1)REP(j,t) dp[i][j] = 0;
    dp[0][0] = 1;

    REP(i,K){
        ll sum = 0;
        REP(j,t){
            (sum += dp[i][j]) %= MOD;
            (dp[i+1][t-1-j] += sum*sz[t-1-j]) %= MOD;
        }
    }

    ll ans = 0;
    REP(i,t) (ans += dp[K][i]) %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 50944
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>

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

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

    if (n < 1000)
        cout << "ABC" << endl;
    else
        cout << "ABD" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
using namespace std;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	
	
	int n;
	cin>>n;
	
	cout<<n*(n+1)/2<<endl;
	
	
	
	
	
	return 0;
}


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

const int maxn = 1e5 + 5;

bool visited[maxn];
int dist[maxn];
vector<int> g[maxn];
int indegree[maxn];

void dfs(int a){
    visited[a] = true;
    for(auto b : g[a]){
        dist[b] = max(dist[b] , 1 + dist[a]);
        --indegree[b];
        if(indegree[b] == 0)
            dfs(b);
    }
}

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

    for(int u=0;u<m;u++){
        int a,b;
        cin>>a>>b;

        g[a].push_back(b);
        indegree[b]++;
    }

    for(int i=1;i<=n;i++){
        if(!visited[i] && indegree[i] == 0)
            dfs(i);
    }

    cout<<*max_element(dist,dist+maxn);
}

Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll A,B;cin>>A>>B;
    ll a=A%2,b=B%2;
    ll ans=0;
    if(!a and b)ans=(B-A+1)/2%2;
    else if(!a and !b)ans=((B-A)/2%2)^B;
    else if(a and b)ans=((B-A)/2%2)^A;
    else ans=((B-A-1)/2%2)^A^B;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

a, b = map(int, input().split())
if a + b == 15:
    print('+')
elif a * b == 15:
    print('*')
else:
    print('x')



Measured memory_bytes: 7880
#include <stdio.h>

int main(void) {
	// your code goes here
	double r;
	double a,l;
	
	scanf("%lf",&r);
	a = 3.141592653589 * r * r;
	l = 2 * r * 3.141592653589;
	
	printf("%f %f\n",a,l);
	
	return 0;
}

Measured memory_bytes: 648
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(20)

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N, M; cin >> N >> M;
  vector<INTV> graph(N);
  INTV in(N);
  REP(i, M){
  	int x, y; cin >> x >> y; --x; --y;
  	in[y]++;
  	graph[x].eb(y);
  }

  queue<int> que;
  INTV dag;
  REP(i, N) if(in[i] == 0) que.push(i);
  while(!que.empty()){
  	int pos = que.front(); que.pop();
  	dag.eb(pos);
  	for(auto nx : graph[pos]){
  		in[nx]--;
  		if(in[nx] == 0) que.push(nx);
  	}
  }

  int dp[100010] = {};
  REP(i, N){
  	int pos = dag[i];
  	for(auto nx : graph[pos]){
  		chmax(dp[nx], dp[pos]+1);
  	}
  }
  cout << dp[dag.back()] << endl;
}


Measured memory_bytes: 8180
#include <stdio.h>
int main(void){
	int i,j,n,m,result[100],h,rank[100];
	scanf("%d%d",&n,&m);
	while(n!=0 && m!=0){
		for(i=0; i<m; i++){
			result[i]=0;
			rank[i]=0;
		}
		for(i=0; i<n; i++){
			for(j=0; j<m; j++){
				scanf("%d",&h);
				result[j]+=h;
			}
		}
		for(i=0; i<m; i++){
			h=0;
			for(j=0; j<m; j++){
				if(result[i]<result[j]){
					h++;
				}
			}
			while(rank[h]!=0){
				h++;
			}
			rank[h]=(i+1);
		}
		for(i=0; i<m; i++){
			if(i!=(m-1)){
				printf("%d ",rank[i]);
			}else{
				printf("%d\n",rank[i]);
			}
		}
		scanf("%d%d",&n,&m);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

vector<pair<int,int>> v;
int N;

int main(){
    cin >> N;
    int a;
    for(int i=0;i<N;i++){
        cin >> a;
        v.push_back(make_pair(a,i+1));
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++){
        cout << v[i].second;
        if(i != v.size()-1) cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1780
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();
int main(){
  long long int a,b;
  cin>>a>>b;
  int min=b*10;
  int max=(b+1)*10;
  bool posible=false;
  for(int i =min;i<max;i++){
    if((i*8)/100==a){
      cout<<i<<"\n";    
      posible=true;
      break;
    }
  }
  if(!posible){
    cout<<-1<<"\n";  
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		long ans = 0;
		int left = 0;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			while (sum + a[i] != (sum ^ a[i])) {
				ans += i - left;
				sum -= a[left];
				left++;
			}
			sum += a[i];
		}
		while (left < n) {
			ans += n - left;
			sum -= a[left];
			left++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 85992
N, M = list(map(int, input().split()))
AB = []
for i in range(M):
    a, b = list(map(int, input().split()))
    AB.append([a, b])

graph = []
for i in range(N):
    graph.append([False]*N)

for a, b in AB:
    a -= 1
    b -= 1
    graph[a][b] = True
    graph[b][a] = True

# for gi in graph:
#     print(gi)

from itertools import permutations
l = [i for i in range(1, N)]
patterns = list(permutations(l))

# print(patterns)

cnt = 0
for pi in patterns:
    cur = 0
    ok = True
    # t: 次の目的地
    for t in pi:
        if not graph[cur][t]:
            ok = False
        cur = t
    if ok:
        cnt += 1


print(cnt)


Measured memory_bytes: 3572
n,y=map(int,input().split())
ans=[]
flag=False
for i in range(0,n+1):
  for j in range(0,n+1):
    if (9000*i+4000*j)==(y-1000*n) and n>=(i+j):
      ans=[i,j,n-i-j]
      flag=True
      break
if flag:
  print(*ans)
else:
  print(-1,-1,-1)



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

int main() {
  int x, y, a, b;
  cin >> x >> y >> a >> b;

  if ((x+y)>(a+b)) {
    cout << "Left" << endl;
  }
  else if( (x+y) < (a+b) ){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
inf = float('inf')
dp = [inf] * N
dp[0] = 0

for i in range(N-1):
  dp[i+1] = min(dp[i]+abs(h[i]-h[i+1]), dp[i+1])
  if i+2 < N:
    dp[i+2] = min(dp[i]+abs(h[i]-h[i+2]), dp[i+2])

print(dp[N-1])

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

using namespace std;
using ll = long long;

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

  ll n;
  cin >> n;
  map<ll, int> m;

  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      m[i]++;
      n /= i;
    }
  }
  if (n > 1) {
    m[n]++;
  }

  int ans = 0;
  for (auto &[k, v] : m) {
    int i = 1;
    while (v > 0) {
      ans++;
      i++;
      v -= i;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}


int main(){
	ll n;
	cin >> n;
	ll b[1000];
	ll ans=0;
	FOR(i,n-1){
		cin >> b[i];
	}
	ans+=b[0];
	ans+=b[n-2];
	for(int i=0;i<n-2;i++){
		ans+=min(b[i],b[i+1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n = 0, b = 0, ans = 0, sum = 0; string s; cin >> s;
	if (s[0] == '>') {
		for (int h = 0; h < s.size(); h++) {
			if (s[h] == '>') { sum++; }
			else { h = s.size(); }
		}
	}
	for (int h = sum; h < s.size(); h++) {
		if (s[h] == '<' && n != 0 && b != 0) {
			if (n >= b) { ans += n * (n + 1) / 2; ans += (b - 1) * b / 2; }
			else { ans += b * (b + 1) / 2; ans += (n - 1) * n / 2; }
			n = 1; b = 0;
		}
		else if (s[h] == '<') {
			n++;
		}
		if (s[h] == '>') {
			b++;
		}
	}
	if (n >= b) { ans += n * (n + 1) / 2; ans += (b - 1) * b / 2; }
	else { ans += b * (b + 1) / 2; ans += (n - 1) * n / 2; }
	cout << ans + sum * (sum + 1) / 2 << endl;
	cin >> n;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned int;
using vi  = vector<int>; using vb  = vector<bool>; using vd  = vector<double>; using vl  = vector<ll>;
using vvi = vector<vi>;  using vvb = vector<vb>;   using vvd = vector<vd>;     using vvl = vector<vl>;
 
#define REP(i,n) for(ll i=0; i<(n); ++i)
#define FOR(i,b,n) for(ll i=(b); i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define TEN(x) ((ll)1e##x)
 
template<typename T> inline string join(const vector<T>& vec, string sep = " ") { stringstream ss; REP(i, vec.size()) ss << vec[i] << ( i+1 == vec.size() ? "" : sep ); return ss.str(); }
 
 
///////////////
 
#define EPS (1e-10)
#define NEXT(x, i) (x[(i + 1) % x.size()])
 
template<class T> using CR = const T &;
using P = complex<ld>;
using G = vector<P>;
 
int sgn(ld a, ld b = 0) {
    if (a > b + EPS) return 1;
    if (a < b - EPS) return -1;
    return 0;
}
 
ld dot(P a, P b) { return real(conj(a)*b); }
ld cross(P a, P b) { return imag(conj(a)*b); }
 
int ccw(P a, P b, P c) {
    b -= a;
    c -= a;
    if (sgn(cross(b, c))) return sgn(cross(b, c)); // clockwise or counter clockwise
    if (sgn(dot(b, c)) == -1) return 2;            // c--a--b
    if (sgn(norm(b), norm(c)) == -1) return -2;    // a--b--c
    return 0;                                      // a--c--b
}
 
struct L : public vector<P> {
    L(P a, P b) { push_back(a); push_back(b); }
};
 
bool iSS(CR<L> s, CR<L> t, bool strict = false) {
	int ccwa = ccw(s[0], s[1], t[0])*ccw(s[0], s[1], t[1]);
	int ccwb = ccw(t[0], t[1], s[0])*ccw(t[0], t[1], s[1]);
	return ccwa <= 0 && (!strict || ccwa == -1)
	    && ccwb <= 0 && (!strict || ccwb == -1);
}
 
//////////////
 
int main() {
#ifdef INPUT_FROM_FILE
    ifstream cin("sample.in");
    ofstream cout("sample.out");
#endif
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(30);
    ll n; cin >> n;
    while (n--) {
        ld x0, y0, x1, y1, x2, y2, x3, y3;
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        P p0(x0, y0), p1(x1, y1), p2(x2, y2), p3(x3, y3);
        cout << iSS(L{ p0, p1 }, L{ p2, p3 }) << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3304
#include <stdio.h>
#include <stdlib.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int n;
int ans[202];
int que[202], qf = 0, qb = 0;

#define E_MAX 10101
#define V_MAX 202
typedef struct edlst{
    int fr, to;
}E;
typedef struct graph{
    E e[E_MAX];
    int st[V_MAX], siz[V_MAX];
}G;
G g;
int upe(const void *a, const void *b){
    if(((E*)a)->fr != ((E*)b)->fr) 
        return (((E*)a)->fr > ((E*)b)->fr ? 1 : -1);
    else
        return (((E*)a)->to == ((E*)b)->to ? 0 : (((E*)a)->to > ((E*)b)->to ? 1 : -1));
}
void g_init(int vn, int en){
    int a, b, u;
    rep(i, vn) g.siz[i] = 0;
    rep(i, vn) {
        scanf("%d%d", &a, &u);
        a--;
        g.siz[a] = u;
        rep(j, u) {
            scanf("%d", &b);
            b--;
            g.e[en].fr = a; g.e[en].to = b;
            en++;
        }
    }
    qsort(g.e, en, sizeof(E), upe);
    g.st[0] = 0;
    rep(i, vn-1){
        g.st[i+1] = g.st[i] + g.siz[i];
    }
}

void solve() {
    rep(i, n)
        ans[i] = -1;
    que[qb++] = 0;
    ans[0] = 0;
    while(qb - qf > 0) {
        int v = que[qf++];
        rep(i, g.siz[v]) {
            int nv = g.e[g.st[v] + i].to;
            if(ans[nv] == -1) {
                ans[nv] = ans[v] + 1;
                que[qb++] = nv;
            } 
        }
    }
}

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

    solve();

    rep(i, n)
        printf("%d %d\n", i+1, ans[i]);
}


Measured memory_bytes: 2052
#include <iostream>

using namespace std;

int main()
{
	int x, y;

	while (1) {
		cin >> x >> y;
        if (x == 0 && y == 0) {
            break;
        }

		else if(x >= y) {
			cout << y << " " << x << endl;
		}

        else if(x < y) {
            cout << x << " " << y << endl;
        }
	}

}



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

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

int main()
{
  int n, k;
  cin >> n >> k;
  int ans = 0;
  rep(i, n)
  {
    int tmp;
    cin >> tmp;
    ans += (tmp >= k);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
#include <sstream>
using namespace std;
const constexpr int INF = 1e9;
#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9+7;
struct Less{
   bool operator()(const pair<string, int>&a, const pair<string, int>&b){
        if(a.first==b.first){
            return a.second < b.second;
        }
       return a.first < b.first;
    }
};

ll extGCD(ll a, ll b, ll& x, ll& y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a/b*x;
    return d;
}
ll GCD(ll a, ll b){
    if(a<b) swap(a, b);
    if(b==0) return a;
    return GCD(b, a%b);
}
int par[100010], rr[100010];
void init(){
    for(int i=0; i<100010; ++i){
        par[i]=i;
        rr[i]=0;
    }
}
int root(int x){
    return par[x] == x ? x:par[x] = root(par[x]);
}
bool same(int x, int y){
    return root(x)==root(y);
}
void unite(int x, int y){
    x = root(x);
    y = root(y);
    if(x==y) return ;
    
    if(rr[x]<rr[y]){
        par[x] = y;
    }else{
        par[y] = x;
        if(rr[x]==rr[y]) rr[x]++;
    }
}

ll pow_mod(ll x, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res*x%MOD;
        }
        x = x*x%MOD;
        n>>=1;
    }
    return res;
}
ll fac[10010];
int main() {
    for(int i=0; i<10010; ++i) fac[i]=1;
    int N; cin >> N;
    for(int i=N; i>=1; --i){
        int t=i;
        for(int j=2; j<=N; ++j){
            while(t%j==0){
                fac[j]++;
                t/=j;
                
            }
        }
    }
    //for(int i=0; i<=N; ++i) cout << fac[i] << endl;
    ll ans=1;
    for(int i=0; i<10010; ++i) ans=(ans*fac[i])%MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>

bool IsPrimeNumber(int number) {
	if (number < 2) return false;
	if (number == 2) return true;
	if (number % 2 == 0) return false;
	int max = (int)std::sqrt(number);
	for (int i=3; i<=max; i+=2)
		if (number % i == 0)
			return false;
	return true;
}

int main() {
	int N[1000000] = {0};
	for (int i=1; i<=999999; i++) {
		if (IsPrimeNumber(i)) {
			N[i] = N[i-1] + 1;
		} else {
			N[i] = N[i-1];
		}
	}
	int n;
	while (std::cin >> n) {
		std::cout << N[n] << std::endl;
	}
	return 0;
}


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

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

int main(void)
{
    ll n,a0=0,a1,sum=0;
    cin >> n;
    for(ll i=0;i<n;i++)
    {
        cin >> a1;
        if(a0>a1)
        {
            sum+=a0-a1;
//            a0=a1;
        }
        else
        {
            a0=a1;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>

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

    if (n % 1000 == 0)
    {
        std::cout << "0" << std::endl;
    }
    else
    {
        std::cout << 1000 - n % 1000 << std::endl;
    }

    return 0;
}

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

int cctoi(char x){//cardのcharをintに変換
	int a;
	if(x=='S')a=0;
	else if(x=='H')a=1;
	else if(x=='C')a=2;
	else if(x=='D') a=3;
	return a;
}
char citoc(int a){//cardのintをcharに変換
	char x;
	if(a==0)x='S';
	else if(a==1)x='H';
	else if(a==2)x='C';
	else if(a==3)x='D';
	return x;
}

int main(){
int n;cin>>n;
int card[4][14]={0};card[0][0]=card[1][0]=card[2][0]=card[3][0]=1;
int a;char x;

	for(int i=0;i<n;i++){
			cin>>x>>a;
			card[cctoi(x)][a]=1;
}
for(int j=0;j<4;j++){
	for(int i=1;i<14;i++){
	if(card[j][i]==0)cout<<citoc(j)<<" "<<i<<endl;
	}
}


 return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <queue>
#include <bits/stdc++.h>
#include <stack>
#include <vector>
#include <list>
#include <string>

using namespace std;

int main(){
  int N;
  int K;
  cin >> N >> K;
  char kirai[10];
  for(int i = 0; i < K; i++)
    cin >> kirai[i];
  int flag=0;
  while(!flag){
    char s[10];;
    sprintf(s,"%d",N);
    for(int i = 0; i < sizeof(s); i++){
      for(int j = 0; j < K; j++){
        if(s[i]==kirai[j]){
          flag = 2;
          break;
        }
        else if((flag!=2)&&(i==sizeof(s)-1)&&(j==K-1))
          flag=1;
      }
    }
    if(flag==1){
      cout << N << endl;
    }
    else if(flag==2){
      flag=0;
      N++;
    }
  }


  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeMap;



 class Main{
	 
	 
	 
	

	public static void main(String[] args) throws IOException {
		
		
		FastScanner sc=new FastScanner();
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		long h[] = new long[N+1];
		for(int i = 0;i<N;i++)h[i+1] =sc.nextLong();
		 
		long[]dp = new long[N+1];

		for(int i = 2;i<=N;i++) {
			if(i-K>=0){
				long dpcost = Long.MAX_VALUE;
				
				for(int j = 1;j<=K;j++) {
					if(dpcost>dp[i-j]+Math.abs(h[i]-h[i-j])) {
						dpcost = dp[i-j]+Math.abs(h[i]-h[i-j]);
						
					}
				}

				dp[i] =dpcost;

			}else {
				long dpcost = Long.MAX_VALUE;
				
				for(int j = 1;j<i;j++) {
					if(dpcost>dp[i-j]+Math.abs(h[i]-h[i-j])) {
						dpcost = dp[i-j]+Math.abs(h[i]-h[i-j]);
						
					}

				}


				dp[i] =dpcost;

			}
		}

		System.out.println(dp[N]);
		
				
	}
	
	
	
	
 
	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long[] readArrayLong(int n) {
        	long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
        }
		long nextLong() {
			return Long.parseLong(next());
		}
		String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
	}
}


Measured memory_bytes: 44928
#include<iostream>

using namespace std;

int main()
{
    int n;
    int a[10000];

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int min=a[0],max=a[0];
    long sum=a[0];

    for(int i=1;i<n;i++){
        if(min>a[i])    min = a[i];
        if(max<a[i])    max = a[i];
        sum += a[i];
    }
    cout<<min<<' '<<max<<' '<<sum<<'\n';
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

const int maxv = 100005;

int main(){
    string N; cin >> N;
    string ans = "No";
    rep(i,N.size()){
        if (N[i] == '7'){
            ans = "Yes";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int f(int x){
if(x==0) return 0;
  else
    return f(x/10)+(x%10);
}
int main(){
  int N;
  cin>>N; int ans=1000;
  for(int i=1;i<=N/2;i++){
  if(f(i)+f(N-i)<ans)
    ans=f(i)+f(N-i);
  
  }cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;

ll N,M,Q;
struct node
{
    ll a,c,d;
};
struct node2
{
	ll a,b,c,d;	
}qq[maxn];
vector<node> adj[maxn]; 
ll A[maxn];
ll res = 0;
void dfs(int id,int last = 1){
    if(id > N){
       	ll sum = 0;
       	for(int i = 1;i<=Q;i++){
       		if(A[qq[i].b] - A[qq[i].a] == qq[i].c)
       			sum += qq[i].d;
       	}
       	res = max(res,sum);
        return ;
    }
    A[id] = last;
    dfs(id+1,last);
    for(auto no:adj[id]){
        ll cur = A[no.a] + no.c;
        if(cur > M || cur < last) continue;
        else{
            A[id] = cur;
            dfs(id+1,cur);
        }
    }
}

int main(){
    // debug;
    ios;

    cin>>N>>M>>Q;
    for(int i = 1;i<=Q;i++){
        ll a,b,c,d; cin>>a>>b>>c>>d;
        adj[b].pb({a,c,d});
        qq[i] = {a,b,c,d};
    }
    dfs(1);
    cout<<res<<'\n';
    return 0;
}


Measured memory_bytes: 27004
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int m;
    cin >> m;
    vi b(m);
    rep(i, m) cin >> b[i];

    int x = -1;
    rep(i, min(n, m)) {
        if(a[i] > b[i]) {
            x = 0;
            break;
        } else if(a[i] < b[i]) {
            x = 1;
            break;
        }
    }
    if(x == -1) {
        if(n >= m) {
            x = 0;
        } else {
            x = 1;
        }
    }

    cout << x << endl;
}


Measured memory_bytes: 3168
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
-- templete


main = getInt >>= putStrLn . (["thu","fri","sat","sun","mon","tue","wed"]!!) . (`mod`7)



Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

//const ll nmax=100001;
const ll inf=1000000000+7;
const ll nmax=1000;
ll a[nmax+1],slis[nmax+1],tlis[(nmax+1)*(nmax+2)/2];

ll N,K;
ll ans;
int main(){
    cin>>N>>K;
    for(ll i=0;i<N;i++){
        cin>>a[i];
        slis[i+1]=slis[i]+a[i];
    }
    ll tm=0;
    ll tlis[(N+1)*N/2];
    for(ll i=0;i<=N;i++){
        for(ll j=i+1;j<=N;j++){
            tlis[tm]=(slis[j]-slis[i]);
            tm++;
        }
    }

    ll x=0;
    ll xt=0;

    for(ll i=40;0<=i;i--){
        xt=x+pow(2,i);
        ll ct=0;
        for(ll j=0;j<=N*(N+1)/2;j++){
            if((tlis[j]&xt)==xt) ct++;
        }
        if(ct>=K) x=xt;
    }
    cout<<x<<endl;

    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int a, b;
  cin >> a >> b;
  if (a >= 13)
    cout << b << endl;
  else if (a >= 6)
    cout << b / 2 << endl;
  else
    cout << 0 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

using namespace std;
using ll = long long;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}

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


//////////////////////////////////////////////////

long long gcd (long long a, long long b) {
    if(a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a%b);
}

int main() {
    ll n, m; cin >> n >> m;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    int g = -1;
    for (int i = 0; i < n; i++)
    {
        if (a[i] == 1) continue;
        if (g == -1) {
            if ((a[i]/2)%2==0) g = 1;
            else g = 0;
        } else {
            if ((g==1 && (a[i]/2)%2!=0) || (g==0 && (a[i]/2)%2==0)) {
                cout << 0 << endl;
                return 0;
            }
        }
    }
    
    
    ll l = a[0]/2;
    vector<bool> ok(1e9+10, false);
    ok[a[0]] = true;
    for (int i = 1; i < n; i++)
    {
        if (ok[a[i]]) continue;
        ll g = gcd(l, a[i]/2);
        l = l/g*a[i]/2;
        if (l > m) {
            cout << 0 << endl;
            return 0;
        }
        ok[a[i]] = true;
    }

    for (int i = 0; i < n; i++)
    {
        a[i] /= 2;
        if (l/a[i]%2 == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    

    ll lc = l*2;
    // cout << lc << endl;
    ll ans = (m-l)/lc+1;
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 123136
N,K=map(int,input().split())
p=list(map(int,input().split()))
ave=[0]*(N-K+1)
tmp=0
for i in range(K):
    tmp+=(p[i]+1)/2
ave[0]=tmp
for i in range(1,N-K+1):
    ave[i]=ave[i-1]-(p[i-1]+1)/2 + (p[i+K-1]+1)/2
print(max(ave))

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

int main(){
    int w, b;
    cin >> w >> b;
    int s = (b-1)/50;
    int r1 = b - 1 - s*50;
    int t = (w-1)/50;
    int r2 = w - 1 - t*50;
    if(b == 1){
        t = w/50;
        r2 = w-t*50;
    }
    cout << 100 << " " << 100 << endl;
    for(int i = 1; i <= 100; i++){
        for(int j = 1; j <= 100; j++){
            if(i <= (s+1)*2){
                if(i == (s+1)*2){
                    if(r1*2 < j) cout << "#";
                    else cout << ".";
                }
                else if(i == (s+1)*2-1){
                    if(r1*2 < j || j%2 == 1) cout << "#";
                    else cout << ".";
                }
                else{
                    if(i%2 == 0) cout << ".";
                    else if(j%2 == 0) cout << ".";
                    else cout << "#";
                }
            }
            else if(i <= (s+t+2)*2){
                if(i == (s+t+2)*2){
                    if(j%2 == 1 && j <= r2*2-1) cout << ".";
                    else cout << "#";
                }
                else if(i%2 == 0){
                    if(j%2 == 1) cout << ".";
                    else cout << "#";
                }
                else cout << "#";
            }
            else cout << "#";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define rep(i, n) for (int i = 0; i < (int)n; i++)
typedef long long ll;
const ll MOD = 1e9+7;
const int inf = 1000000;
const int minf = -1000000;
const ll lnf = 1e9;
const ll mlnf = -1e9;

void debug_vector(vector<int>& v){
    int n = v.size();
    for (int i = 0; i < n; i++){
        cout << v[i] << " ";
    }
    cout << endl;
}

void solve();
int count_divisor(int n);

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

void solve(){
    int N; cin >> N;
    int res = 0;
    for (int i = 3; i <= N; i+=2){
        if (count_divisor(i) == 8) res++;
    }
    printf("%d\n", res);
}

int count_divisor(int n){
    int ans = 0;
    for (int i = 1; i <= n; i++){
        if (n % i == 0) ans++;
    }
    return ans;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

//Zig-Zag Numbers
public class Main{

	int[] s;
	int n, MOD, M = 10000;
	//idx, free, isUp, pre, M
	int[][][][][] dp;
	
	int get(int k, int f, int u, int pre, int m, boolean zero){
		if(k==n)return zero?0:m==0?1:0;
		int res = 0;
		if(zero){
			res+=get(k+1,f,u,0,0,true);
			for(int p=1;p<10;p++){
				res+=get(k+1,f,0,p,p%MOD,false);
				if(k+1!=n)res+=get(k+1,f,1,p,p%MOD,false);
			}
			return res%M;
		}
		if(dp[k][f][u][pre][m]!=-1)return dp[k][f][u][pre][m];
		if(f==1){
			if(u==1){
				for(int p=pre+1;p<10;p++){
					res+=get(k+1,f,1-u,p,(m*10+p)%MOD,false);
				}
			}
			else{
				for(int p=0;p<pre;p++){
					res+=get(k+1,f,1-u,p,(m*10+p)%MOD,false);
				}
			}
		}
		else{
			if(u==1){
				for(int p=pre+1;p<=s[k];p++){
					if(p==s[k])res+=get(k+1,0,1-u,p,(m*10+p)%MOD,false);
					else res+=get(k+1,1,1-u,p,(m*10+p)%MOD,false);
				}
			}
			else{
				int t = Math.min(pre-1, s[k]);
				for(int p=0;p<=t;p++){
					if(p==s[k])res+=get(k+1,0,1-u,p,(m*10+p)%MOD,false);
					else res+=get(k+1,1,1-u,p,(m*10+p)%MOD,false);
				}
			}
		}
		return dp[k][f][u][pre][m] = res%M;
	}
	
	int f(String r){
		n = r.length();
		s = new int[n];
		for(int i=0;i<n;i++)s[i]=r.charAt(i)-'0';
		dp = new int[n+1][2][2][10][MOD];
		for(int i=0;i<=n;i++)for(int j=0;j<2;j++)for(int k=0;k<2;k++)for(int p=0;p<10;p++)for(int m=0;m<MOD;m++)dp[i][j][k][p][m]=-1;
		int res = 0;
		res += get(1, 1, 0, 0, 0, true);
		for(int p=1;p<=s[0];p++){
			if(p==s[0]){
				res+=get(1,0,0,p,p%MOD,false);
				if(n!=1)res+=get(1,0,1,p,p%MOD,false);
			}
			else{
				res+=get(1,1,0,p,p%MOD,false);
				if(n!=1)res+=get(1,1,1,p,p%MOD,false);
			}
		}
		return res%M;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		String A = sc.nextBigInteger().subtract(BigInteger.ONE).toString(), B = sc.next();
		MOD = sc.nextInt();
		System.out.println((f(B)-f(A)+M)%M);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 90000
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef double db;
const int mod = 998244353;
const int N = 2e3 + 5;
const int M = 1e3 + 5;
ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll qsm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
int n, m, k;
vector<int> g[N];
int ans[N];
int x,y;

int main(){
    scanf("%d%d%d",&n,&x,&y);
    rep(i,1,n-1) g[i].pb(i+1);
    g[x].pb(y); g[y].pb(x);
    rep(i,1,n) rep(j,i+1,n){
        int w=min(j-i,abs(i-x)+abs(j-y)+1);
        ans[w]++;
    }
    rep(i,1,n-1) printf("%d\n", ans[i]);
    return 0;
}
/*
1 2 3 4 5
*/
//
//                            _ooOoo_
//                           o8888888o
//                           88" . "88
//                           (| -_- |)
//                           O\  =  /O
//                        ____/`---'\____
//                      .'  \|     |//  `.
//                     /  \|||  :  |||//  \
//                    /  _||||| -:- |||||-  \
//                    |   | \  -  /// |   |
//                    | \_|  ''\---/''  |   |
//                    \  .-\__  `-`  ___/-. /
//                  ___`. .'  /--.--\  `. . __
//               ."" '<  `.___\_<|>_/___.'  >'"".
//              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//              \  \ `-.   \_ __\ /__ _/   .-` /  /
//         ======`-.____`-.___\_____/___.-`____.-'======
//                            `=---='
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                     佛祖保佑      永无BUG


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define lint long long
#define P pair<int, int>

int main(){
    lint N, K;
    cin >> N >> K;
    
    vector<lint> A(N);
    
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }
    
    int bits = 0;
    const lint INF = -1E18;
    
    while(((lint)1<<bits) < K){
        bits++;
    }
    
    lint cnt[50];
    for(int i = 0; i < 50; ++i){
        cnt[i] = 0;
        for(int j = 0; j < N; ++j){
            cnt[i] += (A[j] >> i) & 1;
        }
    }
    
    
    lint dp[50][2];
    
    dp[49][0] = 0;
    dp[49][1] = INF;
    
    for(int i = 49; i >0 ; --i){
        
        
        if((K>>(i - 1)) & 1){
            dp[i - 1][0] = dp[i][0] + ((lint)1 << (i - 1)) * (N - cnt[i - 1]);
            dp[i - 1][1] = max(dp[i][0] + ((lint)1 << (i - 1)) * (cnt[i - 1]), dp[i][1] + ((lint)1 << (i - 1)) * max(cnt[i - 1],N - cnt[i - 1]));

//            cerr << 1 << " " << cnt[i -1] << " " << dp[i- 1][0] << " " << dp[i - 1][1] << endl;
        } else {
            dp[i - 1][0] = dp[i][0] + ((lint)1 << (i - 1)) * cnt[i - 1];
            if(dp[i][1] > INF){
                dp[i - 1][1] = dp[i][1] + ((lint)1 << (i - 1)) * max(cnt[i - 1], N - cnt[i - 1]);
            } else {
                dp[i - 1][1] = dp[i][1];
            }
            
//            cerr << 0 << " " << cnt[i -1] << " " << dp[i- 1][0] << " " << dp[i - 1][1] << endl;
        }
    }
    
    cout << max(dp[0][0], dp[0][1]) << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//絶対値
long long int change_plus(long long int a) {
	if (a < 0) { return -a; }
	if (a >= 0) { return a; }
}
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

int main() {
	long long int n, m, k,p,q;
	char str[30],str2[15],str3[15];
	scanf("%lld",&n);
	
	
		printf("%lld",n*(n+1)/2);
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())
#define DEBUG

using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> pr;
typedef long long LL;
typedef vector<LL> Vll;

long N, K;
int t;
short c = 0;
short total = 0;
LL data[100000] = {0};
// memset( data , 0 , sizeof(data) );
Vll ans;

int main(){
    cin >> N;
    REP(i, N){
        cin >> data[i];
    }
    sort(data, data+N);
    for(int i= N-1; i >= 0; i--){
        // // cout << data[i];
        if (data[i] == 0) break;
        if(ans.size() >= 2){
            break;
        }
        if (data[i] == data[i - 1]){
            ans.push_back(data[i]);
            i--;
        }
    }
    if(ans.size() >= 2){
            cout << ans[0] * ans[1];
            return 0;
    }else{
        cout << 0;
        return 0;
    }
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#define ll long long
using namespace std;
ll n;
int a[100050],b[100050];
int main(){
	scanf("%lld",&n);
	ll sub=n*(n+1)/2,tot=0;
	for(register int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		tot+=a[i];
	}
	a[n+1]=a[1];
	for(register int i=2;i<=n+1;i++)b[i-1]=a[i]-a[i-1];
	int k=tot/sub;
	if(k*sub!=tot){
		cout<<"NO"<<endl;
		return 0;
	}
	ll x=0;
	for(register int i=1;i<=n;i++){
		ll tmp=k-b[i];
		ll xx=tmp/n;
		if(xx*n!=tmp||xx<0){
			cout<<"NO"<<endl;
			return 0;
		}
		x+=xx;
	}
	if(x==k){
		cout<<"YES"<<endl;
		return 0;
	}
	cout<<"NO"<<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
char s1[10]={'L','R','U','D'};
char s2[10]={'R','L','D','U'};
int lim[10];
char p1[1<<20],p2[1<<20];
void GG()
{puts("NO");exit(0);}
int main()
{
    int n,m,len;
    scanf("%d%d%d",&n,&m,&len);
    int x0,y0;
    scanf("%d%d",&x0,&y0);
    lim[0]=y0-1,lim[1]=m-y0,lim[2]=x0-1,lim[3]=n-x0;
    scanf("%s%s",p1+1,p2+1);
    //
    int L=1,R=n;
    for(int i=len;i;--i){
        if(p2[i]=='U')++R;
        if(p2[i]=='D')--L;
        L=max(L,1),R=min(R,n);
        if(p1[i]=='U')++L;
        if(p1[i]=='D')--R;
        if(L>R)GG();
    }
    if(R<x0||L>x0)GG();
    //
    L=1,R=m;
    for(int i=len;i;--i){
        if(p2[i]=='L')++R;
        if(p2[i]=='R')--L;
        L=max(L,1),R=min(R,m);
        if(p1[i]=='L')++L;
        if(p1[i]=='R')--R;
        if(L>R)GG();
    }
    if(R<y0||L>y0)GG();
    //
    puts("YES");
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<bool> dec(10,1);
  int x;
  int mx = 0;
  for (int i = 0 ; i < k; i++) {
    cin >> x;
    dec[x] = 0;
  }
  for (int i = 0; i < 10; i++) {
    if(dec[i]) {
      mx = i;
    }
  }
  int res = mx;
  int cnt = 1;
  while(res < n) {
    res *= 10;
    res += mx;
    cnt *= 10;
  }
  int ans = 0;
  int i = 0;
  while(res > 0) {
    if(dec[i]) {
      if(ans + (i*cnt) + (res/10) >= n) {
        ans += i*cnt;
        res /= 10;
        cnt /= 10;
        i = -1;
      }
    }
    i++;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
int dy[4] = { 1, 0, -1, 0 }, dx[4] = { 0, 1, 0, -1 };
const ll MOD = 1e9 + 7;
const ll INF = 1e9;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll t = 1, a = 1;
    rep(i, n)
    {
        ll x, y;
        cin >> x >> y;
        ll co = max((t + x - 1) / x, (a + y - 1) / y);
        t = co * x;
        a = co * y;
    }
    cout << t + a << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 2005;

int cnt0[N][N],cnt1[N][N];
int n,k;

int calc0(int x1,int x2,int y1,int y2){
	if (x1>x2)return calc0(x1,k*2-1,y1,y2)+calc0(0,x2,y1,y2);
	if (y1>y2)return calc0(x1,x2,y1,k*2-1)+calc0(x1,x2,0,y2);
	return cnt0[x2][y2]-(x1?cnt0[x1-1][y2]:0)-(y1?cnt0[x2][y1-1]:0)+(x1&&y1?cnt0[x1-1][y1-1]:0);
}

int calc0(int x,int y){
	int x1=(x+k-1)%(k*2),y1=(y+k-1)%(k*2);
	return calc0(x,x1,y,y1)+calc0((x1+1)%(k*2),(x+2*k-1)%(2*k),(y1+1)%(k*2),(y+2*k-1)%(2*k));
}

int calc1(int x1,int x2,int y1,int y2){
	if (x1>x2)return calc1(x1,k*2-1,y1,y2)+calc1(0,x2,y1,y2);
	if (y1>y2)return calc1(x1,x2,y1,k*2-1)+calc1(x1,x2,0,y2);
	return cnt1[x2][y2]-(x1?cnt1[x1-1][y2]:0)-(y1?cnt1[x2][y1-1]:0)+(x1&&y1?cnt1[x1-1][y1-1]:0);
}

int calc1(int x,int y){
	int x1=(x+k-1)%(k*2),y1=(y+k-1)%(k*2);
	return calc1(x,x1,y,y1)+calc1((x1+1)%(k*2),(x+2*k-1)%(2*k),(y1+1)%(k*2),(y+2*k-1)%(2*k));
}


int main(){
	n=get(),k=get();
	fo(i,1,n){
		int x=get(),y=get();
		char c;
		c=getchar();
		if (c=='B')cnt0[x%(k*2)][y%(k*2)]++;
		else cnt1[x%(k*2)][y%(k*2)]++;
	}
	fo(i,0,k*2-1)
		fo(j,0,k*2-1){
			if (i)cnt0[i][j]+=cnt0[i-1][j],cnt1[i][j]+=cnt1[i-1][j];
			if (j)cnt0[i][j]+=cnt0[i][j-1],cnt1[i][j]+=cnt1[i][j-1];
			if (i&&j)cnt0[i][j]-=cnt0[i-1][j-1],cnt1[i][j]-=cnt1[i-1][j-1];
		}
	int ans=0;
	fo(i,0,k*2-1)
		fo(j,0,k*2-1){
			int tmp0=calc0(i,j),tmp1=calc1((i+k)%(k*2),j);
			int tmp=tmp0+tmp1;
			ans=max(ans,tmp);
			//if (tmp==6)printf("%d %d\n",i,j);
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 31616
# -*- coding: utf-8 -*-

A, B, K = map(int, input().split())

ans = list()
for i in range(1, max(A, B) + 1):
    if A % i == 0 and B % i == 0:
        ans.append(i)
ans.sort(reverse=True)
print(ans[K - 1])


Measured memory_bytes: 2940