akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int h,n;
    cin>>h>>n;
    LL ans=0;
    FOR(i,0,n){
        int f;
        cin>>f;
        ans+=f;
    }
    if(ans<h){
        cout<<"No";
    }else{
        cout<<"Yes";
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    int n, m, q;
    int[][] qArr;
    int max;
    List<Integer> list;
    void run() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        q = sc.nextInt();
        qArr = new int[q][4];
        for (int i = 0; i < q; i++) {
            qArr[i] = new int[]{sc.nextInt() - 1, sc.nextInt() - 1, sc.nextInt(), sc.nextInt()};
        }

        for (int i = 0 ;i < m; i++) {
            list = new ArrayList<>();
            dfs(i);
        }

//        for (int bit = 0; bit < (1 << m); bit++) {
//            List<Integer> list = new ArrayList<>();
//            for (int i = 0; i < m; i++) {
//                if ((bit & (1 << i)) != 0) {
//                    list.add(i);
//                }
//            }
//            if (list.size() != n) {
//                continue;
//            }
//            debug(list);
//
//            int ans = 0;
//            for (int i = 0; i < q; i++) {
//                int[] arr = qArr[i];
//                if (list.get(arr[1]) - list.get(arr[0]) == arr[2]) {
////                    debug(arr);
//                    ans += arr[3];
//                }
//            }
//            max = Math.max(max, ans);
//        }

        System.out.println(max);
    }

    void dfs(int i) {
        list.add(i);
//        debug(list);
        if (list.size() == n) {
            int ans = 0;

            for (int j = 0; j < q; j++) {
//                debug("fuga");
                int[] arr = qArr[j];
                if (list.get(arr[1]) - list.get(arr[0]) == arr[2]) {
                    ans += arr[3];
                }
            }
            max = Math.max(max, ans);
//            debug("max", max, list);
            return;
        }
        for (int j = i ; j < m; j++) {
            dfs(j);
//            debug(j, list);
            list.remove(list.size() - 1);
        }
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 38988
N, K, Q = map(int, input().split())
A = []
for q in range(Q):
    A.append(int(input()))
score = [K - Q] * (N + 1)
for a in A:
    score[a] += 1
ans = "\n".join("No" if s <= 0 else "Yes" for s in score[1:])
print(ans)

Measured memory_bytes: 11316
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(b>a)return 0;
	if(a==b)return 1;
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,s,ans=1000000000000;
bool ok(int a,int b){
	int res=0;
	while(a){
		res+=a%b;
		a-=a%b;
		a/=b;
	}
	return res==s;
}
signed main(){
	cin>>n>>s;
	if(n==s){
		cout<<n+1<<endl;
		return 0;
	}
	for(int b=2;b*b<=n;b++){
		if(ok(n,b)){
			cout<<b<<endl;
			return 0;
		}
	}
	for(int p=1;p*p<n;p++){
		if(n-s+p<=0)continue;
		if((n-s+p)%p)continue;
		int b=(n-s+p)/p;
		if(ok(n,b))ans=min(ans,b);
	}
	if(ans==1000000000000)puts("-1");
	else cout<<ans<<endl;
	return 0;
}


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

const int N = 2e5 + 7;

int a[N];
long long res;
int n;

int main() {
	cin >> n;
	a[0] = -1;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i] - a[i - 1] > 1) {
			cout << -1;
			return 0;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (a[i] >= a[i + 1])
			res += a[i];
	}
	cout << res;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int mo2 = 998244353;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
vector<int> E[200050];
vector<int> dist(200050);
void dfs(int u){
    for(auto v : E[u]){
        dist[v] += dist[u];
        dfs(v);
    }
}
int main(){
    int n,q;
    cin>>n>>q;
    for(int i=0;i<n-1;++i){
        int a,b;
        cin>>a>>b;
        a--;b--;
        E[a].push_back(b);
    }
    for(int i=0;i<q;++i){
        int p,x;
        cin>>p>>x;
        p--;
        dist[p]+= x;
    }
    dfs(0);
    for(int i=0;i<n;++i){
        if(i)cout << " ";
        cout << dist[i];
    }
    cout << endl;
    return 0;
}



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

