akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<ll> A(N);
    map<ll, int> M;
    rep(i, N) {
        cin >> A[i];
        M[A[i]]++;
    }
    
    vector<pair<ll, int>> B;
    for(auto a: M){
        if(a.second >= 2) B.pb(mp(a.first, a.second));
    }
    sort(all(B));
    reverse(all(B));
    if(B.size() < 1){
        output(0);
        return 0;
    }
    if(B[0].second >= 4){
        output(B[0].first * B[0].first);
        return 0;
    }
    if(B.size() < 2){
        output(0);
    }
    else {
        output(B[0].first * B[1].first);
    }
    
    
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    int N;
    cin >> N;
    vector<int> D(N);
    REP(i,N){
        int d;
        cin >> d;
        D[i] = d;
    }

    ll ans = 0;
    REP(i,N){
        REPi(j, i+1, N){
            int d1 = D[i];
            int d2 = D[j];
            ans += d1*d2;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    int *v = new int [n];
    int *c = new int [n];
for (int i = 0; i<n ;i ++){
    cin >> v[i];
}
for ( int i = 0;i < n ; ++i){
    cin >> c[i];
}
int sum = 0;
for (int i = 0; i < n;i ++){
    if (v[i] > c[i])
    sum+=v[i] - c[i];
}
    cout << sum;
}


Measured memory_bytes: 256
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    k,n=map(int,input().split())
    a=list(map(int,input().split()))
    dis=[]
    for i in range(n-1):
        dis.append(abs(a[i]-a[i+1]))
    dis.append(abs(a[0]+k-a[-1]))
    dism=max(dis)
    print(sum(dis)-dism)




if __name__ == "__main__":

    main()

Measured memory_bytes: 85068
//submitted by Himj
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;
vector<int> tree[mxn];
ll dp[mxn][2];
ll solve(int u,int p,int c)
{
  ll ans=1;
  if(dp[u][c])
    return dp[u][c];
  for(auto v:tree[u])
  {
    if(v==p)
      continue;
    if(c)
      ans=(ans*solve(v,u,0))%mod;
    else
    {
      ll temp=solve(v,u,0);
      temp=(temp+solve(v,u,1))%mod;
      ans=(ans*temp)%mod;
    }
  }
  if(ans==0)
    return 1;
  return dp[u][c]=ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

  int t=1;
  //cin>>t;
    while(t--){
      ll n,i,u,v;
      cin>>n;
      ms(dp,0);
      fr(i,0,n-1)
      {
        cin>>u>>v;
        tree[u].pb(v);
        tree[v].pb(u);
      }
      ll ans=(solve(1,1,0)+solve(1,1,1))%mod;
      cout<<ans;
      
       
    }
  return 0;
  }



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

long f(long x, long y, long z){
	return pow(x+y+z,2)-x*y-y*z-z*x;
}

int main(){
	long N;
	cin >> N;

	for(int i=1; i<=N; i++){
		long cnt=0;
		long max = sqrt(i);
		for(long x=1; x <= max; x++){
			for(long y=1; y<=x; y++){
				for(long z=1; z<=y; z++){
					if(f(x,y,z) == i){
						if(x==y){
							if(y==z){
								cnt++;
							}else{
								cnt=cnt+3;
							}
						}else if(y==z){
							if(z==x){
								cnt++;
							}else{
								cnt=cnt+3;
							}
						}else if(z==x){
							if(x==y){
								cnt++;
							}else{
								cnt=cnt+3;
							}
						}else{
							cnt=cnt+6;
						}
					}
				}
			}
		}
		cout << cnt << endl;
	}
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
long long int q[6];
long long int ans;
int main() {
	int n;
	char ch[11];
	scanf("%d", &n);
	for(int i=0; i<n; i++)
	{
		scanf("%s", ch);
		if(ch[0]=='M') q[1]++;
		if(ch[0]=='A') q[2]++;
		if(ch[0]=='R') q[3]++;
		if(ch[0]=='C') q[4]++;
		if(ch[0]=='H') q[5]++;
	}
	for(int i=1; i<=3; i++)
	{
		for(int j=i+1; j<=4; j++)
		{
			for(int k=j+1; k<=5; k++)
			{
				if(q[i]==0 || q[j]==0 || q[k]==0) ;
				else ans=ans+q[i]*q[j]*q[k];
			}
		}
	}
	printf("%lld", ans);
}

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

int main(void)
{
	int r;
	cin >> r;
	cout << r*r << endl;

	return 0;
}

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

int main() {
    long long N, K; cin >> N >> K;
    long long answer = N;

    N = N % K;
    answer = min(answer, N);

    for (int i = 0; i < 10000; ++i) {
        N = abs(N - K);
        answer = min(answer, N);
    }

    cout << answer << endl;
}



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

int main()
{
    int n;
    std::cin >> n;

    std::vector<int> a(n);

    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    std::vector<int> sorted = a;

    std::sort(sorted.begin(), sorted.end(), std::greater<int>());

    int max = sorted[0], second_max = sorted[1];

    for (auto i : a) {
        std::cout << (i == max ? second_max : max) << std::endl;
    }
}


Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	    	Scanner sc = new Scanner(System.in);
	    	String s = sc.next();
	    	int len = s.length();
	    	boolean bool = true;
	    	int temp = 0;
	    	String key = "keyence";
	    	if (s.startsWith(key) || s.endsWith(key) || s.equals(key)) {
	    		System.out.println("YES");
	    		return;
	    	}
	    	for (int i = 0; i < 7; i++) {
			if (s.charAt(i) == key.charAt(i)) {
				continue;
			} else {
				temp = 7-i;
				break;
			}
		}
	    	int count  = 0;
	    	for (int i = s.length()-1; i > s.length()-1-temp; i--) {
			if (s.charAt(i) == key.charAt(key.length()-1-count)) {
				count++;
				continue;
			} else {
				System.out.println("NO");
				return;
			}
		}
	    	System.out.println("YES");
	}
}


