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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, Q;
    cin >> N >> Q;
    vector<ll> g[N];
    REP(i, N - 1)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<ll> p(Q), x(Q);
    REP(i, Q)
    {
        cin >> p[i] >> x[i];
        p[i]--;
    }

    vector<ll> count(N, 0);
    REP(i, Q)
    {
        count[p[i]] += x[i];
    }
    
    queue<ll> q;
    vector<bool> visited(N, false);
    q.push(0);
    while(!q.empty())
    {
        ll now = q.front();
        q.pop();
        visited[now] = true;
        REPV(iter, g[now])
        {
            if (!visited[*iter])
            {
                q.push(*iter);
                count[*iter] += count[now];
            }
        }
    }
    
    REP(i, N) cout << count[i] << " "; 
}


Measured memory_bytes: 21104
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
class UnionFind{
  vi p,r;
public:
  UnionFind(int n):p(n,-1),r(n,0){}
  int find(int x){ return (p[x]<0)?x:(p[x]=find(p[x])); }
  bool same(int x,int y){return find(x)==find(y);}
  void unite(int x,int y){
    x = find(x); y = find(y);
    if(x==y)return;
 
    if(r[x]<r[y])p[x] = y;
    else p[y] = x;
    if(r[x] == r[y])r[x]++;
  }
};
 
int main(){
  cin.tie(0); ios::sync_with_stdio(0);
 
  int n;
  cin >> n;
  vi c(n);
  rep(i,n)cin >> c[i];
  vector< vector<pii> > nei(n);
  UnionFind uf(n);
  vector< vi > g(n);
 
  int m;
  cin >> m;
  rep(i,m){
    int a,b;
    cin >> a >> b; a--; b--;
    if(c[a] == c[b])uf.unite(a,b);
    else if(c[a] < c[b])g[a].push_back(b);
    else g[b].push_back(a);
    nei[a].push_back(pii(c[b],b));
    nei[b].push_back(pii(c[a],a));
  }
 
  rep(i,n){
    if(nei[i].empty())continue;
 
    sort(all(nei[i]));
    rep(j,nei[i].size()-1){
      pii u = nei[i][j], v = nei[i][j+1];
      if(u.first == v.first){
	uf.unite(u.second,v.second);
      }else{
	g[u.second].push_back(v.second);
      }
    }
  }
 
  vi comp_size(n,1);
  rep(i,n){
    rep(j,g[i].size())g[i][j] = uf.find(g[i][j]);
  }
 
  rep(i,n){
    int u = uf.find(i);
    if(u != i){
      comp_size[u]++; comp_size[i]--;
      rep(j,g[i].size())g[u].push_back(g[i][j]);
      g[i].clear();
    }
  }
 
  vi deg(n,0), ord;
  queue<int> q;
  rep(i,n){
    if(i == uf.find(i)){
      sort(all(g[i]));
      g[i].erase(unique(all(g[i])), g[i].end());
      for(int v : g[i])deg[v]++;
    }else deg[i] = -1;
  }
 
  rep(i,n){
    if(deg[i] == 0)q.push(i);
  }
 
  while(q.size()){
    int v = q.front(); q.pop();
    ord.push_back(v);
    for(int u : g[v]){
      deg[u]--;
      if(deg[u]==0)q.push(u);
    }
  }
 
  vi dp(n,1);
  long long res = 0;
  for(int v : ord){
    res += (long long)dp[v] * comp_size[v];
    for(int u : g[v]){
      dp[u] = max(dp[u], dp[v]+1);
    }
  }
 
  cout << res << endl;
}

Measured memory_bytes: 20512
import java.io.BufferedReader; 
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
   public static void main(String args[])
    {
        Scanner  sc=new Scanner(System.in);
        PrintWriter pw=new PrintWriter(System.out);
        int t=1;//sc.nextInt();
        long ans=0,te=0;
        while(t-->0)
        {
            int a[]=new int[3];
            a[0]=sc.nextInt();a[1]=sc.nextInt();a[2]=sc.nextInt();
            Arrays.sort(a);
            int sum=(a[2]-a[1])+(a[2]-a[0]);
            if(sum%2==0) pw.println(sum/2);
            else pw.println(sum/2 + 2);
        }
           pw.close();
    }
}
  

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

const double eps = 1e-6;

double  caclDistance2(double x1, double y1, double x2, double y2){
    double ans;
    ans = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);

    return ans;
}