int main(){
  int k,s;
  cin >> k >> s;

  int ans=0;
  rep(i,k+1){
    rep(j,k+1){
      if(0<=s-i-j && s-i-j<=k)ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,X;
	while(cin>>N>>X) {
		VI A(N);
		REP(i, N) cin>>A[i];
		ll ans = 0;
		RANGE(i, 1, N) {
			ll sub = min(A[i], max(0LL, A[i-1]+A[i]-X));
			A[i]-=sub;
			ans += sub;
		}
		ll sub = min(A[0], max(0LL, A[0]+A[1]-X));
		A[0]-=sub;
		ans += sub;
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

string solve (int n, vector<int> &a, vector<int> &b){
    long long a_countup = 0;
    for (int i=0; i<n; ++i){
        if(b[i] > a[i]){
            a_countup += (b[i] - a[i] + 1) / 2;
            a[i] += ((b[i] - a[i] + 1) / 2) * 2;
        }
    }
    for (int i=0; i<n; ++i){
        a_countup -= a[i] - b[i];
    }
    return (a_countup >= 0) ? "Yes" : "No";
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i=0; i<n; ++i){
        cin >> a[i];
    }
    for (int i=0; i<n; ++i){
        cin >> b[i];
    }
    cout << solve(n, a, b) << endl;
    return 0;
}

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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int max_i, sum = 0;
  for (int i = 1; i <= n; i++) {
    sum += i;
    if (sum >= n) {
      max_i = i;
      break;
    }
  }
  int exc = sum - n;
  for (int i = 1; i <= max_i; i++) {
    if (i == exc) continue;
    cout << i << '\n';
  }
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    ll a,maxa=0,mina=INFINITY;
    rep(i,n){
        cin>>a;
        maxa=max(maxa,a);
        mina=min(mina,a);
    }
    cout<<maxa-mina;
}

Measured memory_bytes: 3588
n = gets.to_i
a = gets.split.map(&:to_i)
ca = Marshal.load(Marshal.dump(a))
b = Array.new(n,0)
ok = true
(1...n).each do |i|
    b[i] += a[i-1]*2
    if (b[i]%2 == 1) 
        ok = false
        break
    end
    a[i] -= b[i]/2
end
c = a[-1]
ok = false if c.odd?
if ok
    n.times do |i|
        b[i] += c*(i%2 == 0 ? 1 : -1)
    end
else
    b = Array.new(n,0)
    b[0] = 2
    ca[0] -= 1
    ca[-1] -= 1
    (1...n).each do |i|
        b[i] += ca[i-1]*2
        ca[i-1] = 0
        ca[i] -= b[i]/2
    end
    c = ca[-1]
    n.times do |i|
        b[i] += c*(i%2 == 0 ? 1 : -1)
    end
end
puts b.join(" ")

Measured memory_bytes: 14920
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std; 
const int mod=1e9+7;
int n;
 
bool isprime(int x){
  for(int i=2;i*i<=x;i++){
    if(x%i==0){
      return false;
    }
  }
  return true;
}
 
int main(){
  cin>>n;
  vector<long long>a(n+1,1);
  for(int i=2;i<=n;i++){
    int ii=i;
    for(int j=2;j<=ii;j++){
      if(isprime(j)){
        while(ii % j == 0){
          ii /= j;
          a[j]++;
        }
      }
    }
  }
  long long ans=1;
  for(int i=2;i<=n;i++){
    ans*=a[i];
    ans=ans%mod;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N, K;
  int ans = 0;
  string s;

  cin >> N >> K;

  vector<int> h(N);
  for(int i = 0; i < N; i++){
    cin >> h[i];
    if(h[i] >=K){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <map>
#include<string>
using namespace std;
#define int long long
const int inf = 10e9 + 7;
#define rep(i,n) for(int i=0;i<n;i++)
int c[505], s[505], f[505];
signed main() {
	int n;
	cin >> n;
	rep(i, n-1)cin >> c[i] >> s[i] >> f[i];
	rep(i, n) {
		int sum = 0;
		for (int j= i; j < n - 1; j++) {
			if (sum < s[j])sum = s[j];
			else if (sum%f[j]==0);
			else sum = sum + f[j] - sum%f[j];
			sum += c[j];
		}
		cout << sum << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define put(x) cout << x << endl;
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<vector<int> > a;
    vector<int> v(n);
    rep(i, k) {
        int d;
        cin >> d;
        rep (j, d) {
            int a;
            cin >> a;
            v[a-1]++;
        }
    }
    int c = 0;
    rep(i, n) {
        if (v[i] == 0) {
            c ++;
        }
    }
    put(c);
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
using namespace std;
 
int main(){
	int n,i;
	
	cin >> n;
	
	while (1) {
		
		for (i=1;i<=n;i++){
			if ( i % 3 == 0 ) {
				cout << " " << i;
			}else if ( i % 10 == 3 ) {
				cout << " " << i;
			}else {
				int x=i;
				while (1) {
					x /=10;
					if ( x == 0 ) break;
					if ( x % 10 == 3 ) {
						cout << " " << i;
						break;
					}
				}
			}
		}
		break;
	}
	cout << endl;
    return 0;
}

Measured memory_bytes: 1164
let N = stdin.ReadLine() |> int
let A = stdin.ReadLine().Split()|>Array.map int|>Array.sort

let rec gcd a b = 
    if b = 0 then a
    else gcd b (a%b)


let mutable cand = Set.empty

for i in [1..int(sqrt(float A.[0]))+1] do
    if A.[0] % i = 0 then 
        cand <- cand.Add i
        cand <- cand.Add (A.[0] / i)

for i in [1..int(sqrt(float A.[1]))+1] do
    if A.[1] % i = 0 then 
        cand <- cand.Add i
        cand <- cand.Add (A.[1] / i)


let l = Set.toArray cand |> Array.rev

Array.iter (fun x -> let aa = Array.filter (fun t -> t % x > 0) A in
                     let sz = Array.length aa in
                     if sz <= 1 then (printfn "%d" x; exit 0)) l


Measured memory_bytes: 38656
using System;

namespace Exception_Handling
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] list = new int[N];
            int[] list02 = new int[N];

            for (int i = 0; i < N; i++)
            {
                list[i] = int.Parse(Console.ReadLine());
                list02[i] = list[i]; 
            }
            Array.Sort(list02);
            int Max = list02[N-1];
            int Second = list02[N - 2];
            for (int i = 0; i < N; i++)
            {
                Console.WriteLine(Max == list[i]?Second:Max);
            }
        }
    }
}


Measured memory_bytes: 19032
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,s1,s3,s2;
	char a=0,b=0,c=0;
	int x=0,n,m;
	getline(cin,s);
	int len=s.length();
	for(int z=0;z<len;z++)
    {
        a=toupper(s[0]);
        if(s[z]==32&&x==0)
        {
            b=toupper(s[z+1]);
            x=1;
        }
        if(x==1&&s[z]==32)
        {
            c=toupper(s[z+1]);
            x==2;
        }
        if(x==2)
            break;

    }
    cout<<a<<b<<c;
}



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

int main()
{
    ll N, X;
    cin >> N >> X;
    ll B[N], L[N], U[N];
    for (int i = 0; i < N; i++)
        cin >> B[i] >> L[i] >> U[i];

    ll base = 0;
    for (int i = 0; i < N; i++)
        base -= B[i] * L[i];

    pair<ll, int> full[N];
    for (int i = 0; i < N; i++)
        full[i] = make_pair(L[i] * B[i] + (X - B[i]) * U[i], i);
    sort(full, full + N);
    reverse(full, full + N);
    
    ll cumsum[N];
    cumsum[0] = full[0].first;
    for (int i = 1; i < N; i++)
        cumsum[i] = cumsum[i - 1] + full[i].first;

    ll low = 0, high = X * N;
    while (low != high)
    { 
        ll mid = (high + low) / 2;
        ll best = base;
        for (int i = 0; i < N; i++)
        {
            ll num_full = mid / X;
            ll now = base;
            if (num_full > 0)
                now += cumsum[num_full - 1];
            if (num_full < N and i <= num_full - 1)
                now += full[num_full].first - full[i].first;
            
            int k = full[i].second;
            ll left = mid - num_full * X;
            if (left > B[k])
                now += (left - B[k]) * U[k] + B[k] * L[k];
            else
                now += left * L[k];
                
            best = max(now, best);
        }
        // cout << low << ' ' << mid << ' ' << high << endl;

        if (best >= 0)
            high = mid;
        else
            low = mid + 1;

    }
    cout << low << endl;
   	return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] monsters = new long [N + 1];
		long[] heros = new long [N];
		long temp = 0;
		long ans = 0;
		
		for(int i = 0; i < N + 1; i++) {
			monsters[i] = sc.nextInt();
		}

		for(int i = 0; i < N; i++) {
			heros[i] = sc.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			// i番目のモンスターを倒せるだけ倒す
			ans += Math.min(monsters[i], heros[i]);
			//　余力を計算
			temp = heros[i] - (monsters[i]);
			if(0 < temp) {
				//　余力がある場合はi+1番目のモンスターを倒す
				ans += Math.min(monsters[i + 1] , temp);
				monsters[i + 1] = monsters[i + 1] - Math.min(monsters[i + 1] , temp);
			}
		}

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

Measured memory_bytes: 66040
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 11e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
  	int data;
    int N,K;
    cin >> N>>K;
  	vector<int> P(N);
  	int cnt=0;
  	for (int i = 0; i < N; i++){
        cin >> P[i];
    }
	for (int i = 0; i < N; i++){
      if(P[i]>=K){
      cnt++;
      }
    }
  	
  
    cout << cnt<< "\n";
}

Measured memory_bytes: 640
package main

import "fmt"

func main() {
	n := make([]int, 2)
	for i := 0; i < 2; i++ {
		fmt.Scan(&n[i])
	}
	x := n[0] * n[1]

	if n[0] < n[1] {
		tmp := n[0]
		n[0] = n[1]
		n[1] = tmp
	}

	r := n[0] % n[1]
	for r != 0 {
		n[0] = n[1]
		n[1] = r
		r = n[0] % n[1]
	}
	fmt.Println(x / n[1])
}


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

int main() {
  long long int N, X;
  //string S;
  vector<string> w_v, ww_v;
  int flag = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string w;
    cin >> w;
    w_v.push_back(w);
  }
  for (int i = 0; i < N; i++) {
    if (i == 0) {;}
    else {
      for (int j = 0; j < ww_v.size(); j++) {
	if (ww_v[j] == w_v[i]) flag = 1;
      }
      //cout << ww_v.back() << endl;
      if (ww_v.back().back() != w_v[i][0]) flag = 1;
    }
    ww_v.push_back(w_v[i]);
  }
  if (flag == 1) cout << "No" << endl;
  else cout << "Yes" << endl;
				       
  return 0;
}


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

int main() {
  int  N;
  cin >> N;
  int A = N / 1000;
  int B = (N - A * 1000)/100;
  int C = (N - A * 1000 - B * 100)/10;
  int D = (N - A * 1000 - B * 100 - C * 10);
  
  if (A == B && B ==C)
    cout << "Yes" << endl;
  
  else if (B == C &&C ==D)
    cout << "Yes" << endl;
  
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int N,K;
	char S[11];
	char s2;
	scanf("%d",&N);
	scanf("%s",S);
	scanf("%d",&K);
	s2 = S[K-1];

	for(int i=0;i<N;i++){
		if(S[i]!=s2){
			S[i] ='*';
		}
		printf("%c",S[i]);
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()

template <typename T, const T& F(const T&, const T&), T ZERO>
struct SegmentTree {
    ll n;
    vector<T> v;

    SegmentTree(ll n_){
        n = 1;
        while(n < n_){ n *= 2; }
        v.resize(2 * n - 1);
        fill(v.begin(), v.end(), ZERO);
    }

    // zero-indexed
    void update(ll k, T a){
        k += n - 1;
        v[k] = a;
        while(k > 0){
            k = (k - 1) / 2;
            v[k] = F(v[k * 2 + 1], v[k * 2 + 2]);
        }
    }

    // [a, b), zero-indexed
    T query(ll a, ll b) const {
        return query_internal(a, b, 0, 0, n);
    }

    T get(ll a) const {
        return query(a, a + 1);
    }

    T query_internal(ll a, ll b, ll k, ll l, ll r) const {
        if(r <= a || b <= l){ return ZERO; }
        if(a <= l && r <= b){
            return v[k];
        }else{
            T v1 = query_internal(a, b, k * 2 + 1, l, (l + r) / 2);
            T v2 = query_internal(a, b, k * 2 + 2, (l + r) / 2, r);
            return F(v1, v2);
        }
    }
};


using MaxST = SegmentTree<ll, max, 0LL>;

ll n;
vector<ll> a;
vector<vector<ll>> net;
vector<ll> ans;

void solve(ll cur, ll par, MaxST& st){
    const ll tmp = st.query(0, a.at(cur)) + 1;
    const ll prev = st.get(a.at(cur));
    st.update(a.at(cur), tmp);
    ans.at(cur) = st.query(0, n);
    for(ll nxt : net.at(cur)){
        if(nxt == par){ continue; }
        solve(nxt, cur, st);
    }
    st.update(a.at(cur), prev);
}

int main(){
    cin >> n;

    vector<ll> a0(n);
    REP(i, n){
        cin >> a0.at(i);
    }

    vector<ll> b = a0;
    sort(ALL(b));
    map<ll, ll> a2i;
    REP(i, n){
        if(!a2i.count(b.at(i))){
            a2i[b.at(i)] = a2i.size();
        }
    }

    a.resize(n);
    REP(i, n){
        a.at(i) = a2i.at(a0.at(i));
    }

    net.resize(n);
    REP(i, n - 1){
        ll ui, vi;
        cin >> ui >> vi;
        ui--; vi--;
        net.at(ui).push_back(vi);
        net.at(vi).push_back(ui);
    }

    ans.resize(n);
    MaxST st(n);
    solve(0, -1, st);
    REP(i, n){
        cout << ans.at(i) << endl;
    }
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

const int maxn = 3e5 + 7;
const int mod = 998244353;

int n,p;
int s[maxn];
int cnt[maxn];
long long ans;
int main()
{
	scanf("%d%d",&n,&p);
	
	for(int i=1;i<=n;i++)
		scanf("%1d",&s[i]);

	if(p==2||p==5)
	{
		for(int i=1;i<=n;i++)
		{
			if(s[i]%p==0)
				ans+=i;
		}
		printf("%lld\n",ans);
		return 0;
	}
	int cur=0;
	int tmp=1;
	cnt[0]=1;
	for(int i=n;i>=1;i--)
	{
		cur=(cur + s[i] * tmp )%p;
		tmp=tmp*10%p;
		ans+=cnt[cur];
		cnt[cur]++;
	}
	printf("%lld\n",ans);
	return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = min(a, b);
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int dp[810];
int p[810];
int d[810];
vector<pair<int, int>> G[810];

void dfs(int u, int p) {
	for (auto v : G[u]) {
		if(v.fi == p) continue;
		dp[v.fi] = dp[u] + v.se;
		dfs(v.fi, u);
	}
	return;
}

int main(void) {
	while(1) {
		int n; scanf("%d", &n);
		if(n == 0) break;

		rep(i, n - 1) scanf("%d", &p[i]);
		rep(i, n - 1) scanf("%d", &d[i]);
		rep(i, n - 1) p[i]--;

		rep(i, 810) G[i].clear();
		rep(i, n - 1){
			int u = i + 1, v = p[i];
			G[u].pb(mp(v, d[i])), G[v].pb(mp(u, d[i]));
		}

		ll all = 0;
		rep(i, n - 1) all += d[i];


		ll allleaf = 0;
		set<int> leafse;

		rep(i, n) if(G[i].size() == 1) allleaf += G[i][0].se;
		
		rep(i, n) if(G[i].size() > 1) leafse.insert(i);

		ll maxe = 0;
		for(auto u : leafse) {
			rep(i, 810) dp[i] = 0;
			dfs(u, -1);
			// u -> v????????¢
			for(auto v : leafse) chmax(maxe, dp[v]);
		}

		// printf("all %lld allleaf %lld maxe %lld \n", all, allleaf, maxe);
		ll ans = all + all * 2 - (allleaf * 2) - maxe;
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3376
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace ABC162
{
    public class Solve
    {
        public static void Main(string[] args)
        {
            new ABC_B();
        }
    }
    public class ABC_A
    {
        public ABC_A()
        {
            var n = Ex.Read;
            Ex.Cw(n[0] == '7' || n[1] == '7' || n[2] == '7');
        }
    }
    public class ABC_B
    {
        public ABC_B()
        {
            // FizzBuzz列の  N  項目までに含まれる数の和
            long n = Ex.ReadLong;
            long ans = 0;

            for (int i = 0; i <= n; i++)
            {
                if (i % 3 == 0 || i % 5 == 0)
                    continue;
                ans += i;

            }
            Ex.Cw(ans);
        }
    }
    public class ABC_C
    {
        public ABC_C()
        {
        }
    }
    public class ABC_D
    {
        public ABC_D()
        {
        }
    }
    public class ABC_E
    {
        public ABC_E()
        {
        }
    }
    public class ABC_F
    {
        public ABC_F()
        {
        }
    }
    public static class Ex
    {
        public static void Cw(object s)
        {
            Console.WriteLine(s);
        }
        public static void Cw(bool b)
        {
            if (b) Ex.Cw("Yes");
            else Ex.Cw("No");
        }

        public static string Read { get { return Console.ReadLine().Trim(); } }
        public static int ReadInt { get { return int.Parse(Read); } }
        public static long ReadLong { get { return long.Parse(Read); } }
        public static double ReadDouble { get { return double.Parse(Read); } }
        public static string[] ReadArray() { return Read.Split(' '); }
        public static int[] ReadIntArray() { return Read.Split(' ').Select(s => int.Parse(s)).ToArray(); }
        public static long[] ReadLongArray() { return Read.Split(' ').Select(s => long.Parse(s)).ToArray(); }
        public static string[] ReadArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public static int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public static long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 17648
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define PI 3.14159265359
#define rep(i,n) for(int i=0; i<n; ++i)
#define INF 1001001001
#define MAX_X 2002
#define MAX_Y 2002
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, k;
    cin >> n >> k;
    map<int, int> mp;

    rep(i, k) {
        int d;
        cin >> d;
        rep(i, d) {
            int a;
            cin >> a;
            ++mp[--a];
        }
    }

    int ans = 0;
    rep(i, n) {
        if (mp[i] == 0) ++ans;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};


template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long pow_mod(long long n,long long k,long long m){
    if (k == 0){
        return 1;
    } else if (k % 2 == 1){
        return pow_mod(n,k-1,m)*n % m;
    } else {
        long long t = pow_mod(n,k/2,m);
        return t*t % m;
    }
}

class UnionFind {
    public :
        vector<int> par;
        UnionFind(int n){
            par = vector<int>(n,-1);
        }
        int root(int a){
            if (par[a] < 0) return a;
            return par[a] = root(par[a]);
        }
        int size(int a){
            return -par[root(a)];
        }
        bool connect(int a,int b){
            a = root(a);
            b = root(b);
            if (a == b){
                return false;
            }
            if (size(a) < size(b)) swap(a,b);
            par[a] += par[b];
            par[b] = a;
            return true;
        }
};



int main(){
    int n,m; cin >> n >> m;
    UnionFind u(n);
    for(int i = 0; i < m; i++){
        int x,y,z; cin >> x >> y >> z;
        x--; y--;
        u.connect(x,y);

        /* 
        if (z % 2 == 1){
            //zが奇数の時a_x,a_yのどちらかは奇数
        } else {
            // a_x,a_yの偶奇は同じ
        }
        */
    }
    map<int,int> mp;
    for(int i = 0; i < n; i++){
        mp[u.root(i)]++;
    }
    cout << mp.size() << endl;
}

Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#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;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

int main() {

    ll N,T; cin >>N>>T;
    vector<ll> t(N); REP(i,N) cin >> t[i];

    ll ans = 0;
    for (ll i = 0; i < N;) {
        ll j = i + 1;
        while (t[j] - t[j-1] <= T & j < N) {
            j++;
        }
        ans += t[j-1] + T - t[i];
        i = j;
    } 

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




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

#define get_variable_name(x) #x
#define debug(x) cout << #x << " = " << x << endl
#define rep(i, begin, end) for(int (i) = (begin); (i) < (end); (i)++)

#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())
#define REVERSE(x) reverse( (x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define PW(x) (1LL<<(x))

using namespace std;
using ll = int64_t;
using P = pair<int, int>;

template<class T,class U>
ostream& operator<<(ostream &os, const pair<T, U> &p) {
    os << get_variable_name(p) << " = (" << p.first <<", " << p.second << ")";
    return os;
}

template<class T>
ostream& operator <<(ostream& os, const vector<T> &v){
    cout << get_variable_name(v) << " = [";
    for(auto i : v) 
        os << " " << i;
    os << " ]";
    return os;
}

const int INF = 1e8;

struct disjoint_set {
    int size;
    vector<int> par;
    vector<int> rank;

    disjoint_set(int n) : size(n) {
        for(int i = 0; i < n; i++) {
            par.emplace_back(i);
            rank.emplace_back(0);
        }
    }

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

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(rank[x] < rank[y]) par[x] = y;
        else {
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
    
    int root(int x) {
        return (par[x] == x ? x : par[x] = root(par[x]));
    }

};


int main() {
    ios::sync_with_stdio(false);
    
    int N, K, L, s, t;
    cin >> N >> K >> L;
    auto a = disjoint_set(N);
    auto b = disjoint_set(N);
    rep(i, 0, K) {
        cin >> s >> t;
        s--, t--;
        a.unite(s, t);
    }

    rep(i, 0, L) {
        cin >> s >> t;
        s--, t--;
        b.unite(s, t);
    }

    map<pair<int, int>, int> memo;

    rep(i, 0, N) {
        memo[make_pair(a.root(i), b.root(i))]++;
    }

    cout << memo[make_pair(a.root(0), b.root(0))];

    rep(i, 1, N) {
        cout << ' ' << memo[make_pair(a.root(i), b.root(i))];
    }

    cout << endl;
}


Measured memory_bytes: 15124
#include <iostream> 
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
    int X, Y;
    cin >> X >> Y;
    int a = Y-2*X;
    if (X < Y) {
        if (a >= 0 && a % 2 == 0) {
            int b = a/2;
            if (b <= X) {
                cout << "Yes" << endl;
            } else cout << "No" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3604
#include <cstdio>
#include <vector>
using namespace std;

int main()
{
  int n,m;
  scanf("%d%d",&n,&m);
  vector<vector<int> > e(n);
  for(int t=0;t<m;t++){
    int a,b;
    scanf("%d%d",&a,&b);
    a--,b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  int r6=0;
  vector<int> r4;
  for(int i=0;i<n;i++){
    if((int)e[i].size()%2!=0){
      puts("No");
      return 0;
    }
    if((int)e[i].size()>=6){
      r6++;
    }
    else if(e[i].size()==4){
      r4.push_back(i);
    }
  }
  if(r6>0||r4.size()>=3){
    puts("Yes");
  }
  else if(r4.size()<2){
    puts("No");
  }
  else{
    bool F=false;
    for(int x=0;x<4;x++){
      int i=e[r4[0]][x];
      int p=r4[0];
      while(e[i].size()==2){
	int temp=e[i][0]+e[i][1]-p;
	p=i;
	i=temp;
      }
      if(i==r4[0]){
	F=true;
      }
    }
    puts(F?"Yes":"No");
  }
  return 0;
}


Measured memory_bytes: 5760
#!/usr/bin/env fsharpi

open System;

let ParseIntN ( str : string ) =
    str.Split(' ')
    |> Array.map System.Int32.Parse

let ParseInt1 ( str : string ) =
    ParseIntN str |> fun arr -> arr.[0]

let ParseInt2 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1])

let ParseInt3 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1],arr.[2])

let ReadLinesN ( n : int ) =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.take n

let ReadLines =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.takeWhile ((<>) null)

Console.ReadLine()
|> ParseIntN
|> Array.sort
|> fun vs -> vs.[0] = 5 && vs.[1] = 5 && vs.[2] = 7
|> function
    | true -> "YES"
    | false -> "NO"
|> Console.WriteLine



Measured memory_bytes: 14048
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    W,H,N=map(int,input().split())
    x, y,a = [0] * N, [0] * N,[0]*N
    for i in range(N):
        x[i], y[i],a[i] = map(int, input().split())


    w,h=0,0
    for i in range(N):
        if a[i]==1:
            w=max(w,x[i])
        elif a[i]==2:
            W=min(W,x[i])
        elif a[i]==3:
            h = max(h, y[i])
        elif a[i] == 4:
            H = min(H, y[i])

    print((W-w)*(H-h) if (W-w)>=0 and (H-h)>=0 else 0)




resolve()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(x,n) for(int i=x;i<n;i++)
#define REP(y,n) for(int j=y;j<n;j++)
#define vi vector<int>
#define vvi vector<vector<int>>
signed main(){
  int n,m,count=0;
  cin>>n>>m;
  int A[n][m];
  int B[m];
  rep(0,n)REP(0,m)cin>>A[i][j];
  rep(0,m)cin>>B[i];
  rep(0,n){
    REP(0,m){
      count+=A[i][j]*B[j];
    }
    cout<<count<<endl;
    count=0;
  }
}



Measured memory_bytes: 3168
#include <iostream>
#include <iomanip>
#include <utility>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <map>
#include <climits>
#include <bitset>

#define ll long long
const ll INF = 1 << 29;

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

    std::vector<double> p(N);
    for (auto i=0; i<N; ++i)
        std::cin >> p[i];

    double dp[N+1][N+1];
    memset(dp, 0, sizeof(dp));

    dp[0][0] = 1.0;
    for (auto i=0; i<N; ++i)
    {
        for (auto j=0; j<=i; ++j)
        {
            // おもて
            dp[i+1][j+1] += dp[i][j] * p[i];
            // 裏
            dp[i+1][j] += dp[i][j] * (1.0 - p[i]);
        }
    }

    double result = 0.0;
    for (auto i=N/2 + 1; i<=N; ++i)
        result += dp[N][i];

    std::cout << std::fixed << std::setprecision(10) << result << std::endl;
}


Measured memory_bytes: 74096
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll N,T;
    cin >> N >> T;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin >> A[i];

    ll ct=0,madif=0;
    ll mi=A[0];
    for(int i=1;i<N;i++){
        if(madif==A[i]-mi){
            ct++;
        }
        else if(madif<A[i]-mi){
            madif=A[i]-mi;
            ct=1;
        }
        mi=min(mi,A[i]);
    }
    cout << ct << endl;

    return 0;
}

Measured memory_bytes: 1024
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

if max(a) < 0:
    a.sort()
    ans = 1
    if k % 2 == 0:
        for e in a[:k]:
            ans *= e
            ans %= mod
    else:
        for e in a[-k:]:
            ans *= e
            ans %= mod

    print(ans)

elif k == n:
    ans = 1
    for e in a:
        ans *= e
        ans %= mod

    print(ans)

else:
    neg = []
    pos = []
    for e in a:
        if e < 0:
            neg.append(e)
        else:
            pos.append(e)

    neg.sort()
    pos.sort(reverse=True)

    ans = 1
    if k % 2:
        ans *= pos.pop(0)
        k -= 1

    nums = [e1 * e2 for e1, e2 in zip(neg[::2], neg[1::2])]
    nums += [e1 * e2 for e1, e2 in zip(pos[::2], pos[1::2])]

    nums.sort(reverse=True)
    for e in nums[:k//2]:
        ans *= e
        ans %= mod

    print(ans)


Measured memory_bytes: 33372
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	int ans = (a < b ? a : b);
	int cnt = 0;
	while (1){
		if (a % ans == 0 and b % ans == 0) cnt++;
		if (cnt == k){
			cout << ans << endl;
			return 0;
		}
		ans--;
	}

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MAX=101000;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        //???
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main(){
    COMinit();
    int n;
    cin>>n;
    int a[n+1];
    vector<vector<int>> v(n);
    vector<bool> app(n,false);
    int dab;
    rep(i,n+1){
        cin>>a[i];a[i]--;
        if(app[a[i]]) dab=a[i];
        app[a[i]]=true;
    }
    int f,m,b,idx1=-1,idx2;
    rep(i,n+1){
        if(a[i]==dab&&idx1<0) idx1=i;
        else if(a[i]==dab&&idx1>=0) idx2=i;
    }
    f=idx1;b=n-idx2;m=idx2-idx1-1;
    

    for(int x=1;x<=n+1;x++){
        ll ans=0;
        ans=(ans+COM(f+m+b,x))%mod;
        ll tmp=2*COM(f+m+b,x-1)-COM(f+b,x-1);
        if(tmp<0) tmp+=mod;
        ans=(ans+tmp)%mod;
        ans=(ans+COM(f+m+b,x-2))%mod;
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 6272
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

char c;
int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		int ans = 0;
		for (int i=0 ; i<3 ; i++) 
		{
			scanf("%c",&c);
			if(c=='1')
			ans++;
		}
		printf("%d",ans);
		
		return 0;
}  


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

typedef pair<int, int> P;

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

    ll ans = (n-1)*(n)/2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
using ll = long long;
using plong = pair<ll,ll>;
ll MOD=998244353;


int main(){
    ll X;cin>>X;
    for(ll a=0;a<1000;a++){
        ll apow = pow(a,5);
        for(ll b=-1000;b<1000;b++){
            if(apow-pow(b,5)==X){
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }

}

Measured memory_bytes: 3960
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long res = 0;
	long N; cin >> N;
	double rt = sqrt(N);
	res = (long)rt;
    res = res * res;
	cout << res << endl;
}

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

int main() {
  // ここにプログラムを追記
int a,b;
double c;
  cin >> a;
  b = 0;
  if (a % 10 > 0)
    b++;
  a /= 10;
  if (a % 10 > 0)
    b++;
  a /= 10;
  if (a % 10 > 0)
    b++;
  cout << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int ans;
int main(){
   int n,m;
   cin>>n>>m;
   vector<int>a(n),b(n),c(m),d(m);
   for(int i=0;i<n;i++){
       cin>>a[i]>>b[i];
   }
   for(int i=0;i<m;i++){
       cin>>c[i]>>d[i];
   }
   for(int i=0;i<n;i++){
       int mi=1000000000;
       for(int j=0;j<m;j++){
           if(mi>abs(a[i]-c[j])+abs(b[i]-d[j])){
               ans=j+1;
               mi=abs(a[i]-c[j])+abs(b[i]-d[j]);
           }
       }
       cout<<ans<<endl;
   }
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm;

void main() {
    auto n = readln.split.join.to!int;

    foreach (i ; 0 .. n) {
        if (i*i > n) break;
        if (i*i == n) {
            writeln("Yes");
            return;
        }
    }
    writeln("No");
}



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



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

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

const int maxn=1e5+5;

int n,k,tot,rt;
bool fake,bo[maxn];
int now[maxn],pre[maxn*2],son[maxn*2];
int l[maxn],r[maxn],odd[maxn],ans[maxn];

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

void add(int a,int b) {
	pre[++tot]=now[a];
	now[a]=tot,son[tot]=b;
}

void dfs(int fa,int u,int now_odd) {
	if(fake)return;
	if(bo[u]&&odd[u]!=now_odd) {fake=1;return;}
	if(!bo[u]) {odd[u]=now_odd,l[u]=l[fa]-1,r[u]=r[fa]+1;}
	for(int p=now[u],v=son[p];p;p=pre[p],v=son[p])
		if(v!=fa) {
			dfs(u,v,now_odd^1);
			l[u]=max(l[u],l[v]-1);
			r[u]=min(r[u],r[v]+1);
		}
	if(r[u]<l[u])fake=1;
}

void check(int fa,int u,int x) {
	ans[u]=x;
	for(int p=now[u],v=son[p];p;p=pre[p],v=son[p])
		if(v!=fa) {
			if(x-1>=l[v]&&x-1<=r[v])check(u,v,x-1);
			else check(u,v,x+1);
		}
}

int main() {
	n=read();
	for(int i=1;i<n;i++) {
		int x=read(),y=read();
		add(x,y),add(y,x);
	}
	k=read();
	for(int i=1;i<=k;i++) {
		int x=read(),v=read();
		if(i==1)rt=x;bo[x]=1;
		l[x]=r[x]=v,odd[x]=v&1;
	}
	dfs(0,rt,odd[rt]);
	if(!fake) {
		puts("Yes");check(0,rt,l[rt]);
		for(int i=1;i<=n;i++)
			printf("%d\n",ans[i]);
	}
	else puts("No");
	return 0;
}


Measured memory_bytes: 10752