Measured memory_bytes: 22868
#include "bits/stdc++.h"
using namespace std;
#define LL long long 
int main(){
    LL n; cin>>n;
    LL a[n];
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a, a+n);

    LL sum = a[n-1];
    for(int i=n-2; i >= (n+1)/2; i--)
        sum += a[i]*2;
    
    if(n&1) sum += a[(n-1)/2];
    cout<<sum<<"\n";
}

Measured memory_bytes: 5192
from collections import Counter

n = int(input())
v = [int(i) for i in input().split(" ")]

even = []
odd = []
for i in range(0, n, 2):
    even.append(v[i + 1])
    odd.append(v[i])

even = Counter(even).most_common(2)
odd = Counter(odd).most_common(2)

if even[0][0] != odd[0][0]:
    ans = n - even[0][1] - odd[0][1]
else:
    if len(even) == 1 and len(odd) == 1:
        ans = even[0][1]
    else:
        ans = min(n - even[1][1] - odd[0][1], n - even[0][1] - odd[1][1])

print(int(ans))

Measured memory_bytes: 15972
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main{

	public static void main(String args[]) throws IOException {

		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String sc1;
		String sc2;
		BigDecimal a,b,c;
		String ks="";

		ks=br.readLine();
		for(int i=0; i<Integer.parseInt(ks); i++) {
			sc1=br.readLine();
			sc2=br.readLine();
			if(sc1.length()>=81 || sc2.length()>=81) {
				System.out.println("overflow");
			}

			else {
				a=new BigDecimal(sc1);
				b=new BigDecimal(sc2);
				c=a.add(b);

				if((c.precision()-c.scale())>=81) {
					System.out.println("overflow");
				}
				else {
					System.out.println(c);
				}
			}
		}
	}
}


Measured memory_bytes: 24612
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(NULL)
#define PI acos(-1.0)
#define TEST(n) cout<<"dhukse"<<n<<'\n'
#define endl '\n'
#define FILEREAD freopen("input.txt","r",stdin)
#define FIXED(n) cout << fixed << setprecision(n);
#define CASE(n) cout<<"Case " << n << ": ";
long long Set(long long N,long long pos){ return N=N | (1<<pos);}
long long reset(long long N,long long pos){return N= N & ~(1<<pos);}
bool check(long long N,long long pos){return (bool)(N & (1<<pos));}
long long min(long long a, long long b){if(a<b)return a;else return b;}
long long max(long long a, long long b){if(a>b)return a;else return b;}

