akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define cina(a, n) for (int i = 0; i < n; ++i){ cin >> a[i]; }
#define ll long long
#define ld long double

using namespace std;

int main () {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int x, y;
	cin >> x >> y;
	for (int i = 0; i <= x; ++i) {
		if (2*i+4*(x-i) == y) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){


int k;
string s;
cin>>k>>s;



if(s.length()<=k) cout<<s<<endl;

else{

        for(int i=0;i<k;i++)   cout<<s[i];



        cout<<"."<<"."<<"."<<endl;


}

}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int mod = 1e9 + 7;
int dp[80][2][2][2], n, d1[80], d2[80];
int solve(ll p, ll q){
	for(n = 0; p; p /= 2) d1[n++] = p % 2;
	for(int m = 0; m < n; q /= 2) d2[m++] = q % 2;
	reverse(d1, d1 + n);
	reverse(d2, d2 + n);
	/*
	rep(i, n) cerr<<d1[i]<<(i==n-1?"\n":" ");
	rep(i, n) cerr<<d2[i]<<(i==n-1?"\n":" ");
	*/
	memset(dp, 0, sizeof(dp));
	dp[0][0][0][0] = 1;
	rep(i, n) rep(j, 2) rep(k, 2) rep(nz, 2){
		rep(y, 2) rep(x, 2){
			if(y < x) continue;
			if(!j && y > d1[i]) continue;
			if(!k && x < d2[i]) continue;
			if(!nz && x != y) continue;
			int nj = j || y < d1[i], nk = k || x > d2[i], nnz = nz || x;
			(dp[i + 1][nj][nk][nnz] += dp[i][j][k][nz]) %= mod;
		}
	}
	ll res = 0; rep(i, 2) rep(j, 2) rep(k, 2) res += dp[n][i][j][k];
	return res % mod;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	ll l, r; cin >> l >> r;
	cout << solve(r, l) << endl;
	return 0;
}

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

#define FOR(x,to) for(int x=0;x<(to);x++)
#define F0R(x,in,to) for(int x=(in);x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))

typedef long long ll;
using namespace std;
ll MOD = 998244353;

typedef pair<int,int> ii;
typedef struct {int a,b,c;}iii;
typedef vector<int> vi;

void mosA(vector<int> a){
	for(int i=0; i<a.size(); i++) printf("%d ",a[i]);
	printf("\n");
}
void mosP(vector<ii> a){
	for(int i=0; i<a.size(); i++) printf("%d %d\n",a[i].first,a[i].second);
	printf("\n");
}

ll min_especial(ll a, ll b){
  if(a!=-1 && b!=-1) return min(a,b);
  else return max(a,b);
}
/*
bool ord(ii a, ii b){
	if(a.first == b.first){
		return a.second < b.second;
	}
	return a.first < b.first;
}*/

bool ord(ll a, ll b){
	return a>b;
}

int ans = 0;
int a,n,nn,w,t,k,m,z,q,l,r,x,b,y;
char A[200005],B[200005];
vi G[200005];

ii dfs(int v, int ant){
	if(G[v].size()==1 && ant!=-1) return {0,v};
	ii ans; ans.first=0;
	for(auto u:G[v]){
		if(u==ant) continue;
		ii aux = dfs(u,v);
		if(aux.first>=ans.first)
			ans = aux;
	}
	ans.first++;
	return ans;
}


int main(){
	scanf("%d",&n);
	FOR(i,n-1){
		scanf("%d%d",&a,&b);
		G[a].pb(b);
		G[b].pb(a);
	}

	if(n==1) return!printf("First\n");

	int v = dfs(1,-1).second;
	int l = dfs(v,-1).first;

	//cout<<v<<" "<<l<<endl;
	
	if(l%3==0) return!printf("First\n");
	if(l%3==1) return!printf("Second\n");
	if(l%3==2) return!printf("First\n");


}




// REVISATE ESTO:
// - memset(A,-1,SIZEOF()*n)
// - (x-y+MOD)%MOD
// - int o ll?

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


int main(){
  int N;
  cin >> N;
  vector<string> s(N);
  rep(i,N) cin >> s[i];
  string match = "MARCH";
  map<char,ll> m;
  rep(i,N) m[s[i][0]]++;
  ll res = 0;
  rep(i,5) for(int j = i + 1; j < 5 ; j++) for(int k = j + 1; k < 5 ; k++) {
    res += m[match[i]] * m[match[j]] * m[match[k]];
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<double> v(n);


    REP(i,n) {
        cin >> v[i];
    }
    sort(ALL(v));

    double ans = v[0];
    FOR(i,1,n) {
        ans = (ans + v[i])/2;
    }

    cout << fixed << setprecision(6);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace _0018
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(x);
            Array.Reverse(x);
            Console.Write(x[0]);
            for(int i=1;i<5;i++)
            {
                Console.Write(" " + x[i]);
            }
            Console.WriteLine();
            Console.ReadLine();
        }
    }
}

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


