akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    string s;
    int n;
    cin >> n;
    bool flag=1;
    for (int i = 0; i < n; i++) {
        cin >> s;
        if (s == "Y") flag = 0;
    }
    if (flag) cout << "Three" << endl;
    else cout << "Four" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <cmath>
using namespace std;
int main() {
  int x;
  int count = 1;
  cin >> x;
  while(1) {
    if (!((x*count)%360)) break;
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3124
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int N;
    cin >> N;
    int A[N] = {}, emp;
    Fp(i, 0, N - 1){
        cin >> emp;
        A[emp - 1]++;
    }
    Fp(i, 0, N) cout << A[i] << endl;
}

Measured memory_bytes: 4404
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int a = Integer.parseInt(sc.next());
            String op = sc.next();
            int b = Integer.parseInt(sc.next());

            if ("?".equals(op)) break;

            switch (op) {
                case "+":
                    System.out.println(a+b);
                    break;
                case "-":
                    System.out.println(a-b);
                    break;
                case "*":
                    System.out.println(a*b);
                    break;
                case "/":
                    System.out.println((int)Math.floor(a/b));
                    break;
            }
        }
    }
}

Measured memory_bytes: 26332
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  string s;
  cin>>n;
  map<string,int> mp;
  int m=0;
  while(n--){
    cin>>s;
    if(mp.find(s)==mp.end()){
      mp[s]=1;
    }else{
      ++mp[s];
    }
    m=max(m,mp[s]);
  }
  for(auto i:mp){
    if(i.second==m){
      cout<<i.first<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 19204
n, k = map(int, input().split())
 
a = list(map(int, input().split()))
 
min_cost = float("inf")
for i in range(2**n):
    if bin(i).count("1") != k:
        continue
 
    min_h = a[0]
    cost = 0
    for j in range(1, n):
        if i >> j & 1:
            min_h += 1
            cost += max(0, min_h-a[j])
 
        min_h = max(min_h, a[j])
 
    min_cost = min(min_cost, cost)
 
print(min_cost)

Measured memory_bytes: 3064
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            int s = int.Parse(Console.ReadLine());
            string k = Console.ReadLine();

            if (k.Length <= s)
            {
                Console.WriteLine(k);
            }
            else 
            {
                var span = k.AsSpan().Slice(0, s);
                Console.WriteLine(span.ToString() + "...");
            }

            Console.Out.Flush();
        }
    }
}



Measured memory_bytes: 27612
a,b=map(int,input().split())
#F(A,B)==F(0,A)^F(0,B)
#n==2k n^(n+1)=1

def xoc(n):
    cnt=0
    tmp = (n+1) // 2
    if (n+1)%2==0:
        if tmp%2==0:
            cnt=0
        else:
            cnt=1
    else:
        if tmp%2==0:
            cnt=0^n
        else:
            cnt=1^n
    return cnt

print(xoc(a-1)^xoc(b))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N = 15;
char a[N]; 
int main(){
	int n,m;
    scanf("%d",&n);
    for(int i=1;i<=9;i++){
    	m=i*100+i*10+i;
    	if(n<=m){
    		printf("%d\n",m);
    		break;
		}
	}
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;
typedef vector<char> vchar;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<string>> vvstring;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================




int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


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

	vll sum(N);
	sum[0] = A[0];
	for (int i = 1; i < N; i++)
	{
		sum[i] = sum[i - 1] + A[i];
	}


	ll ans = LLINF;
	for (int i = 0; i < N; i++)
	{
		ans = min(ans, abs(sum[N - 1] - sum[i]*2));
	}

	cout << ans << endl;




}



Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
#define all(obj) obj.begin(), obj.end()
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

using namespace std;

typedef unsigned long long ull;
typedef int long long ll;
constexpr ll bigNum = 1000000007;

