akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



int main () {
	SpeedForce;
	cin >> n;
	For (i, 2, n) cin >> a[i];
	FOr(i, n, 1) {
		u[a[i]] ++;
	}
	For (i, 1, n) cout << u[i] << '\n';

	return Accepted;
}

// B...a

Measured memory_bytes: 19236
import sys
input=sys.stdin.readline
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
def YesNo(x):print("Yes")if x==True else print("No")
a,b,h,m=NM()
from math import cos,sqrt,pi
s=h/12+m/720-m/60
print(sqrt(a**2+b**2-2*a*b*cos(2*pi*(s))))

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int X, Y;

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

  std::cin >> X >> Y;

  int res = 0;

  if(X <= 3){
      res += 100000 * (4 - X);
  }

  if(Y <= 3){
      res += 100000 * (4 - Y);
  }

  if(X == 1 && Y == 1){
      res += 100000 * 4;
  }

  std::cout << res << std::endl;
}


Measured memory_bytes: 256
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	a = 10^100
	s = readline() |> chomp
	l = length(s)
	r = 1
	a = Tuple{Int,Int}[]
	for i in 2:l
		if s[i] == 'R'
			r = i
		elseif r > 0
			push!(a,(r,i))
			r = 0
		end
	end
	d = zeros(Int,l)
	now = shift!(a)
	for i in 1:l
		if now[1]<=i<=now[2]
			d[i]+=1
		elseif i<now[1]&&s[i]=='R'
			d[now[1]+(now[1]-i)%2]+=1
		elseif s[i]=='L'
			d[now[2]-(i-now[2])%2]+=1
		else
			now = shift!(a)
			d[now[1]+(now[1]-i)%2]+=1
		end
	end
	for i in 1:l-1
		print(d[i], " ")
	end
	println(d[l])
end

main()

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

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

        int n = sc.nextInt();
        int hitpoint = sc.nextInt();

        int[][] katana = new int[n][3];

        for (int i = 0; i < n; i++) {
            katana[i][0] = i;
            katana[i][1] = sc.nextInt();
            katana[i][2] = sc.nextInt();
        }

        // aの強い順に並び替える
        Arrays.sort(katana, (o1, o2) -> o2[1] - o1[1]);

        int[] aMaxKatana = katana[0].clone();

        // bの強い順に並び替える
        Arrays.sort(katana, (o1, o2) -> o2[2] - o1[2]);

        int count = 0;
        for (int i = 0; i < n; i++) {
            if (aMaxKatana[1] <= katana[i][2]) {
                // katana[i]を投げる
                hitpoint -= katana[i][2];
                // katana[i]使用不可
                count++;

                // 倒した
                if (hitpoint <= 0) {
                    break;
                }
            }
        }

        if (0 <= hitpoint) {
            count += hitpoint/aMaxKatana[1];
            int residue = hitpoint % aMaxKatana[1];
            // 余りを減らす一発
            if (residue != 0){
                count++;
            }
        }
        System.out.println(count);
    }
}


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

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

  char S[110], T[110];

  cin >> S >> T;

  string str;

  for(int i=0; i<N; ++i){
    str += S[i];
    str += T[i];
  }

  cout << str;
    
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    char a[5]={'a'},c;
    cin>>a;
    for(int i=0;i<4;i++){
        if(a[i]==a[i+1]) c++;
    }
    if(c>0) cout<<"Bad"<<endl;
    else cout<<"Good"<<endl;
}


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