/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////In the name of almighty ALLAH/////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////Coded By: pranonrahman////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////

int main()
{
    FAST;
    long long t=1;
   // cin >> t;
    long long T = t;
    while(t--)
    {
        long long n,k;
        cin >> n >> k;
        int sum=0;
        for(int i=0;i<k;i++)
        {
            int x;
            cin >> x;
            sum+=x;
        }
        if(sum>=n)  cout << "Yes" << endl;
        else        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>

int main()
{
    int N;
    std::vector<int> V, C;
    std::cin >> N;
    for (int i = 0; i < N; ++i)
    {
        int element;
        std::cin >> element;
        V.push_back(element);
    }
    for (int i = 0; i < N; ++i)
    {
        int element;
        std::cin >> element;
        C.push_back(element);
    }
    int ans = 0;
    for (int i = 0; i < N; ++i)
    {
        int p = V[i] - C[i];
        if (p > 0) ans += p;
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
N, W = list(map(int, input().split()))
wv = [list(map(int, input().split())) for _ in range(N)]

DP = [[0] * (3 * N + 1) for _ in range(N + 1)]

for i in range(N):
  for j in range(i, -1, -1):
    for k in range(3 * i, -1, -1):
      kk = k + wv[i][0] - wv[0][0]
      DP[j + 1][kk] = max(DP[j + 1][kk], DP[j][k] + wv[i][1])

ans = 0
for i in range(N + 1):
  if i * wv[0][0] > W:
    break
  for j in range(3 * N + 1):
    if i * wv[0][0] + j > W:
      break
    ans = max(ans, DP[i][j])

print(ans)

Measured memory_bytes: 4212
let input_line = readLine()!.characters.split{$0==" "}.map { Int(String($0))! }
let n = input_line[0]
let canCalcTakahashi = !((1...9).map { n % $0 == 0 && n / $0 < 10 }.filter { $0 }.isEmpty)
print(canCalcTakahashi ? "Yes" : "No")

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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; }
 
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;
	if(S == "ABC") cout << "ARC" << endl;
	else cout << "ABC" << endl;
}

Measured memory_bytes: 3652
N = int(input())
A =  list(map(int, input().split()))
Q = int(input())
B = [0]*(Q+1)
C = [0]*(Q+1)
S = [0]*(Q+1)


for i in range(1,Q+1,1):
    B[i],C[i] = map(int,input().split())

a = [0]*(10**5+3)

for i in range(N):
    a[A[i]] += 1
    S[0] += A[i]

for i in range(1,Q+1,1):
    S[i] = S[i-1] + a[B[i]]*(C[i]-B[i])
    a[C[i]] = a[C[i]] + a[B[i]]
    a[B[i]] = 0
    print(S[i])

Measured memory_bytes: 27384
#include<bits/stdc++.h>
using namespace std;
long long n,a;
int main()
{cin>>n;
 a=sqrt(n);
 for(int i=a;i>=1;i--) if(n%i==0) {n=n/i;break;}
 if(n>=0&&n<10) cout<<1;
 if(n>=10&&n<100) cout<<2;
 if(n>=100&&n<1000) cout<<3;
 if(n>=1000&&n<10000) cout<<4;
 if(n>=10000&&n<100000) cout<<5;
 if(n>=100000&&n<1000000) cout<<6;
 if(n>=1000000&&n<10000000) cout<<7;
 if(n>=10000000&&n<100000000) cout<<8;
 if(n>=100000000&&n<1000000000) cout<<9;
 if(n>=1000000000&&n<10000000000) cout<<10;
 return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int MAX=100005;
long long int a[MAX],prefixPos[MAX],prefix[MAX],n,k,ans;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;++i){
		cin>>a[i];
		prefix[i]=prefix[i-1]+a[i];
		if(a[i]>0) prefixPos[i]=prefixPos[i-1]+a[i];
		else prefixPos[i]=prefixPos[i-1];
	}
//	for(int i=1;i<=n;++i) cout<<prefixPos[i]<<" ";
//	cout<<endl;
	ans=0;
	for(int i=k;i<=n;++i){
		int temp=i-k;
//		cout<<prefixPos[n]-prefixPos[i]+prefixPos[temp]<<" "<<i<<endl;
		ans=max(ans,max(prefixPos[n]-prefixPos[i]+prefixPos[temp],prefixPos[n]-prefixPos[i]+prefixPos[temp]+prefix[i]-prefix[temp]));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
chomp($s=<>);
($n,$k)=split/ /,$s;
@ary=split/ /,<>;

for($i=0;$i<=$n-$k;$i++){
    if(abs($ary[$i]) > abs($ary[$i+$k-1])){
        $sum=abs($ary[$i+$k-1])+abs($ary[$i]-$ary[$i+$k-1]);
    }else{
        $sum=abs($ary[$i])+abs($ary[$i+$k-1]-$ary[$i]);  
    }
    push @a,$sum;
}
@a=sort{$a <=> $b}@a;
print $a[0];

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

int main() {
	// your code goes here
	double r,a,b;
	cin>>r;
	 a= r*r*3.141592653589;
	 b= 2*r*3.141592653589;
	 
	 printf("%.5lf ",a);
	 printf("%.5lf\n",b);
	  
	return 0;
}

Measured memory_bytes: 3216
S = input()
T = input()
lis_s=[]
lis_t=[]

for i in S:
    lis_s.append(i)

for j in T:
    lis_t.append(j)

counter=0
for k in range(len(S)):
    if lis_s[k]==lis_t[k]:
        counter+=1
print(len(S)-counter)

Measured memory_bytes: 12464
s=input()
k=int(input())
i=0
while True:
  if i<len(s) and s[i]=='1':
    i+=1
  else:
    break
if i==0:
  print(s[0])
  exit()
if i<k:
  print(s[i])
else:
  print(s[0])


Measured memory_bytes: 2940
import java.util.Scanner;

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

    int n = in.nextInt();
    int max = in.nextInt();
    int min = max;
    long sum = max;
    for (int i = 0; i < n - 1; i++) {
      int t = in.nextInt();
      if(t > max) {
        max = t;
      }
      else if (t < min) {
        min = t;
      }
      sum += t;
    }
    System.out.println(min + " " + max + " " + sum);
  }
}

Measured memory_bytes: 42540
import java.util.*;
import java.awt.*;

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

    int H = sc.nextInt();
    int W = sc.nextInt();
    int[][] a = new int[H][W];
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        a[i][j] = sc.nextInt();
      }
    }

    int h = 0;
    int w = 0;
    int true_j = 0;
    int flag = 1;
    int back = 1;
    int[][] ans = new int[H * W][4];
    int count = 0;

    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (back == 1) {
          true_j = j;
        } else {
          true_j = W-1-j;
        }

        int current = a[i][true_j];

        if (flag == 1) {
          if (current % 2 == 1) {
            flag *= -1;
          }
        } else {
          if (current % 2 == 1) {
            flag *= -1;
          }

          ans[count][0] = h+1;
          ans[count][1] = w+1;
          ans[count][2] = i+1;
          ans[count][3] = true_j+1;
          count++;
        }

        h = i;
        w = true_j;
      }

      back *= -1;
    }

    System.out.println(count);
    for (int i = 0; i < count; i++) {
      System.out.println(ans[i][0]+" "+ans[i][1]+" "+ans[i][2]+" "+ans[i][3]);
    }
  }
}