int main(){
    while(1){
        int n;
        cin >> n;
        if(n == 0){
            break;
        }

        vector<pair<double, double> > point(n);

        int ans = 1;

        for(int i=0; i<n; i++){
            cin >> point[i].first >> point[i].second;
        }

        for(int i=0; i<n; i++){
            for(int j=i+1; j < n; j++){

                int point_num = 0;

                double distance_of_two_points = sqrt(caclDistance2(point[i].first, point[i].second, point[j].first, point[j].second));
                //cout << "distance = "<< distance_of_two_points << endl;
                if(distance_of_two_points > 2.0 + eps) continue;

                pair<double, double> midpoint;
                midpoint.first = (point[i].first + point[j].first) / 2;
                midpoint.second = (point[i].second + point[j].second) / 2;

                pair<double, double> vector;                
                pair<double, double> centor;
                
                vector.first = (-1) * (point[i].second - point[j].second);
                vector.second = (point[i].first - point[j].first);

                //cout << vector.first << " " << vector.second << endl;

                double vector_size = sqrt(vector.first * vector.first + vector.second * vector.second);

                double distance_from_centor = sqrt(1.0 - (distance_of_two_points / 2.0) * (distance_of_two_points / 2.0));

                centor.first = midpoint.first + (distance_from_centor/vector_size) * vector.first;
                centor.second = midpoint.second + (distance_from_centor/vector_size) * vector.second;

                //cout << centor.first << " " << centor.second << endl;

                for(int k = 0; k<n; k++){
                    if(caclDistance2(centor.first, centor.second, point[k].first, point[k].second) <= 1.00005){
                        point_num++;
                    }
                }

                ans = max(ans, point_num);

                point_num = 0;

                vector.first = (point[i].second - point[j].second);
                vector.second = (-1) * (point[i].first - point[j].first);

                centor.first = midpoint.first + (distance_from_centor/vector_size) * vector.first;
                centor.second = midpoint.second + (distance_from_centor/vector_size) * vector.second;

                //cout << centor.first << " " << centor.second << endl;

                for(int k = 0; k<n; k++){
                    if(caclDistance2(centor.first, centor.second, point[k].first, point[k].second) <= 1.00005){
                        point_num++;
                    }
                }

                ans = max(ans, point_num);                
            }
        }

        cout << ans << endl;

    }
    return 0;
}


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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	int n ;
	cin >> n ;
	vector<int> h(n);
	rep(i,n) cin >>h[i];
	h[0] -- ;
	for(int i = 1 ; i < n ; i++){
		if(h[i] > h[i-1]){
			h[i] -- ;
		} 
		if(h[i] < h[i-1]){
			coN();
			return 0;
		}
	}
	coY();
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n; cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    lli sum = 0;
    rep(i, n-1){
        for(lli j=i+1; j<n; j++){
            sum += a[i] * a[j];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import copy
def main():
    N = int(input())
    A = [int(input()) for a in range(N) ]
    C = sorted(A)
    Af = C[-1]
    As = C[-2]

    for i in range(N):
        if A[i] != Af:
            print(Af)
        else:
            print(As)
if __name__ == "__main__":
    main()

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    if (s[i] != t[i]) {
      cout << "No" << '\n';
      return 0;
    }
  }
  cout << "Yes" << '\n';
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

struct uf_tree {
    std::vector<int> parent;
    int __size;
    uf_tree(int size_) : parent(size_, -1), __size(size_) {}
    void unite(int x, int y) {
        if ((x = find(x)) != (y = find(y))) {
            if (parent[y] < parent[x]) std::swap(x, y);
            parent[x] += parent[y];
            parent[y] = x;
            __size--;
        }
    }
    bool is_same(int x, int y) { return find(x) == find(y); }
    int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
    int size(int x) { return -parent[find(x)]; }
    int size() { return __size; }
};

signed main() {
    int n, m;
    while (cin >> n >> m) {
        vector<int> a(m), b(m);
        rep(i, m) cin >> a[i] >> b[i];

        vector<ll> ans;
        ll cur = 0;
        uf_tree uf(n);
        for (int i = m - 1; i >= 0; --i) {
            ans.push_back(cur);

            int u = a[i], v = b[i];
            --u, --v;
            if (uf.is_same(u, v)) continue;
            ll x = uf.size(u), y = uf.size(v);
            uf.unite(u, v);
            ll z = uf.size(u);
            cur -= x * (x - 1) / 2;
            cur -= y * (y - 1) / 2;
            cur += z * (z - 1) / 2;
        }

        ll tot = n * (n - 1) / 2;
        reverse(all(ans));
        for (auto &x : ans) cout << tot - x << endl;
    }
}


Measured memory_bytes: 4596
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
#include <bitset> // bitset
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = max({a * c, a * d, b * c, b * d});
    if (a * b <= 0 || c * d <= 0) {
        ans = max(ans, ll(0));
    }
    cout << ans << endl;
}


