akhauriyash/Code-Regression huggingface dataset:
/*
Author: Arham_doshi
@quote "Code like there's no tommorow!"
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
#include <bits/stdc++.h>

#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007



using namespace std;

int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
bool mod(double a,double b) {return a/b - floor(a/b);}

int occurs(vi v,int n){
auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}

int logb(int base, int x) {
    return (log(x) / log(base));
}



signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int i,j,x,n,k,sum=0,mx=-1;
    cin>>n>>k;
    vi a,f;
    fo(i,0,n){
        cin>>x;
        a.pb(x);
    }
    
    fo(i,0,n){
        cin>>x;
        f.pb(x);
    }
    
    sort(all(a));
    sort(rall(f));
    
    int l=0,r=1e18 + 5 ,mid,ans=-1;
    
    while(l<=r){
        mid=(l+r)/2;
        x=0;
        fo(i,0,n){
            j=(a[i]-mid/f[i]);
            x+=max(0ll,j);
        }
        
        if(x>k){
            l=mid+1;
        }
        else{
            r=mid-1;
            ans=mid;
        }
        
        
    }
    
    cout<<ans;
    
    
    
    return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define int int64_t
#define all(x) (x).begin(), (x).end()
#define OUT(x) ((cout << x), exit(0))
#define out(x) return void(cout << x << endl)
using namespace std;
typedef long double db;
const int64_t INF = (int64_t)(2e18);
const int inf = (int)(1e9 + 7);
//------------------------------------------//

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cin.tie(nullptr);

#ifdef _MY
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    for (auto& it : v)
    {
        int x, l;
        cin >> x >> l;
        it = { x - l, x + l };
    }
    sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b)
        {
            return a.second < b.second;
        });

    int mx = -INF;
    int res = 0;
    for (auto& it : v)
    {
        if (it.first >= mx)
        {
            //cout << &it - &*v.begin() << "-" << endl;
            mx = it.second;
            res++;
        }
    }

    cout << res;



    return 0;
}

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

int main() {
  int N,a = 0;
  cin >> N;
  vector<int> B(N-1);
  for (int i=0; i<N-1; i++){
    cin >> B.at(i);
  }
  a += B.at(0) + B.at(N-2);
  if (N > 2) {
    for (int i=2; i<N; i++){
      a += min(B.at(i-1),B.at(i-2));
    }
  }
  cout << a << endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation
#include<complex>
#include<math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep2(i, j, n) for (int i = j; i < (int)(n); i++)

int main() {
	int N;
	cin >> N;
	long double answer;
	answer = N * 2 * 3.14159265;
	cout << answer << endl;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
main(){
int i,j,k,l,n,p;
char s[5],s1[5];
while(cin>>s>>s1){ p=0;
     for(i=0;i<3;i++) if(s[i]==s1[i]) p++;
     cout<<p<<endl;
}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

bool isPal(std::string s) 
{
    for(int i=0;i<s.size();++i){
        if(s[i]!=s[(s.size()-1)-i]) return false;
    }

    return true; 
}

int main(){
    std::string s;
    bool result;
    std::cin>>s;
    result=isPal(s) && isPal(s.substr(0,(s.size()-1)/2)) && isPal(s.substr((s.size()+2)/2, s.size()));
    std::cout<<(result?"Yes":"No");

    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

cntw = 0
cnte = 0
lstw = [0] * N
lste = [0] * N

for i in range(N):
    lstw[i] = cntw
    lste[N-i-1] = cnte
    if(S[i] == 'W'):
        cntw += 1
    if(S[N-i-1] == 'E'):
        cnte += 1 
    
ans = N
for i in range(N):
    ans = min(ans,lstw[i]+lste[i])

print(ans)

Measured memory_bytes: 17636
N,K=[int(s) for s in input().split()]
snuke=[0 for _ in range(N)]
for i in range(K):
  a=int(input())
  ls=[int(s) for s in input().split()]
  for e in ls:
    snuke[e-1]+=1
ans=0
for e in snuke:
  if e==0:
    ans+=1
print(ans)

Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
int main() 
{
    int a[100];


    a[1]=1;
    a[2]=1;
    a[3]=1;
    a[4]=2;
    a[5]=1;
    a[6]=2;
    a[7]=1;
    a[8]=5;
    a[9]=2;
    a[10]=2;
    a[11]=1;
    a[12]=5;
    a[13]=1;
    a[14]=2;
    a[15]=1;
    a[16]=14;
    a[17]=1;
    a[18]=5;
    a[19]=1;
    a[20]=5;
    a[21]=2;
    a[22]=2;
    a[23]=1;
    a[24]=15;
    a[25]=2;
    a[26]=2;
    a[27]=5;
    a[28]=4;
    a[29]=1;
    a[30]=4;
    a[31]=1;
    a[32]=51;
  int k;
  cin >> k;
  cout << a[k] << endl;
}

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

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	int ans = 99999999;
	for (int i = 0; i <= n; i++) {
		int a = pow(2, i);
		ans = min(ans, a + (n - i)*k);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(){
    int N, K;
    string S;
    cin >> N >> S >> K;

    for (int i=0; i<N; ++i){
        if (S[i]!=S[K-1]){
            S[i] = '*';
        }
    }
    cout << S << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    char[] ns = scanner.next().toCharArray();
    int N = ns.length;
    int[] digits = new int[N + 1];
    for (int i = 0; i < N; i++) digits[i + 1] = ns[i] - '0';
    int K = scanner.nextInt();

    long[][] dp0 = new long[N + 1][K + 1];
    long[][] dp1 = new long[N + 1][K + 1];
    dp0[0][0] = 1;
    for (int i = 1; i <= N; i++) {
      for (int j = 0; j <= K; j++) {
        dp1[i][j] = dp1[i - 1][j];
        if (j > 0) dp1[i][j] += dp1[i - 1][j - 1] * 9;
        if (digits[i] == 0) {
          dp0[i][j] = dp0[i - 1][j];
        } else {
          if (j > 0) dp0[i][j] = dp0[i - 1][j - 1];
          dp1[i][j] += dp0[i - 1][j];
          if (j > 0) dp1[i][j] += dp0[i - 1][j - 1] * (digits[i] - 1);
        }
      }
    }
    System.out.println(dp0[N][K] + dp1[N][K]);
  }
}


Measured memory_bytes: 21844
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()
h = li()
r = [[]*n]
flg = [1] * n
for i in range(m):
    a,b = mi()
    if h[a-1] < h[b-1]:
        flg[a-1] = 0
    elif h[b-1] < h[a-1]:
        flg[b-1] = 0
    else:
        flg[a-1] = 0
        flg[b-1] = 0

print(sum(flg))

Measured memory_bytes: 20144
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>

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

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int dp[101][100001][2];

template<typename T>
vector<T> slide_minimum(vector<T>& v, int k) {
	int n = v.size();
	deque<pair<int, T>> dq;
	vector<T> res;
	for (int i = 0; i < n; i++) {
		while (!dq.empty() and dq.back().second >= v[i]) dq.pop_back();
		while (!dq.empty() and dq.front().first + k - 1 < i) dq.pop_front();
		dq.emplace_back(i, v[i]);
		if (i >= k - 1) {
			res.push_back(dq.front().second);
		}
	}
	return res;
}
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	ll N, L; scanf("%lld %lld", &N, &L);
	vector<ll> a(N); for (int i = 0; i < N; i++) scanf("%lld", &a[i]);
	auto sm = slide_minimum<ll>(a, L);
	for (int i = 0; i < sm.size(); i++) {
		cout << sm[i];
		if (i + 1 == sm.size()) cout << "\n";
		else cout << " ";
	}
	return 0;
}
 


Measured memory_bytes: 19068
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<vc> vcc;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const int INF = 1e9 + 7;

void solve(){
    int a,b; cin>>a>>b;
    int sum=1;
    int cur=0;
    while(1){
        if(sum>=b){
            cout<<cur;
            return;
        }
        sum+=a-1;
        cur++;
    }

}
int main(){
    int T=1;
    //cin>>T;
    for(int i = 0; i < T; i++) solve(); 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

int main(){
	int d,t,s;
	cin >> d >> t >> s;
	double time=double(d)/double(s);
	if(time<=double(t)){
		cout << "Yes";
	}
	else cout << "No";
	return 0;
}


Measured memory_bytes: 3588
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
int main()
{
	int a,b,c,k,max1,maxn;
	cin>>a>>b>>c>>k;
	max1=max(max(a,b),c);
	maxn=max1;
	for(int i=0;i<k;i++)
	maxn*=2;
	cout<<maxn+a+b+c-max1<<endl;
	return 0;
 } 

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

int N;
string s;
string ans;
bool check(string init) {
  ans = s;
  ans[0] = init[0];
  ans[1] = init[1];
  rep(i, 2, N) {
    if (s[i - 1] == 'o') {
      if (ans[i - 1] == 'S') ans[i] = ans[i - 2];
      else ans[i] = (ans[i - 2] == 'S')? 'W': 'S';
    } else {
      if (ans[i - 1] == 'W') ans[i] = ans[i - 2];
      else ans[i] = (ans[i - 2] == 'S')? 'W': 'S';
    }
  }
  if (ans[N - 2] == ans[0]) {
    if (ans[N - 1] == 'S' && s[N - 1] == 'x') return false;
    if (ans[N - 1] == 'W' && s[N - 1] == 'o') return false;
  }
  if (ans[N - 2] != ans[0]) {
    if (ans[N - 1] == 'S' && s[N - 1] == 'o') return false;
    if (ans[N - 1] == 'W' && s[N - 1] == 'x') return false;
  }
  if (ans[N - 1] == ans[1]) {
    if (ans[0] == 'S' && s[0] == 'x') return false;
    if (ans[0] == 'W' && s[0] == 'o') return false;
  }
  if (ans[N - 1] != ans[1]) {
    if (ans[0] == 'S' && s[0] == 'o') return false;
    if (ans[0] == 'W' && s[0] == 'x') return false;
  }
  return true;
}
int main() {
  cin >> N  >> s;
  if (check("SS") || check("SW") || check("WS") || check("WW")) {
    cout << ans << BR;
  } else {
    cout << "-1" << BR;
  }
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, m, i, j, k, ans;
	cin >> n >> m;
	vector<string> s(n);
	for (i = 0; i < n; i++) cin >> s[i];

	vector<vector<int>> a(n, vector<int>(m, 0));
	vector<vector<int>> b(n, vector<int>(m, 0));
	vector<vector<int>> c(n, vector<int>(m, 0));
	vector<vector<int>> d(n, vector<int>(m, 0));

	for (i = 0; i < n; i++) {
		for (j = 0; j < m;j++) 
			if (s[i][j] == '.') {
				if (i == 0) a[i][j] = 1;
				else a[i][j] = a[i - 1][j] + 1;

				if (j == 0) b[i][j] = 1;
				else b[i][j] = b[i][j - 1] + 1;
			}
	}

	for (i = n - 1; i >= 0; i--) {
		for (j = m - 1; j >= 0; j--)
			if (s[i][j] == '.') {
				if (i == n - 1) c[i][j] = 1;
				else c[i][j] = c[i + 1][j] + 1;

				if (j == m - 1) d[i][j] = 1;
				else d[i][j] = d[i][j + 1] + 1;
			}
	}

	ans = 0;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) ans = max(ans, a[i][j] + b[i][j] + c[i][j] + d[i][j] - 3);
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 67328
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
int main() {
	string s; cin >> s;
	for (int i = 0; i < s.size(); i++)if (s[i] == '9') { cout << "Yes\n"; return 0; }
	cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MX = 1e18;

int main(){
    ll n; cin >> n;
    ll res = 1;
    bool ng = false;
    for(int i=0; i<n; ++i){
        ll a; cin >> a;
        if(a==0){cout << 0 << endl; return 0;}
        if(ng || (MX+1)/res < a || res*a > MX){
            ng = true;
        }
        res *= a;
    }
    if(ng){cout << -1 << endl;}
    else{cout << res << endl;}
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 100005;
int A[MAXN], n;

void quit(int x) {
	puts(x ? "First" : "Second");
	exit(0);
}

void dfs(int w) {
	int cnt = 0;
	for (int i = 1; i <= n; i++) if (~A[i] & 1) ++cnt;
	if (cnt & 1) quit(w);
	if (cnt == 0 || cnt + 2 <= n) quit(w ^ 1);
	for (int i = 1; i <= n; i++) if (A[i] & 1) cnt = i;
	if (A[cnt] == 1) quit(w ^ 1);
	int g = 0; --A[cnt];
	for (int i = 1; i <= n; i++) g = __gcd(g, A[i]);
	for (int i = 1; i <= n; i++) A[i] /= g;
	dfs(w ^ 1);
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", A + i);
	dfs(1);
	return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in(),K=in();
	if(K%2){
		ll S=0;
		REP(i,N){
			if(!((i+1)%K)) S++;
		}
		out(S*S*S);
	}
	else{
		ll S=0,H=0;
		REP(i,N){
			if(!((i+1)%K)) S++;
			if(((i+1)%K)==(K/2)) H++;
		}
		out(S*S*S+H*H*H);
	}
	return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : alds_1_2_b_selectionSort.cpp
// Author      : lovesaemi
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int selectionSort(int A[], int N) {
	int i, j, t, sw = 0, minj;
	for (i = 0; i < N; i++) {
		minj = i;
		for (j = i; j < N; j++) {
			if (A[j] < A[minj]) {
				minj = j;
			}
		}
		t = A[i];
		A[i] = A[minj];
		A[minj] = t;
		if (i != minj) {
			sw++;
		}
	}
	return sw;
}

int main() {
	int A[100], N, sw;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sw = selectionSort(A, N);
	for (int i = 0; i < N; i++) {
		if (i) {
			cout << " ";
		}
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;
	return 0;
}



Measured memory_bytes: 3096
import sys
readline = sys.stdin.readline

def main():
    N, K = map(int, readline().rstrip().split())
    d = list(map(int, readline().rstrip().split()))
    # d = {i+1: a for i, a in enumerate(A)}
    if K <= N:
        pre = 1
        for _ in range(K):
            pre = d[pre-1]
        print(pre)
        return

    pre = 1
    visited = set([1])
    visited_l = [1]
    for i in range(N):
        pre = d[pre-1]
        if pre in visited:
            break
        visited.add(pre)
        visited_l.append(pre)
    
    loop_start = visited_l.index(pre)
    loop = i - loop_start + 1

    num_loop = (K - loop_start) // loop
    now = loop_start + num_loop * loop
    for i in range(now+1, K+1):
        pre = d[pre-1]
    
    print(pre)

if __name__ == '__main__':
    main()

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

public class Main{
  public static void main(String[] args) {
     Scanner in = new Scanner(System.in);
     int n = in.nextInt();
     int div = n / 500;
     int sub = n - div * 500 ;
     int res = sub / 5;
     System.out.println(div * 1000 + res * 5);
  }
}


Measured memory_bytes: 21844
want_to_join = {
    '1': 111,
    '2': 222,
    '3': 333,
    '4': 444,
    '5': 555,
    '6': 666,
    '7': 777,
    '8': 888,
    '9': 999
}

number_letter = input()
first_letter = number_letter[0]
if want_to_join[first_letter] >= int(number_letter):
    print(want_to_join[first_letter])
else:
    next_letter = str(int(first_letter)+1)
    print(want_to_join[next_letter])

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = Input.num;
        var ar = Input.ar;
        var list = new List<int>() { ar[0] };
        for (var i = 1; i < num; i++)
            if (list[list.Count - 1] != ar[i])
                list.Add(ar[i]);
        if (list.Count == 1)
        {
            WriteLine(1);
            return;
        }
        var ct = 1;
        var isInc = list[0] < list[1];
        for(var i = 1; i < list.Count-1; i++)
        {
            if ((isInc && list[i] > list[i + 1]) || (!isInc && list[i] < list[i + 1]))
            {
                i++;
                ct++;
            }
            if(i+1<list.Count)
            isInc = list[i] < list[i + 1];
        }
        WriteLine(ct);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

Measured memory_bytes: 19552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T;
    cin >> S >> T;
    int N = S.size(),M = T.size();
    vec<int> A(N+1),B(M+1);
    for(int i=0;i<N;i++){
        int c = (S[i]=='A'? 1:2);
        A[i+1] = A[i]+c;
    }
    for(int i=0;i<M;i++){
        int c = (T[i]=='A'? 1:2);
        B[i+1] = B[i]+c;
    }
    int Q;
    cin >> Q;
    while(Q--){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        a--; b--; c--; d--;
        int x = A[b+1]-A[a],y = B[d+1]-B[c];
        cout << (x%3==y%3? "YES\n":"NO\n");
    }
}

Measured memory_bytes: 1744
#include <stdio.h>
#define N 100000
#define NIL -1
struct Node{
  int l,p,r;
  };
struct Node T[N];
int depth(int),child(int);
int main(){
  int i,j,n,b,d,c,m;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=NIL;
    T[i].l=NIL;
    T[i].r=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&b,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      T[c].p=b;
      if(j==0)
        T[b].l=c;
      else
        T[m].r=c;
      m=c;
    }
  }
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,T[i].p,depth(i));
    if(T[i].p==NIL)
      printf("root, [");
    else if(T[i].l==NIL)
      printf("leaf, [");
    else
      printf("internal node, [");
    child(T[i].l);
    printf("]\n");
  }
  return 0;
  }
  int depth(int x){
    int a;
    if(T[x].p==NIL)
      return 0;
    else{
      a=depth(T[x].p)+1;
      return a;
    }
  }
  int child(int x){
    if(x==NIL)
      return 0;
    else{
      if(T[x].r==NIL)
        printf("%d",x);
      else{
        printf("%d, ",x);
        child(T[x].r);
      }
    }
  }



Measured memory_bytes: 2864
def resolve():
    import sys
    sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
    to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
    print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

    # 入力を整数に変換して受け取る
    def input_int():
        return int(input())

    def map_int_input():
        return map(int, input())

    MII = map_int_input

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

    def MII_to_index():
        return map(to_index, input())

    def MII_split_to_index():
        return map(to_index, input().split())

    # 入力全てを整数に変換したものの配列を受け取る
    def list_int_inputs():
        return list(map(int, input()))

    LII = list_int_inputs

    def LII_split():
        return list(map(int, input().split()))

    # 2次元リスト化
    def LII_2D(rows_number):
        return [LII() for _ in range(rows_number)]

    def LII_split_2D(rows_number):
        return [LII_split() for _ in range(rows_number)]

    N = input_int()
    a_list = LII_split()

    ans = 0
    for i in range(N):
        if i % 2 == 0 and a_list[i] % 2 == 1:
            ans += 1
    print(ans)
resolve()

Measured memory_bytes: 9272
def greatest_common_divisor(a, b):
    # a 割る b = c あまり d
    # b 割る d = ...
    residue = a % b
    if residue != 0:
        return greatest_common_divisor(b, residue)
    return b


def main():
    a, b = map(int, input().split(" "))
    print(greatest_common_divisor(a, b))


if __name__ == "__main__":
    main()



Measured memory_bytes: 5600
import java.util.Scanner;

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

	while(true){
	    H = in.nextInt();
	    W = in.nextInt();
	    if(H==0 && W==0)break;
	     
	    for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
		    System.out.print("#");
		}
		System.out.println();
	    }
	   System.out.println(); 
	}
    }
}
	   



Measured memory_bytes: 34856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;

    int cnt = 0;
    REP(i, 1, n+1)
    {
        if (int(log10(i)) % 2 == 0)
        {
            cnt ++;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
int main(){
	string s;
	cin>>s;int a=s.size()-1;
	while(s.substr(0,a/2)!=s.substr(a/2,a/2))a--;
	cout<<a/2*2<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n, max=0, c=0;
    cin >> n;
    vector<int> h(n);

    for (int i = 0;i < n; ++i) {
        cin >> h[i];
        if (h[i] >= max) {
            max = h[i];
            c++;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 256
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    usize n, C;
    i64 K;
    std::cin >> n >> C >> K;
    vec<i64> a(n);
    for (i64& x: a) std::cin >> x;
    std::sort(ALL(a));

    usize ans = 0;
    for (usize i=0, j=0; i<n; i=j) {
        for (; j<n && j<i+C && a.at(j)<=a.at(i)+K; j++);
        ans++;
    }
    std::cout << ans << '\n';
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  double N,R,ans;
  cin>>N>>R;
  for(int i=0;i<=30;i++){
  	if(N>=pow(R,i)&&N<pow(R,i+1)){
    ans=i+1;
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#define ll long long
using namespace std;
const int maxn=1e5,maxv=1e5;
int N,V[maxv+500],A[maxv+500],B[maxv+500],maxa=0,maxb=0;
int a,b,num,a2,b2,maxa2=0,maxb2=0,ans=0;
int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		scanf("%d",&V[i]);
		if(i%2!=0){
			A[V[i]]++;
			if(A[V[i]]>maxa){
				maxa2=maxa;
				a2=a;
				maxa=A[V[i]];
				a=V[i];
			}
			else if(V[i]!=a&&A[V[i]]>maxa2){
				maxa2=A[V[i]];
				a2=V[i];
			}
		}
		else {
			B[V[i]]++;
			if(B[V[i]]>maxb){
				maxb2=maxb;
				b2=b;
				maxb=B[V[i]];
				b=V[i];
			}
			else if(V[i]!=b&&B[V[i]]>maxb2){
				maxb2=B[V[i]];
				b2=V[i];
			}
		}
	}
	num=N/2;
	if(a!=b){
		ans+=num-maxa;
		ans+=num-maxb;
	}
	else {
		if(num-maxa+num-maxb2<num-maxa2+num-maxb)
			ans=num-maxa+num-maxb2;
		else ans=num-maxa2+num-maxb;
	}
	if(a==b&&maxa==maxb&&maxa==num)ans=num;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1408
A, B, C, D = gets.chomp.chars.map(&:to_i)

0.upto(1) do |i|
  0.upto(1) do |j|
    0.upto(1) do |k|
      sum = A
      sum += i == 1 ? -B : B
      sum += j == 1 ? -C : C
      sum += k == 1 ? -D : D
      if sum == 7
        puts "#{A}#{i == 1 ? '-' : '+'}#{B}#{j == 1 ? '-' : '+'}#{C}#{k == 1 ? '-' : '+'}#{D}=7"
        exit
      end
    end
  end
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
    int n, m, sum = 0, minn = 0;
    cin >> n >> m;
    minn = m;
    for(ll i = 2; i <= n; i ++)
    {
        if(abs(minn) > abs(m + i - 1))
        {
            minn = m + i- 1;
        }
    }
    for(ll i = 1; i <= n; i ++)
    {
        sum += m + i - 1;
    }
    cout << sum - minn;
}


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

int main() {
  int N,K,Z=1000000000,P=0,Q=0;
  cin>>N>>K;
  vector<int> p;
  vector<int> q;
  q.push_back(0);
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    if(a>0){
      q.push_back(a);
      Q++;
    }
    else if(a<0){
      p.push_back(a);
      P++;
    }
    else{
      K--;
    }
  }
  p.push_back(0);
  reverse(p.begin(),p.end());
  for(int i=min(K,P);K-min(Q,K)<=i;i--){
    Z=min(Z,min(p.at(i)*-1,q.at(K-i))*2+max(p.at(i)*-1,q.at(K-i)));
  }
  cout<<Z<<endl;
    
}

Measured memory_bytes: 3932
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int X, Y, Z, K;
  cin>>X>>Y>>Z>>K;
  vector<ll> A(X), B(Y), C(Z);
  for(int i=0;i<X;++i) cin>>A[i];
  for(int i=0;i<Y;++i) cin>>B[i];
  for(int i=0;i<Z;++i) cin>>C[i];
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  int index1=X-1, index2=Y-1, index3=Z-1;
  vector<ll> ans;
  ll tmpans1, tmpans2, tmpans3;
  priority_queue<tuple<ll, int, int, int> > que;
  que.push(make_tuple(A[index1]+B[index2]+C[index3], index1, index2, index3));
  map<tuple<int, int, int>, int> amap;
  tuple<ll, int, int, int> state;
  while(true) {
    state = que.top();que.pop();
    index1 = get<1>(state);
    index2 = get<2>(state);
    index3 = get<3>(state);
    if(amap[make_tuple(index1, index2, index3)]>0) continue;
    amap[make_tuple(index1, index2, index3)]++;
    ans.push_back(A[index1]+B[index2]+C[index3]);
    if(ans.size()==K) break;
    if(index1>0) que.push(make_tuple(A[index1-1]+B[index2]+C[index3], index1-1, index2, index3));
    if(index2>0) que.push(make_tuple(A[index1]+B[index2-1]+C[index3], index1, index2-1, index3));
    if(index3>0) que.push(make_tuple(A[index1]+B[index2]+C[index3-1], index1, index2, index3-1));
  }
  for(int i=0;i<K;++i) cout<<ans[i]<<endl;
}



Measured memory_bytes: 3960
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(){
  char W[10];
  char T[1000];
  int c=0,i;
  scanf("%s", W);
  while(scanf("%s", T) && strcmp(T, "END_OF_TEXT") != 0){
    for(i=0;i<strlen(T);i++) 
    {
    	T[i] = tolower(T[i]);
    }
    if(strcmp(T, W) == 0) c++;
  }
  printf("%d\n", c);
  return 0;
}


Measured memory_bytes: 2724
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> x(N);
	for (int i = 0; i < N; i++)
	{
		cin >> x[i];
	}
	int ans = 1e9;
	for (int i = 0; i < N-K+1; i++)
	{
		int ans1,lr,rl;
		lr = abs(x[i]) + abs(x[i + K - 1]-x[i]);
		rl = abs(x[i + K - 1]) + abs(x[i] - x[i + K - 1]);
		ans1 = min(lr, rl);
		ans = min(ans1, ans);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;

int main(){
	int r,c;
	cin >> r >> c;
	char ch[r][c+1];
	for(int i=0 ; i<r ; i++){
		scanf("%s",ch[i]);
	}

	long long int dp[r][c];

	for(int i=0 ; i<r ; i++){
		for(int j=0 ; j<c ; j++){
			dp[i][j] = 0;
			if(i==0 && j==0){
				dp[i][j] = 1;
			}
			else if(i==0 && j!=0){
				if(ch[i][j] == '#'){
					dp[i][j] = 0;
				}
				else{
					dp[i][j] = dp[i][j-1];
				}
			}
			else if(i!=0 && j==0){
				if(ch[i][j] == '#'){
					dp[i][j] = 0;
				}
				else{
					dp[i][j] = dp[i-1][j];
				}
			}
			else{
				if(ch[i][j] == '#'){
					dp[i][j] = 0;
				}
				else{
					dp[i][j] = (dp[i-1][j]%MOD + dp[i][j-1]%MOD)%MOD ;
				}
			}
			//cout << dp[i][j] << " ";
		}

	}
	cout << dp[r-1][c-1]%MOD << "\n";
		return 0;
}

Measured memory_bytes: 9088
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll N;
  string S, T;
  cin >> N >> S >> T;
  rep (i, N) cout << S[i] << T[i];
  cout << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int H, W, A, B;

void solve() {
	cin >> H >> W >> A >> B;
	rep(i, 0, H) {
		rep(j, 0, W) {
			cout << ((i >= B) + (j >= A)) % 2;
		}
		cout << "\n";
	}
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n), prefsum(n + 1, 0), possum(n + 1, 0);
    rep(i, n) {
        cin >> a[i];
        prefsum[i + 1] = prefsum[i] + a[i];
        possum[i + 1] = possum[i] + max(0ll, a[i]);
    }

    ll ans = -1e18;
    for (int i = 0; i + k <= n; i++) {
        int l = i, r = i + k;
        // paint [l,r) either white or black
        ll tmp = max(0ll, prefsum[r] - prefsum[l]);
        // paint the rest as you wish
        tmp += possum[l];
        tmp += possum[n] - possum[r];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5620
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

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

	if (N >= K)
	{
		N %= K;
	}

	cout << min(N, abs(N - K)) << endl;

	return 0;
}

Measured memory_bytes: 3600
// execute g++ main.cpp -std=c++14 -I C:\Users\naoya\Desktop\code\Atcoder
#include<bits/stdc++.h>
//#include<atcoder/all>
typedef long long ll;
typedef long double ld;
using namespace std;
//using namespace atcoder;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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


char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(){
    string s; cin >> s;
    if(s.back() != 's'){
        cout << s << "s" << endl;
    }else{
        cout << s << "es" << endl;
    }
}

Measured memory_bytes: 3628
if __name__ == "__main__":
    n = int(input())
    s = input().strip()
    r = g = b = 0
    for c in s:
        if c == 'R':
            r += 1
        elif c == 'G':
            g += 1
        elif c == 'B':
            b += 1
    ans = r * b * g

    valid = frozenset('RGB')
    for i in range(n):
        for j in range(1, min(i, n-1-i)+1):
            if frozenset(s[i] + s[i-j] + s[i+j]) == valid:
                ans -= 1
    print(ans)
    

Measured memory_bytes: 9144
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(n-2):
    a = p[i]
    b = p[i+1]
    c = p[i+2]
    if max(a,b,c) != b and min(a,b,c) != b:
        cnt += 1
print(cnt)


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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

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

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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


int main(void){
  ios::sync_with_stdio(false);
  ll N, M;
  cin >> N >> M;

  vector<pair<ll, ll>> pairs(N);
  REP (i, N){
    ll A, B;
    cin >> A >> B;
    pairs[i] = make_pair(A, B);
  }

  sort(pairs.begin(), pairs.end());

  ll total = 0;
  ll ans = 0;
   for (int i = 0; i < N; i++) {
//    printf("(%lld,%lld) ", pairs[i].first, pairs[i].second);}
   if (total + pairs[i].second < M){
     total += pairs[i].second;
     ans += pairs[i].first * pairs[i].second;
   }
   else {
     while (total < M){
       total += 1;
       ans += pairs[i].first;
     }
   }}

cout << ans << endl;



  return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 20005;
const int N = 100;

int max_v[MAX],cur_v[MAX],t[N],v[N];

int main() {
	cout << fixed << setprecision(15);
	int n;cin>>n;
	rep(i,n) cin>>t[i];
	rep(i,n) cin>>v[i];
	int idx=0;
	rep(i,n) rep(j,t[i]) {max_v[idx++]=v[i];}
	max_v[idx]=0;
	cur_v[0]=0;
	rep1(i,idx) {
		int tmp_v=cur_v[i-1],tmp_i=i,dif_v=1000;
		while(tmp_v>=0&&tmp_i<=idx) {
			dif_v=min(dif_v,max_v[tmp_i]-tmp_v);
			dif_v=min(dif_v,max_v[tmp_i-1]-tmp_v);
			tmp_i++;tmp_v--;
		}
		if(dif_v<=0) cur_v[i]=cur_v[i-1]+dif_v;
		else cur_v[i]=cur_v[i-1]+1;
	}
	double ans=0;
	rep1(i,idx) {
		ans+=((double)cur_v[i-1]+(double)cur_v[i])/2.0;
		if(cur_v[i-1]==cur_v[i]&&cur_v[i-1]<max_v[i-1]) ans+=0.25;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 384
#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

def lcm(a,b):
    return a*b//gcd(a,b)

n=int(input().rstrip())
a=[int(i) for i in input().split()]
ans=a[0]
for i in range(1,n):
    ans=lcm(ans,a[i])
print(ans)


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;


int main() {
    string S, T; cin >> S >> T;
    string tmp = "";

    for(ll i = 0; i < S.length(); i++){
        if(T == tmp + S.substr(0, S.length()-i)){
            cout << "Yes" << endl;
            return 0;
        }
        //cout << tmp + S.substr(0, S.length()-i) << endl;
        //cout << S.length()-1-i << endl;
        tmp = S[S.length()-1-i] + tmp;
        //cout << tmp << endl;
    }


    cout << "No" << endl;
}

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

int main(){
  string s;
  cin >> s;
  if(s=="AAA"||s=="BBB")cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)
b=list(set(a))
m=len(b)

p=[0]*(10**6+1)
for i in b:
    if p[i]==0:
        j=2
        while i*j<=10**6:
            p[i*j]=1
            j+=1
a.append(-1)
a.insert(0,-1)
ans=0
for i in range(1,n+1):
    if a[i]!=a[i+1] and a[i]!=a[i-1] and p[a[i]]==0:
        ans+=1
print(ans)


Measured memory_bytes: 134840
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int n;
	cin>>n;
	deque<int> Q;
	while(n!=0){
		int surp = n%(-2);
		Q.push_front(abs(surp));
		n /= -2;
		if(surp == -1)n++;
	}
	if(Q.empty()){
		cout<<0<<endl; return 0;
	}
	while(!Q.empty()){
		cout<<Q.front();
		Q.pop_front();
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(){
    int l,r;
    cin >> l >> r;

    int ans = 2019;
  	if ( r-l <= 2019){
        for ( int i = l ; i < r ; i++ ){
            for ( int j = i+1 ; j <= r ; j++ ){
                ans = min(ans,((i%2019) * (j%2019))%2019); 
            }
        }    
    }      
    else ans = 0;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000010;
constexpr ll INF= 1000000000000000000;
constexpr ll MOD = 998244353;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    int Xor = 0;
    for(int i = 0;i < N;i++) {
        Xor = (Xor ^ vec.at(i));
    }
    for(int i = 0;i < N;i++) {
        cout << (Xor ^ vec.at(i)) << " ";
    }
    cout << endl;
}

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

int main(){
    int n,q; cin>>n>>q;
    vector<int>v[n];
    while(q--){
        int a,b,c;
        cin>>a>>b;
        if(!a){
            cin>>c;
            v[b].push_back(c);
        }
        else if(a==1){
            r(i,(int) v[b].size()){
                if(i)cout<<' ';
                cout<<v[b][i];
            }
            cout<<endl;
        }
        else v[b].clear();
    }
}


Measured memory_bytes: 5904
def main():
    a = []
    for _ in range(5):
        hoge = int(input())
        if hoge < 40:
            hoge = 40
        else:
            pass
        a.append(hoge)

    total = 0
    for score in a:
        total += score

    print(total // 5)


if __name__ == "__main__":
    main()

Measured memory_bytes: 7764
// C - Anti-Division

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;

ll get_gcd(ll x, ll y) {
	if (x < y) {
		swap(x, y);
	}

	ll m = x % y;

	while (m != 0) {
		x = y;
		y = m;
		m = x % y;
	}

	return y;
}

ll get_lcm(ll x, ll y) {
	return x * y / get_gcd(x, y);
}

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

	ll lcm_CD = get_lcm(C, D);

	ll div_C = B / C - (A-1) / C;
	ll div_D = B / D - (A-1) / D;
	ll div_CD = B / lcm_CD - (A-1) / lcm_CD;

	ll ans = B - A + 1 - (div_C + div_D - div_CD);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            while(scn.hasNextInt()) {
                int weight = scn.nextInt();
                boolean flg = false;
                for(int i = 0; i < 10; i++) {
                    if((weight & 1 << i) > 0) {
                        System.out.print((flg ? " " : "") + (1 << i));
                        flg = true;
                    }
                }
                System.out.println();
            }
        }
    }
}

Measured memory_bytes: 25932