Measured memory_bytes: 108944
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              (double)3.14159265358979323844
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll one=ceil(c/(b*1.0));
    ll two=ceil(a/(d*1.0));
    if (one<=two){
    	cout<<"Yes"<<endl;
    	return;
    }
    cout<<"No"<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

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

using namespace std;

int n;
map<pair<int, pair<int,int> >, int> mp;

int main(){
    cin >> n;
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= n; ++j){
            for(int k = 1; k <= n; ++k){
                mp[make_pair(i,make_pair(j,k))] = 1;
            }
        }
    }
    cout << mp.size() << '\n';
    return 0;
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = __INT_MAX__;               // 2^31 - 1
const long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

struct mint {
    // Preparation: MOD is already defined.
    ll value;

    mint(ll value = 0) : value((value % MOD + MOD) % MOD) {}

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint pow(mint m) const {
        return pow(m.value);
    }

    mint inv() const {
        ll a = value, b = MOD, u = 1, v = 0;
        while (b) {
            ll t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        return u;
    }

    mint &operator+=(const mint a) {
        if ((value += a.value) >= MOD) value -= MOD;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((value += MOD - a.value) >= MOD) value -= MOD;
        return *this;
    }
    mint &operator*=(const mint a) {
        (value *= a.value) %= MOD;
        return *this;
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    int n;
    cin >> n;
    map<int, int> m;
    rep(i, n) {
        int x;
        cin >> x;
        m[x]++;
    }

    ll ans = 0;
    ll store = 0;
    for (auto e : m) {
        int f = e.first;
        int s = e.second;
        if (s <= 1)
            continue;
        m[f] -= store;
        while (m[f] >= 3) {
            m[f] -= 2;
        }
        store = m[f] - 1;
        m[f] = 1;
    }
    if (store > 0)
        ans -= store;

    for (auto e : m) {
        int f = e.first;
        int s = e.second;
        ans += s;
    }
    out(ans);
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll MOD = (ll)1e9 + 7;
const ll mxN = 200200;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	ll a,b,c,k; cin>>a>>b>>c>>k;
	if(k<=a) cout<<k<<"\n";
	else if(k<=b+a) cout<<a<<"\n";
	else cout<<2*a-k+b<<"\n";
	

}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int k,s,x,y,ans=0;
	cin >> k >> s;
	for(x=0;x<=k;x++){
		for(y=0;y<=k;y++){
			if(s-x-y>=0 && s-x-y<=k){
				ans++;
			}
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
N = gets.to_i
array_x=gets.chomp.split(" ").map(&:to_i)
array_y=gets.chomp.split(" ").map(&:to_i)

def distance(x, y, p)
    (0..(N-1)).to_a.map {|n| (x[n]-y[n]).abs**p }.inject(:+)**(1.0/p)
end

puts format("%0.5f", distance(array_x,array_y,1))
puts format("%0.5f", distance(array_x,array_y,2))
puts format("%0.5f", distance(array_x,array_y,3))
puts format("%0.5f", (0..(N-1)).to_a.map {|n| (array_x[n]-array_y[n]).abs }.max)


Measured memory_bytes: 6952
package main

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for A - Table Tennis Training
	sc.Split(bufio.ScanWords)
	var N, A, B int
	N, A, B = nextInt(), nextInt(), nextInt()

	var ans int
	if (B-A)%2 == 0 {
		ans = (B - A) / 2
	} else {
		if A-1 > N-B {
			ans = N - B
		} else {
			ans = A - 1
		}
		ans += (B-A)/2 + 1
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1772
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <map>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define setpre(n) fixed << setprecision(n)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
ll modinv(ll a,ll mod){
  return modpow(a,mod-2,mod);
}
const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
void initialize(){
  COMinit();
}
#define nHr(n,r) COM((n)+(r)-1,(r))
map<ll,ll> soin;
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  string s;
  
  cin >> n >> m;
  ll tmp=m,cnt=0;
  soin.clear();
  for(i=2;i<=sqrt(m);i++){
    while(tmp%i==0){
      soin[i]++;
      cnt++;
      tmp/=i;
    }
  }
  if(tmp>=2){
    soin[tmp]++;
    cnt++;
    tmp=1;
  }
  result=1;
  for(const auto& [key,value] : soin){
    //cout << key << " "  << value << endl;
    result *= nHr(n,value);
    result %= MOD;
  }
  cout << result << endl;
  return 0;
}

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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		String s = nextString();
		long ans =0;
		for(int i=0;i<3;i++){
			if(s.charAt(i)=='1')
				ans++;
		}
		System.out.println(ans);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21076
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])

Measured memory_bytes: 9412
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main() {
	cin>>a>>b;
	string s[1001];
	for(int i=0; i<a; i++) {
		cin>>s[i];
	}
	sort(s,s+a);
	for(int i=0; i<a; i++) {
		cout<<s[i];
	}
}

Measured memory_bytes: 256
N, = map(int, raw_input().split())
T, A = map(int, raw_input().split())
H = map(int, raw_input().split())
mi = 0
md = abs(T-0.006*H[0]-A)
for i in range(1, N):
  d = abs(T-0.006*H[i]-A)
  if d<md:
    md=d
    mi=i
print mi+1

Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    while(cin >> n >> m){
        if(n==0&&m==0){
            return 0;
        }
        vector<pair<int,int>> a(n);
        int sum=0;
        rep(i,n){
            int d,p;cin >> d >> p;
            a[i]={p,d};
            sum+=d*p;
        }
        sort(a.begin(),a.end(),greater<pair<int,int>>());
        int t=0;
        rep(i,n){
            if(m-a[i].second>=0){
                t+=a[i].first*a[i].second;
                m-=a[i].second;
            }
            else{
                t+=a[i].first*m;
                break;
            }
        }
        cout << sum-t << endl;
    }
}


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

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