Measured memory_bytes: 3608
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    int N;
    cin>>N;
    long long int A=0;
    long long int B=0;

    for(int i=1;i<=N;i++){
        if(i%3==0||i%5==0){
            A+=i;
        }

        B+=i;
    }

    cout<<B-A<<endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	llong n,k;
	cin>>n>>k;
	
	n=n%k;
	
	cout<<min(n,abs(n-k))<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl;
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000001;
const ll MAXL=1000000000000000001LL;
const ll mod=1000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int n,m;
bool check(int x,int y) {
  if(x<0 || x>=n) return false;
  if(y<0 || y>=m) return false;
  return true;
}

int news(char c) {
  if(c=='U' || c=='^') return 0;
  else if(c=='D' || c=='v') return 2;
  else if(c=='L' || c=='<') return 1;
  else return 3;
}

int main() {
  int T;
  cin >> T;
  rep(r,T) {
    if(r) cout << endl;
    cin >> n >> m;
    string s[n];
    P now;
    int k;
    rep(i,n) {
      cin >> s[i];
      rep(j,m) {
	if(s[i][j]=='v' || s[i][j]=='^' || s[i][j]=='<' || s[i][j]=='>') {
	  k=news(s[i][j]);
	  now.F=i;
	  now.S=j;
	  s[i][j]='.';
	}
      }
    }
    int l;
    cin >> l;
    string t;
    cin >> t;
    rep(i,t.size()) {
      if(t[i]=='S') {
	int x=now.F+dx[k],y=now.S+dy[k];
	while(1) {
	  if(!check(x,y) || s[x][y]=='#') break;
	  if(s[x][y]=='*') {
	    s[x][y]='.';
	    break;
	  }
	  x+=dx[k];
	  y+=dy[k];
	}						   
      } else {
	k=news(t[i]);
	int x=now.F+dx[k],y=now.S+dy[k];
	if(check(x,y) && s[x][y]=='.') {
	  now.F=x;
	  now.S=y;
	}
      }
    }
    rep(i,n) {
      rep(j,m) {
	if(i==now.F && j==now.S) {
	  if(k==1) cout << '<';
	  else if(k==0) cout << '^';
	  else if(k==3) cout << '>';
	  else cout << 'v';
	} else cout << s[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}


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

int main() {
    double r, g;
    cin >> r >> g;
    cout << 2 * g - r << endl;

    return 0;
}


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

int main()
{
	int a, b;
	bool first = false;

	while (scanf("%d%d", &a, &b), a){
		if (first){
			printf("\n");
		}

		first = true;

		bool check = true;
		for (int i = a; i <= b; i++){
			if (i % 400 == 0 || (i % 4 == 0 && i % 100 != 0)){
				printf("%d\n", i);
				check = false;
			}
		}

		if (check){
			printf("NA\n");
		}
	}

	return (0);
}

Measured memory_bytes: 1044
import collections

N = int(input())
S = [input() for i in range(N)]
cS = collections.Counter(S)
lS = list(cS.items())
M = int(input())
T = [input() for i in range(M)]
cT = collections.Counter(T)
list1 = []
ans = 0

for i in range(len(lS)):
    
    if lS[i][0] in cT:
        x = lS[i][1] - cT[lS[i][0]]
        
    else:
        x = lS[i][1]
        
    if x > 0:
        list1.append(x)
    
if list1 == []:
  print(0)
else:
  print(max(list1))

Measured memory_bytes: 9368
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;

ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
	}
	
	mod& operator=(const ll & tx) {
		x = tx;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return (x + m2.x) % MOD;
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return (x - m2.x + MOD) % MOD;
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return (x * m2.x) % MOD;
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return mod(((*this).x * (*this).inv().x) % MOD);
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}

/* TEMPLATE ENDS HERE */

#define MAXN (1 << 10)

int x[MAXN], y[MAXN];
int n;

int main() {
	cout << fixed << setprecision(12);	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}
	int best = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) {
				continue;
			}
			int cur = 0;
			for (int ii = 0; ii < n; ii++) {
				for (int jj = 0; jj < n; jj++) {
					if ((x[ii] - x[jj] == x[i] - x[j]) && (y[ii] - y[jj] == y[i] - y[j])) {
						cur++;
					}
				}
			}
			best = max(best, cur);
		}
	}
	cout << n - best << endl;
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>

