akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <string>

int main()
{	
	std::map<std::string, long long int> M;
	
	int q; std::string sq;
	getline(std::cin, sq); q = std::stoi(sq);
	for (int i=0; i<q; i++) {
		std::string key;
		int op;
		long long int x;
		std::string L, R;
		int sp_pos;
		
		std::string buf;
		getline(std::cin, buf);
		op = buf[0] - '0';
		
		if (op==0) {
			sp_pos = buf.find(' ', 2);
			key = buf.substr(2, sp_pos-2);
			x = std::stoll(buf.substr(sp_pos+1));
			M[key] = x;
		} else if (op == 1) {
			key = buf.substr(2);
			if (M.find(key) != M.end()) std::cout << M[key] << std::endl;
			else std::cout << 0 << std::endl;
		} else if (op==2) {
			key = buf.substr(2);
			M.erase(key);
		} else {
			sp_pos = buf.find(' ', 2);
			L = buf.substr(2, sp_pos-2);
			R = buf.substr(sp_pos+1);
			std::map<std::string, long long int>::iterator lb, ub;
			lb = M.lower_bound(L);
			ub = M.upper_bound(R);
			for (std::map<std::string, long long int>::iterator it = lb; it != ub; ++it) {
				std::cout << it->first << " " << it->second << std::endl;
			}
		}
	}
	
	return 0;
}



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

int main(){
  int A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;

  double m=0;
  vector<int> ans={100*A,0};

  for(int a=0;a<=30;++a){
    for(int b=0;b<=30;++b){
      int W=100*(a*A+b*B);
      if(W>=F) continue;
      for(int c=0;c<=100;++c){
        for(int d=0;d<=100;++d){
          int S=c*C+d*D;
          if(S==0 && W==0) continue;
          else if(S+W>F) continue;
          else if((W/100)*E<S) continue;
          else{
            if(m<(double)(100*S)/(S+W)){
              ans[0]=S+W;
              ans[1]=S;
              m=(double)(100*S)/(S+W);
            }
          }
        }
      }
    }
  }

  cout<<ans[0]<<" "<<ans[1]<<endl;
}


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

int main() {
    string S;
    cin >> S;

    long min_count = pow(10, 5);

    char now_color = '0';
    long count = 0;

    for(int i = 0; i < S.size(); i++)
    {//white start

        if(S[i] != now_color) count++;
        if(now_color == '0') now_color = '1';
        else if(now_color == '1') now_color = '0';
    }
    min_count = count;
    now_color = '1';
    count = 0;
    for(int i = 0; i < S.size(); i++)
    {//black start

        if(S[i] != now_color) count++;
        if(now_color == '0') now_color = '1';
        else if(now_color == '1') now_color = '0';
    }
    min_count = min(min_count, count);
    cout << min_count << endl;
    return 0;  

}

Measured memory_bytes: 512
#!/usr/bin/env python3
import sys


def solve(S: str):
    print(700+S.count("o")*100)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << (a) << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

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

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

    int n; cin >> n;
    vi a(n); forn(i,n) cin >> a[i], a[i]--;
    vi res;
    forn(_,n) {
        bool found = false;
        for (int i = si(a)-1; i >= 0; i--) {
            if (i == a[i]) { 
                res.pb(i+1);
                a.erase(a.begin()+i);
                found = true;
                break;
            }
        }
        if (!found) return cout << -1, 0;
    }
    reverse(all(res));
    for (auto x : res) cout << x << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 998244353
#define INF 1 << 30

using namespace std;
typedef long long ll;

ll Pow(ll n, ll k) {
	ll ans = 1, a = n % MOD;
	while (k > 0) {
		if (k & 1) {
			ans *= a;
			ans %= MOD;
		}
		a *= a;
		a %= MOD;
		k >>= 1;
	}
	return ans;
}

ll Inverse(ll a) {
	return Pow(a, MOD - 2);
}

int main(void) {
	int num, i, a;
	ll ans = 1;
	cin >> num >> a;
	if (a != 0) {
		printf("0\n");
		return 0;
	}
	vector<int> d(num, 0);
	vector<ll> k(num + 1);
	d[0] = 1;
	for (i = 0; i < num - 1; i++) {
		cin >> a;
		if (a == 0) {
			printf("0\n");
			return 0;
		}
		d[a]++;
	}
	for (i = 1; i < num; i++) {
		ans *= Pow(d[i - 1], d[i]);
		ans %= MOD;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1408
#include"bits/stdc++.h"
using namespace std;

int main(){
    int n,p;
    cin >> n >> p;
    int ans;
    int rem;
    bool flag;
    while (n!=0 || p!=0){
        vector<int> stone(n);
        for (int i = 0; i<n; i++) stone[i] = 0;
        flag = false;
        rem = p;
        while (1){
            for (int i = 0; i<n; i++){
                if (rem!=0){
                    stone[i]++;
                    rem--;
                }
                else{
                    rem += stone[i];
                    stone[i] = 0;
                }
                if (stone[i] == p){
                    ans = i;
                    flag = true;
                    break;
                }
                
            }
            if (flag) break;
        }
        cout << ans << endl;
        cin >> n >> p;
    }
}



Measured memory_bytes: 3068
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int main(void){
	int M[100][100] = {0};
	int n, u, k, v, i, j;
	n = u = k = v = 0;

	//printf("Gの頂点数：");
	scanf("%d", &n);

	for(i = 0; i < n; i++){
			//printf("\n頂点：");
			scanf("%d", &u);
			//printf("頂点%dの出次数：", u);
			scanf("%d", &k);
			for(j = 0; j < k; j++){
				//printf("頂点%dに隣接する頂点番号：", u);
				scanf("%d", &v);
				v--;
				M[i][v] = 1;
			}	
	}
	
	//puts("\n<<Gの隣接行列>>");
	for(i = 0; i < n; i++){
		for(j = 0; j < n; j++){
			if(j){
				printf(" ");
			}
			printf("%d", M[i][j]);
		}
		putchar('\n');
	}

}


Measured memory_bytes: 2140
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String str;
		int sum=0,len=0;
		while(true){
			str=sc.nextLine();
			if(str.equals("0")==false){
				sum=0;
				len=str.length();
				for(int i=0;i<len;i++){
					sum+=Integer.parseInt(str.substring(i,i+1));
				}
				System.out.println(sum);
			}
			else{
				break;
			}
		}
	}
}


