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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, K;
    ll count = 0;
    map<ll, ll> m;
    cin >> N >> K;
    repi2(i, 1, N) m[i % K]++;
    rep(a, K) {
        ll b = (K - a) % K;
        ll c = b;
        if((b + c) % K == 0) count += m[a] * m[b] * m[c];
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 6528
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
	ll N;
	cin >> N;
	for(ll h=1; h<=3500;h++)
		for(ll n=1;n<=3500; n++){
			ll child = N*h*n;
			ll mother= 4*n*h-N*n-N*h;
			if(mother !=0 && child % mother == 0 && child / mother > 0){
				cout << h << " " << n << " " << child / mother << endl;
				return 0;
			}

		}
	assert(false);
	return 0;
}

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

#define ll long long

struct D
{
    ll x,y;
}a[100010];
bool cmp(D a , D b)
{
    return a.x < b.x;
}
int main()
{
    int n , M;
    scanf("%d%d",&n,&M);

    for (int i = 1 ; i <= n ; i++)
        scanf("%lld%lld",&a[i].x,&a[i].y);

    sort(a+1,a+1+n,cmp);

    int i = 1;
    ll res = 0;
    while( M )
    {
        if ( a[i].y > M ) res += a[i].x * M , M = 0;
        else res += a[i].x * a[i].y , M -= a[i].y;
        i++;
    }

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


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;
int main(){
	int n,x,y,tx,ty;
	char board[10][10];
	queue<P> q;
	P p,tp;
	string str;
	cin >> n;
	getline(cin,str);
	for(int i = 0;i < n;++i){
		getline(cin,str);
		memset(board,'\0',sizeof(board));
		for(int j = 0;j < 8;++j){
			getline(cin,str);
			for(int k = 0;k < 8;++k){
				board[j + 1][k + 1] = str[k];
			}
		}
		cin >> x >> y;
		getline(cin,str);
		p.first = x;
		p.second = y;
		q.push(p);
		while(!q.empty()){
			tp = q.front();
			x = tp.first;
			y = tp.second;
			q.pop();
			board[tp.second][tp.first] = '0';
			tx = 0;
			for(ty = 0;ty < 4;++ty){
				if(board[y + ty][x + tx] == '\0') break;
				else if(board[y + ty][x + tx] == '1'){
					tp.first = x + tx;
					tp.second = y + ty;
					q.push(tp);
				}
				board[y + ty][x + tx] = '0';
			}
			for(ty = 0;ty > -4;--ty){
				if(board[y + ty][x + tx] == '\0') break;
				else if(board[y + ty][x + tx] == '1'){
					tp.first = x + tx;
					tp.second = y + ty;
					q.push(tp);
				}
				board[y + ty][x + tx] = '0';
			}
			ty = 0;
			for(tx = 0;tx < 4;++tx){
				if(board[y + ty][x + tx] == '\0') break;
				else if(board[y + ty][x + tx] == '1'){
					tp.first = x + tx;
					tp.second = y + ty;
					q.push(tp);
				}
				board[y + ty][x + tx] = '0';
			}
			for(tx = 0;tx > -4;--tx){
				if(board[y + ty][x + tx] == '\0') break;
				else if(board[y + ty][x + tx] == '1'){
					tp.first = x + tx;
					tp.second = y + ty;
					q.push(tp);
				}
				board[y + ty][x + tx] = '0';
			}
		}
		cout << "Data " << i + 1 << ":" << endl;
		for(int j = 1;j < 9;++j){
			for(int k = 1;k < 9;++k){
				cout << board[j][k];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s;
    long long int ans = 0;

    cin >> s;

    int len = s.size()-1;

    for (long long int bit = 0; bit < (1<<len); bit++) {
        string t;
        long long int num = 0;
        string sub;
        for (long long int i = 0; i < len; i++) {
            if (bit & (1<<i)) {
                t += '+';
            }
            else {
                t += ' ';
            }
        }
        t += ' ';
        for (int i = 0; i < (int)s.size(); i++) {
            sub += s[i];
            if (t[i] == '+') {
                num += stol(sub);
                sub = "";
            }
        }
        if (!sub.empty()) {
            num += stol(sub);
            sub = "";
        }
        ans += num;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

struct mint {
    const int mod = 1e9 + 7;
    long long x;
    
    mint (long long x = 0) : x((x % mod + mod) % mod) {
        
    }
    
    mint& operator=(const long long a) {
        x = a % mod;
        return *this;
    }
    
    mint& operator=(const mint a) {
        x = a.x % mod;
        return *this;
    }
    
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    
    mint& operator-=(const mint a) {
        if ((x += (mod - a.x)) >= mod) x -= mod;
        return *this;
    }
    
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    
    mint inv() const {
        return pow(mod - 2);
    }
    
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string l;
    cin >> l;
    ll n = len(l);
    // dp[figure][smaller]
    vector<vector<mint>> dp(n + 1, vector<mint>(2, 0));
    dp[0][0] = 1;
    rep(i, n) {
        if (l[i] == '0') {
            dp[i + 1][0] = dp[i][0];
            dp[i + 1][1] = dp[i][1] * 3;
        }
        else {
            dp[i + 1][0] = dp[i][0] * 2;
            dp[i + 1][1] = dp[i][1] * 3 + dp[i][0];
        }
    }
    cout << (dp[n][0] + dp[n][1]).x << endl;
    return 0;
}


Measured memory_bytes: 7376
package main

import (
	"fmt"
	"sort"
)

type shop struct {
	price int
	num   int
}

type Drink []shop

func (p Drink) Len() int {
	return len(p)
}

func (p Drink) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Drink) Less(i, j int) bool {
	return p[i].price < p[j].price
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	ss := make([]shop, n)
	for i := range ss {
		fmt.Scan(&ss[i].price, &ss[i].num)
	}
	sort.Sort(Drink(ss))

	ans := 0
	count := 0

	for i := 0; count < m && i < n; i++ {
		if (m - count) >= ss[i].num {
			ans += ss[i].price * ss[i].num
			count += ss[i].num
		} else {
			ans += ss[i].price * (m - count)
			count += m - count
		}
		if count >= m {
			break
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 5376
def calculate(n,k,q,arr):
    result = [k]*n
    for index in range(q):
        result[arr[index] - 1] = result[arr[index] - 1] + 1

    for index in range(len(result)):
        if (result[index] - q) > 0:
            print("Yes")
        else:
            print("No")

N,K,Q = input().split(' ')
N = int(N)
K = int(K)
Q = int(Q)

arr = []
for i in range(Q):
    arr.append(int(input()))

calculate(N,K,Q,arr)

Measured memory_bytes: 10516
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    int rev = 1;
    cin >> n;
    deque<int> deq;
    rep(i,n){
        int x;
        cin >> x;
        if(rev == 1){
            deq.push_back(x);
        }else{
            deq.push_front(x);
        }
        rev ^= 1;
    }
    if(rev == 0) reverse(deq.begin(), deq.end());
    for(auto u : deq){
        cout << u << endl;
    }
    return 0;
}

Measured memory_bytes: 4432
#include<stdio.h>


int main(void) {

	unsigned long long int A, B, K;
	unsigned long long int i;

	scanf("%llu %llu %llu", &A, &B, &K);


	if (A>=K) {
		A = A - K;
		printf("%llu %llu", A, B);
		return 0;
	}
	else {
		K = K - A;
		A = 0;
		
	
		if (K > 0 && B >= K) {
			B = B - K;
			printf("%llu %llu", A, B);
			return 0;
		}
		else if (K > 0 && B < K) {
			B = 0;
			printf("%llu %llu", A, B);
			return 0;
		}

	}
		
}


Measured memory_bytes: 128
INF = float('inf')

def dijkstra(s,N,M,cost,ans):
  d = [INF] * N
  used = [False] * N
  d[s] = 0
  prvv = [[] for _ in range(N)]
  while True:
    v = -1
    for i in range(N):
      if (not used[i]) and (v == -1): v = i
      elif (not used[i] and d[i] < d[v]): v = i
    if v == -1: break
    used[v] = True
  
    for j in range(N):
      if d[j] > d[v]+cost[v][j]:
        d[j] = d[v]+cost[v][j]
        prvv[j] = [v]
      elif d[j] == d[v]+cost[v][j]:
        d[j] = d[v]+cost[v][j]
        prvv[j].append(v)
  
  for i, vs in enumerate(prvv):
    for v in vs:
      ans.add(tuple(sorted([v,i])))

  return prvv

N,M = map(int,input().split())

cost = [[INF for _ in range(N)] for _ in range(N)]
for i in range(M):
  a,b,c = map(int,input().split())
  cost[a-1][b-1] = c
  cost[b-1][a-1] = c


ans =set([])
for i in range(N):
  dijkstra(i,N,M,cost,ans)
print(M-len(ans))
#print(ans)

Measured memory_bytes: 45916
"use strict";
function main(arg) {
    const inputs = arg.split("\n")
    const N = parseInt(inputs[0].split(" ")[0])
    const X = parseInt(inputs[0].split(" ")[1])
    console.log(func(N,X))
}
function all(level) {
    return Math.pow(2, level + 2) - 3
}
function patty(level) {
    return Math.pow(2, level + 1) - 1
}
function func(level, X) {
    const All = all(level-1)
    if(level === 0){
        return (X === 0) ? 0 : 1
    }else if (X <= 1){
        return 0
    }else if(X <= All + 1){
        return func(level - 1, X - 1)
    }else{
        return patty(level - 1) + 1 + func(level - 1, X - All - 2)
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

ll dp[100005][2];
ll A[100005];
int main(){
  int K; cin>>K;
  for(int i=1;i<=K;i++) cin>>A[i];
  reverse(A+1,A+K+1);
  dp[0][0] = 2;
  dp[0][1] = 2;
  for(int i=1;i<=K;i++){
    ll mn = ceil((double)dp[i-1][0] / A[i]);
    ll mx = ceil(dp[i-1][1] / A[i]);
    if(mn > mx){
      cout<<-1<<endl;
      return 0;
    }
    dp[i][0] = mn * A[i];
    dp[i][1] = mx * A[i] + A[i] - 1;
  }
  cout<<dp[K][0]<<" "<<dp[K][1]<<endl;
  return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
int eat[200];
int main(void){
    int hum,day,final,i,j,temp,ans=0;
    scanf("%d",&hum);
    scanf("%d %d",&day,&final);
    for(i=0;i<200;i++){
        eat[i]=0;
    }
    for(i=0;i<hum;i++){
        scanf("%d",&temp);
        for(j=1;j<=day;j+=temp){
            eat[j]++;
        }
    }
    for(i=1;i<=day;i++){
        ans+=eat[i];
    }
    printf("%d\n",ans+final);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

signed main() {
  ll A;
  cin >> A;

  if (A % 2 == 0) {
    COUT(A / 2);
  } else {
    COUT(A / 2 + 1);
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    int *a = new int[n + 5];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    string s = "APPROVED";
    for (int i = 0; i < n; i++) {
        if (a[i] % 2 == 0) {
            if ((a[i] % 3 != 0) && (a[i] % 5 != 0)) {
                s = "DENIED";
            }
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3580
import java.io.*;
import java.util.*;

public class Main
{
	public static void main(String []args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		
		//int n=Integer.parseInt(br.readLine());
		//String []s=br.readLine().split(" ");
		
		String S = br.readLine();
		String T = br.readLine();
		
		int c=0;
		
		for(int i=0;i<3;i++)
			if(S.charAt(i) == T.charAt(i))
				c++;
					
		System.out.println(c);	
		
	}
}




Measured memory_bytes: 22996
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    char[] c = s.toCharArray();
    
    System.out.println(String.valueOf(c[0]) + (s.length() - 2) + String.valueOf(c[s.length()-1]));
  }
}


Measured memory_bytes: 21844
#include <stdio.h>

int main(){
   int i1[2] = {};
   for(int n = 0; n < 5; n++){
     scanf("%d",&i1[1]);
     if(i1[1] <= 40) i1[0] += 40;
     else i1[0] += i1[1];
   }
   printf("%d\n",i1[0] / 5);
} 

Measured memory_bytes: 2764
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	class D implements Comparable<D>{
		int a, b;

		D(int a, int b) {
			this.a = a;
			this.b = b;
		}

		@Override
		public int compareTo(D o) {
			if (this.a != o.a) {
				return this.a - o.a;
			}
			return this.b - o.b;
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long k = sc.nextLong();
		D[] d = new D[n];
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			d[i] = new D(a, b);
		}
		Arrays.sort(d);
		long sum = 0;
		for (int i = 0; i < n; i++) {
			if (sum + (long)d[i].b < k) {
				sum += (long)d[i].b;
			} else {
				System.out.println(d[i].a);
				return;
			}
		}
	}

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


Measured memory_bytes: 81600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;

signed main(){
  int n;
  cin >> n;
  vvint A(n,vint(2));
  rep(i,n) cin >> A[i][1] >> A[i][0];
  sort(A.begin(),A.end());
  int temp = 0;
  bool flag = true;
  rep(i,n){
    temp += A[i][1];
    if(temp > A[i][0]){
      flag = false;
      break;
    }
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
int main(){
    int min=999, t1, N;
  	string S;
  	cin >> S;
    N = S.size() - 2;
    for(int i = 0; i < N; i++){
        t1 = stoi(S.substr(i,3)) - 753; 
        if(t1<0)t1= -t1;
        if(t1<min)min=t1;
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool ff=0;for(auto outi:v){cout<<(ff?" ":"")<<outi;ff=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

vector<int> Zalgorithm(string s){
  int i=1,j=0,k=0,N=s.size();
  vector<int> res(N);
  res[0]=N;
  while(i<N){
    while(i+j<N&&s[i+j]==s[j])++j;
    res[i]=j;
    if(!j){
      ++i;
      continue;
    }
    k=1;
    while(res[k]+k<j){
      res[i+k]=res[k];
      ++k;
    }
    i+=k;
    j-=k;
  }
  return res;
}

int main(){
  startupcpp();
  int i,N,K,ans=0;
  string first,s="",t;
  cin>>first>>t;
  while(s.size()<t.size())s+=first;
  N=s.size();K=t.size();
  vector<int> v=Zalgorithm(t+s+s);
  queue<pair<int,int>> que;
  rep(i,N){
    if(v[i+K]<K)que.push(pair<int,int>(0,(i+K)%N));
  }
  rep(i,N){
    if(que.empty()){
      print(-1);
      return 0;
    }
    auto x=que.front();que.pop();
    chmax(ans,x.first++);
    if(v[x.second+=K]>=K){
      x.second%=N;
      que.push(x);
    }
  }
  print(ans);
}

Measured memory_bytes: 20180
#include<stdio.h>
int main()
{
    char s[5];
    int type , powder, min,temp, num = 0;
    scanf("%d %d",&type, &powder);
    scanf("%d",&min);
    ++num; powder -= min;
  	for(int i = 0; i < type - 1; i ++){
      scanf("%d",&temp);
      ++num; powder -= temp;
      min = temp < min ? temp : min;
    }
    num += powder / min;
    
    printf("%d\n",num);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
        public static void main(String[] args){
                try(Scanner sc = new Scanner(System.in)){
                        int N = sc.nextInt(), M = sc.nextInt();
                        int[] ans = new int[N];
                        for(int i = 0; i < M * 2; i++){
                                ans[sc.nextInt()-1]++;
                        }
                        for(int i = 0; i < N; i++){
                                System.out.println(ans[i]);
                        }
                }
        }
}

Measured memory_bytes: 21972
N = int(input())
L = list(map(int, input().split()))
T = []
cnt = 0

import itertools

for t in itertools.combinations(L, 3):
  if len(set(t)) == len(list(t)):
                        T.append(list(t))
  
for i in range(len(T)):
  T[i].sort()
  if T[i][0] + T[i][1] > T[i][2]:
    cnt += 1

print(cnt)

Measured memory_bytes: 25556
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())
 
int main() {
  int64_t n, k;
  cin >> n >> k;

  n %= k;
  int64_t mi = n;
  while(true){
    int64_t n0 = n;
    n = abs(n-k);
    mi = min(mi, n);

    if(n0-k<0) break;
  }
  
  cout << mi << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
s = []
for i in range(n):#h:高さ
    s.append([int(m) for m in input().split()])
s.sort()
t = 0
for i in range(n):
    if i == 0:
        if k <= s[i][1]:
            print(s[i][0])
            break
    elif i == n - 1:
        print(s[i][0])
        break
    else:
        t += s[i - 1][1]
        if t < k <= t + s[i][1]:
            print(s[i][0])
            break

Measured memory_bytes: 21648
import math
n,a,b = map(int,input().split())
mod = 10**9+7

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])%mod
            result%=mod

    return result%mod

  
def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
            K%=mod
        x *= x
        x%=mod
        n //= 2

    return K * x%mod

ans=pow_k(2,n)-1
ans=ans- cmb(n, min(a,n-a))-cmb(n, min(b,n-b))
print(ans%mod)

Measured memory_bytes: 108236
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

        int N=gi();
        Map<String, Integer> m=new HashMap<String, Integer>();
        String b=gs();
        m.put(b, 1);
        for (int i=1; i<N; i++) {
        	String w=gs();
        	if (m.containsKey(w)) {
        		System.out.println("No");
        		return;
        	}
        	if (b.charAt(b.length()-1)!=w.charAt(0)) {
        		System.out.println("No");
        		return;
        	}
          m.put(w,1);
        	b=w;
        }


        System.out.println("Yes");
//        if (a>0) {
//        	System.out.println("Yes");
//        }else {
//        	System.out.println("No");
//        }
	}


	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35580
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, m, ans, a, b;
	cin >> n >> m;
	vector<bool> used(n + 1, false);
	vector<int> ct(n + 1, 1);
	used[1] = true;
	for (i = 0; i < m; i++) {
		cin >> a >> b;
		if (used[a]) used[b] = true;
		ct[b]++;
		ct[a]--;
		if (ct[a] == 0) used[a] = false;
	}
	ans = 0;
	for (i = 1; i <= n; i++) {
		if (used[i]) ans++;
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

inline int read() {
    int x = 0, f = 1;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while('0' <= c && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

string s;

int main() {
    cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<long> H(N);

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

    bool can = true;
    long max_high = 0;

    for (int n = 0; n < N; n++) {
        if (max_high - H[n] >= 2) {
            can = false;
        }

        if (max_high < H[n]) {
            max_high = H[n];
        }
    }

    if (can) {
        cout << "Yes"
             << "\n";
    } else {
        cout << "No"
             << "\n";
    }

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
vector<int> a, b;
long long co[200020] = { 0 };
long long ans[200020];
int a1, b1;
int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a1;
        co[a1]++;
        a.emplace_back(a1);
    }
    for (int i = 0; i < n; i++) {
        cin >> b1;
        co[b1]++;
        b.emplace_back(b1);
    }
    for (int i = 0; i <= n; i++) {
        if (co[i] > n) {
            cout << "No" << endl;
            return 0;
        }
    }
    reverse(b.begin(), b.end());
    bool bo = false;
    int m, co1 = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == b[i]) {
            co1++;
            bo = true;
            m = a[i];
        }
    }
    if (bo) {
        int l = 1000000007, r = 1000000007;
        int l1 = 1000000007, r1 = 1000000007;
        for (int i = 0; i < n; i++) {
            if (l1 == 1000000007 && a[i] == b[i]) {
                l1 = i;
            }
            if (r1 == 1000000007 && l1 != 1000000007 && a[i] != b[i]) {
                r1 = i;
            }
        }
        if (r1 == 1000000007) {
            r1 = n;
        }
        int now = l1;
        for (int i = 0; i < n; i++) {
            if (now == r1) {
                break;
            }
            if (a[i] != b[now] && a[now] != b[i]) {
                swap(b[now], b[i]);
                now++;
            }
        }
    }
    cout << "Yes" << endl;
    for (int i = 0; i < n; i++) {
        cout << b[i];
        if (i != n - 1) {
            cout << " ";
        }
    }
    cout << endl;
}


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

int N , M , tmp ;
int table[110][110] ;
int photo[4][60][60];

bool Cheak( int nx , int ny , int p ){
	for( int i=0 ; i<M ; i++ ){
		for( int j=0 ; j<M ; j++ ){
			if( photo[p][i][j] < 0 ) continue ;
			if( table[ny+i][nx+j] != photo[p][i][j] ) return false ;
		}
	}
	return true ;
}

void func(){
	
	for( int y=0 ; y<N-M+1 ; y++ ){
		for( int x=0 ; x<N-M+1 ; x++ ){
			for( int k=0 ; k<4 ; k++ ){
				if( Cheak( x , y , k ) ){
					for( int i=0 ; i<M ; i++ ){
						for( int j=0 ; j<M ; j++ ){
							if( photo[k][i][j] != -1 ){
								cout << x+j+1 << " " << y+i+1 << endl ;
								return ;
							}
						}
					}
				}
			}
		}
	}
	
	cout << "NA" << endl ;
}

int main(){
	
	while( cin >> N >> M , N ){
		for( int i=0 ; i<N ; i++ ){
			for( int j=0 ; j<N ; j++ ){
				cin >> table[i][j] ;
			}
		}
		for( int i=0 ; i<M ; i++ ){
			for( int j=0 ; j<M ; j++ ){
				cin >> tmp ;
				photo[0][i    ][j    ] = tmp ;
				photo[1][j    ][M-i-1] = tmp ;
				photo[2][M-i-1][M-j-1] = tmp ;
				photo[3][M-j-1][i    ] = tmp ;
			}
		}
		
		func() ;
	}
	
return 0 ;
}

Measured memory_bytes: 1264
#include<stdio.h>
int main(){
  long long x;
  scanf("%lld",&x);
  long long num=x/11;
  num*=2;
  x%=11;
  if(x>6)
    num+=2;
  else if(x>0)
    num++;
  printf("%lld\n",num);
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> vec(N);
  map<string, int> mode;
  
  for (int i = 0; i < N; i++) {
    cin >> vec[i];
    if (!mode.count(vec[i])) {
      mode[vec[i]] = 1;
    }
    else {
      mode[vec[i]] += 1;
    }
  }
  
  int max = 0;
  for (auto m : mode) {
    if (max < m.second) {
      max = m.second;
    }
  }
  
  vector<string> newv;
  for (auto m : mode) {
    if (m.second == max) {
      newv.push_back(m.first);
    }
  }
  
  sort(newv.begin(), newv.end());
  for (string s : newv) {
    cout << s << endl;
  }
}

Measured memory_bytes: 28532
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    int N, S;
    cin >> N;
    cin >> S;
    cout << N - S + 1;
}

Measured memory_bytes: 256
def solve(src, dst):
    if src == dst: return 0
    answer = 0
    if src % 2 != 0:
        answer += 1
        src += 1
    if dst % 2 != 0:
        answer += 1
        dst -= 1
    answer += solve(src // 2, dst // 2)
    return answer

N = int(input())
for i in range(N):
    s,d = map(int, input().split())
    print(solve(s,d))







Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define endl '\n'
#define ll long long
#define mod 1000000007
#define inf 1000000000000000000

int main()
{
	fastio;
	#ifdef APNA_IO
		freopen("input.txt" , "rt" ,stdin);
		freopen("output.txt" , "wt" ,stdout);
	#endif
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		ll e=__gcd(c,d);
		ll f=(c*d)/e;
		ll ans=(b-a)+1;
		ll g,h,x;
		if(b-(b%c)>=a+c-((a-1)%c+1))
		{
			ans-=(b-(b%c)-(a+c-((a-1)%c+1)))/c;
			ans--;
		}
		if(b-(b%d)>=a+d-((a-1)%d+1))
		{
			ans-=(b-(b%d)-(a+d-((a-1)%d+1)))/d;
			ans--;
		}
		if(b-(b%f)>=a+f-((a-1)%f+1))
		{
			ans+=(b-(b%f)-(a+f-((a-1)%f+1)))/f;
			ans++;
		}
		cout<<ans<<endl;
		
	return 0;
}





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

int main() {
	string S;
	cin >> S;
	int ans = 0;
	int i = 0;
	for (int j = 0; j < S.size(); j++) {
        if (S[j] == 'A' || S[j] == 'C' || S[j] == 'G' || S[j] == 'T') {
			i++;
			ans = max(ans, i);
		} else {
			i = 0;
		}
    }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
m = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
x = 0
s = [x := x + c for c in a]
ans = 0

for i in range(n - 1):
    ans += a[i] * (s[n-1]-s[i])
    ans %= m
print(ans)

Measured memory_bytes: 31396
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge{
    int to, cost;
};


// dijikstra
/* int V;
vector<edge> G[10];
int d[10];

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d + V + 1, INF);
    d[s] = 0;
    que.push(P(0, s));

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

int main(){
    int n;
    cin >> n;
    vector<int> a;
    REP(i, n){
        int tmp;
        cin >> tmp;
        a.pb(tmp);
    }
    SORT(a);
    ll cnt = 1;
    ll before = -1;
    REP(i, n){
        if(i == 0){
            if(n % 2 && a[0] == 0){
                continue;
            }else if(n % 2 == 0 && a[0] == 1 && a[1] == 1){
                i++;
                cnt *= 2;
                continue;
            }else{
                cnt = -1;
                break;
            }
        }else{
            if(before == -1){
                before = a[i];
            }else{
                if(before == a[i]){
                    cnt = cnt * 2 % MOD;
                    before = -1;
                }else{
                    cnt = -1;
                    break;
                }
            }
        }
    }
    if(cnt != -1 && before == -1){
        cout << cnt << endl;
    }else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
#include<vector>
#include<deque>
#include<list>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int n,m;
	cin>>n>>m;
	ll ma[100001]={};
	ll h[100001];
	rep(i,n)cin>>h[i];
	rep(i,m){
		int a,b;
		cin>>a>>b;
		if(ma[a-1]<h[b-1])ma[a-1]=h[b-1];
		if(ma[b-1]<h[a-1])ma[b-1]=h[a-1];
	}
	int ans=0;
	rep(i,n){
		if(ma[i]<h[i])ans++;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 5188
import java.math.BigInteger;
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int h1 = sc.nextInt();
        int w1 = sc.nextInt();
        BigInteger h = BigInteger.valueOf(h1);
        BigInteger w = BigInteger.valueOf(w1);
        BigInteger ans = BigInteger.valueOf(0);

        if(h == BigInteger.valueOf(1) || w == BigInteger.valueOf(1)){
            ans = BigInteger.valueOf(1);
        }

        else if(h.remainder(BigInteger.valueOf(2)) != BigInteger.valueOf(0)){
            ans = ((h.subtract(BigInteger.valueOf(1))).divide(BigInteger.valueOf(2))).multiply(w);
            if(w.remainder(BigInteger.valueOf(2)) != BigInteger.valueOf(0)){
                ans = ans.add(((w.subtract(BigInteger.valueOf(1))).divide(BigInteger.valueOf(2))).add(BigInteger.valueOf(1)));
            }
            else{
                ans = ans.add(w.divide(BigInteger.valueOf(2)));
            }
        }
        else{
            ans = w.multiply(h.divide(BigInteger.valueOf(2)));
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  int n, m; cin >> n >> m;
  vector<vector<int> > v(200001);
  for(int i = 0; i < m; i++){
    int a, b; cin >> a >> b;
    v[a].push_back(b);
  }

  for(int j = 0; j < v[1].size(); j++){
    //cout << v[1][j] << "->";
    for(int k = 0; k < v[v[1][j]].size(); k++){
      //cout << v[v[1][j]][k] << endl;
      if(v[v[1][j]][k] == n){
        cout << "POSSIBLE" << endl;
        return;
      }
      if(v[v[1][j]][k] > n) break;
    }
  }

  cout << "IMPOSSIBLE" << endl;
  return;
}

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


Measured memory_bytes: 8576
n = int(input())
# h = [int(j) for j in input().split()]
l = []
for i in range(n):
    s = [int(j) for j in input().split()]
    l.append(s)
dp0 = [0 for i in range(n)]
dp1 = [0 for i in range(n)]
dp2 = [0 for i in range(n)]
dp0[0]=l[0][0]
dp1[0]=l[0][1]
dp2[0]=l[0][2]

for i in range(1,n):
    dp0[i] = l[i][0] + max(dp1[i-1], dp2[i-1])
    dp1[i] = l[i][1] + max(dp0[i-1], dp2[i-1])
    dp2[i] = l[i][2] + max(dp1[i-1], dp0[i-1])
print(max(dp0[n-1],dp1[n-1],dp2[n-1]))

Measured memory_bytes: 36376
#include <stdio.h>

#define N 1000000

int s[N + 10];

int main(void) {
	int m, n;
	int i, j, k;
	
	for (i = 1; i <= N; i *= 2){
		for (j = 1; i * j <= N; j *= 3){
			for (k = 1; i * j * k <= N; k *= 5){
				s[i * j * k] = 1;
			}
		}
	}
	
	for (i = 0; i < N; i++){
		s[i + 1] += s[i];
	}
	
	while (scanf("%d %d", &m, &n) == 2){
		printf("%d\n", s[n] - s[m - 1]);
	}
	
	return (0);
}

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int a,b,t;
  cin>>a>>b>>t;
  int res=0;
  for(int i=1;i<=t;i++){
    if(a*i<=t)res+=b;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
 
int main()
{
  int n, tmp;
  std::cin >> n;
  
  tmp = n / 10;
  n = n - tmp * 10;
  
  switch(n)
  {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      std::cout << "hon";
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      std::cout << "pon";
      break;
    case 3:
      std::cout << "bon";
      break;
  }
  
  return 0;
}

Measured memory_bytes: 3640
n = int(input())
a = list(map(int, input().split()))
l = max(a)
b = l / 2
r = 0
m = 10 ** 9
for i in range(n):
    if abs(a[i] - b) < m:
        m = abs(a[i] - b)
        r = a[i]

if n == 2:
    print(a[0], a[1])
else:
    print(l, r)


Measured memory_bytes: 14428
#include<iostream>
#include <algorithm>
#include <vector>
using namespace std;
long gcd(long m, long n)
{
  while (m>0&&n>0){
    n = n % m;
    if (n>0)
      m = m % n;
  }
  if (n==0)
    return m;
  else
    return n;
}
int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  int d=gcd(a,b);
  int t=0;
  int i;
  for(i=d;i>=1;i--){
    if(a%i==0&&b%i==0) t++;
    if(t==c) break;
  }
  cout << i << endl;
  return 0;
}

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


#define ll long long
#define pb push_back

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

typedef pair <int,int> ii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <ll> vl;

const int mod = 1e9+7;
const ll inf = 2e18+5;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n, d, a;
    cin>>n>>d>>a;
    vii monsters;
    loop(i,0,n){
        int x,h;
        cin>>x>>h;
        h=(h+a-1)/a; //ceil(h/a)
        monsters.emplace_back(x,h);
    }
    assert((int)monsters.size()==n);
    sort(monsters.begin(),monsters.end());

    int base = 1;
    while(base<n)
        base*=2;

    vi tree(2*base);
    loop(i,0,n){
        tree[base+i] = monsters[i].second;
    }

    auto get_health = [&](int i){
        int total = 0;
        for(int j=base+i; j>=1; j/=2)
            total += tree[j];
        return total;
    };

    auto add_interval = [&](int L, int R, int x){
            L += base;
            R += base;
            tree[L] += x;
            if(L != R)
                tree[R] += x;
            while(L+1 < R){
                if(L % 2 == 0)
                    tree[L+1] += x;
                if(R % 2 == 1)
                    tree[R-1] += x;
            
                L /= 2;
                R /= 2;
            }
    };
    ll ans=0;
    loop(i,0,n){
        int my_health = get_health(i);
        if(my_health <= 0)
            continue;
        //find the last monster still hit by a bomb starting here
        int lo=i, hi=n-1, ok=-1;
        while(lo<=hi){
            int mid=(lo+hi)/2;
            if(monsters[mid].first <= monsters[i].first + 2LL*d){
                ok=mid;
                lo = mid+1;
            }
            else
                hi = mid-1;

        }
        add_interval(i,ok,-my_health);
        ans += my_health;  
        
    }
    cout<<ans;
    return 0;
}   

Measured memory_bytes: 3952
//quming
#include<bits/stdc++.h>
#define R register
#define fi first
#define se second
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=2e5+5;
typedef pair<int,int> pi;
int n,res,st[N],ins[N],top;pi a[N],Pre[N],suf[N];
inline pi operator +(const pi &a,const pi &b){return pi(max(a.fi,b.fi),min(a.se,b.se));}
inline int Len(const pi &b){return max(b.se-b.fi+1,0);}
int main(){
//  freopen("testdata.in","r",stdin);
    scanf("%d",&n);
    fp(i,1,n)scanf("%d%d",&a[i].fi,&a[i].se);
    sort(a+1,a+1+n,[](const pi &a,const pi &b){
        return a.se==b.se?a.fi<b.fi:a.se<b.se;
    });
    Pre[0]=pi(0,1e9);
    fp(i,1,n)Pre[i]=Pre[i-1]+a[i];
    suf[n+1]=pi(0,1e9);
    fd(i,n,1)suf[i]=suf[i+1]+a[i];
    fp(i,2,n)cmax(res,Len(Pre[i-1])+Len(suf[i]));
    fp(i,1,n)cmax(res,Len(a[i])+Len(Pre[i-1]+suf[i+1]));
    printf("%d\n",res);
//    fp(i,1,n){
//        while(top&&a[st[top]].se>=a[i].se)--top;
//        st[++top]=i;
//    }
//    fp(i,1,top)ins[st[i]]=1;
//    L=a[st[1]],Pre[1]=L.se-L.fi+1;
//    fp(i,2,top){
//        L=L+a[st[i]];if(L.se<L.fi)break;
//        Pre[i]=L.se-L.fi+1;
//    }
//    L=a[st[top]],suf[top]=L.se-L.fi+1;
//    fd(i,top-1,1){
//        L=a[st[i]]+L;if(L.se<L.fi)break;
//        suf[i]=L.se-L.fi+1;
//    }
//    fp(i,1,top-1)cmax(res,Pre[i]+suf[i+1]);
//    fp(i,1,n)if(!ins[i])cmax(res,Pre[top]+a[i].se-a[i].fi+1);
//    fp(i,2,top-1)cmax(res,Pre[i-1]+suf[i+1]+a[st[i]].se-a[st[i]].fi+1);
//    printf("%d\n",res);
    return 0;
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S=input()

for i in range(3):
    if S[i]==S[i+1]:
        print('Bad')
        exit()
print('Good')


Measured memory_bytes: 3064
#include <stdio.h>


int main()
{
 int a, b;
 scanf("%d %d", &a, &b);
 
 if(a < b)
 {
  printf("a < b\n");
 }
 else if(a >b)
 {
  printf("a > b\n");
 }
 else
 {
  printf("a == b\n");
 }

 return 0;
}

Measured memory_bytes: 1832
from heapq import *
import sys
from collections import *

from itertools import *
from decimal import *
import copy
from bisect import *
import time

import math
import datetime
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
sys.setrecursionlimit(10**7)
input=lambda :sys.stdin.readline().rstrip()

N,K=map(int,input().split())
print(K*pow(K-1,N-1))


Measured memory_bytes: 5452
x, y = map(int,input().split())
rwd = 0
if x == 1:
  rwd += 300000
elif x == 2:
  rwd += 200000
elif x == 3:
  rwd += 100000
if y == 1:
  rwd += 300000
elif y == 2:
  rwd += 200000
elif y == 3:
  rwd += 100000
if x == 1 and y == 1:
  rwd += 400000
print(rwd)

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
 
class Main{
    public static void main(String args[])throws IOException{
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       String s;
       int sum=0;
       while((s = br.readLine())!=null){
           if("0".equals(s))break;
           try{
               for(int i=0; i<s.length(); i++){
                   int num = s.charAt(i) - 0x30;
                   sum += num;
               }
               System.out.println(sum);
               sum=0;
           }catch(NumberFormatException e){
           }
       }
    }
}

Measured memory_bytes: 16932
#include<stdio.h>
int main(void)
{
	int n,m,k,i,l,j,d,g,a[200],b[100],c[200];
	scanf("%d %d",&n,&m);
	for(j=0;j<2*n;j++){
		a[j]=j+1;
	}
	for(i=0;i<m;i++){
		scanf("%d",&k);
		g=2*n-k;
		if(k>=1 && k<=2*n-1){
			for(j=0;j<g;j++){
				c[j]=a[k+j];
			}
			for(d=0;d<k;d++){
				c[g]=a[d];
				g++;
			}
		}
		else if(k==0){
			l=1;
			for(j=0;j<n;j++){
				b[j]=a[n+j];
				c[l-1]=a[j];
				c[l]=b[j];
				l+=2;
			}
		}
		for(j=0;j<2*n;j++){
			a[j]=c[j];
		}
	}
	for(i=0;i<2*n;i++){
		printf("%d\n",a[i]);
	}
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll t, x; cin>>t>>x;
	cout << setp(12) << (lf)t/x << "\n";
	return 0;
}

Measured memory_bytes: 256