using namespace std;

#define T_MAX 64
#define P_MAX 16

class C_Team{
private :
	int id;
	int penalty;
	int correct;
	int wrong[P_MAX];
public :
	C_Team(){};
	C_Team(int tID);
	void Submit(int time, int pID, bool result);
	int GetCorrect() const { return correct; }
	int GetPenalty() const { return penalty; }
	int GetID() const { return id; }
};

// 判定基準
bool HighPoint(const C_Team& rteamLeft, const C_Team& rteamRight) {
	if(rteamLeft.GetCorrect() != rteamRight.GetCorrect()) return rteamLeft.GetCorrect() > rteamRight.GetCorrect();
	if(rteamLeft.GetPenalty() != rteamRight.GetPenalty()) return rteamLeft.GetPenalty() < rteamRight.GetPenalty();
	return rteamLeft.GetID() < rteamRight.GetID();
}

int main()
{
	while(1) {
		C_Team team[T_MAX];
		int t, p, r;
		cin >> t >> p >> r;
		if(!t && !p && !r) break;
		for(int i = 1; i <= t; i++) {
			team[i] = C_Team(i);
		}
		for(int i = 0; i < r; i++) {
			int tid, pid, time;
			string message;
			cin >> tid >> pid >> time >> message;
			team[tid].Submit(time, pid, message == "CORRECT");
		}
	
		sort(team+1, team+t+1, HighPoint);
		for(int i = 1; i <= t; i++) {
			cout << team[i].GetID() << " " << team[i].GetCorrect() << " " << team[i].GetPenalty() << endl;
		}
	}
	return 0;
}

C_Team::C_Team(int tID) {
	id = tID;
	correct = 0;
	penalty = 0;
	for(int i = 0; i < P_MAX; i++) {
		wrong[i] = 0;
	}
}

void C_Team::Submit(int time, int pID, bool result) {
	if(result) {
		correct++;
		penalty += wrong[pID] * 1200 + time;
	} else {
		wrong[pID]++;
	}
}

Measured memory_bytes: 1220
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	string vals[3] = {"Sunny", "Cloudy", "Rainy"};
	
	string S; cin >> S;
	
	F0R(i, 3) {
		if (S == vals[i]) {
			cout << vals[(i+1)%3] << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}

use std::cmp::{max, min};

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    if a < 10 && b < 10 {
        println!("{}", a * b);
    } else {
        println!("{}", -1);
    }
}


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

int c, k, n, m;
ll t[1 << 17], d[1 << 17];
vector<int>u, v;
string s[11];

int main(){
    cin >>n;
    double j=0,b=0;
    for(int i= 0;i<n;i++){
        double a;
        cin >> a >> s[i];
        if(s[i]=="JPY")j+=a*1.0;
        else b+=a*380000.0;
    }
    printf("%lf",j+b);
}



Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
using namespace std;

const int N = 200005;
int T, n, a, b, c;
string s, t;
int main()
{
	cin >> s >> t;
	int ns = s.size(), nt = t.size(), cur;
	for(int i = 0; i + nt <= ns; ++i)
	{
		cur = 0;
		for(int j = 0; j < nt; ++j)
			if(t[j] == s[i + j]) ++cur;
		a = max(cur, a);
	}
	cout << nt - a << endl;
	return 0;
}


Measured memory_bytes: 3576
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	int x; cin >> x;
	int cnt_500 = x / 500;
	int cnt_5 = (x - cnt_500 * 500) / 5;
	ll ans = (ll)1000 * cnt_500 + (ll)5 * cnt_5;
	cout << ans << endl;
	return 0;
}

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