Measured memory_bytes: 26964
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define PI 3.14159265358979
#define MOD 1000000007
#define ERR 0.00000000000001
#define NUM 200010

int main(){
    int x,y,z;
    scanf("%d %d %d",&x,&y,&z);
    printf("%d %d %d", z, x, y);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String card1,card2;
		int player1=0,player2=0;

		for(int i = 0;i<n;i++) {
			card1 = sc.next();
			card2 = sc.next();

			if(card1.compareTo(card2) >= 1) {

				player1 += 3;

			}else if(card1.compareTo(card2) <= -1){

				player2 += 3;

			}else if(card1.compareTo(card2) == 0) {

				player1++;
				player2++;

			}

		}

		System.out.println(player1 + " " + player2);
		sc.close();

	}

}


Measured memory_bytes: 29940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ std::cin >> head; _cin(std::forward<Tail>(tail)...); }
void _cout(){ std::cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ std::cout << head; _cout(std::forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

using namespace std;
using ll = long long;

int main(void){
    Cin(int, k, s);
    int ans = 0;
    For(x, k+1) For(y, k+1){
        if(0 <= s-x-y && s-x-y <= k) ans ++;
    }
    Cout(ans);
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define INF (1e9 + 7)
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using vvs = vector<vector<string>>;

void solve(){
    
    ll N, res;
    cin >> N;
    vl v(N + 100);
    rep2(x, 1, 110){
        rep2(y, 1, 110){
            rep2(z, 1, 110){
                res = pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x;
                if(res <= N + 50){
                    v[res] += 1;
                }
            }
        }
    }
    
    rep2(i, 1, N + 1){
        cout << v[i] << endl;
    }

}

int main(){

    solve();    
    
	return 0;
	
}

Measured memory_bytes: 3584
#!/usr/bin/env python3
import sys

def solve(H: int, W: int, A: "List[List[int]]", B: "List[List[int]]"):
    SA=[[0]*W for i in range(H)]
    MAX = (H+W)*80
    for i in range(H):
        for j in range(W):
            SA[i][j]=abs(A[i][j]-B[i][j])

    DP=[[0 for i in range(W)] for j in range(H)]
    DP[0][0]=1<<MAX+SA[0][0]

    for i in range(H):
        for j in range(W):
            tempbit=DP[i][j]
            if i<H-1:
                DP[i+1][j]|=tempbit<<SA[i+1][j]
                DP[i+1][j]|=tempbit>>SA[i+1][j]

            if j<W-1:
                DP[i][j+1]|=tempbit<<SA[i][j+1]
                DP[i][j+1]|=tempbit>>SA[i][j+1]

    ANS=1<<MAX*2
    for i in range(MAX*2+1):
        if 1<<i & DP[-1][-1]!=0:
            ANS=min(ANS,abs(i-MAX))

    print(ANS)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    A = [[int(next(tokens)) for _ in range(W)] for _ in range(H)]  # type: "List[List[int]]"
    B = [[int(next(tokens)) for _ in range(W)] for _ in range(H)]  # type: "List[List[int]]"
    solve(H, W, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 20468
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N, L = in_nn()
    A = in_nl()

    max_l = 0
    ind = -1
    for i in range(N - 1):
        t = A[i] + A[i + 1]
        if max_l < t:
            ind = i
            max_l = t

    if max_l >= L:
        print("Possible")
        for i in range(1, ind + 1):
            print(i)
        for i in range(N - 1, ind, -1):
            print(i)
    else:
        print("Impossible")


if __name__ == '__main__':
    main()


Measured memory_bytes: 18784
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, ll> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;

ll mod_pow(ll x, int n){
    if(n == 0)      return 1;

    ll res = 1;
    while(n > 0){
        if(n & 1)   res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

struct Combination{
    int sz;
    vector<ll> fact;
    vector<ll> ifact;

    Combination(int sz = 1e+5) : sz(sz) {
        fact = vector<ll>(sz + 1);
        ifact = vector<ll>(sz + 1);

        fact[0] = 1;
        for(ll i = 1; i <= sz; ++i){
            fact[i] = fact[i - 1] * i % mod;
        }

        ifact[sz] = mod_pow(fact[sz], mod - 2);
        for(ll i = sz; i > 0; --i){
            ifact[i - 1] = ifact[i] * i % mod;
        }
    }

    ll get_combination(int n, int r){
        if(n < 0 || r < 0 || n < r)     return 0;

        return fact[n] * ifact[r] % mod * ifact[n - r] % mod;
    }
};

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

    ll n, m, k;
    cin >> n >> m >> k;
    if(n < m)   swap(n, m);
    Combination c(n * m);
    ll mul = c.get_combination(n * m - 2, k - 2);
    ll res = 0;
    ll add = 0;
    for(int x = 0; x < n; ++x){
        for(int y = 0; y < m; ++y){
            for(int i = y; i >= 0; --i){
                // 初項 : y-i+1, 公差 : 1, 要素数 : n-(x+1) の等差数列の和
                add = (n - (x+1)) * (y - i + 1) + (n - (x+1)) * (n - (x+1) - 1) / 2;
                res = (res + add) % mod;
                // cerr << "(" << x << ", " << y << ") " << i << "  " << add << "\n";
            }
            for(int i = y+1; i < m; ++i){
                // 初項 : i-y, 公差 : 1, 要素数 : n-x の等差数列の和
                add = (n - x) * (i - y) + (n - x) * (n - x - 1) / 2;
                res = (res + add) % mod;
                // cerr << "(" << x << ", " << y << ") " << i << "  " << add << "\n";
            }
        }
    }
    res = res * mul % mod;
    cout << res << endl;
}

Measured memory_bytes: 3328
a = list(map(int, input().split()))
print(min(abs(a[2] - a[1]) + abs(a[1] - a[0]),
          abs(a[1] - a[0]) + abs(a[0] - a[2]),
          abs(a[0] - a[2]) + abs(a[2] - a[1])))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

int main() {
  int n = 0, m = 0;
  std::cin >> n >> m;
  std::vector<int> tree(n);
  int a = 0, b = 0;
  for (int i=0; i<m; i++) {
    std::cin >> a >> b;
    a--;
    b--;
    tree.at(a)++;
    tree.at(b)++;
  }
  for (int x : tree) {
    std::cout << x << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
from bisect import *
def solve():
    mod = 10**9+7
    d = defaultdict(lambda: [])
    N = int(input())
    for i in range(N):
        a = int(input())
        d[a].append(i)
    selist = [[-1,-1]]
    ends = [-1]
    for l in d.values():
        for i in range(len(l)-1):
            if l[i+1]-1>l[i]:
                selist.append([l[i],l[i+1]])
                ends.append(l[i+1])
    selist = sorted(selist,key=lambda x:x[1])
    ends.sort()
    dp = [0]*(len(selist))
    for i in range(1,len(selist)):
        dp[i] = dp[i-1]+1
        ind = bisect_right(ends,selist[i][0])
        dp[i] += dp[ind-1]
        dp[i] %= mod
    ans = dp[-1]+1
    ans %= mod
    return ans
print(solve())


Measured memory_bytes: 52120
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<pair<int,int>>>;
#define MOD 1000000007
#define INF 1000000000

int main(){
  int N;
  cin>>N;
  int cnt=0;
  bool flag=false;
  for(int i=0;i<N;i++){
    int x,y;
    cin>>x>>y;
    if(x==y){
      cnt++;
    }else{
      cnt=0;
    }
    if(cnt==3){
      flag=true;
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//   for(auto x : v) cout << x << " "; cout << "\n";    // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }

int main()
{
  int w, h, x, y;

  cin >> w >> h >> x >> y;
  if (w % 2 == 0 && h % 2 == 0 && w / 2 == x && h / 2 == y)
  {
    cout << fixed << setprecision(9) << (double)w * h / 2 << ' ' << 1 << endl;
    return (0);
  }
  cout << fixed << setprecision(9) << (double)w * h / 2 << ' ' << 0 << endl;
}


Measured memory_bytes: 3828
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  string s; cin >>s;
  ll n=s.size();
  vector<ll> vec(n);
  ll ans=0;
  ll key=0;
  ll black=0;
  rep(i,n)if(s[i]=='B')black++;
  rep(i,n){
    if(s[i]=='B'){
      key++;
      ans+=n-black+key-1-i;
    }
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 2180
N, C = map(int, input().split())
cost = []
c = []
for i in range(C):
    cost.append(list(map(int, input().split())))

for i in range(N):
    c.append(list(map(int, input().split())))

color = [[0 for i in range(C+1)] for j in range(3)]
for i in range(N):
    for j in range(N):
        color[(i+j)%3][c[i][j]] += 1

ans = 10000000000
for i in range(1, C+1):
    for j in range(1, C+1):
        for k in range(1, C+1):
            if i == j or j == k or k == i:
                continue
            temp = 0
            for b in range(1, C+1):
                temp += cost[b-1][i-1] * color[0][b]
            for b in range(1, C+1):
                temp += cost[b-1][j-1] * color[1][b]
            for b in range(1, C+1):
                temp += cost[b-1][k-1] * color[2][b]
            ans = min(temp, ans)

print(ans)


Measured memory_bytes: 5620
#include"bits/stdc++.h" 
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long int ll;
vector<int>u;
vector<int>w;
vector<int>::iterator it;
priority_queue<int>pq;
const int N=1e5+10;
/*--------------------------hbp16@hbp16-Inspiron-3543:-$------------------------------*/
int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	int a=0,b=0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i] == 'A')
		{
			a++;
		}
		else if(s[i] == 'B')
		{
			b++;
		}
	}
	if(a == 3 or b == 3)
	{
		cout<<"No";
		return 0;
	}

	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  long long N, A, B;
  
  cin >> N >> A >> B;
  
  long long cntb = 0;
  
  cntb = (N / (A + B)) * A;
  
   if(N % (A + B) <= A){
        cntb += N % (A + B);
    }
    else{
        cntb += A;
    }
  
  cout << cntb << endl;
  
  return 0;
}

Measured memory_bytes: 256
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def q4():
    N = int(input())
    arr = prime_factorize(N)
    if not arr:
        print(0)
        return

    ans_count = 0
    count = 1

    min_val = min(arr)
    while arr:
        if arr.count(min_val) < count:
            arr = list(filter(lambda a: a != min_val, arr))
            count = 1
            if not arr:
                break
            min_val = min(arr)
            continue
        arr = arr[count:]
        ans_count += 1
        count += 1
    print(ans_count)


q4()


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

typedef long long ll;
const int MAX_N = 50;

ll dp[MAX_N+1][MAX_N+1][MAX_N*50+1];

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

    int N, A; cin >> N >> A;
    vector<int> x(N+1);
    for (int i = 1; i <= N; i++) {
        cin >> x[i];
    }

    dp[0][0][0] = 1;
    for (int j = 1; j <= N; j++) {
        for (int k = 0; k <= j; k++) {
            for (int s = 0; s <= MAX_N*50; s++) {
                if (s < x[j]) {
                    dp[j][k][s] = dp[j-1][k][s];
                } else if (k >= 1 && s >= x[j]) {
                    dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j]];
                } else {
                    dp[j][k][s] = 0;
                }
            }
        }
    }

    ll ans = 0;
    for (int k = 1; k <= N; k++) {
        ans += dp[N][k][k*A];
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 26368
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

// mod_nck(n, k) → nCk // O(n)
// 1. mod_fact(n); mod_inv_fact(n);
// 2. ll ans = mod_nck(n,k);

const ll MAX_N = 200000;
ll fact[MAX_N+1], inv_fact[MAX_N+1];

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

void mod_fact(ll n){
  fact[0] = 1;
  REP(i,n)fact[i+1] = fact[i] * (i+1) % MOD;
}

void mod_inv_fact(ll n){
  inv_fact[n] = mod_pow(fact[n], (MOD-2));
  REP(i,n){
    inv_fact[n-1-i] = inv_fact[n-i] * (n-i) % MOD;
  }
}

ll mod_comb(int n, int k){
  return fact[n] * inv_fact[k] % MOD * inv_fact[n-k] % MOD ;
}

int main(){
  ll h, w, a, b;
  cin >> h >> w >> a >> b;

  ll ans = 0ll;
  mod_fact(h+w);
  mod_inv_fact(h+w);

  REP(i, min(h-a, w-b)){
    ll x = h-a-1-i;
    ll y = b+i;
    ans = (ans + mod_comb(x+y,y) * mod_comb(h-x-1+w-y-1, w-y-1) % MOD) % MOD;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
    int a,b;
    cin >> a >>b;
    int ans = a;
    dump(ans);
    if (a > b)ans--;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

void rsort_u32(void *base, const int count){
	uint32_t *a=base;
	uint32_t *b=malloc(count*sizeof(uint32_t));
	int c[0x100];
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(0<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(0<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(1<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(1<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	free(b);
}

int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }

inline int max2(const int a, const int b){return a>b?a:b;}

short a[3000][2];
int d[3000][3001];
int main(void){
	int n=nextint();
	int t=nextint();
	for(int i=0; i<n; i++){
		a[i][0]=nextint();
		a[i][1]=nextint();
	}
	rsort_u32(a, n);
	for(int i=1; i<t; i++){
		for(int j=0; j<n; j++){
			d[i][j+1] = max2(d[i-1][j+1], d[i][j]);
			if(i>=a[j][0]){
				int now = d[i-a[j][0]][j] + a[j][1];
				if(now>d[i][j+1]) d[i][j+1]=now;
			}
		}
	}
	int ans=0;
	for(int j=0; j<n; j++){
		int now = d[t-1][j]+a[j][1];
		if(now>ans) ans=now;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 35328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int h, a; cin >> h >> a;
  cout << ((h + a - 1) / a) << endl;

  return 0;
}


Measured memory_bytes: 256
let array_of_string s = Array.init (String.length s) (fun i -> s.[i])

module MultiSet = struct
  module type S = sig
    type elt
    type t
    val empty : t
    val is_empty : t -> bool
    val mem : elt -> t -> bool
    val count : elt -> t -> int
    val add : elt -> t -> t
    val remove : elt -> t -> t
    val clear : elt -> t -> t
    val cardinal : t -> int
    val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a
    val max_elt : t -> elt
    val subset : t -> t -> bool
    val inter : t -> t -> t
  end

  module Make (E : Set.OrderedType) : S with type elt = E.t = struct
    module EltMap = Map.Make (E)
    type elt = EltMap.key
    type t = int EltMap.t

    let empty = EltMap.empty
    let is_empty = EltMap.is_empty
    let mem = EltMap.mem
    let count x m = try EltMap.find x m with Not_found -> 0
    let add x m = EltMap.add x (count x m + 1) m
    let remove x m =
      match EltMap.find x m with
      | 1 -> EltMap.remove x m
      | n -> EltMap.add x (n - 1) m
      | exception Not_found -> m
    let clear = EltMap.remove
    let cardinal m = EltMap.fold (fun _ -> ( + )) m 0
    let fold f = EltMap.fold (fun x n -> Array.fold_right f (Array.make n x))
    let max_elt m = fst (EltMap.max_binding m)
      let subset m1 m2 = EltMap.for_all (fun x n1 -> n1 <= count x m2) m1
    let inter m1 m2 = EltMap.merge (fun _ o1 o2 ->
      match o1, o2 with
      | None, _ | _, None -> None
      | Some n, Some m -> Some (min n m)) m1 m2
  end
end

module CharMultiSet = MultiSet.Make (struct
  type t = char
  let compare = compare
end)

let () =
  let n = int_of_string @@ read_line () in
  let ss = Array.init n (fun _ -> read_line ()) in
  Array.to_list ss
  |> List.map array_of_string
  |> List.map (Array.fold_left (fun m x -> CharMultiSet.add x m) CharMultiSet.empty)
  |> (fun (s :: ss) -> List.fold_left CharMultiSet.inter s ss)
  |> (fun s -> CharMultiSet.fold (fun c s -> c :: s) s [])
  |> List.rev
  |> List.iter print_char;
  print_newline ()

Measured memory_bytes: 1152
import sys
sys.setrecursionlimit(1000000)

N=int(input())
a=list(map(int,input().split()))

b=[i for i in range(1,N+1)]

A=[]
for i in range(N):
    A.append([a[i],b[i]])
A.sort(reverse=True)
#print(A)
PL=[i for i in range(N+1)]+[N+1]
PR=[i for i in range(N+1)]+[N+1]

def findL(x):
    if x==PL[x]:
        return x
    else:
        return findL(PL[x])
        
def findR(x):
    if x==PR[x]:
        return x
    else:
        return findR(PR[x])
#print(PR)
ans=0
for i in range(N):
    ans+=A[i][0]*(A[i][1]-findL(A[i][1]-1))*(findR(A[i][1]+1)-A[i][1])
    #print(ans,A[i][1],(A[i][1]-findL(A[i][1])+1),findR(A[i][1])-A[i][1]+1)
    #print(PR)
    PL[A[i][1]]=findL(A[i][1]-1)
    PR[A[i][1]]=findR(A[i][1]+1)
print(ans)

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

int map[1002][1002];
long long int dp[1002][1002];
long long int x,y;
int h,w;
long int n;

void root(int xx,int yy){
	x=xx,y=yy;
	if(xx<=w && yy<=h){
		if(map[xx][yy]==1){
			root(xx+1,yy);
		}else{
			root(xx,yy+1);
		}
	}
}

int main(void){
	int a,b,c;
	while(1){
		memset(map,0,sizeof(map));
		memset(dp,0,sizeof(dp));
		scanf("%d%d%d",&h,&w,&n);
		if(h==0 && w==0 && n==0)break;
		for(a=1;a<=h;a++){
			for(b=1;b<=w;b++){
				scanf("%d",&map[b][a]);
			}
		}
		dp[1][1]=n-1;
		for(a=1;a<=h;a++){
			for(b=1;b<=w;b++){
				if(dp[b][a]%2==0)dp[b+1][a]+=dp[b][a]/2;
				else{
					if(map[b][a]==1)dp[b+1][a]+=(dp[b][a]+1)/2;
					if(map[b][a]==0)dp[b+1][a]+=(dp[b][a]-1)/2;
				}
				if(dp[b][a]%2==0)dp[b][a+1]+=dp[b][a]/2;
				else{
					if(map[b][a]==1)dp[b][a+1]+=(dp[b][a]-1)/2;
					if(map[b][a]==0)dp[b][a+1]+=(dp[b][a]+1)/2;
				}
			}
		}
		for(a=1;a<=h;a++){
			for(b=1;b<=w;b++){
				map[b][a]=(map[b][a]+dp[b][a])%2;
			}
		}
		root(1,1);
		cout << y << " " << x << endl;
	}
    return 0;
}

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

using namespace std;
using ll = long long;
using indx = size_t;

#define endl '\n'
#define get(type, args...) type args; read(args)
#define all(v) v.begin(), v.end()
#define debug(args...) { string _s = #args; \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s); istream_iterator<string> _it(_ss); \
    err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
template <typename... T>
void read(T&... args) {
    ((cin >> args), ...);
}
template <typename T>
void read(vector<T>& v) {
    for (auto& x : v) cin >> x;
}
template <typename... T>
void write(T&&... args) {
    ((cout << args << " "), ...);
    cout << '\n';
}
template <typename T>
void write(vector<T>& v) {
    for (auto x : v) cout << x << " ";
    cout << '\n';
}

int main() {
    ll d = 100;
    get(ll, x);
    ll ans = 0;
    ll y = d;
    while (y < x) {
        ans++;
        y = y * pow(1.01, 1);
    }
    write(ans);
}


Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int R = in.nextInt();
		if(R < 1200) {
			System.out.print("ABC");
		}else if(R < 2800) {
			System.out.print("ARC");
		}else {	
			System.out.print("AGC");
		}
		in.close();
	}
}

Measured memory_bytes: 22996
#include<cmath>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const int p=1000000000+7;
const int maxn=100000*3+5;
ll n,m,k;
ll p1[maxn*4],p2[maxn*4];
ll f[maxn*4];//有x个空格，不大于m k个b c 填空种类数
ll pw3[maxn*4];
ll pw(ll x,ll y){
	ll ans=1;
	while ((bool)y){
		if ((bool)(y&1)){
			ans=ans*x%p;
		}
		x=x*x%p;
		y=y>>1;
	}
	return ans;
}
ll c(ll x,ll y){
	if ((x<y)||(y<0))return 0;
	return p1[x]*p2[y]%p*p2[x-y]%p;
}
void solve(){
	ll b1,b2,b3,b4;
	ll ans;
	scanf("%lld%lld%lld",&n,&m,&k);
	f[0]=1;
	if (m>k) swap(m,k);
	for (b1=1;b1<=m+k+n;b1++){
		f[b1]=(f[b1-1]*2-(c(b1-1,m)+c(b1-1,k))%p+p)%p;
	}
	ans=0;
	for (b1=n;b1<=n+m+k;b1++){
		ans=(ans+f[b1-n]*c(b1-1,n-1)%p*pw3[n+m+k-b1]%p)%p;
		//printf("%lld\n",f[b1-n]*c(b1-1,n-1)*pw3[n+m+k-b1]);
	}
	printf("%lld\n",ans);
	
	
	
	//printf("%lld",f[m+k]-c(m+k,k));
}
int main(){
	ll b1,b2,b3,b4;
	p1[0]=1;
	for (b1=1;b1<maxn*3;b1++){
		p1[b1]=p1[b1-1]*b1%p;
	}
	p2[maxn*3-1]=pw(p1[maxn*3-1],p-2);
	for (b1=maxn*3-1;b1>=1;b1--){
		p2[b1-1]=p2[b1]*b1%p;
	}
	pw3[0]=1;
	for (b1=1;b1<maxn*3;b1++){
		pw3[b1]=pw3[b1-1]*3%p;
	}
	solve();
}





Measured memory_bytes: 36992
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
double tenchoku(double x1, double y1 , double x2 , double y2, double x, double y) {
double a = (y1-y2)/(x1-x2);
double b = -1;
double c = y1-a*x1;
double k = abs(a*x+b*y+c)/sqrt(a*a+b*b);
return k;}
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);}
return res;}
int main(){
cout << fixed << setprecision(10);
ll counter=3;
ll f=0;
ll n;
cin>>n;
string s1,s2;
cin>>s1>>s2;
ll ca=0;
ll cb=0;
for(ll i=0; i<n; i++){
if(s1.at(i)==s2.at(i)&&ca>0){
counter=(counter*2)%mod;
f++;
ca++;
cb=0;}
else if(s1.at(i)==s2.at(i)){
ca++;
cb=0;}
else if(cb>0){
i++;
counter=(counter*3)%mod;
ca=0;}
else{
i++;
cb++;
counter=(counter*2)%mod;
ca=0;}}
cout<<counter<<endl;}


Measured memory_bytes: 3724
n=int(input())
v=list(map(int,input().split()))
from collections import Counter

v1=Counter(v[::2])
v2=Counter(v[1::2])
lenv=len(v)
c1=v1.most_common()
c2=v2.most_common()

if c1[0][0]!=c2[0][0]:
    print(lenv-c1[0][1]-c2[0][1])
else:
    if c1[0][1]==c2[0][1]==len(v)//2:
        print(lenv//2)
    elif c1[0][1]==len(v)//2:
        print(lenv//2-c2[1][1])
    elif c2[0][1]==len(v)//2:
        print(lenv//2-c1[1][1])    
    else:
        print(lenv-max(c1[0][1]+c2[1][1],c1[1][1]+c2[0][1]))

Measured memory_bytes: 20984
from decimal import Decimal
import math
a , b, h , m = map(int , input().split())
angh = (h/12)*360 + (m/60)*30
angm = (m/60)*360
#print("h , m ",angh,angm)
ang = abs(angh-angm)
#ang = min(360-ang,ang)
#print("ang :",ang)
#if ang == 180: print(0); exit()
#if ang == 0: print(0); exit()
val = a*a + b*b - 2*a*b*math.cos(math.radians(ang))
print(val**0.5)


Measured memory_bytes: 10248
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
const long long MOD = 1e9+7;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
struct segment_tree{
    const long INF = 2*1e9;
    long n = 1;
    vector<long> data; //ここめっちゃ注意
    segment_tree(int a){
        while(n<a) n*=2;
        for(int i = 0;i<2*n;i++) data.push_back(0);
    }
    //segment treeの大きさ取得
    long nreturn(){
        return n;
    }
    //0-indexでk番目の値をaに変更
    void change(long k,long a){
        k+=n-1;
        data[k] = a;
        while(k>0){
            k = (k-1)/2;
            data[k] = data[2*k+1]+data[2*k+2];
            //cout << "data" << k << "is changed to" << data[k] << endl;
        }
        return;
    }
    //区間[a,b)の最小値:呼ぶときはrmq(a,b,0,0,n)
    long rmq(long a,long b,long k,long l,long r){
        if(a>=r || b<=l) return 0;
        if(a<=l && b>=r) return data[k];
        long teml = rmq(a,b,2*k+1,l,(l+r)/2);
        long temr = rmq(a,b,2*k+2,(l+r)/2,r);
        return teml+temr;
    }
};
int main(){
    int n;
    string s;
    int q;
    cin >> n >> s >> q;
    segment_tree tree(n);
    vector<segment_tree> treevec;
    rep(i,27) treevec.push_back(tree);
    rep(i,n){
        treevec[int(s[i]-'a')].change(i,1);
    }
    int a,b,c2;
    char c1;
    vector<int> ansvec;
    rep(i,q){
        cin >> a >> b;
        if(a==1){
            cin >> c1;
            b--;
            treevec[(s[b]-'a')].change(b,0);
            treevec[(c1-'a')].change(b,1);
            s[b]=c1;
        }
        else{
            cin >> c2;
            int ans = 0;
            rep(j,27) if(treevec[j].rmq(b-1,c2,0,0,treevec[j].n)>0) ans++;
            ansvec.push_back(ans);
        }
    }
    rep(i,ansvec.size()) cout << ansvec[i] << endl;
}

Measured memory_bytes: 230556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[100010];
int main() {
	ll n,t;
	cin>>n>>t;
	map<ll,ll>b;
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	ll buy=a[0];
	for(ll i=1;i<n;i++){
		b[a[i]-buy]++;
		buy=min(buy,a[i]);
	}
	cout << b.rbegin()->second;
	// your code goes here
	return 0;
}


Measured memory_bytes: 7296
import java.util.*;

class Main {
public static void main(String[] args){

Scanner sc = new Scanner(System.in);
String s = sc.next();
int length = s.length();
int a = length;
int z = -1;
String ss;
for(int i = 0;i < length ;i++){
  ss = s.substring(i,i+1);
  if(ss.equals("A") && a > i){
    a = i;
  }else if(ss.equals("Z") && z < i){
    z = i;
  }
}
int ans = z - a + 1;
System.out.println(ans);

}
}

Measured memory_bytes: 35652
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
int a[100005], dp[100005];
vector<int> g[100005];
int n, k;
int ans = 0;
int dfs(int u){
	int d = 0;
	for(int i=0;i<g[u].size();i++){
		int v = g[u][i];
		int x = dfs(v);
		d = max(d, x);
	}
	if(d == k-1 && a[u] != 1){
		ans++;
		d = -1;
	}
	return d+1;
}
int main(){
	memset(dp, -1, sizeof(dp));
	scanf("%d%d", &n, &k);
	for(int i=1;i<=n;i++){
		scanf("%d", &a[i]);
		if(i == 1) continue;
		g[a[i]].push_back(i);
	}
	queue<int> q;
	q.push(1);
	dp[1] = 0;
	while(!q.empty()){
		int u = q.front();
		q.pop();
		for(int i=0;i<g[u].size();i++){
			int v = g[u][i];
			if(dp[v] == -1){
				dp[v] = dp[u]+1;
				q.push(v);
			}
		}
	}
	bool ok = 1;
	int cycle = dp[a[1]]+1;
	dp[1] = cycle;
	for(int i=1;i<=n;i++){
		if(dp[i] > k){
			ok = 0;
			break;
		}
		if( (k-dp[i])%cycle  == 0) continue;
		ok = 0;
		break;
	}
	if(ok){
		printf("0\n");
		return 0;
	}
	for(int i=0;i<g[a[1]].size();i++){
		if(g[a[1]][i] == 1){
			g[a[1]].erase(g[a[1]].begin()+i);
			break;
		}
	}
	if(a[1] != 1) a[1] = 1, ans++;
	dfs(1);
	printf("%d\n", ans);
}

Measured memory_bytes: 11136
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
    long long a,b;
} ab_data;

int compare_a(const void *a, const void *b) {
    ab_data *A = (ab_data *)a;
    ab_data *B = (ab_data *)b;
    return A->a - B->a;
}

int main()
{
    ab_data ab[100000];
    long long n,k;

    scanf("%lld %lld",&n,&k);

    int i;
    for (i = 0; i < n; i++)
    {
        scanf("%lld %lld",&ab[i].a, &ab[i].b);
    }

    qsort(ab,n,sizeof(ab_data),compare_a);

    long long cnt = 0;
    for (i = 0; i < n; i++)
    {
        cnt += ab[i].b;
        if(cnt >= k)break;
    }
    
    printf("%lld",ab[i].a);
}

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

using namespace std;
typedef pair<int, int> ii;



int main() {
    int n;
    scanf("%d", &n);
    int cnt[3] = {0};
    for(int i = 0; i < n; ++i)  {
        int cc; scanf("%d", &cc);
        cnt[cc-1] += 1;
    }

    double dp[311][311][cnt[2] + 3] ;

    // dp[cnt[0]][cnt[1]][cnt[3]] ;
    dp[0][0][0] = 0;
    for(int c = 0; c <= cnt[2]; ++c) {
        for(int b = 0; b <= n; ++b) {
            for(int a = 0; a <= n; ++a) {
                if(a + b + c == 0) continue;
                if(a + b + c > n) continue;

                double dd = a + b + c;
                dp[a][b][c] = n / dd;
                if(a > 0) {
                    dp[a][b][c] += dp[a-1][b][c]* a / dd;
                }
                if(b > 0) {
                    dp[a][b][c] += dp[a+1][b-1][c] * b / dd;
                }
                if(c > 0) {
                    dp[a][b][c] += dp[a][b+1][c-1] * c / dd;
                }
                
            }
        }
    }

    printf("%.10lf\n", dp[cnt[0]][cnt[1]] [cnt[2]] );

}

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

using namespace std;

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int res = 0;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        res = res ^ a[i];
    }
    for(int i = 0; i < n; i++) {
        cout << (res ^ a[i]) << ' ';
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 3964
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int result = 0;
        for (int i = 1; i <= num; i++){
            for (int j = 1; j <= num; j++){
                for (int k = 1; k <= num; k++){
                    int gcdK = gcd(i,j);
                    int gcdResult = gcd(gcdK, k);
                    result = result + gcdResult;
                }
            }
        }
        System.out.println(result);
    }
    public static int gcd(int a, int b){
        int c = a % b;
        if (c == 0 ){
            return b;
        } else {
            return gcd(b, c);
        }
    }
}


Measured memory_bytes: 35752
#include<bits/stdc++.h>
using namespace std;
int a[300],b[300];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]+=a[i-1];
	}
	for(int i=1;i<=n;i++)
	{
		int y;
		cin>>y;
		b[i]=max(b[i-1],a[i])+y;
	}
	cout<<b[n];
	return 0;
}

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

long long gcd(long long a, long long b) {
	return b == 0 ? a : gcd(b, a % b);
}

int main() {
	long long a, b, c, d;
	cin >> a >> b >> c >> d;

	long long ret = b - a + 1;
	ret -= b / c - (a - 1) / c;
	ret -= b / d - (a - 1) / d;
	long long lcm = c / gcd(c, d) * d;
	ret += b / lcm - (a - 1) / lcm;

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

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

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////


void solve() {
	int A, B, C;
	cin >> A >> B >> C;
	LL now = 0;
	for (int i = 1; i <= 300; ++i) {
		now += A;
		if (now % B == C) {
			cout << "YES" << endl;
			return;
		}
	}
	cout << "NO" << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
n = int(input())
r = [list(map(int,input().split())) for _ in range(n)]
for i in range(n):
  r[i] = [r[i][0] - r[i][1], r[i][0] + r[i][1]]
r.sort(key = lambda x:x[1])
#print(r)
cur = -1001001001
ans = 0
for i in range(n):
  if cur <= r[i][0]:
    ans += 1
    cur = r[i][1]
print(ans)

Measured memory_bytes: 28668
def main():
    N = int(input())
    x = N%10
    
    if x in [2,4,5,7,9]:
        print("hon")
    elif x in [0,1,6,8]:
        print("pon")
    else:
        print("bon")
 
 
if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10000)
    main()

Measured memory_bytes: 9120
import Data.Map (Map)
import qualified Data.Map as Map
import Control.Applicative
import Control.Monad

main :: IO ()
main = do
    [users, events] <- map (read::String -> Int) . words <$> getLine
    inputLines 0 events Map.empty ([]::[Int])
 
addDict map (fn:sn:_) = 
    Map.insertWithKey (\k x y -> x + y)  fn sn map

getHeighest [x] = x
getHeighest xs = do
    if (length greater > 0)
        then getHeighest greater 
        else (xu, xn)
    where
        h = (length xs) `div` 2
        (xu, xn) = xs !! h
        greater = [(u, n) | (u, n) <- xs, xn < n || (xn == n && u < xu)]
            

format :: (Int,Int) -> String
format (a,b) = (show a) ++ " " ++ (show b)

inputLines n limit acc higher = do
  if n < limit
    then do
      s <- map (read::String -> Int) . words <$> getLine
      let dict = addDict acc s
      let t = f higher s dict
      putStrLn $ format t
      inputLines (n + 1) limit dict [fst t, snd t]
    else return ()
        where
            f :: [Int] -> [Int] -> Map.Map Int Int -> (Int, Int)
            f [] _ dict = getHeighest . Map.toList $ dict
            f (h:hx:_) (s:sx:_) dict =
                if (sx < 0 && h == s)
                then getHeighest . Map.toList $ dict
                else if (hv < sv || (hv == sv && s < h))
                    then (s, sv)
                    else (h, hv)
                where
                    hv = dict Map.! h
                    sv = dict Map.! s
 


Measured memory_bytes: 23620
#include <iostream>
using namespace std;
 
int main(){
  int a, b, c[13] = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
  cin >> a >> b;
  if(c[a-1] == c[b-1]) cout << "Yes" << '\n';
  else cout << "No" << '\n';
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
S = list(map(int, input().split()))
Q = int(input())
T = list(map(int, input().split()))

def binary_search(target_num, head, tail):
    while head <= tail:
        idx = int((head+tail)/2)
        if target_num == S[idx]:
            return True
        elif target_num < S[idx]:
            tail = idx - 1
        else:
            head = idx + 1
    return False


match_count = 0
for target_num in T:
    if binary_search(target_num, 0, len(S)-1):
        match_count += 1

print(str(match_count))


Measured memory_bytes: 16708
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var scanner *bufio.Scanner

func printIt() {
	x1 := nextFloat()
	y1 := nextFloat()
	x2 := nextFloat()
	y2 := nextFloat()

	fmt.Println(math.Sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)))
}

func nextFloat() float64 {
	scanner.Scan()
	num, err := strconv.ParseFloat(scanner.Text(), 10)
	if err != nil {
		panic(1)
	}
	return num
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	printIt()
}



Measured memory_bytes: 1148
'use strict'

function main(input) {
  let ans = 'NA'
  const str1 = input.slice(0, 2)
  const str2 = input.slice(2, 4)

  if (str1 > 0 && str1 <= 12 && str2 > 0 && str2 <= 12) {
    ans = 'AMBIGUOUS'
  } else if (str1 > 0 && str1 <= 12 ) {
    ans = 'MMYY'
  } else if (str2 > 0 && str2 <= 12 ) {
    ans = 'YYMM'
  }
  else{
    ans = 'NA'
  }
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
#include <iostream>

using namespace std;

int main() {
    int group[] = { 0, 1, 2, 1, 3, 1, 3, 1, 1, 3, 1, 3, 1 };
    int x, y;
    cin >> x >> y;
    cout << (group[x] == group[y] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256