    double hd = double(h);
    double md = double(m);

    double hAngle = (hd * 30.f) + (md / 60.f * 30.f);
    double mAngle = md * 6.f;
    double angleDiff = abs(hAngle - mAngle);
    if(angleDiff > 180.f)
    {
        angleDiff = 360.f - angleDiff;
    }

    double ad = double(a);
    double bd = double(b);
    double rad = angleDiff * M_PI / 180.f;
    double sqrAns = (ad*ad) + (bd*bd) - (cos(rad) * (2 * ad * bd));
    double ans = sqrt(sqrAns);

    cout << fixed << setprecision(9) << ans;

    return 0;
}


Measured memory_bytes: 4256
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
ll n,m,v,p;
int a[100005];
//int cf[100005];
bool check(int now){
    int c[100005];
    for(int i=1;i<=n;i++) c[i]=a[i];
    ll has=m+a[now],lft=(v-1)*m,ove=0;
    for(int i=1;i<now;i++) if(a[i]>has) ove++,c[i]=a[i]+m,lft-=m;
    if(ove>=p) return 0;
    if(lft<=0) return 1;
    vector<int> vec;
    for(int i=now+1;i<=n && lft>=1;i++)
        c[i]+=min(m,has-a[i]),lft-=min(has-a[i],m);
    if(lft<=0) return 1;
    for(int i=1;i<now && lft>=1;i++)
        if(a[i]<has)
            c[i]+=has-a[i],lft-=has-a[i],vec.pb(m-has+a[i]);
        else if(a[i]==has)
            vec.pb(m);
    if(lft<=0) return 1;
    ll ans=0;
    for(int i=0;i<vec.size();i++)
        if(ans+vec[i]>=lft){
            ove+=i+1;
            break;
        }
        else ans+=vec[i];
    if(ove>=p) return 0;
    return 1;
}
main(){
    scanf("%lld %lld %lld %lld",&n,&m,&v,&p);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    sort(a+1,a+n+1);
    reverse(a+1,a+n+1);
    int lb=0,ub=n+1;
    while(lb<=ub){
        int mid=(lb+ub)/2;
        if(check(mid))
            lb=mid+1;
        else
            ub=mid-1;
    }
    printf("%lld\n",min(ub,n));
    return 0;
}