int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    
    if (a + (2 * sqrtl((long double)a) * sqrtl((long double)b)) + b < c) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    char A[4][4],B[4];
    rep(i,3){
        cin >> A[i];
    }
    rep(i,3){
        cout << A[i][i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define x first
#define y second

namespace lsr_faster
{
	typedef std::pair<int,int> pii;
	const int N=3010,M=N*2;
	pii s[N];
	int begin[N],next[M],to[M];
	int A[N],ans[N];
	int n,e,tot;
	void add(int x,int y,bool k=1)
	{
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
		if(k)add(y,x,0);
	}
	void initialize()
	{
		scanf("%d",&n);
		for(int i=1;i<=n;i++)scanf("%d",A+i),s[i]=pii(A[i],i);
		for(int i=1,u,v;i<n;i++)scanf("%d%d",&u,&v),add(u,v);
		std::sort(s+1,s+n+1);
	}
	bool f[N];
	bool check(int p,int h=0)
	{
		for(int i=begin[p],q;i;i=next[i])
			if((q=to[i])!=h)
			{
				if(A[q]>=A[p])continue;
				if(!f[q])return f[p]=1;
			}
		return f[p]=0;
	}
	void solve()
	{
		initialize();
		tot=0;
		for(int i=1;i<=n;i++)
			if(check(s[i].y))ans[++tot]=s[i].y;
		std::sort(ans+1,ans+tot+1);
		for(int i=1;i<=tot;i++)
			printf("%d ",ans[i]);
		printf("\n");
	}
}

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


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(void){
    int a,b,ans=1;
    scanf("%d%d",&a,&b);
    while(abs(a-ans)!=abs(b-ans)){
        ++ans;
        if(ans>a&&ans>b){
            printf("IMPOSSIBLE");
        }
        if(ans>a&&ans>b)
        break;
    }
    if(abs(a-ans)==abs(b-ans))
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 
        while(true){
          	String strArr[] = (br.readLine()).split(" ");
            int a = Integer.parseInt(strArr[0]);
            int b = Integer.parseInt(strArr[1]);
            int c = Integer.parseInt(strArr[2]);
			
          	if(a == -1 && b == -1 && c == -1){
            	break;
            }
          	
          	int sum = a + b;
			if(a == -1 || b == -1) {
            	System.out.println("F");
            } else if(sum >= 80 ) {
            	System.out.println("A");
            } else if(sum >= 65 ) {
            	System.out.println("B");
            } else if(sum >= 50 || c >= 50) {
            	System.out.println("C");
            } else if(sum >= 30) {
            	System.out.println("D");
            } else {
           		System.out.println("F"); 
            }
        }
    }
}


Measured memory_bytes: 24364
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (l) < (x) && (x) < (r)

int main() {
    int X, N;
    cin >> X >> N;
    vector<bool> in_p(105,false);
    rep(i,0,N) {
        int p;
        cin >> p;
        in_p[p] = true;
    }
    int ans = 0;
    rep(i,1,102) {
        if (!in_p[i]) {
            ans = abs(ans-X) > abs(i-X) ? i : ans;
        }
    }
    cout << ans << endl;
}

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

int main(void)
{
	int m;
	std::cin >> m;

	for ( int i = 0; i < m; ++i ) {
		int sikin, nen, n;

		std::cin >> sikin >> nen >> n;

		int max = 0;
		for ( int j = 0;j < n; ++j ) {
			int hukuri = 0;
			double rate;
			int cost;

			std::cin >> hukuri >> rate >> cost;

			if ( hukuri == 1 ) {
				int A = sikin, B = 0;
				for ( int i = 0; i < nen; ++i ) {
					B = A * rate;
					A = A + B - cost;
				}
				if ( A > max ) max = A;
			} else {
				int A = sikin, B = 0;
				for ( int i = 0; i < nen; ++i ) {
					B += A * rate;
					A = A - cost;
				}
				if ( A + B > max ) max = A+B;
			}
		}
		std::cout << max << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int n,m,a,b;
	cin >> n >> m >> a >> b;
	swap(a,b);
	for(int i=1; i<=n ;i++){
		for(int j=1; j<=m ;j++){
			cout << ((i<=a)^(j<=b));
		}
		cout << endl;
	}
}


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

int main() {
    int h,w;
    cin>>h>>w;
    int const mod = 1000000007;
    
    char arr[h][w];
    for(int i = 0;i<h;i++){
        for(int j = 0;j<w;j++){
            cin>>arr[i][j];
        }
    }
    
    int dp[h][w];
    dp[0][0] = 1;
    
    for(int i = 0;i<h;i++){
        for(int j = 0;j<w;j++){
            if(i==0 && j==0 )continue;
            else if (i==0){
                if(arr[i][j] == '.')dp[i][j] = dp[i][j-1];
                else dp[i][j] = 0;
            }
            else if (j==0){
                if(arr[i][j] =='.')dp[i][j] = dp[i-1][j];
                else dp[i][j] = 0;
            }
            else{
                if(arr[i][j]=='.'){
                    dp[i][j] = (dp[i][j-1]%mod + dp[i-1][j]%mod)%mod;
                }
                else dp[i][j] =0;
            }
        }
    }
    
    cout<<dp[h-1][w-1]<<endl;
    
	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define     SZ  50500
#define     LIM 2500005
#define     pll pair<LL, LL>
#define     pb  push_back
#define     ff  first
#define     ss  second
#define     LL  long long


int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    LL a, b, n, cnt = 0;
    cin>>a>>b>>n;
    if (a%n == 0) ++cnt;

    cout<<((b/n) - (a/n) + cnt)<<endl;


    return 0;
}




Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
int main(){
	int a;
	while(cin>>a,a){
		while(a--){
			int b,c,d,e,f,g,h,i;cin>>b>>c>>d>>e>>f>>g>>h>>i;
			printf("%d %d %d %d\n",b*f-c*g-d*h-e*i,b*g+c*f+d*i-e*h,b*h-c*i+d*f+e*g,b*i+c*h-d*g+e*f);
		}
	}
}


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

using namespace std; 
  
int main() 
{ int c=0,i=0;
 int n;
  while(c<5){
    cin>>n;
    if(n==0)
      cout<<(i+1);
    c++;
    i++;
  }
} 


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const ll INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

const ll MAX = 1e6;

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

int main(){
	int n;
	ll a, b;
	cin >> n >> a >> b;
	int bp;
	cin >> bp;
	ll ans = 0;
	rep(i, n-1){
		int d;
		cin>>d;
		ans += min((d-bp)*a, b);
		bp = d;
	}

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


Measured memory_bytes: 256
import java.util.Scanner;




public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

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

    	int N=sc.nextInt();

    	int[] A=new int[N];

    	for(int i=0;i<N;i++) {
    		A[i]=sc.nextInt()-1;
    	}

    	int now=A[0];
    	int next=0;

    	int counter=0;

    	while(true) {
    		counter++;

    		if(now==1) {
    			break;
    		}

    		next=A[now];

    		A[now]=-1;
    		
    		if(next==-1) {
    			counter=-1;
    			break;
    		}else {
    			now=next;
    		}

    	}


    	System.out.println(counter);


    }

}



Measured memory_bytes: 50448
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// nがあり、nの数だけの整数の入力
			long n = sc.nextLong();
			List<Long> an = new ArrayList<>();
			for (long i = 0; i < n; i++) {
				an.add(sc.nextLong());
			}
			long result = 0;
			long min = Integer.MAX_VALUE;
			for (long l : an) {
				if (min > l) {
					result++;
					min = l;
				}
			}
			System.out.println(result);
		}
	}

	/**
	 * 最小公倍数
	 */
	static long lcm(long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return c / b;
	}

	/**
	 * 最大公約数
	 */
	static long gcd(long a, long b) {
		long temp;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return b;
	}
}