int main()
{
    int a,b;
    cin>>a>>b;
    if(a==1)a+=13;
    if(b==1)b+=13;
    if(a>b)cout<<"Alice"<<endl;
    else if(b>a)cout<<"Bob"<<endl;
    else cout<<"Draw"<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
static const int MAX = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
static const int INFTY = (1<<21);
int n,M[MAX][MAX];

void dijkstra(){
    int color[MAX],d[MAX],p[MAX];
    int minv;
    for (int i = 0; i < n; i++)
    {
        color[i] = WHITE;
        d[i] = INFTY;
        
    }
    d[0] = 0;color[0] = GRAY;
    while (1)
    {
        minv = INFTY;
        int u = -1;
        for (int i = 0; i < n; i++)
        {
            if(minv>d[i]&&color[i]!=BLACK){
                u = i;
                minv = d[i];
            }
        }
        if(u==-1)break;
        color[u] = BLACK;
        for (int v = 0; v < n; v++)
        {
            if(color[v]!=BLACK&&M[u][v]!=INFTY){
                if(d[v]>d[u]+M[u][v]){
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    for (int  i = 0; i < n; i++)
        {
            cout << i << " " << (d[i]==INFTY?-1:d[i]) << endl;
        }  
}


int main(){
    cin >> n;
    int u,k,c,v;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            M[i][j] = INFTY;
        }
    }
    
    
    for (int i = 0; i < n; i++){
        cin >> u >> k;
        for (int j = 0; j < k; j++){
            cin >> v>> c;
            M[u][v] = c;
        }
    }
    dijkstra();
    return 0;
    
}


Measured memory_bytes: 3128
N = int(input())
A = list(map(int, input().split()))
MOD = 1000000007

memo = [0] * 3
answer = 1
for i in range(N):
    first = True
    count = 0
    for j in range(3):
        if memo[j] == A[i]:
            if first == True:
                first = False
                memo[j] += 1
            count += 1
    if count == 0:
        print(0)
        exit()
    elif count == 3:
        answer *= 3
    elif count == 2:
        answer *= 2

print(answer % MOD)

Measured memory_bytes: 13964
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const ll INFL = (1LL << 62);
const ll MOD = 1000000007;
template <class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T>
ll mod_pow(ll a, ll n, T mod) {
    mod = (ll)mod;
    ll res = 1, p = a % mod;
    while (n) {
        if (n & 1) res = res * p % mod;
        p = p * p % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N + 1), B(N);
    ll sum = 0;
    rep(i, N + 1) {
        cin >> A[i];
        sum += A[i];
    }
    rep(i, N) cin >> B[i];

    rep(i, N) {
        if (A[i] > B[i]) {
            A[i] -= B[i];
        } else {
            int amari = B[i] - A[i];
            A[i] = 0;
            A[i + 1] = max(A[i + 1] - amari, 0);
        }
    }
    ll sum2 = 0;
    rep(i, N + 1) sum2 += A[i];

    cout << sum - sum2 << endl;

    return 0;
}

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

int main(void)
{
    int N;
    cin >> N;

    vector<char> S(N);
    string ans = "Three";
    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
        if (S[i] == 'Y')
            ans = "Four";
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YEs() printf("YEs\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPs=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int cnt[26] = {},ans;
	string s;
	cin >> s;
	ans = s.length() * (s.length() - 1) / 2;
	for(char c : s) cnt[c - 'a']++;
	for(int i = 0;i < 26;i++) ans -= (cnt[i] - 1) * cnt[i] / 2;
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val s = mutableListOf(0L)

    for (i in 0 until n) {
        val a = sc.nextInt()
        s.add(s.last() + a)
    }
    s.sort()
    var ans = 0L
    var cnt = 0
    for (i in 1 until s.size) {
        if (s[i - 1] == s[i]) {
            cnt++
        } else {
            cnt = 0
        }
        ans += cnt
    }
    println(ans)
}


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

int main(void)
{
    int N;
    int a[200];
    int alice = 0;
    int bob = 0;

    cin  >> N;
    for(int i = 0; i < N; i++)
        cin >> a[i];

    sort(a, a + N, greater<int>());

    for(int i = 0; i < N; i++)
    {
        if(i % 2 == 0)
        {
            alice += a[i];
        }
        else
        {
            bob +=a[i];
        }
    }
    cout << alice - bob << endl;
    
    return 0;
}

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

ll sum[201010];

int main() {
    ll N, K;
    cin >> N >> K;

    vector<ll> A(N);
    ll ans = 0;
    rep(i, N) {
        cin >> A[i];
        //if (A[i]%K == 1) ans++;
        //A[i] %= K;
    }

    if (K == 1) {
        cout << 0 << endl;
        return 0;
    }


    rep(i, N) {
        sum[i+1] = (sum[i] + A[i]) % K;
    }

    // rep(i, N+1) {
    //     cout << sum[i] << " ";
    // }
    // cout << endl;

    map<ll, ll> mp;
    mp[0]++;
    for (int i=1; i<=N; ++i) {
        ll tmp = ((sum[i] - i) % K + K) % K;
        ans += mp[tmp];
        mp[tmp]++;

        if (i+1-K >= 0) {
            mp[((sum[i+1-K] - (i+1-K)) % K + K) % K]--;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 15872
#include <cstdio>
#include <set>
using namespace std;
int N; set<long long> A; long long t;
int main() {
  scanf("%d", &N);
  for(int i = 0, c; i < N; i++) {
    scanf("%lld", &t);
    c = A.count(t);
    if(c < 1) A.insert(t);
    else if(c == 1) A.erase(t);
  }
  printf("%d", A.size());
}

Measured memory_bytes: 4864
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;

#define fi first
#define se second
typedef long long LL;
typedef long double LD;

const int inf=(1<<30);
struct edge{
    int to,c;
    edge(){}
    edge(int to, int c) : to(to), c(c) {}
};

int N,M,dp[1<<15][15],cost[15][1<<15];
vector<edge> g[15];
pair<int,int> to[1<<15][15];

int main(){
    cin >> N >> M;

    int i,x,y,c,k,mask;
    for (i=1; i<=M; i++){
        cin >> x >> y >> c;
        x--,y--;
        g[x].push_back(edge(y,c));
        g[y].push_back(edge(x,c));
    }


    for (i=0; i<N; i++)
        for (int mask=0; mask<(1<<N); mask++){
            for (edge e : g[i])
                if (mask&(1<<e.to)) cost[i][mask]+=e.c;
        }

    for (mask=(1<<N)-1; mask>=0; mask--){
        if (mask&(1<<(N-1))) continue;
        for (k=0; k<N-1; k++){
            dp[mask][k]=inf;

            if (mask&(1<<k)) continue;

            int sub = ~(mask|(1<<k));
            sub&=((1<<(N-1))-1);

            int crmask = sub;
            do{
                int nxt = mask | crmask | (1<<k),c=0;
                for (i=0; i<N; i++)
                    if ((crmask&(1<<i)) || i==k)
                        c+=cost[i][(~nxt)&((1<<N)-1)];

                for (edge e : g[k])
                    if ((nxt&(1<<e.to))==0)
                        if (dp[mask][k]>c-e.c+dp[nxt][e.to]){
                            dp[mask][k]=c-e.c+dp[nxt][e.to];
                            to[mask][k]={nxt,e.to};
                        }


                crmask=(crmask-1)&sub;
            } while (crmask!=sub);

            dp[mask][N-1]=0;

        }

    }

    cout << dp[0][0] << "\n";

    return 0;
}
/*
4 4
1 2 2
2 3 3
1 3 100
3 4 4
*/


Measured memory_bytes: 6912
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

/*例: 数列Aで,整数x > Ai となるAiがK個となる最小の整数xを求めよ*/
ll N, M;

bool C(ll mid){//ここに条件を書く
    ll rest;
    rest = M - mid*2;

    // cout << mid << " " << rest << endl;
    if(rest < 0) return false;
    if((N+rest/2) < mid) return false;
    return true;
}

ll nibutan(ll lb, ll ub){
    while(ub-lb>1){
        // cout << lb<<" "<<ub <<endl;
        ll mid=(lb+ub)/2;
        if(C(mid)) lb=mid;
        else ub=mid;
    }
    return lb;
}

int main(){
    ll ans;
    cin >> N >> M;
    ans = nibutan(0, 1e12+2);
    P(ans);
}

// int main(){
//     ll N, M, ans=0, rest;
//     rest = M - 2*N;
//     if(rest>=0){

//     }else{

//     }
// }

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

int main(){
  double a, b, c, rad, pi = 3.14159265358979;
  cin >> a >> b >> c;
  rad = pi/180 *c;
  printf("%.7f %.7f %.7f", a*b*sin(rad)/2, a+b+sqrt(a*a+b*b-2*a*b*cos(rad)), b*sin(rad));

  return 0;
}


Measured memory_bytes: 3608
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

lint solve(int n, int xi, int yi, const vector<lint>& x, const vector<lint>& y){
    lint res = 0;
    lint maxi = 0;

    rep(i, n){
        res += (abs(x[xi] - x[i]) + abs(y[yi] - y[i])) << 1;
        chmax(maxi, abs(x[xi] - x[i]) + abs(y[yi] - y[i]));
    }

    res -= maxi;

    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int w, h;
    cin >> w >> h;

    int n;
    cin >> n;

    vector<lint> x(n), y(n);
    vector<int> id1, id2;
    rep(i, n){
        cin >> x[i] >> y[i];
        id1.emplace_back(i);
        id2.emplace_back(i);
    }

    sort(id1.begin(), id1.end(), [&](int i, int j){ return x[i] > x[j]; });
    sort(id2.begin(), id2.end(), [&](int i, int j){ return y[i] > y[j]; });

    lint ansx = x[id1[n >> 1]], ansy = y[id2[n >> 1]];
    lint ans = solve(n, id1[n >> 1], id2[n >> 1], x, y);

    if(n != 1){
        rep(i, 2){
            rep(j, 2){
                if(chmin(ans, solve(n, id1[(n >> 1) - i], id2[(n >> 1) - j], x, y))){
                    ansx = x[id1[(n >> 1) - i]];
                    ansy = y[id2[(n >> 1) - j]];
                }
            }
        }
    }

    cout << ans << endl;
    cout << ansx << ' ' << ansy << endl;

    cout << flush;

    return 0;
}


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MIN(a, b) ((a) <= (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
int main(){
	ll n,ans;
	ans = 0;
	cin >> n;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0&&n/i-1>i){
			ans = ans + (n/i)-1;
		}
	}
	cout << ans << endl;
	
}


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

int main() {
  
  int N,K;
  cin >> N >> K;
  int ans = 1;
  
  while(ans<=K){
    ans *=2;
    N--;
    
    if(N==0)
      break;
  }
  
  ans += N*K;
  
  cout << ans <<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int otsuri = 10000-N;
		if(String.valueOf(otsuri).length() >= 4) {
			System.out.println(Integer.parseInt(String.valueOf(otsuri).substring(1)));
		} else {
			System.out.println(otsuri);
		}
	}
}

Measured memory_bytes: 26988
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
vector<set<in> > usd;
VI dst;
VVI egt;
vector<map<in,VI> > eso;
queue<in> q;
void ttk(in u, in c, in d){
  if(usd[u].find(c)!=usd[u].end())
    return;
  usd[u].insert(c);
  if(dst[u]>d){
    dst[u]=d;
    q.push(u);
  }
  VI& tp=eso[u][c];
  forv(i,tp){
    ttk(tp[i],c,d);
  }
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,m;
  cin>>n>>m;
  in x,y,c;
  egt.resize(n);
  const in inf=1e9;
  usd.resize(n);
  dst.resize(n,inf);
  q.push(0);
  dst[0]=0;
  eso.resize(n);
  forn(z,m){
    cin>>x>>y>>c;
    --x;
    --y;
    eso[x][c].PB(y);
    eso[y][c].PB(x);
    egt[x].PB(c);
    egt[y].PB(c);
  }
  in u;
  while(!q.empty()){
    u=q.front();
    q.pop();
    forv(i,egt[u]){
      c=egt[u][i];
      if(usd[u].find(c)!=usd[u].end())
	continue;
      ttk(u,c,dst[u]+1);
    }
  }
  if(dst[n-1]==inf)
    cout<<-1<<endl;
  else
    cout<<dst[n-1]<<endl;
  return 0;
}


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

ll solve() {
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> H(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> H[i];
    }

    auto check = [&](ll n) {
        ll r = n;
        ll d = A - B;
        for ( int i = 0; i < N; i++ ) {
            ll h = H[i] - B * n;
            if ( h > 0 ) {
                r -= (h + d - 1) / d;
                if ( r < 0 ) return false;
            }
        }
        return true;
    };

    ll l = 0, r = 2 + 1e9 / B;
    while ( r - l > 1 ) {
        ll m = (l + r) / 2;
        if ( check(m) ) r = m;
        else l = m;
    }

    return r;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;int main(void){
    // Your code here!
    int A,B,C,tmp;
    std::cin >> A >> B >> C;
    int P[3] = {A,B,C};
    for (int a = 0; a < 2; a++) {
        for (int i = 0; i < 2; i++) {
            if(P[i] > P[i+1]){
                tmp = P[i];
                P[i] = P[i+1];
                P[i+1] = tmp;
            }
        }
    }
    A = P[0];
    B = P[1];
    C = P[2];
    if((3 * C % 2) == (A+B+C) % 2)
    std::cout << (3 * C - (A + B + C)) / 2 << std::endl;
    else{
        std::cout << (3 * (C + 1) -(A + B + C)) / 2 << std::endl;
    }
}


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

int main(){
	int s,w;
	cin>>s>>w;
	if(s>w){
		cout<<"safe"<<endl;
	}
	else{
		cout<<"unsafe"<<endl;
	}

	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
 int H , W , h , w;
 cin >> H >> W >> h >> w;
 cout << H * W - h * W - H * w + h * w << endl;
}

Measured memory_bytes: 256
using System;
public class Program {
	public static void Main() {
		int[] a = new int[10];
		for(int i = 0; i < 10; i++) a[i] = int.Parse(Console.ReadLine());
		Array.Sort(a);
		for(int i = 9; i > 6; i--) Console.WriteLine(a[i]);
	}
}

Measured memory_bytes: 9292
#include <iostream>

void solve() {
    int sum = 0;
    for (int i = 0; i < 5; ++i) {
        int x;
        std::cin >> x;
        sum += std::max(x, 40);
    }
    std::cout << sum / 5 << std::endl;
}

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

    solve();

    return 0;
}



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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((c - 1) / b <= (a - 1) / d) {cout << "Yes" << endl;}
    else {cout << "No" << endl;}

}


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


int main() {
  long long N,M,ans=0;
  cin>>N>>M;
  ll C[N];
  for (int i=0;i<N;i++){
    cin>>C[i];
  }
  sort(C,C+N);
  vector<pair<ll,ll>> B(M);
  for(int i=0;i<M;i++){
    cin>>B[i].second>>B[i].first;
  }
  sort(B.begin(),B.end());
  reverse(B.begin(),B.end());
  ll cnt=0;
  ll i=0;
  while(cnt<N&&i<M){
    if(lower_bound(C,C+N,B[i].first)-C-cnt>B[i].second){
      cnt+=B[i].second;
      ans+=B[i].first*B[i].second;
      //cout<<1<<" ";
    }
    else if(lower_bound(C,C+N,B[i].first)-C-cnt>0){
      
      ans+=B[i].first*(lower_bound(C,C+N,B[i].first)-C-cnt);
      cnt+=lower_bound(C,C+N,B[i].first)-C-cnt;
      //cout<<lower_bound(C,C+N,B[i].first)-C;
      //cout<<2<<" ";
    }
    //cout<<cnt<<" "<<i<<" "<<ans<<endl;
    i++;
  }
  if(cnt<N){
    ll a=N-cnt;
    for(int i=0;i<a;i++){
      ans+=C[N-1-i];
    }
  }
  cout<<ans;

}


Measured memory_bytes: 2560
#include<stdio.h>

int A[1000000],n;

int binarySearch(int key)
	{
		int left=0;
		int right=n;
		int mid;
		while(left < right)
		{
			mid = (left + right) / 2;
			if(key == A[mid]) return 1;
			if(key > A[mid] )left = mid + 1;
			else if(key < A[mid]) right = mid;
		}
		return 0;
	}

int main()
{
	int i,q,k,sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&A[i]);
	}
	
	scanf("%d",&q);
	for(i=0;i<q;i++)
	{
		scanf("%d",&k);
		if(binarySearch(k))sum++;
	}
	printf("%d\n",sum);
	
	return 0;
}

Measured memory_bytes: 3004
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)
#define ifaxb(a, x, b) if (a < x && x < b)
#define toInt(x) (x - '0')
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define vvs vector<vs>
#define all(x) x.begin(), x.end()
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
  int a,b;
  cin>>a>>b;
  int ans=max({a+b,a-b,a*b});
  cout<<ans<<endl;
  return 0;
}

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

ll merge(ll a[], ll l, ll m, ll r){
    ll n1 = m - l, n2 = r - m;
    ll L[n1+1], R[n2+1];
    rep(i, n1) L[i] = a[l + i];
    rep(i, n2) R[i] = a[m + i];
    L[n1] = LLONG_MAX;
    R[n2] = LLONG_MAX;
    ll i = 0, j = 0;
    for(ll k = l; k < r; k++)
        (L[i] <= R[j]) ? a[k] = L[i++] : a[k] = R[j++];
    return r - l;
}

ll merge_sort(ll a[], ll l, ll r){
    ll cnt = 0;
    if(l + 1 < r){
        ll m = (l + r)/2;
        cnt += merge_sort(a, l, m);
        cnt += merge_sort(a, m, r);
        cnt += merge(a, l, m, r);
    }
    return cnt;
}

int main(){
    ll n; cin >> n;
    ll s[n]; rep(i, n) cin >> s[i];

    ll cnt = merge_sort(s, 0, n);
    rep(i, n) cout << s[i] << char((i < n-1) ? ' ' : '\n');
    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 10808
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

void main(){

    int n = readln().chomp().to!int;
    for(int i=0;i<n;i++){
	auto s = readln().chomp().split(':');
	int h = s[0][0] == '0' ? to!int(s[0][1]-'0') : to!int(s[0]);
	int w = s[1][0] == '0' ? to!int(s[1][1]-'0') : to!int(s[1]);
	real angleh,anglew;
	h %= 12;
	angleh = to!real(h) / 12.0 * 360.0 + to!real(w) / 60.0 * 30.0;
	anglew = to!real(w) / 60.0 * 360.0;
	real angle = min(abs(angleh-anglew),360-abs(angleh-anglew));
	if(angle < 30.0) writeln("alert");
	else if(90 <= angle && angle <= 180) writeln("safe");
	else writeln("warning");
    }

}

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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;


int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n,d;
    cin >> n >> d;

    int one= 2*d+1;

    int ans = n/one;
    if(n%one!=0) ans++;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int h1, h2;
    cin >> h1 >> h2;
    int k1, k2;
    cin >> k1 >> k2;
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int h = h1 * a + (h1 / 10) * c + h2 * b + (h2 / 20) * d;
    int k = k1 * a + (k1 / 10) * c + k2 * b + (k2 / 20) * d;

    if (h > k)cout << "hiroshi" << endl;
    else if (h == k)cout << "even" << endl;
    else cout << "kenjiro" << endl;
    return 0;
}


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

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  
  ll ans = 0;
  
  for(int i=1; i<=n; i++){
    int tmp = 0;
    int j = i;
    
    while(j > 0){
      tmp += (j % 10);
      j /= 10;
    }
    
    ans += (a <= tmp && tmp <= b) ? i : 0;
  }
  
  cout << ans << endl;
}

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