Measured memory_bytes: 2860
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <climits>
#include <ctime>
#include <random>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
//#define ll long long
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>v(n);
	int mn = inf, ans = 0;
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		if (v[i] < mn)
			mn = v[i], ans++;
	}
	cout << ans;
}

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

const ll MX = 1e18;

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

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

int main(){
    int n,k;
    string s;
    cin>>n>>k>>s;
    vector<int> v0,v1;
    if(s[0]='0')v1.push_back(0);
    for(int i=0;i<n;){
        int t=0;
        if(s[i]=='0'){
            while(s[i]=='0'&&i!=n){
                t++;
                i++;
            }
            v0.push_back(t);
        }
        else{
            while(s[i]=='1'&&i!=n){
                t++;
                i++;
            }
            v1.push_back(t);
        }
    }
    if(s[n-1]='0')v1.push_back(0);
    for(int i=1;i<v0.size();i++){
        v0[i]+=v0[i-1];
    }
    for(int i=1;i<v1.size();i++){
        v1[i]+=v1[i-1];
    }
    int ans;
    for(int i=0;i<v0.size();i++){
        int t=min(i+k-1,(int)v0.size()-1);
        if(!i){
            ans=v0[t]+v1[t+1];
        }else{
            ans=max(ans,v0[t]-v0[i-1]+v1[t+1]-v1[i-1]);
        }
    }
    cout<<ans<<endl;
}


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