Measured memory_bytes: 94292
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    int res=0;
    while(n--){
        int a,b; cin >> a >>b ;
        res+=(b-a+1);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3568
using System;
public class Hello{
    public static void Main()
    {
        // Your code here!
        int N = int.Parse(Console.ReadLine());
        int CMAX = 100 / 4;
        int DMAX = 100 / 7;
        for(int i = 0; i < CMAX; i++) //ケーキの個数
        {
            for(int j = 0; j < DMAX; j++) //ドーナツの個数
            {
                if(4 * i + 7 * j == N)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
        }
        Console.WriteLine("No");
    }
}

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

int main() {
  int x[10000];
  int count = 0;
  
  while(1){
    cin >> x[count];
    if(x[count]==0)
      break;
    count++;
  }
  
  for(int i=0; i<count; i++)
    cout << "Case " << i+1 << ": " << x[i] << endl;
    
  
}



Measured memory_bytes: 3064
#include <stdio.h>
int main()
{
    int toori,limit;
    int cost,time;
    int i,cheapest=1001;

    scanf("%d %d",&toori,&limit);
    for(i=0;i<toori;i++){
        scanf("%d %d",&cost,&time);
        if(time<=limit && cost <= cheapest){
            cheapest = cost;
        }
    }

    if(cheapest==1001){
        printf("TLE");
    }else{
    printf("%d",cheapest);
    }
    return 0;
}

Measured memory_bytes: 128
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    string_code(1, S, C),
*/

main:-
    get_number(N),
    R is (N + 1) div 2,
    writeln(R).


Measured memory_bytes: 7980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()
template <unsigned mod>
struct RollingHash {
  vector<unsigned> hashed, power;

  inline unsigned mul(unsigned a, unsigned b) const {
    unsigned long long x = (unsigned long long)a * b;
    unsigned xh = (unsigned)(x >> 32), xl = (unsigned)x, d, m;
    asm("divl %4; \n\t" : "=a"(d), "=d"(m) : "d"(xh), "a"(xl), "r"(mod));
    return m;
  }

  RollingHash(const vector<int>& s, unsigned base = 10007) {
    int sz = (int)s.size();
    hashed.assign(sz + 1, 0);
    power.assign(sz + 1, 0);
    power[0] = 1;
    for (int i = 0; i < sz; i++) {
      power[i + 1] = mul(power[i], base);
      hashed[i + 1] = mul(hashed[i], base) + s[i];
      if (hashed[i + 1] >= mod) hashed[i + 1] -= mod;
    }
  }

  unsigned get(int l, int r) const {
    unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
    if (ret >= mod) ret -= mod;
    return ret;
  }

  unsigned connect(unsigned h1, int h2, int h2len) const {
    unsigned ret = mul(h1, power[h2len]) + h2;
    if (ret >= mod) ret -= mod;
    return ret;
  }

  int LCP(const RollingHash<mod>& b, int l1, int r1, int l2, int r2) {
    int len = min(r1 - l1, r2 - l2);
    int low = -1, high = len + 1;
    while (high - low > 1) {
      int mid = (low + high) / 2;
      if (get(l1, l1 + mid) == b.get(l2, l2 + mid))
        low = mid;
      else
        high = mid;
    }
    return (low);
  }
};

using RH = RollingHash<1000000007>;

int N;

int main() {
  cin >> N;
  vector<int> a(N), b(N);
  rep(i, N) cin >> a[i];
  rep(i, N) cin >> b[i];

  vector<int> c(N), d(N);
  rep(i, N) {
    c[i] = a[i] ^ a[(i + 1) % N];
    d[i] = b[i] ^ b[(i + 1) % N];
  }

  RH rhc(c), rhd(d);

  rep(k, N) {
    if (rhd.get(0, N) == (rhc.connect(rhc.get(k, N), rhc.get(0, k), k))) {
      int x = b[(N - k + N) % N] ^ a[0];
      cout << k << " " << x << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 9728
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        long a = scanner.nextLong();
        long b = scanner.nextLong();
        int k = scanner.nextInt();
        int n = (int) gcd(a, b);
        List<Integer> divs = getDivisors(n);
        Collections.reverse(divs);
        System.out.println(divs.get(k - 1));
    }

    static long gcd(long x, long y) {
        if (x < y) {
            return gcd(y, x);
        }
        if (y == 0) {
            return x;
        }
        return gcd(y, x % y);
    }

    static List<Integer> getDivisors(int n) {
        List<Integer> divisors = new ArrayList<>();
        List<Integer> tmp = new ArrayList<>();
        for (int i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                divisors.add(i);
                if (i != n / i) {
                    tmp.add(n / i);
                }
            }
        }
        Collections.reverse(tmp);
        divisors.addAll(tmp);
        return divisors;
    }

}

Measured memory_bytes: 24020
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
    int n,a[1002],i;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    cout<<a[n-1]-a[0]<<endl;
}


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

using namespace std;

void autoinput()
{
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
}

#define ll long long
#define scan(x) scanf("%lld",&x)
#define pb push_back
#define mp make_pair
#define edge(xx,yy) v[xx].pb(yy);v[yy].pb(xx) 
const ll mod=(998244353);


ll bigmod(ll N,ll P)
{
    if(P==0) return 1;
    if(P%2==0)
    {
        ll ret=bigmod(N,P/2);
        return ((ret%mod)*(ret%mod))%mod;
    }
    else return ((N%mod)*(bigmod(N,P-1)%mod))%mod;

}


std::vector < ll > v[100005];
bool visited[100005];

int main()
{

    //autoinput();
   
    ll i,j,k,l,m,n,w;
    cin >> n >> m;
    for(i=0;i<m;i++)
    {
        cin >> j >> k >> w;
        v[j].pb(k);
        v[k].pb(j);
    }
    queue < ll > q;
    ll ans=0;
    for(i=1;i<=n;i++)
    {
        if(!visited[i])
        {
            visited[i]=1;
            ans++;
            q.push(i);
            while(!q.empty())
            {
                ll u=q.front();
                q.pop();
                for(auto it: v[u])
                {
                    if(!visited[it])
                    {
                        visited[it]=1;
                        q.push(it);
                    }
                }

            }
        }
    }
    cout << ans << endl;



}


Measured memory_bytes: 7412
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<vector<int>> table(9, vector<int>(9));
  for (int a=1; a<=9; a++) {
    for (int b=1; b<=9; b++) {
      int subcount = 0;
      if (a == b) {
        int now = a;
        for (int p=1; now <= N; p++) {
          for (int q=0; q < pow(10, p-1) && now <= N; q++) {
            subcount++;
            now = a*pow(10, p) + 10*q + a;
          }
        }
        table.at(a-1).at(b-1) = subcount;
      }
      else {
        int now = a*10 + b;
        for (int p=2; now <= N; p++) {
          for (int q=0; q < pow(10, p-1) && now <= N; q++) {
            subcount++;
            now = a*pow(10, p) + 10*q + b;
          }
        }
        table.at(a-1).at(b-1) = subcount;
      }
    }
  }
  int count = 0;
  for (int i=0; i<9; i++) {
    count += table.at(i).at(i) * table.at(i).at(i);
  }
  for (int i=0; i<9; i++) {
    for (int j=i+1; j<9; j++) {
      count += 2 * table.at(i).at(j) * table.at(j).at(i);
    }
  }
  cout << count << endl;
}

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