long long f[300000];
int n;
map<int , int > a;
int main()
{
	long long ans=0;
	cin>>n;
	for(int i=1;i<=n;++i)
	  {
	  	   cin>>f[i];
	  	   a[f[i]+i]++;
	  }
	for(int i=1;i<=n;++i)
	  {
	  	   if(a[-(f[i]-i)]>0)
			  ans+=a[-(f[i]-i)]; 
	  }  
	cout<<ans<<endl;  
}

Measured memory_bytes: 22036
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define all(a) a.begin(), a.end()
#define x first
#define y second
#define MOD 1000000007
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  if (n > k)
    cout << (x * k + y * (n - k)) << endl;
  else
    cout << x * n << endl;
}

Measured memory_bytes: 3540
#include<iostream>
using namespace std;
int main()
{
 int a,b,c,x,i,j,k,s=0;
 cin>>a;
 cin>>b;
 cin>>c;
 cin>>x;
 
 for(i=0;i<=a;i++)
  for(j=0;j<=b;j++)
   for(k=0;k<=c;k++)
   {
    if(i*500+j*100+k*50==x)
    s++;
   }
   cout<<s<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N;cin >> N;
    LL ans = 0;
    for(int i = 1;i <= N;i++){
        if(i % 3 == 0)continue;
        else if(i % 5 == 0)continue;
        else ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
def B_Coins():
    A=int(input())
    B=int(input())
    C=int(input())
    X=int(input())
    count = 0
    
    for i in range(A+1):
        for j in range(B+1):
            y = (X-(500*i+100*j))/50
            if y >=0 and y <= C:
                count += 1
    print(count)

B_Coins()   

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main()
{
    IOS;
    ll w,h,x,y;
    cin>>w>>h>>x>>y;
    cout<<fixed;
    cout<<setprecision(10)<<((ld)w*h)/2;
    if(2*x==w && 2*y==h) 
    {
        cout<<" 1\n";
    }
    else cout<<" 0\n";
}
 

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

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

    string s, ns; cin >> s;
    int N = s.size();
    rep(i, N) if (s[i] != 'x') ns += s[i];
    int n = ns.size();
    rep(i, n) {
        if (ns[i] != ns[n-i-1]) {
            cout << -1 << endl;
            return 0;
        }
    }
    vector<int> cnt(n+11);
    int idx = 0;
    rep(i, N) {
        if (s[i] == 'x') ++cnt[idx];
        else ++idx;
    }
    int ans = 0;
    rep(i, (n+1) / 2) {
        ans += abs(cnt[i] - cnt[n-i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1104
s = input()
ans = [0] * len(s)
cnt = 1
prev = -1
for i in range(1,len(s)+1):
    if i == len(s) or s[i] != s[i-1]:
        if s[i-1] == "L":
            ans[prev-1] += cnt // 2
            ans[prev] += (cnt+1) // 2
        else:
            ans[i] += cnt // 2
            ans[i-1] += (cnt+1) // 2
        prev = i
        cnt = 1
    else:
        cnt += 1

print(" ".join(map(str,ans)))


Measured memory_bytes: 10484
import heapq
N = int(input())
G = [[] for i in range(N)]
for i in range(N - 1):
    a, b, c = map(int, input().split())
    a, b = a - 1, b - 1
    G[a].append([b, c])
    G[b].append([a, c])

Q, K = map(int, input().split())
K -= 1


def dijkstra(x):
    d = [float('inf')] * N
    d[x] = 0
    visited = {x}

    # d, u
    hq = [(0, x)]

    while hq:
        u = heapq.heappop(hq)[1]
        visited.add(u)

        for node, cost in G[u]:
            if (node not in visited) and d[node] > d[u] + cost:
                d[node] = d[u] + cost
                heapq.heappush(hq, (d[u]+cost, node))
    return d


dist = dijkstra(K)
for q in range(Q):
    x, y = map(int, input().split())
    x, y = x - 1, y - 1
    print(dist[x] + dist[y])


Measured memory_bytes: 60892
/**
 * @author yuzining
 * @date 2020/08/02 20:14
 */

#ifdef local
#include "D:\vscode\acm\local.hpp"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(...) do { } while(false)
void Main();
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
  return 0;
}
#endif

const int N = 2e5 + 10;

int a[N], n;

int64_t check(int x) {
  int64_t ans = 0;
  for(int i = 0; i < n; i++) {
    ans += (a[i] - 1) / x;
  }
  return ans;
}

void Main() {
  int k; cin >> n >> k;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int left = 1, right = 1000000000, ans = 1000000000;
  while(left <= right) {
    int mid = (left + right) >> 1;
    if(check(mid) <= k) {
      ans = mid;
      right = mid - 1;
    } else {
      left = mid + 1;
    }
  }
  cout << ans << '\n';
}

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

class Main {
    static Scanner scanner = new Scanner();
    static long mod = 1000000007;

    public static void main(String[]$) {
        int n = scanner.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        int d = -2;
        for (int i = 0; i <= n; i++) {
            int a = scanner.nextInt();
            if (map.containsKey(a)) {
                d = n - i + map.get(a);
            }
            map.put(a, i);
        }
        n++;

        long[] fac = new long[n + 1];
        long[] inv = new long[n + 1];
        fac[0] = inv[0] = 1;
        for (int i = 1; i <= n; i++) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = powAndMod(fac[i], mod - 2);
        }

        for (int i = 1; i <= n; i++) {
            long a = combination(n, i, fac, inv);
            if (d >= i - 1) {
                a = (a + mod - combination(d, i - 1, fac, inv)) % mod;
            }
            System.out.println(a);
        }
    }

    static long combination(int n, int r, long[] fac, long[] inv) {
        return fac[n] * inv[r] % mod * inv[n - r] % mod;
    }

    static long powAndMod(long a, long b) {
        return b == 0 ? 1 : b % 2 == 1 ? a * powAndMod(a, b - 1) % mod : powAndMod(a * a % mod, b / 2);
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

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

    int ans = inf;
    for (int i = -100; i <= 100; i++) {
        int tmp = 0;
        for (int j = 0; j < n; j++) {
            tmp += (a[j] - i) * (a[j] - i);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

int main() {
    ll A,B,K;
    cin >>A>>B>>K;
    
    const auto &res = enum_divisors(gcd(A,B));
    
    
    
    cout << res[res.size()-K] << endl;


    return 0;
    

}

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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

// #define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE     ;
#define dumpV(v);
#define STOP     ;
#endif
#define mp make_pair

namespace std {
template<class S, class T>
ostream &operator <<(ostream& out, const pair<S, T>& a) {
    out << '(' << a.fi << ", " << a.se << ')';
    return out;
}
}

vector<int> calc(ll n, ll x, ll y, bool rev) {
    if (x > n || y > n) {
        LINE;
        return vi{};
    }
    vector<int> len;
    ll m = n - x;
    len.pb(x);
    rep(i, y - 1) {
        {
            int k = 1;
            ll r = m;
            ll p = y - (ll)len.size() - 1;
            if (r > p) {
                k = min(x, r - p);
            }
            len.pb(k);
            m -= k;
            if(m<0 || k <= 0) {
                LINE;
                return vi{};
            }
        }
    }
    if(accumulate(all(len), 0LL) != n) {
        dumpV(len);
        LINE;
        return vi{};
    }
    vector<int> ans;
    queue<int> q;
    if(rev) {rep(i, n) q.push(i+1);}
    else {rep(i, n) q.push(n - i);}
    rep(i, y) {
        stack<int> st;
        rep(j, len[i]) {
            st.push(q.front());
            q.pop();
        }
        while (!st.empty()) {
            ans.pb(st.top());
            st.pop();
        }
    }
    return ans;
}

int main() {
    ll n, x, y;
    cin >> n >> x >> y;
    vector<int> ans = calc(n, x, y, false);
    if(ans.empty()) {
        ans = calc(n, y, x, true);
    }
    if(ans.empty()) {
        cout << -1 << endl;
        return 0;
    }
    rep(i, n) {
        if (i != 0) cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4788
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    6月で水色になるぞ〜!!!
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{one, zero, One, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

pub const MOD: usize = 1000000007;
pub const MAX: usize = 1usize << 63usize;
pub const MIN: i64 = i64::MIN;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 'A' as u8;

// code...
// #[fastout]
fn main() {
    input! {
        n: usize, k: usize,
        mut a: [usize; n]
    }

    a.sort();
    let ans = a.iter().take(k).sum::<usize>();
    println!("{}", ans);
}


Measured memory_bytes: 2156
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int K=stdIn.nextInt();
		String S=stdIn.next();
		if(S.length()<=K)
			System.out.println(S);
		else
			System.out.println(S.substring(0,K)+"...");
	}
}


Measured memory_bytes: 38640
N,X = map(int,input().split())
L = [1]
for i in range(50) :
    L.append(L[-1]*2+3)
def dp(n,x) :
    if x == 0 :
        return 0
    elif n == 0 :
        return 1
    else :
        if x == 1 :
            return 0
        elif x <= L[n-1]+1 :
            return dp(n-1,x-1)
        elif x == L[n-1]+2 :
            return dp(n-1,x-1)+1
        elif x <= L[n]-1 :
            return dp(n-1,x-1)+1+dp(n-1,x-L[n-1]-2)
        else :
            return dp(n-1,x-1)*2+1
ans = dp(N,X)
print(ans)


Measured memory_bytes: 3064
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
#define int long long
using namespace std;
using point = pair< int,int >;

signed main() {
    int a, b;
    REP (i, 7) {
        cin >> a >> b;
        OUT(a - b);
    }
    return 0;
}




Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

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

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int A, B; cin >> A >> B;
  if ((A + B) % 2 == 0) cout << (A + B) / 2 << endl;
  else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256