typedef long long                   ll;
typedef long double                 ld;
typedef pair<ll,ll>                 pll;
typedef pair<ld,ld>                 pld;


#define all(x)          (x).begin(),(x).end()
#define Sort(x)         sort(all(x))
#define sep             ' '

#define endl            '\n'
#define tab             '\t'
#define X               first
#define Y               second
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io         freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define set_random      mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll MOD = 1e9 + 7,
         MAXN= 1e6+10,
         INF=1e18;
ll a,b;
int main()
{
    fast_io;
    cin>>a>>b;
    if(a<=8 && b<=8)cout<<"Yay!";
    else cout<<":(";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;

ll size[51];
ll p[51];

ll dfs(ll level,ll num){
  if(num == 0)return 0;
  else if(num == size[level])return p[level];
  else if(num >= size[level-1] + 2){
    return dfs(level-1,num-size[level-1] - 2) + p[level-1] + 1;
  }
  else if(num >= 1){
    return dfs(level-1,num-1);
  }
}

int main(){
  size[0] = 1;
  p[0] = 1;
  for(int i = 1;i <= 50;i++){
    size[i] = size[i-1] * 2 + 3;
    p[i] = p[i-1] * 2 + 1;
  }

  ll n,x;
  cin >> n >> x;

  ll ans = dfs(n,x);

  cout << ans << endl;
}


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

int main() {
  string s;
  cin >> s;
  int A,Z;
  for(int i=0; i<s.size(); i++){
    if(s.at(i)=='A'){
      A=i+1;
      break;
    }
  }
  for(int i=s.size()-1; i>=0; i--){
    if(s.at(i)=='Z'){
      Z=i+1;
      break;
    }
  }
  cout << Z-A+1 << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

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

		int c = Math.min(a, b);
		int cnt = 0;
		int ans = 0;
		for (int i = c; i > 0; i--) {
			if (a % i == 0 && b % i == 0) {
				cnt++;
				if (cnt == k) {
					ans = i;
					break;
				}
			} else {
				continue;
			}
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 21332
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

template<typename T>
void printVec(vector<T> &v) {
    for(int i = 0; i < v.size(); i++) {
        cout << v[i] << " ";
    }
    cout << endl;
}

signed main() {
    int n; cin >> n;
    double ans = (n % 2 == 0 ? 1 / 2.0 : (n / 2 + 1.0) / n);
    cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endre getchar();getchar();return 0
#define moder (int)(1e9+7)
#define inf (int)(5*1e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
struct edge { int from, to, cost; };
int dx[5] = { 0,1,0,-1 }, dy[5] = { 1,0,-1,0 };
map<int, int>factor(int x) {
	map<int, int>res;
	for (int i = 2; i*i <= x; i++) {
		while (x%i == 0) {
			x /= i;
			res[i]++;
		}
	}
	if (x != 1)res[x]++;
	return res;
}
/*--------Library Zone!--------*/

int n, m;
P p[100005];
signed main() {
	cin >> n >> m;
	rep(i, n)cin >> p[i].first >> p[i].second;
	sort(p, p + n);
	int ans = 0;
	rep(i, n) {
		if (m > p[i].second) {
			ans += p[i].first*p[i].second;
			m -= p[i].second;
		}
		else {
			ans += p[i].first*m;
			cout << ans << endl;
			endre;
		}
	}
	endre;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef long long ll;
typedef pair<int,int> pint;
const ll mod= 998244353;
const int inf=1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

ll fact[303030],invfact[303030];

ll comb(int n,int k){
  ll ret=invfact[k]*invfact[n-k] %mod;
  return ret*fact[n]%mod;
  }

ll pow(ll n,ll k){
  ll ret=1;
  while(k>0){
    if(k&1)ret=n*ret %mod;
    n=n*n %mod;
    k/=2;
    }
  return ret;
  }

int main(){
  ll n;
  cin>>n;
  ll a,b,k;
  cin>>a>>b>>k;
  fact[0]=1;invfact[0]=1;
  rep(i,n+2){
    fact[i+1]=fact[i]*(i+1) %mod;
    invfact[i+1]=invfact[i]*pow((ll)(i+1),mod-2)%mod;
    }
  ll ans=0;
  rep(i,n+1){
    ll res=k-a*(ll)i;
    if(res>=0 && res%b==0 &&res/b <=n){
      ans+=comb(n,i)*comb(n,res/b) %mod;
      ans%=mod;
      }
    }
  cout<<ans<<endl;
  return 0;
  }

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

long long L, R;

int main() {
    cin >> L >> R;

    R = min(R, L + 2019);

    long long ans = 1e18;
    for (long long i = L; i <= R; i++) {
        for (long long j = i + 1; j <= R; j++) {
            long long a1 = i % 2019;
            long long a2 = j % 2019;
            ans = min((a1 * a2) % 2019, ans);
        }
    }

    cout << ans << endl;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

// mod付きコンビネーション
const int MAX = 1100000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
Int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 素因数分解
vector<pair<Int, Int>> factorization(Int n) {
    vector<pair<Int, Int>> ret;
    for (Int i = 2; i * i <= n; i++) {
        Int cnt = 0;
        while (n % i == 0) {
            n /= i;
            cnt++;
        }
        if (cnt > 0) {
            ret.emplace_back(i, cnt);
        }
    }
    if (n > 1) {
        ret.emplace_back(n, 1);
    }
    return ret;
}

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    map<Int, Int> mp;
    for (Int i = 0; i < n; i++) {
        vector<pair<Int, Int>> fc = factorization(a[i]);
        for (Int j = 0; j < (Int)fc.size(); j++) {
            mp[fc[j].fi] = max(mp[fc[j].fi], fc[j].se);
        }
    }
    Int x = 1;
    for (auto i : mp) {
        for (Int j = 0; j < i.se; j++) {
            x = x * i.fi % mod;
        }
    }
    COMinit();
    Int res = 0;
    for (Int i = 0; i < n; i++) {
        res += x * inv[a[i]] % mod;
        res %= mod;
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 26752
#include<stdio.h>
int main()
{
	int n,m,a[10000]={0};
	int i;
	int sum=0;

	scanf("%d %d",&n,&m);
	i=0;
	while(scanf("%d",&a[i])){
		i++;
		if(i>=m){break;}
	}
	for(i=0;i<m;i++){
		sum+=a[i];
	}
	if(sum<=n){
		printf("%d",(n-sum));
	}
	else{
		printf("-1");
	}
	return 0;
}

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

int main(int argc, char const* argv[]){

    int n;
    cin >> n;

    string s;
    cin >> s;

    int r, nume=0, numw=0;
    for (int i = 1; i < n; i++) {
        if (s[i] == 'E') {
            nume++;
        }
    }

    r = nume;
    for (int i = 1; i < n; i++) {
        if (s[i-1] == 'W') numw++;
        if (s[i] == 'E') nume--;
        r = min(r, numw+nume);
    }
    cout << r << endl;

    return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(ll (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{	
    int k;
    string s;
    cin >> k >> s;

    if(s.size() <= k) cout << s << endl;
    else cout << s.substr(0, k) << "..." << endl;
}


Measured memory_bytes: 3628
n,x = map(int,input().split())
l = list(map(int,input().split()))
# print(listl)

cnt=1
d=0
# print(d)
for i in range(len(l)):
    d = d+l[i]
    if d > x:
        break
    # print(d)
    cnt+=1

print(cnt)

Measured memory_bytes: 38384