signed main()
{
    fast;

    int n = 0;
    cin >> n;

    vector<double> vec(n);

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

    sort(all(vec));
    long double ans = 0;

    for (int j = n - 1; j >= 0; j--)
    {
        for (int i = j; i >= 0; i--)
        {
            if (j == 1)
            {
                vec[0] /= 2;
                vec[1] /= 2;
                i = -1;
                j = -1;
                break;
            }
            else
            {
                vec[i] /= 2;
            }
        }
    }

    for (int i = 0; i < n; i++)
    {
        ans += vec[i];
    }

    cout << ans;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

typedef struct{
  char name;
  int sum;
}Store;

int main(){
  Store data[5];
  int am,pm;
  while(cin >> am >> pm && am + pm){
    char now = 'A';
    data[0].name = now;
    data[0].sum = am+pm;
    for(int i = 1; i < 5; i++){
      now++;
      cin >> am >> pm;
      data[i].name = now;
      data[i].sum = am+pm;
    }
    Store max = data[0];
    
    for(int i = 1; i < 5; i++){
      if(data[i].sum > max.sum) max = data[i];
    }

    cout << max.name << " " << max.sum << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
int main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  string s;
  cin >> s;
  vector<pl> storeRL;
  {
    bool isBefR = s[0] == 'R';
    int r = 0;
    int l = 0;
    for (char i : s) {
      if (i == 'R' and isBefR) {
        r++;
      } else if (i == 'R' and !isBefR) {
        storeRL.push_back({r - 1, l - 1});
        r = 1;
        l = 0;
      } else if (i == 'L') {
        l++;
      }
      isBefR = i == 'R';
    }
    storeRL.push_back({r - 1, l - 1});
  }
  rep(i, SIZE(storeRL)) {
    ll x = storeRL[i].F, y = storeRL[i].S;
    ll move_count = max(x, y);
    ll l = (x + y) / 2 + (x + y) % 2 + 1;
    ll r = (x + y) / 2 + 1;
    if (y < x) swap(l, r);
    if (move_count % 2 == 0) swap(l, r);
    rep(j, x) cout << 0 << " ";
    cout << l << " " << r << " ";
    rep(j, y) {
      if (i == SIZE(storeRL) - 1 and j == y - 1) {
        cout << 0 << endl;
      } else {
        cout << 0 << " ";
      }
    }
  }

  return 0;
}


Measured memory_bytes: 1480
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9,MOD = 1e9+7,ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=LINF,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,hozon[2000+10][2000+10];
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n>>x;
    rep(i,n)cin>>a[i],a[i+n]=a[i];
    rrep(i,n,2*n){
        cnt=0;
        rrrep(j,i,i-n){
            if(cnt!=0)hozon[i-n][cnt]=min(hozon[i-n][cnt-1],a[j]);
            else hozon[i-n][cnt]=a[j];
            cnt++;
        }
    }
    rep(mahou,n+1){
        cnt=mahou*x;
        rrep(i,n,2*n){
            cnt+=hozon[i-n][mahou];
        }
         ans=min(ans,cnt);
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 33024
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
int maxn = 100101;
int rem[1001010];
int main(){
    int n,x;
    scanf("%d",&n);
    for(int i = 1; i <= n; i ++){
        scanf("%d",&x);
        rem[x] ++;
        //maxn = maxn > x ? maxn : x;
    }
    int ans = 0;
    //printf("%d\n",maxn);
    for(int i = 1; i <= maxn; i ++)
        if(rem[i-1] + rem[i] + rem[i+1] > ans)
            ans = rem[i-1] + rem[i] + rem[i+1];
    printf("%d",ans);
    return 0;
}


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

int main(int argc, char *argv[])
{
	int A,B,TEMP;
	
	scanf("%d %d",&A,&B);
	
	if(A<=0 || A>8)
	{
		printf("\n\n:(");
		exit(0);
	}
	
	if(B<=0 || B>8)
	{
		printf("\n\n:(");
		exit(0);
	}	
	
	TEMP=A+B;
	
	if(TEMP>16)
	{
		printf("\n\n:(");
		exit(0);
	}
	else
	{
		printf("\n\nYay!");
		exit(0);
	}
	
	return 0;
}

Measured memory_bytes: 1716
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int A = 10, B = 11, C = 12, D = 13, E = 14, F = 15;

int main()
{
	char x, y;
	scanf("%c %c", &x, &y);
	if(x > y) printf(">\n");
	else if(x < y) printf("<\n");
	else printf("=\n");
	return 0;
}

Measured memory_bytes: 256
N, Ma, Mb = map(int, input().split())
items = []
for i in range(N):
    a, b, c = map(int, input().split())
    items.append((a, b, c))

a_sum = sum([item[0] for item in items])
b_sum = sum([item[1] for item in items])
inf = float("inf")
dp = [[[inf for _ in range(a_sum + 60)] for _ in range(b_sum + 60)] for i in range(N + 1)]
dp[0][0][0] = 0

for i in range(N):
    for a in range(a_sum):
        for b in range(b_sum):
            if dp[i + 1][a][b] > dp[i][a][b]:
                dp[i + 1][a][b] = dp[i][a][b]
            if dp[i + 1][a + items[i][0]][b + items[i][1]] > dp[i][a][b] + items[i][2]:
                dp[i + 1][a + items[i][0]][b + items[i][1]] = dp[i][a][b] + items[i][2]

ans = inf
for a in range(1, a_sum + 1):
    for b in range(1, b_sum + 1):
        if a * Mb == b * Ma:
            ans = min(ans, dp[N][a][b])
if ans != inf:
    print(ans)
else:
    print(-1)


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

#ifdef LOCAL_BOOKNU
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// ........................macro.......................... //
#define FOR(i, f, n) for(int (i) = (f); (i) < (int)(n); ++(i))
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (int)(n); --(i))
#define pb push_back
#define emb emplace_back
#define fi first
#define se second
#define ENDL '\n'
#define sz(A) (int)(A).size()
#define ALL(A) A.begin(), A.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define next next9876
#define prev prev1234
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef long long i64;
typedef unsigned long long ui64;
// inline i64 GCD(i64 a, i64 b) { if(b == 0) return a; return GCD(b, a % b); }
inline int getidx(const vi& ar, int x) { return lower_bound(ALL(ar), x) - ar.begin(); } // 좌표 압축에 사용: 정렬된 ar에서 x의 idx를 찾음
inline i64 GCD(i64 a, i64 b) { i64 n; if(a < b) swap(a, b); while(b != 0) { n = a % b; a = b; b = n; } return a; }
inline i64 LCM(i64 a, i64 b) { if(a == 0 || b == 0) return GCD(a, b); return a / GCD(a, b) * b; }
inline i64 CEIL(i64 n, i64 d) { return n / d + (i64)(n % d != 0); } // 음수일 때 이상하게 작동할 수 있음.
inline i64 ROUND(i64 n, i64 d) { return n / d + (i64)((n % d) * 2 >= d); }
const i64 MOD = 1e9+7;
inline i64 POW(i64 a, i64 n) {
	assert(0 <= n);
	i64 ret;
	for(ret = 1; n; a = a*a%MOD, n /= 2) { if(n%2) ret = ret*a%MOD; }
	return ret;
}
template <class T> ostream& operator<<(ostream& os, vector<T> v) {
	os << "[";
	int cnt = 0;
	for(auto vv : v) { os << vv; if(++cnt < v.size()) os << ","; }
	return os << "]";
}
template <class T> ostream& operator<<(ostream& os, set<T> v) {
	os << "[";
	int cnt = 0;
	for(auto vv : v) { os << vv; if(++cnt < v.size()) os << ","; }
	return os << "]";
}
template <class L, class R> ostream& operator<<(ostream& os, pair<L, R> p) { return os << "(" << p.fi << "," << p.se << ")"; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H, debug_out(T...); }
// ....................................................... //

string s, ar[3], br[3] = { "2019", "04", "30" };
void input() {
	cin >> s;
}

int solve() {
	int p = 0;
	FOR(i, 0, s.size()) {
		if(s[i] == '/') {
			++p;
			continue;
		}
		ar[p].pb(s[i]);
	}
	FOR(i, 0, 3) {
		if(ar[i] > br[i]) {
			cout << "TBD" << ENDL;
			return 0;
		}
	}
	cout << "Heisei" << ENDL;
	return 0;
}

// ................. main .................. //
void execute() {
	input(), solve();
}

int main(void) {
#ifdef LOCAL_BOOKNU
	freopen("input.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	cin.tie(0), ios_base::sync_with_stdio(false);
	execute();
	return 0;
}
// ......................................... //

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	int s=0,t=0,v;
	for (int i=0;i<a.size();i++)
	{
		if (a[i]=='C')
			s=1;
		if (a[i]=='F')
			t=1,v=i;			
	}
	if (s==0 || t==0)
	{
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0;i<=v;i++)
	{
		if (a[i]=='C')
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
# N以下の素数のリストを出力する
def prime_sieve(N):
    if N < 2:
        return []
    search_list = list(range(2, N + 1))
    prime_list = []
    while search_list[0] <= N ** 0.5:
        prime_list.append(search_list[0])
        tmp = search_list[0]
        search_list = [i for i in search_list if i % tmp != 0]
    prime_list.extend(search_list)
    return prime_list


A = prime_sieve(100005)
X = int(input())
for p in A:
    if p >= X:
        print(p)
        break


Measured memory_bytes: 7448
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;
const int MOD = 1e9+7;

//C++17
template<typename Type>
Type GCD(Type a,Type b){ return b ? GCD(b,a%b) : a ;}
template<typename Type>
Type LCM(Type a,Type b){ return a*b / GCD(a,b) ;}

template<typename Type>//文字列の置換/Boost:replace_all()
Type replace_str(Type str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main() {
    int n,k;cin >> n >> k;
    cout << n%k << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	char str1[4];
	char str2[4];
	scanf("%s",str1);
	scanf("%s",str2);
	int count = 0;
	for(int i=0;i<3;i++){
		if(str1[i]==str2[i]) count++;
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int N;
int h[100004][3];
int n[100004][3] = { 0 };

int getBest(int i, int lastAction) {
	if (i >= N)
		return 0;
	if (n[i][lastAction] != 0)
		return n[i][lastAction];
	int best;
	for (int c = 0; c < 3; c++) {
		if (c != lastAction) {
			best = h[i][c] + getBest(i + 1, c);
			if (best > n[i][lastAction])
				n[i][lastAction] = best;
		}	
	}
	return n[i][lastAction];
}

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
		scanf("%d %d %d", &h[i][0], &h[i][1], &h[i][2]);

	printf("%d", getBest(0, -1));
}


Measured memory_bytes: 10368
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
#include <numeric>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, K;
	cin >> N >> K;
	VI A(N);
	int sum = 0;
	REP(i, N) {
		cin >> A[i];
		sum += A[i];
	}
	rSORT(A);
	int res = 0;
	vector<bool> dp(K);
	dp[0] = true;
	REP(i, N) {
		bool f = false;
		REP(j, K) {
			f |= dp[j] && j + sum >= K;
		}
		if (!f) 
			res++;

		sum -= A[i];
		for (int j = K - 1 - A[i]; j >= 0; j--) {
			dp[j + A[i]] = dp[j + A[i]] | dp[j];
		}
	}

	cout << res << endl;
	return 0;
}



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

int main(){
    int n, t, a;
    cin >> n;
    cin >> t >> a;
    vector<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    t *= 1000;
    a *= 1000;

    int ans = 0;
    for(int i = 1; i < n; i++){
        if(abs(a-(t-h[i]*6)) < abs(a-(t-h[ans]*6))){
            ans = i;
        }
    }
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define NREP(i, n) for(int i = 1; i <= (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int nums(int n){
	return to_string(n).length();
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cout << fixed << setprecision(7);
////////////////////////////////////////////
	int a,b;
	cin >> a >> b;
	for(int i=b-a+1;i<b+a;i++){
		cout << i;
		if(i==a+b-1){
			cout << endl;
		}else{
			cout << " ";
		}
	}
///////////////////////////////////////////
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int input;
  int h, m, s;

  scanf("%d", &input);

  h = input / 3600;
  input = input % 3600;
  m = input / 60;
  input = input % 60;
  s = input % 60;

  printf("%d:%d:%d\n", h, m, s);

  return 0;
}

Measured memory_bytes: 592
N,K = map(int, input().split())
#print(N,K)
H = list(map(int, input().split()))
#H = input().split()
#print(H)
if N<=K:
  print(0)
else:
  # Hの中身を入れ替えて大きいものから順に必殺技で倒す
  # つまり、配列をカットする
  # 配列の残りの和が倒すのに必要な数
  H.sort(reverse=True)
  newH = H[K:]
  sumH = sum(newH)
  print(sumH)

Measured memory_bytes: 26764
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

  vector<int> v(5);
  REP(i,5) {
    cin >> v[i];
  }
  int k;
  cin >> k;

  bool flg = true;
  REP(i,5) {
    FOR(j,i+1,5) {
      if (abs(v[i] - v[j]) > k) flg = false;
    }
  }

  if(flg) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d.at(i);

    sort(d.begin(), d.end());
    if(d.at(n/2-1) < d.at(n/2)){
        cout << d.at(n/2) - d.at(n/2-1) << endl; 
    }
    else cout << 0 << endl;
}

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

int gcd(int x, int y);

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/


int main() {
    int n;
    cin >> n;
    int ans = 0;
    int cnt = 0;
    int back = 0;
    int num;


    rep(i, n) {
        cin >> num;
        if (back < num) {
            back = num;
            ans = max(cnt, ans);
            cnt = 0;
        }
        else {
            cnt++;
            back = num;
        }
    }
    ans = max(cnt, ans);

    
    

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

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){

  int n, i, a, b, c, d, e, x, max, min;

  while(1)
    {
      max=0;
      min=500;
      scanf("%d", &n);
      if( n == 0) break;     
      for( i = 0; i < n; i++)
	{
	  scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
	  x = a+b+c+d+e;
	  if( x > max)
	    {
	      max = x;
	    }
	  if( x < min)
	    {
	      min = x;
	     }
	}
      printf("%d %d\n", max, min);

    }
  return 0;
}

Measured memory_bytes: 600
direction = {'N':(0, 1), 'E':(1, 0), 'W':(-1, 0), 'S':(0, -1)}

while True:
    N = int(raw_input())
    if N == 0:
        break
    B = [[False for j in xrange(21)] for i in xrange(21)]
    for i in xrange(N):
        x, y = map(int, raw_input().split())
        B[y][x] = True
    M = int(raw_input())
    px, py = 10, 10
    taken = 0
    for i in xrange(M):
        d, step = raw_input().split()
        d = direction[d]
        step = int(step)
        for j in xrange(step):
            px += d[0]
            py += d[1]
            if B[py][px]:
                taken += 1
                B[py][px] = False
    print 'Yes' if taken == N else 'No'
        

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

int main() {
	int x, y;
	cin >> x >> y;
	if (x < y)swap(x, y);
	while (x%y != 0) {
		x = x - y*(x / y);
		swap(x, y);
	}
	cout << y << endl;
	return 0;
}

Measured memory_bytes: 3104
n, t = gets.strip.split.map(&:to_i)
mincost=1<<10
(1..n).each do |i|
	cost, time = gets.strip.split.map(&:to_i)
	if time<=t && cost<mincost
		mincost=cost
	end
end

if mincost < 1<<10
	puts mincost
else
	puts 'TLE'
end



Measured memory_bytes: 1788
#include <iostream>

int main(){
   int N;
   std::cin >> N;
   double x[N];
   std::string u[N];
   for(int i=0; i<N; ++i){
      std::cin >> x[i] >> u[i];
   }

   const double B2Y = 380000;
   double sum = 0;
   for(int i=0; i<N; ++i){
      sum += (u[i]=="JPY" ? x[i] : x[i]*B2Y);
   }
   std::cout << sum << std::endl;

   return 0;
      
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self,n):
        self.d = []
        for i in range(n):
            self.d.append(-1)
    def find(self, x):
        if self.d[x] < 0:
            return x
        else:
            self.d[x] = self.find(self.d[x])
            return self.d[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.d[x] > self.d[y]:
            y, x = x, y
        self.d[x] += self.d[y]
        self.d[y] = x
        return True
    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.d[self.find(x)]

n, m, k = map(int, input().split())

dame = [set() for _ in range(n)]
uf = UnionFind(n)

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.unite(a, b)
    dame[a].add(b)
    dame[b].add(a)

for i in range(k):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    if not uf.same(c, d):
        continue
    dame[c].add(d)
    dame[d].add(c)

for i in range(n):
    ans = uf.size(i) - 1
    ans -= len(dame[i])
    print(ans, end=" ")
print()

Measured memory_bytes: 126112
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
#define REP3(i,x,n) for(ll i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    ll N;
    string S = "bon";
    cin >> N;
    if(N%10==2||N%10==4||N%10==5||N%10==7||N%10==9)S="hon";
    else if(N%10==0||N%10==1||N%10==6||N%10==8)S="pon";
    cout << S << endl;;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

int h, w;
long long a, b, m = 0;
string s[400];
bool f[400][400];

void check(int ht, int wt) {
	f[ht][wt] = 1;

	if (s[ht][wt] == '#') {
		b++;
		if (ht + 1 < h && !f[ht + 1][wt] && s[ht + 1][wt] == '.')
			check(ht + 1, wt);
		if (wt + 1 < w && !f[ht][wt + 1] && s[ht][wt + 1] == '.')
			check(ht, wt + 1);
		if (ht > 0 && !f[ht - 1][wt] && s[ht - 1][wt] == '.')
			check(ht - 1, wt);
		if (wt > 0 && !f[ht][wt - 1] && s[ht][wt - 1] == '.')
			check(ht, wt - 1);
	}

	if (s[ht][wt] == '.') {
		a++;
		if (ht + 1 < h && !f[ht + 1][wt] && s[ht + 1][wt] == '#')
			check(ht + 1, wt);
		if (wt + 1 < w && !f[ht][wt + 1] && s[ht][wt + 1] == '#')
			check(ht, wt + 1);
		if (ht > 0 && !f[ht - 1][wt] && s[ht - 1][wt] == '#')
			check(ht - 1, wt);
		if (wt > 0 && !f[ht][wt - 1] && s[ht][wt - 1] == '#')
			check(ht, wt - 1);
	}
}

int main()
{
	cin >> h >> w;

	for (int i = 0; i < h; i++)
		cin >> s[i];

	memset(f, 0, sizeof(f));

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (!f[i][j]) {
				a = 0;
				b = 0;
				check(i, j);
				m += a * b;
			}
		}
	}

	cout << m << endl;

	return 0;
}

Measured memory_bytes: 18048
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}

int main(){
    int a,b,c,n;
    //string s,p;
    char ch;
    vector<int>v;
    
    int sum=0;
    cin >> n;
    
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            int p = gcd(i,j);
            for(int k=1; k<=n; k++){
                int q = gcd(p,k);
                sum+=q;
            }
        }
    }
    
    cout << sum << endl;
    
    
    return 0;
}




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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

char query(int n)
{
    cout << n << endl;
    string s;
    cin >> s;
    return s[0];
}

int main(void)
{
    const int N_MAX = 99999;
    int N;
    cin >> N;
    int c[N_MAX];
    REP(i, N) c[i] = 'U'; // undefined
    c[0] = query(0);
    if (c[0] == 'V') {
        return 0;
    }
    int first, last;
    first = 0;
    last = N - 1;
    while (true) {
        int dif;
        if (first < last) {
            dif = last - first;
        } else {
            dif = last + N - first;
        }
        assert(dif != 0);
        if (dif == 1) {
            query(last);
            return 0;
        }
        int steps = dif / 2;
        int mid = (first + steps) % N;
        c[mid] = query(mid);
        if (c[mid] == 'V') {
            return 0;
        } else if (steps % 2 == 0 && c[first] == c[mid] || steps % 2 == 1 && c[first] != c[mid]) {
            first = mid;
        } else {
            last = mid - 1;
        }
    }
    return 0;
}


Measured memory_bytes: 1236
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,e,f,g,h;
    cin >> a >> b >> c >> d >> e >> f >> g >> h;
    
    if (a*e+b*f+a/10*g+b/20*h < c*e+d*f+c/10*g+d/20*h)
    cout << "kenjiro" << endl;
    
    else if (a*e+b*f+a/10*g+b/20*h == c*e+d*f+c/10*g+d/20*h)
    cout << "even"<<endl;
    
    else cout << "hiroshi" <<endl;
    
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define FOR(i,a) for(auto i:a)
#define pub push_back
#define pob pop_buck
#define all(in) in.begin(),in.end()

using ll = long long; // typedef long long ll; と同意
using ull = unsigned long long;
using namespace std;

int main(){
    int count = 0;
    rep(i, 5) {
        int x; cin >> x;
        count++;
        if(x == 0) break;
    }
    cout << count << endl;
}

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

int main() {
    int n;
    std::cin >> n;
    std::vector<int> S(n);
    for (int i = 0; i < n; i ++) {
        std::cin >> S[i];
    }

    int q;
    std::cin >> q;
    std::vector<int> T(q);
    for (int i = 0; i < q; i ++) {
        std::cin >> T[i];
    }

    int C = 0;
    for (int t : T) {
        for (int s : S) {
            if (t == s) {
                C += 1;
                break;
            }
        }
    }
    std::cout << C << std::endl;
}



Measured memory_bytes: 3088
import std.stdio;
import std.conv;
import std.string;

void main(){
	int n;
	while(n = to!int(readln.chomp), n){
		int S = 0;
		int max = int.min;
		for(int i = 0; i < n; i ++){
			S += to!int(readln.chomp);
			if(S > max) max = S;
			if(S < 0) S = 0;
			}
		writeln(max);
		}
	}

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

using namespace std;

int main()
{
    int n, k;

    while (cin >> n >> k) {
        int arr[n];

        for (int i = 0; i < n; i++) cin >> arr[i];

        int dp[n];

        for (int i = 0; i < n; i++) dp[i] = 1e9;

        dp[0] = 0;

        for (int i = 1; i < n; i++) {
            for (int j = 1; j <= k; j++) {
                if (i - j >= 0) dp[i] = min(dp[i], dp[i - j] + abs(arr[i - j] - arr[i]));
            }
        }

        cout << dp[n - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int i,Ans[101]={0},count[101]={0},Max=0,j=1;
	while(scanf("%d",&i)!=EOF){
		count[i]++;
	}
	for(i=1;i<101;i++){
		if(Max<count[i]) Max=count[i];
	}
	for(i=1;i<101;i++){
		if(Max==count[i]){
			Ans[j]=i;
			j++;
		}
	}
	for(i=1;i<101;i++){
		if(Ans[i]!=0) printf("%d\n",Ans[i]);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,m,n) for (int i = m; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

template<typename T>
vector<T> radix_conversion(T x, T b, int n = -1) {
  vector<T> res;
  T t = 1, k = llabs(b);
  while(x) {
    res.emplace_back((x * t) % k);
    if(res.back() < 0) res.back() += k;
    x -= res.back() * t;
    x /= k;
    t *= b/k;
  }
  if(res.empty()) res.emplace_back(0);
  for (int i = res.size(); i < n; ++i) res.emplace_back(0);
  // reverse(res.begin(),res.end());
  return res;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  vector<ll> a(n);
  ll cul = 0;
  rep(i,n) {
    cin >> a[i];
    cul ^= a[i];
  }
  rep(i,n) {
    cout << (cul^a[i]) << "\n";
  }
  return 0;
}

Measured memory_bytes: 4752
n = int(input())
L = [*map(int, input().split())]
L.sort()
c = 0
for i in range(n):
    for j in range(i+1, n):
        if L[i] == L[j]: continue
        for k in range(j+1, n):
            if L[j] == L[k]: continue
            if L[k] == L[i]: continue
            if L[i] + L[j] > L[k]: c += 1
print(c)


Measured memory_bytes: 9184
#include <stdio.h> 
int main(){
  long int n,a,b,i;
  scanf("%ld", &n);
  int c=n;
  for(a=1;a*a<=n;a++) {
    if(n%a==0){
      b=n/a;
      i=0;
      while(b>0){
        b=b/10;
        i++;
      }
      if(i<n){
        c=i;
      }
    }
  }
  printf("%ld\n",c);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<pii>>;
using mat = vector<vector<int>>;
const int MOD = 1e9 + 7;

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

    ll a, b, x;
    cin >> a >> b >> x;
    ll ans = b / x + 1;
    if (a != 0)
        ans -= (a - 1) / x + 1;

    cout << ans << endl;

    return 0;
}


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

int main() {
	int a, b;
	char c;
	while (1) {
		cin >> a >> c >> b;
		if (c == '+')
			printf("%d\n", a + b);
		if (c == '-')
			printf("%d\n", a - b);
		if (c == '*')
			printf("%d\n", a * b);
		if (c == '/')
			printf("%d\n", a / b);
		if (c == '?')
			break;
	}
	return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

int a[200001], ans[200001], prv[200001];
vector<int> graph[200001], lis;

void dfs(int node = 1, int parent = 0) {
    int pos = lower_bound(lis.begin(), lis.end(), a[node]) - lis.begin();
    if (pos == lis.size()) lis.push_back(a[node]);
    else {
        prv[node] = lis[pos];
        lis[pos] = a[node];
    }
    ans[node] = lis.size();

    for (int i : graph[node]) if (i != parent) dfs(i, node);

    if (prv[node] == -1) lis.pop_back();
    else lis[pos] = prv[node];
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    FOR(i, 1, n + 1) cin >> a[i];
    FOR(i, 1, n) {
        int x, y;
        cin >> x >> y;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    fill(prv + 1, prv + n + 1, -1);
    dfs();
    assert(!lis.size());
    FOR(i, 1, n + 1) cout << ans[i] << '\n';
    return 0;
}

Measured memory_bytes: 31216
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args){
		FastScanner stdIn = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int k = stdIn.nextInt();
		
		List<Integer> list = new ArrayList<>();
		
		int i = 1;
		while(i<=Math.max(a,b)) {
			if(a%i==0 && b%i==0) {
				list.add(i);
			}
			i++;
		}
		/*Collections.sort(list);
		Collections.reverse(list);	*/
		Collections.sort(list,Collections.reverseOrder());
		int cnt = 0;
		for(int x: list) {
			cnt++;
			if(cnt==k) {
				out.println(x);
			}
		}
		out.flush();
		
		}
	}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 21204
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;


int main(void) {

	int n;
	int p[100];
	int counter = 0;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	for (unsigned int i = 1; i < n -1; i++)
	{
		int is = max({ p[i], p[i + 1], p[i - 1] });
		int ia = min({ p[i], p[i + 1], p[i - 1] });
		if (is != p[i] && ia != p[i]) {
			counter++;
		}
	}
	cout << counter << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;

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


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

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (count(i) == 8) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
from math import sqrt,ceil,floor
def mi():return map(int,input().split())
def li():return list(mi())
def ii():return int(input())

n,k=mi()
m=[0]*(n+1)
for i in range(k):
    d=ii()
    a=li()
    for i in a:
        m[i]+=1
        
m=m[1:]
print(m.count(0))

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


int main(){
    ll A, B, M,amin = 1e5+2 ,bmin = 1e5+2;
    cin >> A >> B >> M;
  vector<ll> a(A),b(B),x(M),y(M),c(M);
    for(int i=0;i<A;i++){
        cin >> a[i];
        amin = min(amin,a[i]);
    }
    for(int i=0;i<B;i++){
        cin >> b[i];
        bmin = min(bmin,b[i]);
    }
    for(int i=0;i<M;i++){
        cin >> x[i] >> y[i] >> c[i];
        x[i]--,y[i]--;
    }

    ll ans = 1e10+2;
    for(int i=0;i<M;i++){
        ll p;
        p = a[x[i]] + b[y[i]] - c[i];
        ans = min(ans,p);
    }
    if(ans<amin+bmin){
        cout << ans << endl;
    }else{
        cout << amin + bmin << endl;
    }
}

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

#define int long long
#define pb push_back
#define mod 1000000007
#define endl '\n'
#define w(x) int x;cin>>x; while(x-->0)

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void mysol()
{
    int n, k; cin >> n >> k;
    int arr[n];
    for (int &a : arr)
        cin >> a;
    int dp[n] ;
    for (int &a : dp)
        a = INT_MAX;
    dp[0] = 0;
    for (int i = 1; i < n; i++)
        for (int j = 1; j <= k; j++)
            if (i - j > -1)
                dp[i] = min(dp[i], dp[i - j] + abs(arr[i] - arr[i - j]));
    cout << dp[n - 1];

}

int32_t main()
{
    //fast();
    // w(t)
    {
        mysol();
    }
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <vector>
#include <list>
using namespace std;

int main()
{

	string s, t, u;

    int a;

    cin >> s >> t;

    u = s + s;

    string::size_type pos = u.find(t);

    while(pos != string::npos){
        a = pos;
        pos = u.find(t, pos + t.length());
        if(a != 0) break;
    }

    if(a != 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#define FREE -1
#define NOT_FREE -2
#define N 8

void putQueen(int);
void printBoard(void);

int row[N];
int col[N];
int dpos[2*N];
int dneg[2*N];

int main(){
  int n,i,j,x,y;

  scanf("%d",&n);

  for(i=0; i < N; i++){
   row[i] =  col[i] = FREE;
  }

  for(i=0; i < 2*N; i++){
    dpos[i] = dneg[i] = FREE;
  }

  for(i=0; i < n; i++){
    scanf("%d%d",&y,&x);
    row[y] = x;
    col[x] = NOT_FREE;
    dpos[y + x] = NOT_FREE;
    dneg[y - x +(N - 1)] = NOT_FREE;
  }

  putQueen(0);

  return 0;
}

void putQueen(int i){
  int j;
  if(i == N){
    printBoard();
    //printf("\n");
    //exit(-1);
    return;
  }
  // append
  if(row[i] != FREE) {
    putQueen(i+1);
    return;
  }
  // 
  for(j=0; j < N; j++){
    if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE) continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
    //printf("%d %d\n", i, j);
    //printBoard();
    //printf("\n");
    putQueen(i+1);
    row[i] = FREE; // append
    col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}

void printBoard(void){
  int i,j;
  for(i=0; i < N; i++){
    for(j=0; j < N; j++){
      if(row[i] == j){
	printf("Q");
      } else {
	printf(".");
      }
    }
    printf("\n");
  }
}



Measured memory_bytes: 2108
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(A: int, B: int):
    print(max(A+B, A-B, A*B))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060