akhauriyash/Code-Regression huggingface dataset:
// atcoder/agc024/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  lli a, b, c, k;
  while (cin >> a >> b >> c >> k) {
    if (k % 2) cout << b - a << endl;
    else cout << a - b << endl;
  }

  return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin>>N;
  vector<ll> A(N);
  cin>>A;
  for(auto &I:A){I--;}
  queue<ll> Q;
  vector<vector<ll>> edge(N);
  vector<vector<ll>> rev(N);
  vector<ll> cnt(N,0),dp(N,-1);
  for(int i=0;i<N;i++){
    edge[A[i]].push_back(i);
    rev[i].push_back(A[i]);
    cnt[A[i]]++;
  }
  for(int i=0;i<N;i++){
    if(cnt[i]==0){Q.push(i);}
  }
  while(!Q.empty()){
    int u=Q.front();
    Q.pop();
    set<ll> S;
    for(auto &v:edge[u]){S.insert(dp[v]);}
    for(int i=0;;i++){
      if(S.count(i)==0){dp[u]=i; break;}
    }
    for(auto &v:rev[u]){
      cnt[v]--;
      if(cnt[v]==0){Q.push(v);}
    }
  }
  int u=-1;
  for(int i=0;i<N;i++){
    if(dp[i]==-1){u=i; break;}
  }
  if(u==-1){cout<<"POSSIBLE"<<endl; assert(false);return 0;}
  set<ll> S;
  for(auto &v:edge[u]){S.insert(dp[v]);}
  int a,b,ad,bd;
  for(int i=0;;i++){
    if(S.count(i)==0){a=i; break;}
  }
  for(int i=a+1;;i++){
    if(S.count(i)==0){b=i; break;}
  }
  ad=a;
  bd=b;
  int st=u;
  do{
    for(auto &v:rev[u]){
      if(dp[v]==-1){u=v; break;}
    }
    S.clear();
    for(auto &v:edge[u]){
      S.insert(dp[v]);
    }
    int nxa=-1,nxb=-1;
    for(int i=0;nxa==-1 || nxb==-1;i++){
      if(S.count(i)==0){
	if(i!=a && nxa==-1){nxa=i;}
	if(i!=b && nxb==-1){nxb=i;}
      }
    }
    a=nxa;
    b=nxb;
  }while(u!=st);
  if(ad==a || bd==b){cout<<"POSSIBLE"<<endl;}
  else{cout<<"IMPOSSIBLE"<<endl;}
  return 0;
}


Measured memory_bytes: 25728
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>
#include <unordered_set>
#include <cmath>
using namespace std;
typedef long long ll;


int main(int argc, char* argv[] ){
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  if( A+B < 2*C ){
    cout << (X*A + Y*B) << endl;
  } else {
    if( X > Y ){
      if( A > 2*C ){
        cout << (2*X*C) << endl;
      } else {
        cout << (2*Y*C + (X-Y)*A ) << endl;
      }
    } else {
      if( B > 2*C ){
        cout << (2*Y*C) << endl;
      } else {
        cout << (2*X*C + (Y-X)*B ) << endl;
      }
    }
  }
  return 0;
 }


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n, minj, esc, count=0;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    
    for(int i=0;i<n;i++){
        minj = i;
        for(int j=i;j<n;j++){
            if(a[j] < a[minj]){
                minj = j;
            }
        }
        esc = a[i];
        a[i] = a[minj];
        a[minj] = esc;
        if(i != minj){
            count++;
        }
    }
    
    for(int i=0;i<n;i++){
        cout << a[i];
        if(i != n-1){
            cout << " ";
        }
    }
    
    cout << endl << count << endl;
    
    
    return 0;
}


Measured memory_bytes: 3108
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    w, h, n = list(map(int, input().split()))
    w_min, w_max = 0, w
    h_min, h_max = 0, h

    for _ in range(n):
        x, y, a = list(map(int, input().split()))

        if a == 1:
            w_min = max(x, w_min)
        elif a == 2:
            w_max = min(x, w_max)
        elif a == 3:
            h_min = max(y, h_min)
        elif a == 4:
            h_max = min(y, h_max)

    print(max(w_max - w_min, 0) * max(h_max - h_min, 0))


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N;
        cin >> N;
        if (N % 2) {
            cout << 0 << endl;
            return;
        }

        Int ans = 0;
        Int base = 10;
        while (base <= N) {
            ans += N / base;
            base *= 5ll;
        }
        cout << ans << endl;
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>

