akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, s, e) for (ll i = s; i < e; i++)
#define Forr(i, s, e) for (ll i = s; i > e; i--)
#define pb push_back
#define ll long long
#define int ll
#define mp make_pair
#define infi 1e12
const ll mod = 1e9 + 7;
vector<ll> lol;
ll n;
ll dfs(vector<vector<ll>> &v, ll node, ll p)
{
    ll count = 0;
    for (auto itr : v[node])
    {
        if (itr != p)
        {
            count += dfs(v, itr, node);
        }
    }
    if (p != -1)
    {
        ll x = (count + 1) * (n - count - 1);
        lol.pb(x);
    }
    return count + 1;
}
signed main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(8);
    ll n, x, t;
    cin >> n >> x >> t;
    ll xx = n % x == 0 ? n / x : (n / x) + 1;
    cout << xx * t << endl;
    return 0;
}

Measured memory_bytes: 3588
open List
open Str
open Printf

let solve n vs cs = combine vs cs
    |> map (fun (v, c) -> v - c)
    |> filter (fun x -> x > 0)
    |> fold_left ( + ) 0

let read_ints () = read_line ()
    |> split (regexp " ")
    |> map int_of_string

let () = begin
    let n = read_line () |> int_of_string in
    let vs = read_ints () in
    let cs = read_ints () in
    solve n vs cs |> printf "%d\n"
end

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
    ll a;
    cin>>a;
    cout<<a+(a*a)+(a*a*a)<<endl;
}
return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,d,x;
  cin>>n>>d>>x;
  int ans=0;
  rep(i,0,n){
    int a;
    cin>>a;
    ans+=(d-1)/a+1;
  }
  cout<<ans+x<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		
		int[] a = new int[1000];
		
		for(int i=0; i<n; i++){
			a[i] = scan.nextInt();}
			
		for(int i=n-1; i>=0; i--){
			System.out.print(a[i]);
			if(i!=0){
				System.out.print(" ");}}
			
		System.out.print("\n");
	}
}


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