int main(){

  int N;
  cin >> N;
  vector<int> a(200000);
  for(int i=1; i<=N; i++){
  	cin >> a[i];
  }
  
  int n=1;
  int count = 1;
  bool exist=1;
  
  while(true){
  	if(a[n] != 2){
      n=a[n]; count++;

      if(count > N){ 
        exist = 0;
        break;
      }
    }
  	else break;
  }
  
  if(exist) cout << count << endl;
  else cout << -1 << endl;
  
}

Measured memory_bytes: 1152
#import math
#import copy
#import sys
#import bisect
#input = sys.stdin.readline
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))

def main():
    #x,y = map(int,input().split())	x=1,y=2
    #a = input().split()	a=['1','2','3',...,'n']
    #a = list(map(int,input().split()))	a=[1,2,3,4,5,...,n]
    #li = input().split('T')	FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    #複数行の「1 2 3 4」型の入力を一配列に
    #x = sorted([list(map(int, input().split())) for _ in range(n)])
    #ソート x.sort(key=lambda y:y[1])
    # print("Yes")  print("No")  x=[[0 for _ in range(n)] for _ in range(n)]
    n,m = map(int,input().split())
    ab = sorted([list(map(int, input().split())) for _ in range(m)])
    ab.sort()
    x=[n+2 for _ in range(n)]
    x[0]=0
    for i in range(m):
        x[ab[i][1]-1]=min(x[ab[i][0]-1]+1,x[ab[i][1]-1])
    if x[n-1]==2:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

main()

Measured memory_bytes: 94040
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>

using namespace std;

int main()
{
    int N = 0;
    int W = 0;
    cin >> N >> W;
    vector<pair<int, int>> vws;
    int v = 0;
    int w = 0;
    for (int i = 0; i != N; ++i){
        cin >> v >> w;
        vws.emplace_back(v, w);
    }
    vector<int> dp(W + 1, 0);  // dp[w]: maximum value of items with weight w.
    for (auto vw : vws){
        tie(v, w) = vw;
        for (int cum_w = W; cum_w > w; --cum_w){
            if (dp[cum_w - w]) dp[cum_w] = max(dp[cum_w], dp[cum_w - w] + v);
        }
        dp[w] = max(dp[w], v);
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
    return 0;
}

Measured memory_bytes: 3132