int main(){
	vector<int> dis={100,200,300,400,500};
	int n;
	cin>>n;
	for(int h=0;h<n;h++){

		
	int r,t;
	cin>>r>>t;
	swap(r,t);
	vector<int> k;
	/*
	if(r==90 || r==60 || r==30 || r==0 || r==-30 || r==-60 || r==-90){k.push_back(r/30+3);}
	else{
		if(r<90 && r>60){k.push_back(5); k.push_back(6);}
		if(r<60 && r>30){k.push_back(5); k.push_back(4);}
		if(r<30 && r>0){k.push_back(4); k.push_back(3);}
		if(r<0 && r>-30){k.push_back(3); k.push_back(2);}
    if(r<-30 && r>-60){k.push_back(1); k.push_back(2);}
		if(r<-60 && r>-90){k.push_back(1); k.push_back(0);}
	}
	*/
	k.push_back(r/30);
	if(r%30!=0){k.push_back(r/30+1);}
	vector<int> d;
	for(int i=0;i<dis.size();i++){
		if(t==dis[i]){d.push_back(dis[i]/100); break;}
		if(i!=0 && t<dis[i] && t>dis[i-1]){d.push_back(dis[i]/100); d.push_back(dis[i-1]/100); break;}
	}
	vector<int> ans;
	for(int i=0;i<k.size();i++){
		for(int t=0;t<d.size();t++){
			ans.push_back(k[i]*5+d[t]);
		}
	}

	sort(ans.begin(),ans.end());
	for(int i=0;i<ans.size();i++){
		cout<<ans[i];
		if(i!=ans.size()-1){cout<<" ";}	
	}
	cout<<endl;

	
	}

	

	return 0;
}