int main() {
 int a,b;
cin >> a >> b;
int kura = max(a,b);
int tugi = max(a,b) -1;
if(kura + tugi >= a+b){
  cout << kura + tugi << endl;
}
else{
  cout << a+b << endl;
}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> B(N,0);
  for (int i = 0; i < N - 1; i++){
    int A;
    cin >> A;
    B.at(A - 1)++;
  }
  
  for (int i = 0; i < N; i++){
    cout << B.at(i) << endl;
  }
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  vector<string> ss(1);
  cin>>ss.at(0);
  for(int i=1;i<n;i++){
    string s;
    cin>>s;
    string prev_s=ss.at(i-1);
    char prev_last=prev_s.at(prev_s.size()-1);
    char s_first=s.at(0);
    if(prev_last!=s_first){
      cout<<"No"<<endl;
      return 0;
    }
    for(int j=0;j<ss.size();j++){
      if(ss.at(j)==s){
        cout<<"No"<<endl;
        return 0;
      }
    }
    ss.push_back(s);
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define INF (long)1e9
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	for(int i = 97; i <= 122; i++)
	{
		char tmp = i;
		if(s.find(i) != -1)
			continue;
		cout << tmp << endl;
		return 0;
	}
	cout << "None" << endl;
	return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n,l,sum,mn=1e9,ans;
int abs(int x){return x>0?x:-x;}
int main(){
	scanf("%d%d",&n,&l);
	for(int i=1;i<=n;i++)sum+=l+i-1;
	for(int i=1;i<=n;i++)if(abs(l+i-1)<mn)mn=abs(l+i-1),ans=sum-(l+i-1);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
//	ZapZu's code hohoho
//	#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define dfs_black 1
#define dfs_white -1
#define pr pair
#define vt vector
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef double db;
typedef long long li;
typedef long double ld;

typedef pr<int, int> ii;
typedef pr<ld,ld> dd;

typedef vt<int> vi;
typedef vt<li> vli;
typedef vt<ld> vld;
typedef vt<ii> vii;

typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, char> mic;

typedef set<int> s_i;
typedef set<char> s_c;

const int MOD = 1e9+7;
const li INF = 1e18;
const ld PI = 4*atan((ld)1);
vi v[2];
int calc(int x)
{
	if(x>=0) 
	{
		int ans=0;
		for(int msk=0; msk<2; msk++)
		{
			int p=-1;
			for(int i=v[msk].size()-1; i>=0; i--)
			{
				while(p+1<v[msk].size() and v[msk][p+1]*v[msk][i]<=x) p++;
				ans+=p+1;
//				cout<<msk<<" "<<p<<endl;
			}
			for(int i=0; i<v[msk].size(); i++)
			{
				if(v[msk][i]*v[msk][i]<=x) ans--;
			}
		}
		ans=ans/2+v[0].size()*v[1].size();
		return ans;
	}
	else
	{
		int ans=0;
		int p=v[1].size();
		for(int i=0; i<v[0].size(); i++)
		{
			while(p-1>=0 and v[1][p-1]*v[0][i]>=-x) p--;
//			cout<<v[1][p]*v[0][i]<<endl;
//			cout<<p<<endl;
			ans+=(v[1].size()-p);
		}
		return ans;
	}
}
signed main()
{
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
	int n;
	cin>>n;
	int k;
	cin>>k;
	for(int i=1; i<=n; i++)
	{
		int temp;
		cin>>temp;
		if(temp<0) v[0].eb(-temp);
		else v[1].eb(temp);
	}
	sort(begin(v[0]), end(v[0]));
	sort(begin(v[1]), end(v[1]));
	
	int ll=-1e18, rr=1e18;
	while(ll<rr)
	{
		int mid=ll+(rr-ll)/2;
//		cout<<ll<<" "<<rr<<" "<<mid<<endl;
//		cout<<calc(mid)<<endl;
		if(calc(mid)>=k) rr=mid;
		else ll=mid+1;
	}
	cout<<ll;
}




Measured memory_bytes: 2548
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <algorithm>
using namespace std;
 
typedef long long ll;
ll mod = 1e9+7;
int a[200010];
int n;
int k;
bool check(int x)
{
    if(x==0)    return false;
    int p=0;
    for(int i=0;i<n;i++)
    {
        p+=a[i]/x;
        if(a[i]%x==0)   p--;
        if(p>k) return false;
    }
    return true;
}

int main()
{
    
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    
    int l=1,r=1e9;
    int ans;
    while(l<=r)
    {
        int mid=(l+r)>>1;
        //cout<<mid<<endl;
        if(check(mid))
        {
            ans=mid;
            r=mid-1;
        }
        else    l=mid+1;
    }
    cout<<ans<<endl;



     
    int ab;
    cin>>ab;
}

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

const int MAX = 200000;
const int MOD = 1000000007;

int fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int h,w,a,b,ans;
signed main(){
    cin>>h>>w>>a>>b;
    COMinit();
    for(int i=b;i<w;i++){
        (ans+=(COM(h-a-1+i,i)*COM(a-1+w-i-1,a-1)))%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=100005;

int n,cnt,last[N],bit[N],ans,bin[25];
struct edge{int to,next;}e[N*2];

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

void addedge(int u,int v)
{
	e[++cnt].to=v;e[cnt].next=last[u];last[u]=cnt;
	e[++cnt].to=u;e[cnt].next=last[v];last[v]=cnt;
}

void dfs(int x,int fa)
{
	int l=0;
	for (int i=last[x];i;i=e[i].next)
	{
		if (e[i].to==fa) continue;
		dfs(e[i].to,x);
		l|=bit[x]&bit[e[i].to];
		bit[x]|=bit[e[i].to];
	}
	int mx=20;
	while (mx>=0&&!(l&bin[mx])) mx--;
	mx++;
	while (bit[x]&bin[mx]) mx++;
	bit[x]|=bin[mx];bit[x]=bit[x]>>mx<<mx;
	ans=max(ans,mx);
}

int main()
{
	bin[0]=1;
	for (int i=1;i<=20;i++) bin[i]=bin[i-1]*2;
	n=read();
	for (int i=1;i<n;i++)
	{
		int x=read(),y=read();
		addedge(x,y);
	}
	dfs(1,0);
	printf("%d",ans);
	return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	int A[1000];
	cin >> N;
	rep(i, 0, N)
	{
		cin >> A[i];
	}

	sort(A, A + N);

	int sum = 0;
	rep(i, 0, N - 1)
	{
		sum+= A[i];
	}

	if (sum <= A[N - 1])
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}

	return 0;
}

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

int main(){
    int n;
    while(cin>>n){
        int ans=0;
        if(n>36)
            cout << 0 << endl;
        else{
            int m = 10;
            for(int i=0;i<m;i++){
                for(int j=0;j<m;j++){
                    for(int k=0;k<m;k++){
                        for(int l=0;l<m;l++){
                            if(i+j+k+l==n)
                                ans++;
                        }
                    }
                }
            }
            cout << ans << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3048
import sys
sys.setrecursionlimit(500000)

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    if r < 0:
        return 0
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


def main():
    N, K = mi()
    MOD = 10**9+7
    for i in range(1, K+1):
        a = combination(N-K+1, i)*combination(K-1, i-1)
        print(a%MOD)



if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
void dfs(int,int,int,V);
int g,d;
int cnt;
V memo(inf);
V p(10),c(10);
int main(){
    cin>>d>>g;
    rep(i,d){
        cin>>p[i]>>c[i];
    }
    V visit(d);
    rep(i,d){
        dfs(i,0,0,visit);
    }
    sort(ALL(memo));
    memo.erase(unique(ALL(memo)),memo.end());
    /*rep(i,(int)memo.size()){
        printf("cnt=%d\n",memo[i]);
    }*/
    cout<<memo[1]<<endl;
}
void dfs(int depth,int sum,int cnt,V visited){
    visited[depth]=1;
    int pos_P=p[depth];
    bool comp=true;
    rep(i,pos_P){
        sum+=100*(depth+1);
        cnt++;
        if(sum>=g){
            comp=false;
            break;
        }
    }
    if(comp)sum+=c[depth];
    if(sum>=g){
        //printf("cnt=%d\n",cnt);
        memo[cnt]=cnt;
        return;
    }
    //printf("depth=%d,sum=%d,cnt=%d\n",depth,sum,cnt);
    for(int j=0;j<d;j++){
        if(visited[j])continue;
        dfs(j,sum,cnt,visited);
    }
}


Measured memory_bytes: 4096
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////
struct Brush {
    int res;

    int N;
    vector<int> cnt;
    vector<int> h;

    Brush(int _N) {
        res = 0;
        N = _N;
        cnt.assign(N, 0);
        h.assign(N, 0);
    }

    int Update(int val, int delta) {
        int p = 0;

        if (delta == 1) {
            h[val]++;
            p = val - h[val] + 1;

            if (p >= 1 && p <= N) {
                cnt[p]++;
                if (cnt[p] == 1) {
                    res++;
                }
            }
        } else {
            h[val]--;
            p = val - h[val];

            if (p >= 1 && p <= N) {
                cnt[p]--;
                assert(cnt[p] >= 0);
                if (!cnt[p]) {
                    res--;
                }
            }
        }

        return res;
    }
};

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

    int N, M;

    cin >> N >> M;

    vector<int> A(N);
    
    Brush brush(N + 1);

    int len = 0;

    for (int i = 0; i < N; i++) {
        cin >> A[i];
        len = brush.Update(A[i], 1);
    }

    auto Debug = [&] () {
        cerr << "Brush\n";    
        for (int i = 1; i <= N; i++) {
            cerr << i << " " << brush.h[i] << " " << brush.cnt[i] << "\n";
        }
        cerr << "len = " << len << "\n";
    };

    //Debug();

    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;

        x--;

        len = brush.Update(A[x], -1);
        A[x] = y;
        len = brush.Update(A[x], 1);

        //Debug();

        cout << N - len << "\n";
    }

    return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

bool dp[100001];

int main(){	
	long long X;
	scanf("%lld",&X);
	dp[0] = true;
	rep(i, 100001) {
		if (dp[i] && i+100 <= 100000) dp[i+100] = true;
		if (dp[i] && i+101 <= 100000) dp[i+101] = true;
		if (dp[i] && i+102 <= 100000) dp[i+102] = true;
		if (dp[i] && i+103 <= 100000) dp[i+103] = true;
		if (dp[i] && i+104 <= 100000) dp[i+104] = true;
		if (dp[i] && i+105 <= 100000) dp[i+105] = true;
	}
	if (dp[X]) cout << "1" << endl; else cout << "0" << endl;
	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int X,Y,A,B,C;
    cin >> X >> Y >> A >> B >> C;
    int i,j;
    long long int p;
    long long int q;
    long long int r;
    long long int sum = 0;
    vector<long long int> aka;
    vector<long long int> mido;
    vector<int> mus;
    for(i=0;i<A;i++){
        cin >> p;
        aka.push_back(p);}
    for(i=0;i<B;i++){
        cin >> q;
        mido.push_back(q);}
    for(i=0;i<C;i++){
        cin >> r;
        mus.push_back(r);}
    sort(aka.begin(),aka.end(),greater<int>());
    sort(mido.begin(),mido.end(),greater<int>());
    for(i=0;i<X;i++)mus.push_back(aka.at(i));
    for(i=0;i<Y;i++)mus.push_back(mido.at(i));  
    sort(mus.begin(),mus.end(),greater<int>());
    for(i=0;i<X+Y;i++)sum += mus.at(i);
        cout << sum << endl;
}

Measured memory_bytes: 3956
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)

int main()
{
  int N, T, A;
  cin >> N;
  cin >> T >> A;
  int h[N];
  int diff = 10000 * 10000;
  int num = 0;
  rep(i, N)
  {
    cin >> h[i];
    int temp = T * 1000 - h[i] * 6;
    if (abs(A * 1000 - temp) < diff)
    {
      diff = abs(A * 1000 - temp);
      num = i + 1;
    }
  }

  cout << num;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int A, B, K;
int s[100];
int main(){
  cin >> A >> B >> K;
  int counter =0;
  for(int i=100; i>=1; i--){
    if (A%i == 0 && B%i ==0){
      s[counter] = i;
      counter++;
    }
  }
  cout << s[K-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define fill(x, y)     memset(x, y, sizeof(y))
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define rep(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
#define repi(i, x, y)  for (__typeof(x) i = x; i >= y; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
const   int            inf = 0;
const   double         eps = 0;
const   int            ms  = 0;
const   int            md  = 0;


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


	return 0;
}


Measured memory_bytes: 3640
a1, b1 = (int(i) for i in raw_input().split(' '))
a2, b2 = (int(i) for i in raw_input().split(' '))
a3, b3 = (int(i) for i in raw_input().split(' '))


def func():
    count_1 = 0
    count_2 = 0
    count_3 = 0
    count_4 = 0
    for x in [a1,a2,a3,b1,b2,b3]:
        if x == 1:
            count_1 += 1
        elif x == 2:
            count_2 += 1
        elif x ==3:
            count_3 += 1
        elif x ==4:
            count_4 += 1
        else:
            print('error')

    for count in [count_1, count_2,count_3,count_4]:
        if count == 0 or count >= 3:
            print('NO')
            return
    print('YES')

func()


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

using namespace std;

namespace {
    string s;
    int X;
    void input() {
        cin >> s;
        cin >> X;
    }

    int calc(char op, int a, int b) {
        if (op == '+') return a + b;
        if (op == '*') return a * b;
        assert(0);
    }

    int number(const string& s, int& index) {
        int r = 0;
        while (index < s.size() && isdigit(s[index])) {
            r = r * 10 + (s[index] - '0');
            index++;
        }
        return r;
    }

    int L(const string& s, int& index) {
        int r = number(s, index);
        while (index < s.size()) {
            char op = s[index++];
            int a = number(s, index);
            r = calc(op, r, a);
        }
        return r;
    }

    int term(const string& s, int& index) {
        int r = number(s, index);
        while (index < s.size() && s[index] == '*') {
            index++;
            int a = number(s, index);
            r *= a;
        }
        return r;
    }

    int M(const string& s, int& index) {
        int r = term(s, index);
        while (index < s.size()) {
            assert(s[index] == '+');
            index++;
            int a = term(s, index);
            r += a;
        }
        return r;
    }

    void solve() {
        int index = 0;
        int m = M(s, index);
        index = 0;
        int l = L(s, index);
        if (m == X && l == X) {
            cout << "U" << endl;
        } else if (m != X && l != X) {
            cout << "I" << endl;
        } else if (m == X) {
            cout << "M" << endl;
        } else if (l == X) {
            cout << "L" << endl;
        }
    }
}

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

Measured memory_bytes: 1200
import copy
N=int(input())
A=list(map(int,input().split()))
A.sort()
B=list(map(int,input().split()))
B.sort()
C=list(map(int,input().split()))
C.sort()
l1n=[-1 for _ in range(N)]
l2n=[-1 for _ in range(N)]
idab=0
idbc=0
buf1=[]
flag1=0
buf2=[]
flag2=0
i=0
#print(A)
#print(B)
#print(C)
exc=0
mulsum=[0]*N
while i<N:
    if (idab!=N)and(A[i]>=B[idab]):
        flag1=1
        idab=idab+1
    elif flag1==1:
        l1n[i]=idab-1
        i=i+1
    else:
        i=i+1
    #print(l1n)
    #input()
#print(l1n)
i=0
while i<N:
    if (idbc!=N)and(B[i]>=C[idbc]):
        flag2=1
        idbc=idbc+1
    elif flag2==1:
        l2n[i]=idbc-1
        i=i+1
    else:
        i=i+1
    #print(l2n)
    #input()
#print(l1n,l2n)
#print(sum(l1n)+N,sum(l2n)+N)
mulsum[0]=l2n[0]+1
for i in range(N-1):
    mulsum[i+1]=mulsum[i]+(l2n[i+1]+1)
#print(mulsum)
for i in range(N):
    if l1n[i]!=-1:
        exc=exc+mulsum[l1n[i]]
        #print(exc)
print(pow(N,3)-(sum(l1n)+N)*N-(sum(l2n)+N)*N+exc)

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

#define int long long

main()
{
  int n, a, b;

  cin >> n >> a >> b;

  if(a > b) cout << 0 << endl;
  else if(a == b) cout << 1 << endl;
  else if(n == 1) cout << 0 << endl;
  else {
    n -= 2;
    cout << (b - a) * n + 1 << endl;
  }

  return (0);

}


Measured memory_bytes: 256
def main():
    K, N = map(int, input().split())
    A = list(map(int, input().split()))
    diff = [A[i + 1] - A[i] for i in range(N - 1)]
    diff.append(A[0] + K - A[-1])
    print(K-max(diff))

if __name__ == '__main__':
    main()

Measured memory_bytes: 86140
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid  + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left; k<right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if(p<r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++) {
    // マージソートとクイックソートの結果を比べる
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}


Measured memory_bytes: 4068
Public Class Program
  Shared Sub Main()
    Dim ab As Integer() = Array.ConvertAll(Of String, Integer)(Console.ReadLine().Split(" "), AddressOf Integer.Parse)
    Dim a As Integer = ab(0)
    Dim b As Integer = ab(1)
    a = If(a > 9, 0, a)
    b = If(b > 9, 0, b)
    Dim ans As Integer = a * b
    Console.WriteLine(If(ans = 0, -1, ans).ToString())
  End Sub
End Class

Measured memory_bytes: 13140
import Data.Char
import Data.List

main :: IO ()
main = getLine >>= putStrLn . solve

solve :: String -> String 
solve s
    | check s = "AC"
    | otherwise = "WA"
    where
        check ('A' : x : xs) = length ys == 1 && all isLower (last xs : x : zs)
            where
                (ys, zs) = partition ('C' ==) $ init xs
        check _ = False

Measured memory_bytes: 508
//JSD
#include<iostream>
#include<algorithm>
using namespace std;
void pfs(long long int n){
	int ans=0;
	for(long long int i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			ans++;
			while(n%i==0)
			{
				n=n/i;
			}
		}
	}
	if(n>1)
	{
		ans++;
	}
	cout<<ans+1;
}
int main(){
	long long a,b;
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>a>>b;	
	long long int x=__gcd(a,b);
	pfs(x);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ll a[3][3];
  for(int i=0;i<3;i++){
	  for(int j=0;j<3;j++){
		  cin>>a[i][j];
	  }
  }

  ll n;
  cin>>n;
  vector<ll> v;
  while(n--){
	  ll b;
	  cin>>b;
	  v.push_back(b);
  }

  for(int i=0;i<v.size();i++){

	  for(int j=0;j<3;j++){
		  for(int k=0;k<3;k++){
			  if(a[j][k] == v[i])
			  a[j][k] = 0;
		  }
	  }

  }
  ll p = 0;
  for(int i=0;i<3;i++){
	  ll m = 0;
	  for(int j=0;j<3;j++){
		  if(a[i][j] == 0)
		  m++;
	  }
	  if(m == 3){

	  p= 1;
	  break;
      }
	  else
	  {
		  m = 0;
	  }  
  }

  for(int j=0;j<3;j++){
	  ll m = 0;
	  for(int i=0;i<3;i++){
		  if(a[i][j] == 0)
		  m++;
	  }
	  if(m == 3){
		  p = 1;
		  break;
	  }
	  else m =0;

  }
  ll k =0 ,m= 0;
  for(int i=0;i<3;i++){
	  if(a[i][k] == 0){
		  m++;
	  }
	  k++;
	
  }
if(m == 3)
p = 1;

m=0;

k--;
  for(int i=0;i<3;i++){
	  if(a[i][k] == 0){
        m++;
	  }
	  k--;
  }

  if(m == 3){
	  p = 1;
  }

  if(p)
  cout<<"Yes"<<endl;
  else
  {
	  cout<<"No"<<endl;
  }
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back

void setIO(string s) 
{
	//ios_base::sync_with_stdio(0); cin.tie(0); 

	//freopen((s+".in").c_str(),"r",stdin);
	//freopen((s+".out").c_str(),"w",stdout);
}
int n;
string s;
void solve()
{
    cin>>n>>s;
    int r = count(s.begin(), s.end(), 'R');
    int ans = r;
    for (int i=0; i < r; ++i)
    {
        ans -= (s[i] == 'R');
    }
    printf("%lld\n", ans);
}
signed main(void)
{
    //setIO("exercise");
    int T = 1; //scanf("%lld", &T);
    while(T--) solve();
    return 0;
}

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

#define N 100001

struct str{
		int s;
		int t;
		int c;
};

int compare_int(const void *a, const void *b){
    struct str A=*(struct str*)a;
	struct str B=*(struct str*)b;
	if(A.c>B.c)return 1;
	else if(B.c>A.c)return -1;
	return A.s-B.s;
}

int main(){
		int n,c,i,max=0;
		int stc[N][3];
		struct str ss[N];
		scanf("%d%d",&n,&c);
		for(i=0;i<n;i++){
				scanf("%d%d%d",&stc[i][0],&stc[i][1],&stc[i][2]);
				ss[i].s=stc[i][0];
				ss[i].t=stc[i][1];
				ss[i].c=stc[i][2];
				if(max<ss[i].t)max=ss[i].t;
		}
		qsort(ss,n,sizeof(struct str),compare_int);
		for(i=1;i<n;i++){
				if(ss[i].c==ss[i-1].c){
						if(ss[i-1].t==ss[i].s){
								ss[i].s=ss[i-1].s;
								ss[i-1].s=0;
								ss[i-1].t=0;
						}
				}
		}
		int imo[N]={0};
		for(i=0;i<n;i++){
				if(ss[i].s==ss[i].t)continue;
				imo[ss[i].s-1]++;
				imo[ss[i].t]--;
		}
		for(i=1;i<=max;i++)imo[i]+=imo[i-1];
		int ans=0;
		for(i=0;i<=max;i++){
				if(ans<imo[i])ans=imo[i];
		}
		printf("%d\n",ans);
		return 0;
}


Measured memory_bytes: 3964
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
//#define maxi 1e18
#define pll pair<ll,ll>
#define inf 1000000007
#define mod 998244353
map<ll,ll> m;
int main(){
    double n;
    cin>>n;
    ll k=1ll*n;
    cout<<fixed<<setprecision(15);
    if(k%2==0)cout<<0.5000000000000000;
    else cout<<(((n-1)/2)+1)/n;
    /*for(i=0;i<n+3;i++){
        cout<<v[i]<<endl;
    }
    ll n,i;
    cin>>n;
    ll a[n];
    vector<vector<ll> > v(2);
    for(i=0;i<n;i++){
        cin>>a[i];
        ll r=sqrt(a[i]);
        if(a[i]!=r*r){
            if(a[i]-r*r<(r+1)*(r+1)-a[i]){
                v[0].pb(a[i]-r*r);
            }
            else v[0].pb((r+1)*(r+1)-a[i]);
        }
        else if(a[i]==0){
            v[2].pb(0);
        }
        else {
            v[1].pb(0);
        }
    }
    ll sum=0,cnt=0;
    sort(all(v[0]));
    sort(all(v[1]));
    for(i=0;i<v[0].size();i++){
        sum+=v[0][i];
    }
   // cout<<v[0].size()<<endl;
    for(i=1ll*v[0].size()-1;i>=0;i--){
           // cout<<"HI"<<endl;
        if(cnt<n/2){sum-=v[0][i];cnt++;}
        else break;
    }
    ll diff=(n/2)-cnt;
    while(diff>0){
        for(i=v[1].size()-1;i>=0;i--){
            if(diff>0){
                diff--;
                sum++;
            }
            else break;
        }
    }
    cout<<sum<<endl;
   /*
    ll n,don=0;
    cin>>n;
    ll i,z=0;
    ll a[n];
    ll sum=0;
    vector<ll> ans;
    for(i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        if(a[i]==0){
            z=1;
        }
    }
    sort(a,a+n);
    if(!z){
        cout<<-1;
        return 0;
    }
   ll  nz=0;
    if(sum%3==0){
        for(i=0;i<n;i++){
            ans.pb(a[i]);
            if(a[i]!=0)nz=1;
        }
        if(!nz){
            ans.clear();ans.pb(0);
        }
    }
    else if(sum%3==1){
        for(i=0;i<n;i++){
            if(!don&&a[i]%3==1){
                don=1;
            }
            else ans.pb(a[i]);
        }
         if(!don){
                ans.clear();
                don=-1;
            for(i=0;i<n;i++){
                if(don<1&&a[i]%3==2){
                    don++;
                }
                else ans.pb(a[i]);
            }
        }
        if(don<1){
            cout<<-1;
            return 0;
        }
    }
    else{
        for(i=0;i<n;i++){
            if(a[i]%3==2)don=1;
            else ans.pb(a[i]);
        }
        if(!don){
                ans.clear();
                don=-1;
            for(i=0;i<n;i++){
                if(don<1&&a[i]%3==1){
                    don++;
                }
                else ans.pb(a[i]);
            }
        }
        if(don<1){
            cout<<-1;
            return 0;
        }
    }
    reverse(all(ans));
    for(i=0;i<ans.size();i++){
        cout<<ans[i];
    }*/
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int Y, M, D;
	char S1, S2;

	cin >> Y >> S1 >> M >> S2 >> D;

	if (M > 4) {
		cout << "TBD" << endl;
	}
	else {
		cout << "Heisei" << endl;
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,A,B;
    cin>>N>>A>>B;
    int p[100] = {0};
    REP(i,N)cin>>p[i];
    VI x1,x2,x3;
    REP(i,N)if(p[i] <= A)x1.PB(p[i]);
    REP(i,N)if(A < p[i] && p[i] <= B)x2.PB(p[i]);
    REP(i,N)if(B < p[i])x3.PB(p[i]);
    PUTS(min(x1.size(), min(x2.size(), x3.size())));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

#define int long long

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

	vector<int> c(3);
	rep(i,3) c[i] = i + 1;
	rep(i,n){
		vector<int> nx(3);

		int sum = accumulate(all(c),0LL);
		nx[0] = 1;
		nx[1] = sum;
		nx[2] = sum + 1;

		c = vector<int>(all(nx));
	}
	cout << c[1] << endl;
}


Measured memory_bytes: 256
data = input().rstrip().split()
mat=[[1 for i in range(int(data[1]))] for j in range(int(data[0]))]
n = input().rstrip().split()
#print(mat)
for i2 in range(int(n[0])):
  for k in range(int(data[1])):
    mat[i2][k]=0
#print(mat)
for j2 in range(int(n[1])):
  for k in range(int(data[0])):
    mat[k][j2]=0
ans=0
for l in range(len(mat)):
  ans+=sum(mat[l])
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N;
std::vector<LL>C,S,F;

int main()
{
	in>>N;
	C.resize(N-1);
	S.resize(N-1);
	F.resize(N-1);
	rep(i,N-1){in>>C[i]>>S[i]>>F[i];}

	rep(i,N-1)
	{
		LL ans=0;
		for(int j=i;j<N-1;++j)
		{
			if(ans<=S[j]){ans=S[j];}
			else{ans=ans/F[j]*F[j]+(ans%F[j]!=0?F[j]:0LL);}
			ans+=C[j];
		}
		out<<ans<<std::endl;
	}
	out<<0LL<<std::endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i=0; i<n; i++) a[i] = sc.nextInt();

        long ans = 0;

//        Arrays.sort(a);

        Map<Long, Long> map = new HashMap<>();

        for (int i=0; i<n; i++){
            if (map.containsKey(a[i])){
                long c = map.get(a[i]);
                map.put(a[i], ++c);
            }else {
                map.put(a[i], 1l);
            }
        }

        for (Long key: map.keySet()){
            if (key<map.get(key)){
                ans += (map.get(key)-key);
            }else if (key>map.get(key)){
                ans += map.get(key);
            }

        }
//        System.out.println(map);
        System.out.println(ans);

    }
}

Measured memory_bytes: 58360
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T=ll>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

class mod_int{
private:
    unsigned long long num;
public:
    static constexpr unsigned long long mod=1000000007;
    static mod_int pow(mod_int x,unsigned long long y)
    {
        return y==0?1:y%2==0?pow(x*x,y/2):x*pow(x,y-1);
    }
    mod_int()=default;
    mod_int(unsigned long long n):num(n%mod)
    {
    }
    explicit operator unsigned long long()const
    {
        return num;
    }
    bool operator==(const mod_int&mi)const
    {
        return num==mi.num;
    }
    bool operator!=(const mod_int&mi)const
    {
        return !operator==(mi);
    }
    mod_int operator~()const
    {
        return pow(*this,mod-2);
    }
    mod_int operator+(const mod_int&mi)const
    {
        return num+mi.num;
    }
    mod_int operator-(const mod_int&mi)const
    {
        return num+mod-mi.num;
    }
    mod_int operator*(const mod_int&mi)const
    {
        return num*mi.num;
    }
    mod_int operator/(const mod_int&mi)const
    {
        return num*(~mi).num;
    }
    mod_int&operator+=(const mod_int&mi)
    {
        return*this=operator+(mi);
    }
    mod_int&operator-=(const mod_int&mi)
    {
        return*this=operator-(mi);
    }
    mod_int&operator*=(const mod_int&mi)
    {
        return*this=operator*(mi);
    }
    mod_int&operator/=(const mod_int&mi)
    {
        return*this=operator/(mi);
    }
};
class combination_modulo:mod_int{
private:
    vector<mod_int>factorial_mod;
public:
    combination_modulo(unsigned long long max_n):factorial_mod(max_n+1)
    {
        factorial_mod[0]=1;
        for(unsigned long long i=1;i<=max_n;++i)factorial_mod[i]=factorial_mod[i-1]*i;
    }
    mod_int operator()(unsigned long long n,unsigned long long r)
    {
        return n<r?0:factorial_mod[n]/(factorial_mod[r]*factorial_mod[n-r]);
    }
};
int main()
{
    ll x=in(),y=in();
    if((2*y-x)%3!=0||(2*x-y)%3!=0){
        cout<<0<<endl;
    }else{
        ll a=(2*y-x)/3,b=(2*x-y)/3;
        if(a<0||b<0){
            cout<<0<<endl;
        }else{
            combination_modulo cm(a+b);
            cout<<(unsigned long long)cm(a+b,a)<<endl;
        }
    }
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mod 1000000007
#define ss second
#define ff first
#define vpii vector<pii>
#define vvi vector<vi>
#define pb push_back
#define vs vector<string>
#define all(x) x.begin(),x.end()
#define mii map<int,int>
const int inf=0x3f3f3f3f3f3f3f3f;
void print(vi &v){
    for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
    cout<<endl;
}
int power(int a,int b){
    int res = 1;
    while(b!=0){
        if(b&1){
            res *= a; 
        }
        a = (a * a);
        b = (b / 2);
    }
    return res;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t = 1;
    while(t--){
        int n,x,y,i,j;
        cin>>n>>x>>y;
        vvi v(n+1,vi(n+1,0));
        for(i=1;i<=n;i++){
        	for(j=1;j<=n;j++){
        		v[i][j] = abs(i-j);
        	}
        }
        v[x][y] = 1;
        v[y][x] = 1;
        for(i=1;i<=n;i++){
        	for(j=1;j<=n;j++){
        		v[i][j] = min(v[i][j],v[i][x]+v[x][j]);
        	}
        }
        for(i=1;i<=n;i++){
        	for(j=1;j<=n;j++){
        		v[i][j] = min(v[i][j],v[i][y]+v[y][j]);
        	}
        }
        mii m;
        for(i=1;i<=n;i++){
        	for(j=i+1;j<=n;j++){
        		m[v[i][j]]++;
        	}
        }
        for(i=1;i<n;i++)cout<<m[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 31744
#include <set>
#include <map>
#include <ctime>
#include <cmath>
#include <queue>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define PII pair<int,int>
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,b,a) for (int i=(b);i>=(a);--i)
typedef long long LL;
inline int read(){
	int x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}

const int MAXN=300005;
const double eps=1e-8,INF=1e20,PI=3.141592653589793238462;
int n,m,a[MAXN],d[MAXN],f[MAXN],s[MAXN];
struct list{
	int l,lt[MAXN],nt[MAXN],x[MAXN];
	void clear(){ l=0; memset(lt,0,sizeof(lt)); }
	void addedge(int a,int b){ l++; nt[l]=lt[a]; lt[a]=l; x[l]=b; }
}E;
void dfs(int x,int fa){
	d[x]=d[fa]+1; f[x]=fa; s[x]=1;
	for (int i=E.lt[x];i;i=E.nt[i]) {
		int j=E.x[i];
		if (j!=fa) {
			dfs(j,x);
			s[x]+=s[j];
		}
	}
}
int main(){
	n=read(); E.clear();
	FOR(i,1,n-1) {
		int x,y;
		x=read(); y=read();
		E.addedge(x,y); E.addedge(y,x);
	}
	d[0]=0; dfs(1,0);
	m=(d[n]+1)/2+1;
	int x=n,y;
	while (d[x]>m) x=f[x];
	y=s[x];
	//cout<<x<<' '<<y<<endl;
	if (y<(n+1)/2) printf("Fennec\n"); else printf("Snuke\n");
	
	return 0;
}

/*
*/


Measured memory_bytes: 13056
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#include "math.h"
#include <complex>
#include <iomanip>
#define ifor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep1(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
using namespace std;
typedef long double ld;
typedef long long int  lli;
typedef complex <double> P;
const double eps = 1e-11;
int vex[4]={1,0,-1,0};
int vey[4]={0,1,0,-1};
int main(){
	int n,k;
	vector<int> data;
	int a;
	cin >> n >> k;
	rep(i,k){
		cin >> a;
		data.push_back(a);
	}
	while(1){
		a = n;
		bool flag = true;
		while (a !=0 ){
			rep(i,k){
				if(a %10==data[i]){
					flag = false;
				}
			}
			a/=10;
		}
		if(flag){
			cout << n;
			return 0;
		}
		n++;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
using namespace std;
void solve() {
        int x;
        cin >> x;
        int dp[x+1] = {0};
        dp[0] = 1;
        for(int i=0;i<x;i++) {
                if(dp[i]) {
                        for(int j=100;j<=105;j++) {
                                if(i+j <= x)
                                dp[i+j] = 1;
                        }
                }
        }
        if(dp[x] == 1)
                cout << '1' << endl;
        else
                cout << '0' <<endl;
        return;

}
int32_t main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        solve();
        return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MAX_N 100000
#define INF 1000000007
using namespace std;

struct Edge {
    int to, d;
};

struct Node {
    int x, point;
};

int points[MAX_N];

bool validate(vector<Edge> es[], int n) {
    fill(points, points + n, INF);
    while (true) {
        queue<Node> que;

        int start = 0;
        bool flag = true;
        for (int i = 0; i < n; i++) {
            if (es[i].size() && points[i] == INF) {
                start = i;
                flag = false;
                break;
            }
        }
        if (flag) {
            return true;
        }
        que.push(Node {start, 0});
        while (!que.empty()) {
            Node p = que.front();
            que.pop();
            if (points[p.x] < INF) {
                if (p.point != points[p.x])
                    return false;
            } else {
                points[p.x] = p.point;
                for (auto e: es[p.x]) {
                    que.push(Node {e.to, e.d + p.point});
                }
            }
        }
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<Edge> es[n];
    for (int i = 0; i < m; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        es[l].push_back(Edge {r,  d});
        es[r].push_back(Edge {l, -d});
    }
    cout << ((validate(es, n)) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 11252