int main(void){

	int m,f,r;
	int t;
	
	while(1){
		scanf("%d %d %d",&m,&f,&r);
		t=m+f;
		if(m==-1&&f==-1&&r==-1){
			break;
		}
		else{
			if(m==-1||f==-1){
				printf("F");
			}
			else if(t>=80){
				printf("A");
			}
			else if(t>=65&&t<80){
				printf("B");
			}
			else if(t>=50&&t<65){
				printf("C");
			}
			else if(t>=30&&t<50){
				if(r>=50){
					printf("C");
				}
				else{
					printf("D");
				}
			}
			else{
				printf("F");
			}
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <algorithm>
#include <queue>
#include <cmath>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
typedef pair<double, int> Pd;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int n, i, pv;
    double xs, ys, xg, yg, x[1007], y[1007], r[1003], d[1007] = {}, ds, nds, dx, dy;
    priority_queue<Pd, vector<Pd>, greater<Pd>> pq;

    scanf("%lf%lf%lf%lf", &xs, &ys, &xg, &yg);
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%lf%lf%lf", &x[i + 1], &y[i + 1], &r[i + 1]);
    }

    for (i = 0; i < n + 2; i++) {
        d[i] = 1000000000000000000.0;
    }

    x[0] = xs;
    y[0] = ys;
    x[n + 1] = xg;
    y[n + 1] = yg;
    r[0] = r[n + 1] = 0.0;
    d[0] = 0.0;
    pq.push(Pd(0.0, 0));
    while (!pq.empty()) {
        Pd p = pq.top();
        pq.pop();
        ds = p.first;
        pv = p.second;
        if (d[pv] < ds) {
            continue;
        }
        for (i = 1; i < n + 2; i++) {
            if (i == pv) {
                continue;
            }
            dx = abs(x[pv] - x[i]);
            dy = abs(y[pv] - y[i]);
            nds = max(0.0, sqrt(dx * dx + dy * dy) - r[pv] - r[i]);
            if (d[i] > ds + nds) {
                d[i] = ds + nds;
                pq.push(Pd(d[i], i));
            }
        }
    }

    printf("%.12lf\n", d[n + 1]);

    return 0;
}

Measured memory_bytes: 6000
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;

int len(ll x) {
	int res = 0;
	while (x > 0)
	{
		res++;
		x /= 10;
	}
	return res;
}
int main() {
	ll n;
	cin >> n;
	int ans = INF;
	for (ll i = 1; i*i <= n; i++)
	{
		if (n % i != 0) continue;
		ans = min(ans, len(n/i));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3652
num_employee = int(input())
boss_employee_ids = map(int, input().split())

boss_num_list = [0] * num_employee

for boss_employee_id in boss_employee_ids:
    boss_num_list[boss_employee_id - 1] += 1

for boss_num in boss_num_list:
    print(boss_num)


Measured memory_bytes: 24624
t1,t2 = map(int, input().split())
a1,a2 = map(int, input().split())
b1,b2 = map(int, input().split())
diff = (t1 * a1 + t2 * a2) - (t1 * b1 + t2 * b2)
diff1 = t1 * (a1-b1)
diff2 = t1 * (a2-b2)
if diff == 0:
  print("infinity")
else:
  if (diff < 0 and diff1 < 0) or (diff > 0 and diff1 > 0):
    print(0)
  else:
    ans = 1
    if diff1 > 0:
      cnt = diff1 // -diff
      if not diff1 % -diff:
        ans += cnt * 2 - 1
      else:
        ans += cnt * 2
    else:
      cnt = -diff1 // diff
      if not -diff1 % diff:
        ans += cnt * 2 - 1
      else:
        ans += cnt * 2 
    print(ans)

Measured memory_bytes: 3064
from sys import stdin
import sys
import math
import random
from decimal import Decimal


N, M, K = [int(x) for x in stdin.readline().rstrip().split()]
A = list(map(int, input().split()))
A1 = [0]
for i, v in enumerate(A):
    x = A1[i]+v
    A1.append(x)
B = list(map(int, input().split()))
B1 = [0]
for i, v in enumerate(B):
    x = B1[i]+v
    B1.append(x)
c1 = 0
c2 = 0
ans = 0
temp = M

for i in range(N+1):
    if A1[i] > K:
        break
    while B1[temp] > K-A1[i]:
        temp -= 1
    ans = max(ans, i+temp)
    # for k in range(temp, 0, -1):
    #     if A1[i]+B1[k] <= K:
    #         ans = max(ans, i+k)
    #         temp = k
    #         break
# print(c1, c2)

print(ans)


Measured memory_bytes: 51832
# nを素因数分解したリストを返す
def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

n = int(input())

from collections import defaultdict
dic = defaultdict(int)

for i in range(1, n+1):
    for prime in prime_decomposition(i):
        dic[prime] += 1

values = dic.values()

up2 = 0
up4 = 0
up14 = 0
up24 = 0
up74 = 0
for d in values:
    if d >= 74:
        up74 += 1
    if d >= 24:
        up24 += 1
    if d >= 14:
        up14 += 1
    if d >= 4:
        up4 += 1
    if d >= 2:
        up2 += 1

# 5 * 5 * 3
# 25 * 3
# 15 * 5
# 75

ans = 0
#75
ans += up74
#25*3
ans += up24 * (up2 - 1)
#15*5
ans += up14 * (up4 - 1)
#5*5*3
ans += up4 * (up4 - 1) * (up2-2) // 2


print(ans)


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

int main() {
    int n, x = 0;
    string s;
    cin >> n >> s;
    int ans = x;
    for (auto c: s) {
        if (c == 'I') x++;
        else x--;
        ans = max(ans, x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  Last Updated: 2018-10-23 ...Maybe
//
//    I hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -DDEBUG_LOCAL'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REAP(i,0,n)
#define REAP(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REAP,_REP,)(__VA_ARGS__)

#define _REPR(i,n) REAPR(i,n,0)
#define REAPR(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define REPR(...) _overload3(__VA_ARGS__,REAPR,_REPR,)(__VA_ARGS__)

#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()

#define coutALL(a) {int loop_coutALL=0;for(auto e:a) cout<<(loop_coutALL++?" ":"")<<e; cout<<endl;}

#define coutYN(a) cout<<((a)?"YES":"NO")<<endl;
#define coutYn(a) cout<<((a)?"Yes":"No")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;

#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)

const int INF=1145141919;
//const long long INF=114514191911451419;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename T> istream &operator >> (istream &is, vector<T> &v){for(T &x:v) is>>x;return is;}
template<typename T> ostream &operator << (ostream &os, vector<T> &v){int i=0;for(T &x:v) os<<(i++?" ":"")<<x;return os;}

ll rev(ll n){ll x=0;for(;n>0;){x=x*10+n%10;n/=10;}return x;}

ll upper(ll n,ll m){return (n+m-1)/m;};
ll rounding(ll n){return (long double)n+0.5;};

bool inG(ll x,ll n){return 0<=x && 0<n;}
bool outG(ll x,ll n){return x<0 || n<=x;}

inline int qp(int a,ll b){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
inline int qp(int a,ll b,int mo){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

inline ll fac(ll k,ll n){ll a=1;for(int i=0;i<n;i++)a*=k--;return a;}
inline ll fac(ll k,ll n,int mo){ll a=1;for(int i=0;i<n;i++)a*=k--,a%=mo;return a;}

inline int dsum(ll n){int a=0;for(;n;n/=10)a+=n%10;return a;}

struct Arithmetic{Arithmetic(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}};

//#define DEBUG_LOCAL

#ifdef DEBUG_LOCAL
template<typename T> void deb(T a){cerr<<"deb: "<<a<<"です"<<endl;}
#define debl {cerr<<"debug: "<<__LINE__<<"行目だ"<<endl;}
void what_cr(){cout<<__GCC_ATOMIC_CHAR16_T_LOCK_FREE<<" ←？"<<endl;}
//ori_func S

//ori_func E
#else
template<typename T>void deb(T a){}
#define debl
void what_cr(){}void t_t(){}
#endif

signed main(){

  Arithmetic Exception;

  for(double a;cin>>a;cout<<a*7.81481481<<endl);
  
  return 0;

}



Measured memory_bytes: 3244
#include <stdio.h>

int main(){
    char s[10];
    int y, m, d, ymd;

    scanf("%s", s);

    ymd = (s[0] - '0') * 10000000;
    ymd += (s[1] - '0') * 1000000;
    ymd += (s[2] - '0') * 100000;
    ymd += (s[3] - '0') * 10000;
    ymd += (s[5] - '0') * 1000;
    ymd += (s[6] - '0') * 100;
    ymd += (s[8] - '0') * 10;
    ymd += (s[9] - '0');

    d = ymd % 100;
    ymd /= 100;
    m = ymd % 100;
    ymd /= 100;
    y = ymd;

    if(y <= 2019 && m <= 4 && d <= 30){
        printf("Heisei\n");
    }
    else{
        printf("TBD\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
const ll MOD=1e9+7;
int main()
{
    int n, x; cin>>n>>x;
	int s[201];
	for(int i=0; i<n; i++){
		cin>>s[i];
	}
	sort(s, s+n);
	ll ans=0;
	ll dp[201][100001]={};
	for(int i=0; i<n; i++){
		dp[0][x%s[i]]++;
	}
	for(int i=0; i<n-1; i++){
		int t=0;
		for(int j=0; j<=x; j++){
			if(dp[i][j]==0) continue;
			while(t<n && s[t]<=j) t++;
			dp[i+1][j]+=dp[i][j]*(ll)max(n-t-i-1, 0);
			dp[i+1][j]%=MOD;
			for(int k=0; k<t; k++){
				dp[i+1][j%s[k]]+=dp[i][j];
				dp[i+1][j%s[k]]%=MOD;
			}
		}
	}
	for(ll i=0; i<=x; i++){
      //cout<<dp[n-1][i]<<endl;
		ans+=dp[n-1][i]*i;
		ans%=MOD;
	}
	cout<<ans<<endl;
    return 0;
}

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

int main()
{
    ll x, y;
    cin >> x >> y;
    int ans = 0;

    while (x <= y)
    {
        ans++;
        x += x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll q;
  cin>>q;
  vector<ll> a(q);
  vector<ll> b(q);

  rep(i,q) cin>>a[i]>>b[i];

  rep(i,q){
    ll score=a[i]*b[i];
    ll sq=(ll)sqrt(score);
    //cout << sq << endl;
    ll ans;
    ll m=min(a[i],b[i]);
    ll M=max(a[i],b[i]);

    if( sq*sq==score ){
      if( m==M ) ans=2*(sq-1);
      else ans=2*(sq-1) -1 ;
    }
    else if( sq*(sq+1)<score){
      ans = 2*(sq-1)+1;
    }
    else ans=2*(sq-1);

    cout << ans << endl;
  }

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

Measured memory_bytes: 256
import heapq

n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True)
ans=0
q=[]
heapq.heappush(q,-arr[0])
for i in range(1,n):
  ans+=-heapq.heappop(q)
  heapq.heappush(q,-arr[i])
  heapq.heappush(q,-arr[i])
print(ans)

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

int main() {
    string s;
    int m;
    int h;

    while (true) {
        cin >> s;

        if (s[0] == '-') {
            break;
        }
        cin >> m;

        for (int i = 0; i < m; i++) {
            cin >> h;
            string s1 = s.substr(h);
            string s2 = s.erase(h);
            s = s1 + s2;
        }
        cout << s << endl;
    }

    return 0;
}


Measured memory_bytes: 3236
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y =  sc.nextInt();
		sc.close();
		BigDecimal bdw = new BigDecimal(W);
		BigDecimal bdh = new BigDecimal(H);
		double d = bdw.multiply(bdh).divide(new BigDecimal("2.0")).doubleValue();
		if(x* 2== W && y * 2 == H) {
			System.out.println(d +" "+"1");
		}else {
			System.out.println(d +" "+"0");
		}
	}
}

Measured memory_bytes: 22100
import static java.lang.System.out;

public class Main {

    public static void main(String[] args) {
        new Main().recursionQQ();
    }

    public void loopQQ() {
        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                out.println(i + "x" + j + "=" + i * j);
            }
        }
    }

    public void recursionQQ() {
        recursionQQ(1);
    }

    public void recursionQQ(int i) {
        if (i > 9)
            return;
        recursionQ(i, 1);
        recursionQQ(++i);
    }

    public void recursionQ(int i, int j) {
        if (j > 9)
            return;
        out.println(i + "x" + j + "=" + i * j);
        recursionQ(i, ++j);
    }
}

Measured memory_bytes: 24292
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<set<int>> Ux(200001);
  vector<set<int>> Dx(200001);
  vector<set<int>> Ly(200001);
  vector<set<int>> Ry(200001);
  vector<set<int>> Uxpy(400001);
  vector<set<int>> Dxpy(400001);
  vector<set<int>> Lxpy(400001);
  vector<set<int>> Rxpy(400001);
  vector<set<int>> Uxmy(400001);
  vector<set<int>> Dxmy(400001);
  vector<set<int>> Lxmy(400001);
  vector<set<int>> Rxmy(400001);
  REP(i, N) {
    int X, Y;
    cin >> X >> Y;
    char U;
    cin >> U;
    if(U == 'U') {
      Ux[X].insert(Y);
      Uxpy[X+Y].insert(X);
      Uxmy[X-Y+200000].insert(X);
    } else if(U == 'R') {
      Ry[Y].insert(X);
      Rxpy[X+Y].insert(X);
      Rxmy[X-Y+200000].insert(X);
    } else if(U == 'D') {
      Dx[X].insert(Y);
      Dxpy[X+Y].insert(X);
      Dxmy[X-Y+200000].insert(X);
    } else if(U == 'L') {
      Ly[Y].insert(X);
      Lxpy[X+Y].insert(X);
      Lxmy[X-Y+200000].insert(X);
    }
  }
  int ans = 1e9;
  REP(i, 200001) for(int k : Ux[i]) {
    auto itr = Dx[i].lower_bound(k);
    if(itr != Dx[i].end()) ans = min(ans, (*itr-k)*5);
  }
  REP(i, 200001) for(int k : Ry[i]) {
    auto itr = Ly[i].lower_bound(k);
    if(itr != Ly[i].end()) ans = min(ans, (*itr-k)*5);
  }
  REP(i, 400001) for(int k : Rxmy[i]) {
    auto itr = Dxmy[i].lower_bound(k);
    if(itr != Dxmy[i].end()) ans = min(ans, (*itr-k)*10);
  }
  REP(i, 400001) for(int k : Uxmy[i]) {
    auto itr = Lxmy[i].lower_bound(k);
    if(itr != Lxmy[i].end()) ans = min(ans, (*itr-k)*10);
  }
  REP(i, 400001) for(int k : Rxpy[i]) {
    auto itr = Uxpy[i].lower_bound(k);
    if(itr != Uxpy[i].end()) ans = min(ans, (*itr-k)*10);
  }
  REP(i, 400001) for(int k : Dxpy[i]) {
    auto itr = Lxpy[i].lower_bound(k);
    if(itr != Lxpy[i].end()) ans = min(ans, (*itr-k)*10);
  }

  if(ans == 1e9) cout << "SAFE" << endl;
  else cout << ans << endl;
}

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

struct UnionFind {
    vector<int> parent;

    UnionFind(int N) {
        parent = vector<int>(N, -1);
    }

    int root(int x) {
        if (parent[x] < 0) return x;
        return root(parent[x]);
    }

    int size(int x) {
        return -parent[root(x)];
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (parent[x] > parent[y]) swap(x, y);
        parent[x] += parent[y];
        parent[y] = x;
        return true;
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);

    UnionFind tree(n);

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        tree.unite(a, b);
    }    

    int ans = 1;

    rep(i, n) {
        ans = max(ans, tree.size(i));
    }
    
    cout << ans << endl;
    return 0;
}

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

int main() {
  double a, b, h ,m;
  cin >> a >> b >> h >> m;
  
  double PI=3.14159265358979;
  
  double Ans = sqrt(a*a + b*b - 2*a*b*cos(PI / 6.0 * h - 11.0 / 360.0 * PI * m) );
  
  cout << fixed << setprecision(15);
  
  cout << Ans << endl;
}




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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll inf = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/



int main(){
    fIO

    string s;
    cin >> s;

    for(int i = 0; i < s.length(); i++){
        if(i & 1){
            if(!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')) return cout << "No", 0;
        }else{
            if(!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) return cout << "No", 0;
        }
    }
    cout << "Yes";
}








Measured memory_bytes: 256
program main
      implicit none
      integer m,n,i,j
      real x
      integer,allocatable :: a(:)

      read *, n,m
      allocate( a(n) )
      read *, a

      j = 0
      do i = 1, n
        x = real(a(i))/real(sum(a(:)))
        if ( x < 1.0/real((4*m))) then
        else
          j = j + 1
        end if
      end do

      if ( j < m ) then
              print *, "No"
      else
              print *, "Yes"
      end if

end program main

Measured memory_bytes: 640
import Control.Applicative
import Data.List
import Data.Char

getInt :: IO Integer
getInt = (\a -> read a :: Integer) <$> getLine

getIntArray :: IO [Integer]
getIntArray = ((map (\a -> read a :: Integer)) . words) <$> getLine

getStrArray :: Integer -> IO [String]
getStrArray 0 = return [] :: IO [String]
getStrArray n = (:) <$> getLine <*> (getStrArray (n - 1))

main = do
    putStrLn =<< ((\[a, b] -> if a + b >= 10 then "error" else show $ a + b) <$> getIntArray)


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=2e5+10;
const int mod=1e9+7;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin>>x;
    if(x>=30)
    {
        cout<<"Yes"<<'\n';
    }
    else
        cout<<"No"<<'\n';



}


Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main(void)
{
	int n;
	int a,b,c;
	bool flg;
	cin>>n;
	for(int i=0;i<n;i++){
		flg=false;
		cin>>a>>b>>c;
		if((c*c)==(a*a)+(b*b)||(b*b)==(a*a)+(c*c)||(a*a)==(b*b)+(c*c)){
			flg=true;
		}
		cout<<((flg)?"YES":"NO")<<endl;
	}
	return 0;
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

signed main(){
  FASTER;
  int n,s=0;cin>>n;
  for(int i=1;i<n;i++)s+=i;
  cout<<s;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner scan = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		int n = si();
		if(n!=0)
		while(true){
			Score[] sc = new Score[n];
			for (int i = 0; i < n; i++) {
				sc[i] = new Score(scan.next(),si(),si(),si());
			}
			Arrays.sort(sc);
			for (int i = 0; i < n; i++) {
				out.println(sc[i].str+","+sc[i].sc);
			}
			n = si();
			if(n==0) break;
			else out.println();
		}
		out.flush();
	}

	static int si() {
		return Integer.parseInt(scan.next());
	}
}

class Score implements Comparable<Object> {
	String str;
	int sc;
	Score(String s,int w,int l,int t){
		str = s;
		sc = w*3+t;
	}
	@Override
	public int compareTo(Object o) {
		return -(this.sc-((Score)o).sc);
	}
}

Measured memory_bytes: 18336
X=int(input())
a=[]
for i in range(-100,200):
  for j in range(-100,200):
    if i**5-j**5==X:
      a.append(str(i))
      a.append(str(j))
      break
  else:
    continue
  break  
print(' '.join(a[0:2]))

    


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

using namespace std;

typedef long long ll;
typedef pair<int,int> p;


int main()
{
  int a,b;
  char op;
  cin >> a >> op >> b;
  if (op == '+') {
    cout << a + b << endl;
  }else{
    cout << a - b << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;

namespace Sample1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            long a = long.Parse(input.Split(' ')[0]);
            long power = 1;
            for(long i = 1;i <= a; i += 1)
            {
                power *= i % 1000000007L;
                power = power % 1000000007L;
            }
            Console.WriteLine(power % 1000000007L);
        }
    }
}

Measured memory_bytes: 13140
W, H, N = map(int, input().split())
left = 0
right = W
down = 0
up = H
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 2:
        right = min(right, x)
    if a == 1:
        left = max(left, x)
    if a == 3:
        down = max(down, y)
    if a == 4:
        up = min(up, y)
# print(left, right, down, up)
if right >= left and up >= down:
    print((right-left)*(up-down))
else:
    print(0)


Measured memory_bytes: 3064
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    a,b = map(int,input().split())
    plug=1
    ans=0

    while True:
        if plug >= b:
            break
        plug+=a-1
        ans+=1
#        print("count={},plug={}".format(count,plug))
    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 9168
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=acos(-1.0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll par[800010];
ll len[800010];
ll you[800010];
void init(ll n){
  for(int i=0;i<n;i++){
    par[i]=i;
    len[i]=0;
    you[i]=1;
  }
}
ll root(ll n){
  if(par[n]==n)return n;
  return par[n]=root(par[n]);
}
void unit(ll a,ll b){
  a=root(a);
  b=root(b);
  if(a==b)return;
  if(len[a]<len[b]){
    par[a]=b;
    you[b]+=you[a];
  }
  else{
    par[b]=a;
    you[a]+=you[b];
    if(len[a]==len[b])len[a]++;
  }
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,m;cin>>n>>m;
    string s;cin>>s;
    ll ma[n+1];
    rep(i,0,n+1)ma[i]=i;
    rep(i,0,m){
        ll l,r;cin>>l>>r;
        ma[l]=max(ma[l],r);
    }
    rep(i,1,n+1){
        ma[i]=max(ma[i],ma[i-1]);
    }
    ll cn[n+1];
    cn[0]=0;
    rep(i,0,n){
        if(s[i]=='0')cn[i+1]=cn[i]+1;
        else cn[i+1]=cn[i];
    }
    ll ze=cn[n];
    ll dp[n+1][ze+1];
    memset(dp,0,sizeof dp);
    dp[0][0]=1;
    rep(i,0,n){
        rep(j,0,ze+1){
            if(dp[i][j]==0)continue;
            ll maa=ma[i+1];
            ll oj=i-j;
            ll zz=cn[maa]-j;
            ll zo=maa-cn[maa]-oj;
            if(zz>0){
                (dp[i+1][j+1]+=dp[i][j])%=mod;
            }
            if(zo>0){
                (dp[i+1][j]+=dp[i][j])%=mod;
            }
        }
    }
    cout<<dp[n][ze]<<endl;
}


Measured memory_bytes: 36736
#include <iostream>
#include <algorithm>
using namespace	std;
int main(){

  long long int result=1;
  int n,m,i;

  cin>>n>>m;
  if(n<m) swap(n,m);
  if(n-m!=1 && n-m!=0){
    cout<<0<<endl;
    return 0;
  }
  if(n-m==0) result++;

  for(i=1;i<=n;i++){
    result*=i;
    result=result%1000000007;
  }
  for(i=1;i<=m;i++){
    result*=i;
    result=result%1000000007;
  }

  cout<<result<<endl;

  return 0;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eps 1e-12
#define int long long
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
    int ans = 1;
    for (; b; b >>= 1, a = a * a % mod)
        if (b & 1)
            ans = ans * a % mod;
    return ans;
}
char s[2000000];
signed main()
{
    io;
    int l=500000,r=l-1;
    int f=1;
    string ss;cin>>ss;
    for(int i=0;i<ss.size();i++)s[++r]=ss[i];
    int q;cin>>q;
    while(q--){
        int op;cin>>op;
        if(op==1){
            f^=1;continue;
        }
        int F;char c;
        cin>>F>>c;
        if(F==1){
            if(f)s[--l]=c;
            else s[++r]=c;
        }
        else {
            if(!f)s[--l]=c;
            else s[++r]=c;
        }
    }
    if(f)rep(i,l,r)cout<<s[i];
    else for(int i=r;i>=l;i--)cout<<s[i];

    getchar();getchar();
}


Measured memory_bytes: 1104
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import           Unsafe.Coerce

main :: IO ()
main = do
    !n <- readLn :: IO Int
    xs <- U.unfoldrN n (C.readInt.C.dropWhile isSpace) <$> C.getLine
    print $ solve xs

solve :: U.Vector Int -> Int
solve xs
    | even negs = U.sum abss
    | otherwise = U.sum abss - 2 * U.minimum abss
  where
    negs = U.length $ U.filter (<0) xs
    abss = U.map abs xs


-------------------------------------------------------------------------------
type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
    (,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt4 :: Parser (Int, Int, Int, Int)
parseInt4 = runStateT $
    (,,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

Measured memory_bytes: 5756
// User: woshiluo
// Email: woshiluo@woshiluo.site
// Problem link: https://atcoder.jp/contests/arc103/tasks/arc103_d
// Comment: 
// Why the problem id is 'F', but the link is 'arc103_d'
// Interesting

#include <cstdio>
#include <cstdlib>

#include <map>
#include <algorithm>

const int N = 1e5 + 1e3;

int n;
int size[N], father[N];

struct node{
	int id;
	long long d;
} a[N];

std::map<long long, int> mp;

void wrong() {
	printf( "-1\n" );
	exit(0);
}
bool cmp( node _a, node _b ) { return _a.d < _b.d; }

int main() {
#ifdef woshiluo
	freopen( "F.in", "r", stdin );
	freopen( "F.out", "w", stdout );
#endif
	scanf( "%d", &n );
	for( int i = 1; i <= n; i ++ ) {
		scanf( "%lld", &a[i].d );
		a[i].id = i;
		size[i] = 1;
		mp[ a[i].d ] = i;
	}
	std::sort( a + 1, a + n + 1, cmp );
	int rt_d, rt;
	rt = a[1].id; rt_d = a[1].d;
	for( int i = n; i > 1; i -- ) {
		int fa = mp[ a[i].d + 2LL * size[ a[i].id ] - n ];
		if( fa == 0 ) {
			wrong();
			return 0;
		} 
		size[fa] += size[ a[i].id ];
		father[ a[i].id ] = fa;
	}
	for( int i = 1; i <= n; i ++ ) {
		if( i == rt ) 
			continue;
		 rt_d -= size[i];
	}
	if( rt_d != 0 ) 
		wrong();

	for( int i = 1; i <= n; i ++ ) {
		if( father[i] == 0 ) 
			continue;
		printf( "%d %d\n", father[i], i );
	}
}

Measured memory_bytes: 9984
#include<iostream>
using namespace std;
int main(){
  int n,a[100],c=0;
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n-1;i++) 
    for(int j=n-1;i<j;j--){
      int tmp=a[j];
      if(a[j-1]>a[j])a[j]=a[j-1],a[j-1]=tmp,c++;
    }
  for(int i=0;i<n-1;i++)cout<<a[i]<<" ";
  cout<<a[n-1]<<endl;
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 1164
def C_TakandCards():
    from collections import Counter
    from collections import defaultdict
    N, A = map(int, input().split())
    x = list(map(int, input().split()))
    # 0からの差分を取る
    Y = [z - A for z in x]
    d = defaultdict(int)
    # 計算都合で合計値0は0個だが1個と置き後で引く
    d[0] = 1
    # xの全要素について、端から順に0からの差分をkeyとして、その個数をvalueに格納する
    for y in Y:
        for k, v in list(d.items()):
            d[k+y] += v
    print(d[0]-1)
    
if __name__ == "__main__":
    C_TakandCards()

Measured memory_bytes: 3572
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;
int main()
{
    char a[50],b[50];
    cin>>a>>b;
    int l=strlen(a);
    for(int i=0;i<l;i++ )
    {
        if(a[i]!=b[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

int main(){
  vector<int> A={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << A.at(K-1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i, n) for (int i=0;i<n;i++)
using namespace std;
int main() {
  string n,m="Sunny";
  cin >> n;
  if (n=="Sunny") m="Cloudy";
  else if (n=="Cloudy") m="Rainy";
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
//------------------------------------------------------------
		int N =sc.nextInt();
		sc.close();
		int ans =1+digitSum(N-1);
		for (int A=1; A<N; A++) {
			int B =N-A;
			ans = Math.min(ans, digitSum(A)+digitSum(B));
		}
		System.out.println(ans);

//------------------------------------------------------------
	}
	public static int digitSum(int n) {
		int digitSum = 0;
		while(n>0) {
			digitSum +=n%10;
			n /= 10;
		}
		return digitSum;
	}
}

Measured memory_bytes: 23252
#include <stdio.h>
#include <iostream>

int main() {
    int arr[100], v;
    int n, i, j;
    
    //input
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }
    
    /* main processing */
    //sort
    for (i = 0; i < n; i++) {
        v = arr[i];
        j = i - 1;
        while (j >= 0 && arr[j] > v) {
            arr[j+1] = arr[j];
            j--;
        }
        arr[j+1] = v;
        
        //output
        for (j = 0; j < n; j++) {
            if (j < n-1) {
                printf("%d ", arr[j]);
            }
            else {
                printf("%d\n", arr[j]);
            }
        }
    }
    
    return 0;
}

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

int main(){
    int N,K,Q;
    cin >> N >> K >> Q;
    vector<int> point(N,K-Q);
    for (int i = 0; i < Q; i++){
        int a;
        cin >> a;
        point.at(a-1)++;
    }
    for (int i = 0; i < N; i++){
        if (point.at(i) > 0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1024
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
count = 0
for i in range(n):
  a = list(map(int, input().split()))
  s = c
  for j in range(m):
    s += a[j]*b[j]
  if s >0:
    count += 1
print(count)

Measured memory_bytes: 3060
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

#define rep(loop, N) for (int loop = 0; loop < N; loop++)

using namespace std;

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
		else {
			break;
		}
	}
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination1(int, int);
};
int Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_ABC_Swap(void) {

	int X, Y, Z; cin >> X >> Y >> Z;

	cout << Z << " " << X << " " << Y;
	return;
}

void B_Popular_Vote(void) {

	int N, M; cin >> N >> M;
	vector<int> A(N); for (int& it : A)cin >> it;

	sort(A.begin(), A.end(), greater<int>());
	int sum = accumulate(A.begin(), A.end(), 0);
	rep(index, M) {
		if (A[index] * 4 * M < sum) {
			cout << "No" << flush;
			return;
		}
	}
	cout << "Yes" << flush;
	return;
}

int main(void) {

	//A_ABC_Swap();
	B_Popular_Vote();
	return 0;
}


Measured memory_bytes: 256