Measured memory_bytes: 3136
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
string S;
int main() {
	cin >> S;
	if (S[2] == S[3] && S[4] == S[5]) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

import java.util.*;
import java.io.*;
import static java.lang.System.*;

public class Main{
	public static void main(String[] args){
		int r;
		Scanner sc = new Scanner(in);
      	r = sc.nextInt();
		out.println(3 * r * r);
	}
}


Measured memory_bytes: 23252
fun main(args: Array<String>) {
    readLine()!!
    val A = readLine()!!.split(" ").map{it.toLong()}.toTypedArray()

    fun calc(n: Long): Long {
        var res = n
        for (a in A) {
            res = res / a * a
        }

        return res
    }

    val INF = 2L + A.size * A.max()!!

    var l = 0L
    var u = INF

    while (u - l > 1) {
        val c = (l + u) / 2

        if (calc(c) >= 2) {
            u = c
        } else {
            l = c
        }
    }

    val a = u

    l = 0L
    u = INF

    while (u - l > 1) {
        val c = (l + u) / 2

        if (calc(c) <= 2) {
            l = c
        } else {
            u = c
        }
    }

    val b = l

    if (a > b) {
        println(-1)
    } else {
        println("$a $b")
    }
}


Measured memory_bytes: 57840
#include<iostream>
#include<string>
#include<algorithm>
#include <math.h>

int main(){
    double x1,y1,x2,y2,result;
    std::cin>>x1>>y1>>x2>>y2;
    result = sqrt(pow(x2-x1,2.0)+pow(y2-y1,2.0));
    printf("%f\n", result);
}



Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fs ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main(){
	ll n,m,dp[1001][1001],mod=1000000007;
	string s[1001];
	cin>>n>>m;
	for(ll i=0;i<n;i++){
		cin>>s[i];
	}
	if(s[0][0]=='.')
	    dp[0][0]=1;
	else
	   dp[0][0]=0;
	for(ll j=1;j<m;j++){
		if(s[0][j]=='.')
		  dp[0][j]=dp[0][j-1];
		else
		  dp[0][j]=0;
	}
	
	for(ll i=1;i<n;i++){
		if(s[i][0]=='.')
		  dp[i][0]=dp[i-1][0];
		else
		  dp[i][0]=0;
	}
	
	for(ll i=1;i<n;i++){
		for(ll j=1;j<m;j++){
			if(s[i][j]=='.'){
				   dp[i][j]=dp[i-1][j]+dp[i][j-1];
				   dp[i][j]%=mod;
			}
		    else
		      dp[i][j]=0;
		}
	}
	cout<<dp[n-1][m-1];
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
 
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;}

int main(){
    double a, b; cin >> a >> b;
    int tmp = 10 * b;
    int ans = -1;
    for(tmp = 10*b; tmp <= 10*b+9; tmp++) {
        if(floor((double)tmp*0.08) == a && floor((double)tmp * 0.1) == b) {
            ans = tmp;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import numpy as np
import sys

n = int(input())
p = np.array(list(map(int, input().split())))
p_s = np.array(sorted(p))

if all(p==p_s):
    print("YES")
else:
    diff = p_s - p
    diff_index = np.where(diff!=0)
    #print(diff_index[0][1])
    if len(diff_index[0]) != 2:
        print("NO")
    else:
        p0 = p[diff_index[0][0]]
        p[diff_index[0][0]] = p[diff_index[0][1]]
        p[diff_index[0][1]] = p0
        if all(p == p_s):
            print("YES")
        else:
            print("NO")  

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

typedef long double ld ;
#define PI 3.14159265358979323846264338327950L
ld rad (ld h , ld m) {
	ld ans = 2* PI * (h/12.0 + (m/60.0) / 12.0 - m/60.0) ;
	return ans ;
}
int main () {
	ld a , b , h , m ;
	cin >> a >> b >> h >> m ;
	ld angle = rad ((ld)h , ld(m)) ;
	ld dist = a*a + b*b - 2*a*b*cosl(angle) ;
	cout << fixed << setprecision(20) << sqrt(dist) ;
	return 0 ;
}

Measured memory_bytes: 4188
(let* ((n (read))
    (k (read))
    (h (make-array n))
    (ans 0))
    (loop for i below n do
        (setf (aref h i) (read))
    )
    (setf h (sort h '>))
    (loop for i to (- n k) do
        (if (zerop i)
            (setq ans (- (aref h i) (aref h (+ i (- k 1)))))
            (if (> ans (- (aref h i) (aref h (+ i (- k 1)))))
                (setq ans (- (aref h i) (aref h (+ i (- k 1)))))
            )
        )
    )
    (format t "~A~%" ans)
)

Measured memory_bytes: 77004
/* ex2_1
    riverstone*/
 
#include<stdio.h>
#include <stdlib.h>

#define LIM 100001 //limit of num
int min(int a, int b);

 
int main(void){
    int i;
    int num, depth[LIM];//variable for N and matrix for depths
    int dp[LIM];//matrix for Dynamic Programming

    //input
    scanf("%d", &num);
    for (i = 0; i < num; i++){
        scanf("%d", &depth[i]);
    }
    
    //initialization
    dp[0] = 0;
    dp[1] = abs(depth[0] - depth[1]);

    //Dynamic Programming
    for (i = 2; i < num; i++){
        dp[i]=min(abs(depth[i] - depth[i - 2]) + dp[i - 2], abs(depth[i] - depth[i - 1]) + dp[i - 1]);
    }
    printf("%d\n", dp[num-1]);//output the result
    return 0;
}

//min funciton
int min(int a, int b) {
    if (a < b)
        return a;
    else
        return b;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
 
#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;
 
ll mod = 1e9 + 7ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll inf = 1ll << 60;
 
int main(){
    vector<vector<int>> a(3, vector<int>(3));
    rp(i, 0, 3){
        rp(j, 0, 3){
            scanf("%d", &a.at(i).at(j));
        }
    }
    int n;
    cin >> n;
    rp(i, 0, n){
        int b;
        cin >> b;
        rp(i, 0, 3){
            rp(j, 0, 3){
                if(a.at(i).at(j) == b) a.at(i).at(j) = -1;
            }
        }
    }
    bool flag = false;
    rp(i, 0, 3){
        if(a.at(0).at(i) < 0 and a.at(1).at(i) < 0 and a.at(2).at(i) < 0) flag = true;
        if(a.at(i).at(0) < 0 and a.at(i).at(1) < 0 and a.at(i).at(2) < 0) flag = true;
    }
    if(a.at(0).at(0) < 0 and a.at(1).at(1) < 0 and a.at(2).at(2) < 0) flag = true;
    if(a.at(0).at(2) < 0 and a.at(1).at(1) < 0 and a.at(2).at(0) < 0) flag = true;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1000000000;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
   int n, m;
   cin >> n >> m;
   vector< pair<int, int>> v;
   
   for (int i = 0; i < n; i++){
	    int x, y;
	    cin >> x >> y;
	    v.push_back({x, y});
	 }	
   sort(all(v));
   int ret = 0, cnt = 0;
   for (auto it : v){
	   cnt = min(m, it.s);
	   ret += cnt * it.f;
	   m -= cnt;
	 }
   cout << ret << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 2420
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n, = map(int,read().split())
n -= 1

k = 26
l = 1
while n >= k:
    n -= k
    k *= 26
    l += 1

#print(n,k,l)

r = []
for i in range(l):
    r.append(n%26)
    n //= 26

s = "".join(map(lambda x: chr(x+ord("a")), r[::-1]))
print(s)





Measured memory_bytes: 9184
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, m;
vector<lli> c;
int main() {
  cin >> n >> m;
  init_n(c, n+1, 0);
  for (lli i=0; i<m; ++i) {
    lli a, b; cin >> a >> b;
    c[a]++; c[b]++;
  }
  bool ok = true;
  for (lli d : c) if (d%2 != 0) ok = false;
  cout << (ok ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);
		int r = stdIn.nextInt();
		int g = stdIn.nextInt();
		int b = stdIn.nextInt();
		if((100*r+10*g+b) % 4 == 0)
		{
			System.out.println("YES");
		}
		else
		{
			System.out.println("NO");
		}

	}

}


Measured memory_bytes: 35640
import java.io.*;
import java.util.*;
import java.math.*;
import java.util.concurrent.*;

class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
    static Random rnd=new Random();
    static long mod=(long)(1e9+7);

    public static void main(String args[]) throws Exception
    {
        int n=sc.nextInt(),m=sc.nextInt();

        if(Math.abs(n-m)>1)
        {
            out.println(0);
        }

        else
        {
            long val1=1,val2=1;

            for(int i=1;i<=n;i++)
            {
                val1=(val1*i)%mod;
            }

            for(int i=1;i<=m;i++)
            {
                val2=(val2*i)%mod;
            }

            long curr=(n==m?2:1),res=(val1*val2*curr)%mod;

            out.println(res);
        }

        out.close();
    }

    private static class FastScanner
    {
        BufferedReader in;
        StringTokenizer st;

        public FastScanner(BufferedReader in) {
            this.in = in;
        }

        public String nextToken() throws Exception {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(in.readLine());
            }
            return st.nextToken();
        }

        public String next() throws Exception {
            return nextToken().toString();
        }

        public int nextInt() throws Exception {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() throws Exception {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() throws Exception {
            return Double.parseDouble(nextToken());
        }
    }
}

Measured memory_bytes: 21076
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = (int)(1e6) + 5;
int s[N];
int f[N];
int get(int k)
{
    return f[k] == k ? k : f[k] = get(f[k]);
}
vi ss[N];
int was[N];
int main(void)
{
    int n,m;
    cin>>n>>m;
    for (int i = 1;i <= n;++i)
        cin>>s[i],f[i] = i;
    while (m --)
    {
        int x,y;
        cin>>x>>y;
        ++x;++y;
        f[get(x)] = get(y);
    }
    int sz = 0;
    for (int i = 1;i <= n;++i)
        if (i == get(i))
            was[i] = ++sz;
    if (sz == 1)
        return puts("0") * 0;
    for (int i = 1;i <= n;++i)
        ss[was[get(i)]].pb(s[i]);
    int v = 0;
    ll ans = 0;
    for (int i = 1;i <= sz;++i)
    {
        sort(all(ss[i]));
        v += ss[i].size();
        ans += ss[i][0];
        ss[i].erase(ss[i].begin());
    }
    if (2 * (sz - 1) > v)
        return puts("Impossible") * 0;
    vi vv;
    for (int i = 1;i <= sz;++i)
        for (auto it : ss[i])
            vv.pb(it);
    sort(all(vv));
    for (int i = 0;i < sz - 2;++i)
        ans += vv[i];
    cout << ans << '\n';
    return 0;
}


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

int main() {
    int a, b;
    string s,t;
    cin >> a >> b >> s;
    t = "Yes";

    for(int i=0; i<s.size(); i++) {
        if(i==a && s.at(i) != '-') {
            t = "No";
        }

        if(i != a && s.at(i) == '-') {
            t = "No";
        } 
    }
    cout << t << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF (1e10)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}

int N, M;
ll ans = INF;
ll K;
int main()
{
	cin >> N >> K;

	ll now = 0;

	map<ll, ll> mp;
	ll a[N], b[N];
	REP(i,0,N){
		
		cin >> a[i] >> b[i];
		mp[a[i]] += b[i];
	}

	for(auto p:mp){
		now += p.second;
		if(K<=now){
			cout << p.first << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

#define N_MAX 128
int N;
bool bin[N_MAX];

int main(void){
	memset(bin,0,sizeof(bin));

	cin >> N;
	for (int i=0; i<N; i++){
		int tmp;
		cin >> tmp;
		bin[tmp] = true;
	}

	int ans=0;
	for (int i=0; i<N_MAX; i++){
		if (bin[i]) ans++;
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    int n;cin >> n;
    vector<int> a(1<<n);
    for (int i = 0; i < 1<<n; i++) {
        cin >> a[i];
    }
    function<int(int,int)> f = [&](int k,int x){
        if(k==n){
            return a[x - (1 << n)];
        }
        int l = f(k + 1, 2 * x), r = f(k + 1, 2 * x + 1);
        return abs(l-r);
    };
    cout << f(0,1) << endl;
    return 0;
}


Measured memory_bytes: 1280
class Accumulate2D: #2次元累積和
    def __init__(self, a):#a=graph
        self.height = len(a)
        self.width = len(a[0])
        self.acc = self.accumulate(a)

    def accumulate(self,a):
        b = [[0]*(self.width+1) for i in range(self.height+1)]
        b[1][1] = a[0][0]
        for i in range(self.height):
            for j in range(self.width):
                b[i+1][j+1] = b[i+1][j]+b[i][j+1]-b[i][j]+a[i][j]
        return b

    def sum(self, p, q):
        y1,x1 = p
        y2,x2 = q
        b = self.acc
        if y1>y2 or x1>x2:
            return 0
        else:
            return b[y2+1][x2+1]-b[y2+1][x1]-b[y1][x2+1]+b[y1][x1]


n,k = map(int, input().split())

kk = k*2

z = [[0]*kk for i in range(kk)]#2k*2kのgraph

for i in range(n):
    x,y,c = input().split()
    x = (int(x) + (k if c=='W'else 0)) % kk#Wの場合はy+kにして、k*kマスへ変換
    y = int(y) % kk#k*kマスへ変換
    z[x][y]+=1

z = Accumulate2D(z)

ans = 0
for i in range(k):
    for j in range(k):#i,jについて全探索
        a = z.sum([0,0],[i-1,j-1])\
            + z.sum([i,j],[i+k-1,j+k-1])\
            + z.sum([0,j+k],[i-1,kk-1])\
            + z.sum([i+k,0],[kk-1,j-1])\
            + z.sum([i+k,j+k],[kk-1,kk-1])
        ans = max(ans,a,n-a)

print(ans)

Measured memory_bytes: 112476
#include <iostream>/*{{{*/
#include <iomanip>
#include <string>
#include <map>
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <exception>
#include <ctime>
#include <climits>
#include <list>
#include <bitset>
#include <cassert>
using namespace std;
#define rep_n(i, a, b) for (int i=(a); i<(b); i++)
#define rep(i, n) rep_n(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define ci1(a) cin>>a 
#define ci2(a, b) cin>>a>>b
#define ci3(a, b, c) cin>>a>>b>>c
#define ci4(a, b, c, d) cin>>a>>b>>c>>d
#define co1(a) cout<<a<<endl;
#define co2(a, b) cout<<a<<" "<<b<<endl;
#define co3(a, b, c) cout<<a<<" "<<b<<" "<<c<<endl;
#define co4(a, b, c, d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
typedef long long ll;/*}}}*/

int main() {
    char s[11];
    ci1(s);

    s[3]='8';

    co1(s);
}


Measured memory_bytes: 256
fn c() {
    input! {
        x: i64,
        k: i64,
        d: i64
    }
    let x = x.abs();

    if k <= (x / d) {
        println!("{}", (x - d * k).abs());
    }
    else {
        let min = x % d;
        let k = (k - x / d) % 2;
        println!("{}", (min - d * k).abs());
    }
}

use proconio::{input, marker::Chars};

fn main() {
    c();
}



Measured memory_bytes: 2120
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int i;
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		sc = null;
		int c = Math.max(a, b);
		if(a==b) System.out.println(a*2);
		else System.out.println(c*2-1);
	}
}

Measured memory_bytes: 25300
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int main(){
    std::stack<int> stack;
    int n;
    cin >> n;
    long long ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++){
                int tmp = gcd(i,j);
                tmp = gcd(tmp, k);
                ans += tmp;
            }
        }
    }
    cout << ans << endl; 
    return 0;
}





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

int main() {
  long long N,money,kabu;
  cin >> N;
  money = 1000;
  kabu=0;
  vector<long long>data(N);
  for (int i=0; i<N; i++) {
    cin >> data.at(i);
  }
  for(int i=0; i<N-1; i++) {
    if (data.at(i) < data.at(i+1)){
      money = money + (((data.at(i+1) - data.at(i)) * (money / data.at(i))));
    }
  }
                        
  cout << money << endl;
}
  


Measured memory_bytes: 3580
def run(N, X, M):
    cnt = len(M)
    X -= sum(M)
    min_m = min(M)
    cnt += (X // min_m)
    return cnt


def main():
    N, X = map(int, input().split())
    M = []
    for i in range(N):
        M.append(int(input()))
    print(run(N, X, M))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    A = list(map(int, input().split()))
    MAX_BIT = 60
    MOD = 10 ** 9 + 7

    data = [0] * (MAX_BIT + 2)
    for a in A:
        for bit in range(MAX_BIT + 1):
            if a & (1 << bit):
                data[bit] += 1
    ans = 0
    for i, d in enumerate(data):
        if d == 0:
            continue
        ans += pow(2, i, MOD) * d * (N-d)
        ans %= MOD
    print(ans)

if __name__ == '__main__':
    main()


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

bool is(int a) {
    return (int)(a / 100) ==(int)( (a%100) / 10) && (int)( (a%100)/ 10) == a % 10;
}

int main() {
    int a;
    cin>>a;
    while(!is(a)) {
        a++;
    }
    cout<<a;
}

Measured memory_bytes: 256
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M, *LRD = map(int, read().split())

    G = [[] for _ in range(N)]
    for l, r, d in zip(*[iter(LRD)] * 3):
        G[l - 1].append((r - 1, d))
        G[r - 1].append((l - 1, -d))

    dist = [INF] * N
    for i in range(N):
        if dist[i] != INF:
            continue

        dist[i] = 0
        queue = deque([i])
        while queue:
            v = queue.popleft()
            for nv, d in G[v]:
                if dist[nv] != INF:
                    if dist[nv] != dist[v] + d:
                        print('No')
                        return
                else:
                    dist[nv] = dist[v] + d
                    queue.append(nv)

    print('Yes')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 154316
#include<stdio.h>
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    char a[n];
    scanf("%s",a);
    if(a[k-1]=='A')
    a[k-1]='a';
    else if(a[k-1]=='B')
    a[k-1]='b';
    else if(a[k-1]=='C')
    a[k-1]='c';
    printf("%s",a);
    return 0;
}

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

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n, k-q);
    vector<int> b(q);
    int i;
    for(i = 0; i < q; i++){
        cin >> b.at(i);
    }
    for(int x : b){
        a.at(x-1)++;
    }
    for(i = 0; i < n; i++){
        if(a.at(i) <= 0){
            cout << "No" << endl;
        }
        else{
            cout << "Yes" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1408
import math
mod=10**9+7
n,k=map(int,input().split())
def f(x):
  if x<0:
    return 1
  else:
    return math.factorial(x)
def c(x,y):
  if x<y or y<0:
    return 0
  elif y==0:
    return 1
  else:
    return f(x)//f(x-y)//f(y)
if k==1:
  print(n)
elif n==k:
  print(1)
  for i in range(n-1):
    print(0)
else:  
  for i in range(1,k+1):
    ans=c(k-1,i-1)
    ans*=(c(n-k-1,i)+2*c(n-k-1,i-1)+c(n-k-1,i-2))
    print(ans%mod)

Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
	int a,b,c,d;

	scanf("%d %d %d %d",&a,&b,&c,&d);
	while(1){
		c=c-b;
		if(c<=0){
			printf("Yes");
			break;
		}
		a=a-d;
		if(a<=0){
			printf("No");
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 1732
char*p;l;M(r){for(r=T();*p==42|*p==47;)*p++-42?r/=T():(r*=T());return r;}A(r){for(r=M();*p==43|*p==45;)r+=*p++-43?-M():M();return r;}T(r){*p==40?r=A(++p),l=1:sscanf(p,"%d%n",&r,&l);p+=l;return r;}main(_,E){for(;~scanf("%*d\n%[^=]=\n"+!!p*4,E);)printf("%d\n",A(p=E));}

Measured memory_bytes: 0
/*
Author: Hrujul Thumar
*/
#include <bits/stdc++.h>
#define int         long long
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define whilet()    int t; scanf("%d",&t); while(t--)
#define vp          vector<pair<int,int>,int>
#define pb          push_back
#define mii         map<int,int>
#define pii         pair<int,int>
#define msi         map<string,int>
#define psi         pair<string,int>
#define mpi         map<pair<int,int>,int>
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define ef          else if
#define MOD         1000000007
#define endl        '\n'
#define fastio       ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define pi          3.141592653589793238
const long long MAX_SIZE = 1000000000;
using namespace std;
int parent[1000000];
int Size[1000000];

void make_set(int v) {
    parent[v] = v;
    Size[v]=1;
}

int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b)
    {
        parent[b] = a;
        Size[a]+=Size[b];
    }
}
signed main()
{
    fastio
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)make_set(i);
    set<int> s;
    while(m--)
    {
        int a,b;
        cin>>a>>b;
        union_sets(a,b);
    }
    int ans=-1;
    for(int i=1;i<=n;i++)
    {
        //cout<<ans<<" "<<Size[parent[i]]<<endl;
        ans=max(Size[parent[i]],ans);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1e9 + 7

template < typename T >
void printVector (const vector < T > & vec) {
	for (const T x : vec) {
		cout << x << " ";
	}
	cout << endl;
}

template < typename T >
void printMatrix (const vector < vector < T > > & mat) {
	for (const vector < T > vec : mat) {
		printVector (vec);
	}
	cout << endl;
}

const ll INF = 1e18L + 5;

template < typename T >
void min_self (T& a, T b) {
	a = min (a, b);
}

template < typename T >
void max_self (T& a, T b) {
	a = max (a, b);
}

void add_self (int & a, int b) {
	a += b;
	if (a >= MOD) {
		a -= MOD;
	}
}

const int mx = 305;
double p[mx][mx][mx], dp[mx][mx][mx];

int main() {
	int n, x;
	scanf ("%d", &n);
	vector < int > count (4, 0);
	for (int i = 0; i < n; i++) {
		scanf ("%d", &x);
		++count[x];
	}
	dp[count[1]][count[2]][count[3]] = 0;
	p[count[1]][count[2]][count[3]] = 1.0;
	for (int c = n; c >= 0; c--) {
		for (int b = n; b >= 0; b--) {
			for (int a = n; a >= 0; a--) {

				if (a == 0 && b == 0 && c == 0) continue;
				if (a + b + c > n) continue;

				double p_waste = (double) (n - (a + b + c)) / (double) n;
				double expected_waste = 1.0 / (1.0 - p_waste);
				dp[a][b][c] += p[a][b][c] * expected_waste;

				if (a != 0) {
					double pa = (double) a / (a + b + c);
					p[a - 1][b][c] += p[a][b][c] * pa;
					dp[a - 1][b][c] += dp[a][b][c] * pa;
				}
				if (b != 0) {
					double pb = (double) b / (a + b + c);
					p[a + 1][b - 1][c] += p[a][b][c] * pb;
					dp[a + 1][b - 1][c] += dp[a][b][c] * pb;
				}
				if (c != 0) {
					double pc = (double) c / (a + b + c);
					p[a][b + 1][c - 1] += p[a][b][c] * pc;
					dp[a][b + 1][c - 1] += dp[a][b][c] * pc;
				}
			}
		}
	}
	// printMatrix (p[1]);
	// printMatrix (dp[1]);
	printf ("%.10lf\n", dp[0][0][0]);
	return 0;
}



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

#define fi first
#define se second
#define forn(i,n) for(int i=0; i< (int)n; ++i)
#define for1(i,n) for(int i=1; i<= (int)n; ++i)
#define fore(i,l,r) for(int i=(int)l; i<= (int)r; ++i)
#define ford(i,n) for(int i=(int)(n) - 1; i>= 0; --i)
#define fored(i,r,l) for(int i=(int)r; i>= (int)l; --i)
#define pb push_back
#define el '\n'
#define d(x) cout<< #x<< " " << x<<el

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<char,int> pci;
typedef tuple<int, int, int> tiii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const ll INF = LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MAXN = 1e5+20;
const double EPS= 1e-10;

int m[MAXN][3];
int dp[MAXN][3];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<< setprecision(2)<< fixed;
    int n;
    cin>> n;
    forn(i,n){
        cin>> m[i][0]>> m[i][1]>> m[i][2];
    }
    dp[0][0]= m[0][0];
    dp[0][1]= m[0][1];
    dp[0][2]= m[0][2];
    for1(i,n-1){
        forn(j,3){
            dp[i][j] = max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]) + m[i][j];
        }
    }
    cout<< max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<el;
}


Measured memory_bytes: 2560
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <list>
#include <bitset>

using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
//sum
#if 1
#include <array>
#include <unordered_set>
#include <unordered_map>
template<class T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

int N;
LL A, B;
LL H[100000];

bool judge(int times) {
	LL P = A - B;
	LL sum = 0;
	REP(i, 0, N) {
		LL tmp = (H[i] + P - B * times - 1) / P;
		sum += tmp >= 0 ? tmp : 0;
	}
	return sum <= times;
}

int main() {
	cin >> N >> A >> B;
	REP(i, 0, N) {
		cin >> H[i];
	}

	int lo = 0;
	int hi = INF;
	while (lo + 1 < hi) {
		int mid = (lo + hi) / 2;
		if (judge(mid)) {
			hi = mid;
		} else {
			lo = mid;
		}
	}
	cout << hi << endl;
	return 0;
}

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

int h,w,ta[60][60];
char c[50][50];
int x[8]={-1,-1,-1,0,0,1,1,1};
int y[8]={-1,0,1,-1,1,-1,0,1};

signed main(){
	cin>>h>>w;
	rep(i,h){
		rep(j,w){
			cin>>c[i][j];
			if(c[i][j]=='#'){
				for(int k=0;k<8;k++){
					ta[i+x[k]+1][j+y[k]+1]++;
				}
			}
		}
	}
	rep(i,h){
		rep(j,w){
			if(c[i][j]=='#')cout<<'#';
			else cout<<ta[i+1][j+1];
		}
		cout<<endl;
	}
	ggr
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  string n;cin>>n;
  int ans=0;
  bool flag=false;
  for(int i=1;i<n.size();i++){
    if(flag){
      n[i]='9';
    }else if(n[i]!='9'){
      n[i-1]--;
      flag=true;
      n[i]='9';
    }
  }
  for(int i=0;i<n.size();i++){
    ans+=n[i]-'0';
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
S_ = input()
T = input()
S__len = len(S_)
T_len = len(T)

for i in range(S__len - T_len, -1, -1):
    t_kamo = S_[i : i + T_len]
    #print(t_kamo)
    for j in range(T_len + 1):
        if j == T_len:
            print((S_[: i] + T + S_[i + T_len :]).replace('?', 'a'))
            quit()
        if t_kamo[j] == '?':
            continue
        elif t_kamo[j] != T[j]:
            break
print('UNRESTORABLE')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,m,K,s[12][1002],ss=0x3f3f3f3f;
int Calc(int x,int y,int j){
	return s[y][j]-s[x-1][j];
}
int main() {
	cin>>n>>m>>K;
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=m; j++) {
			char x;
			cin>>x;
			s[i][j]=s[i-1][j]+x-'0';
			//cout<<i<<' '<<j<<' '<<s[i][j]<<endl;
		}
	}
	for(int i=0; i<(1<<(n-1)); i++) {
		int s[12]= {0},tmp[12]= {0},ssss=0;
		for(int j=1; j<n; j++)if(i&(1<<(j-1)))tmp[++ssss]=j;
		tmp[++ssss]=n;
		int ans=0;
		for(int j=1; j<=m; j++) {
			bool flag=0;
			for(int k=1; k<=ssss; k++) {
				//cout<<tmp[k-1]+1<<' '<<tmp[k]<<endl; 
				s[k]+=Calc(tmp[k-1]+1,tmp[k],j);
				//cout<<"I:"<<i<<" J:"<<j<<" K:"<<s[k]<<endl;
				if(s[k]>K)flag=1;
			}
			if(flag) {
				++ans;
				for(int k=1; k<=ssss; k++) {
					s[k]=Calc(tmp[k-1]+1,tmp[k],j);
					if(s[k]>K){
						goto yy;
					}
				}
			}
		}
		ss=min(ss,ans+ssss-1);
		yy:;
	}
	cout<<ss;
}
/*
4 10 4
1110010010
1000101110
0011101001
1101000111
*/

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc142d()
}

fun abc142d() {
    val (a, b) = readLine()!!.split(" ").map { it.toLong() }

    val answer = primeFactorization(gcd(a, b))

    println(answer.size + 1)
}

//素因数分解
fun primeFactorization(n: Long): Map<Long, Long> {
    val factors = mutableMapOf<Long, Long>()
    var temp = n
    var i = 2L
    while (i * i <= temp) {
        while (temp % i == 0L) {
            factors[i] = (factors[i] ?: 0) + 1
            temp /= i
        }
        i++
    }
    // 残った数=素数が1以上の場合、それも含めるように
    if (temp > 1) factors[temp] = 1
    return factors
}

private tailrec fun gcd(a: Long, b: Long): Long {
    return if (b == 0L) a else gcd(b, a % b)
}

Measured memory_bytes: 37744
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n; cin >> n;
    vector<P> r(n), b(n);
    rep(i, n) {
        cin >> r[i].fr >> r[i].sc;
    }
    rep(i, n) {
        cin >> b[i].fr >> b[i].sc;
    }
    int ans = 0;
    vector<bool> used(n, 0);
    sort(all(b));
    rep(i, n) {
        int k = -1, ma = -1;
        rep(j, n) {
            if(r[j].fr < b[i].fr && r[j].sc < b[i].sc && !used[j]) {
                if(chmax(ma, r[j].sc)) {
                    k = j;
                }
            }
        }
        if(k != -1) {
            used[k] = 1;
            ++ ans;
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n, t; cin >> n >> t;
  vector<int> a(n), b(n);
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
  }

  vector<int> v;

  vector<int> order(n);
  iota(order.begin(),order.end(),0);
  sort(order.begin(),order.end(),[&](int i, int j){
    if(a[i] == a[j]) return b[i] > b[j];
    return a[i] < a[j];
  });
  for(int i = 0; i < min(n, 10LL); i++){
    v.push_back(order[i]);
  }

  iota(order.begin(),order.end(),0);
  sort(order.begin(),order.end(),[&](int i, int j){
    if(b[i] == b[j]) return a[i] < a[j];
    return b[i] > b[j];
  });
  for(int i = 0; i < min(n, 10LL); i++){
    v.push_back(order[i]);
  }

  int ans = 0;
  for(int u = 0; u < v.size(); u++){
    vector<int> dp(t+10, 0);
    for(int i = 0; i < n; i++){
      if(i == v[u]) continue;
      for(int j = t; j >= 0; j--){
        if(j + a[i] > t) continue;
        dp[j + a[i]] = max(dp[j + a[i]], dp[j] + b[i]);
      }
    }
    ans = max(ans, dp[t-1] + b[v[u]]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[12];
    int a;
    cin>>a>>s;
    if(a>3200)
        cout<<s<<endl;
    else if(a<3200)
        cout<<"red"<<endl;
    else if(a==3200)
        cout<<s<<endl;

    else
        cout<<"red"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100001];
int main(){
  int n, m;
  cin >> n >> m;
  int p = 0, ac = 0;
  while(m--){
    int x;
    string s;
    cin >> x >> s;
    if(s == "WA"){
      if(a[x] == -1)continue;
      a[x]++;
    }else{
      if(a[x] == -1)continue;
      p += a[x];
      a[x] = -1;
      ac++;
    }
  }
  cout << ac << " " << p << endl;
}

Measured memory_bytes: 640