akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  double n,m; cin >> n >> m;
  vector<double> a(n);
  ll sum=0;
  rep(i,n){
    cin >> a[i];
    sum+=a[i];
  }
  int cnt=0;
  rep(i,n){
    //cout << double(sum/(4*m)) << endl;
    if(a[i]>=double(sum/(4*m))) cnt++;
  }
  if(cnt>=m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#define rep(i,o,u) for(i = o;i < u; i++)
using namespace std;

int a[101];
int main(){
	int n;
	int i,j;
	cin >> n;
	rep(i,0,n) cin >> a[i];
	int ans = 0;
	rep(i,0,n-1){
		rep(j,0,n-1-i){
			if(a[j] > a[j+1]){
				swap(a[j],a[j+1]);
				ans++;
			}
		}
	}
	rep(i,0,n-1) cout << a[i]  << " ";
	cout << a[n-1] << endl;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main(){

    int N,M,a,b,ans[60]={};
    cin >> N>>M;

    for(int i=1;i<=N;i++){
        ans[i]=0;
    }

    for(int i=1;i<=M;i++){
        cin >> a>>b;

        ans[a]++;
        ans[b]++;
    }

    for(int i=1;i<=N;i++){
        cout << ans[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())

ans = ":("
for i in range(1,N+1):
    if int(i*1.08)==N:
        ans = i
        break

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <random>
#include <time.h>
#include <queue>

using namespace std;
#define int long long
const int INF = 1e16 + 7;
const int MAXN = 2e5 + 7;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, c;
    cin >> a >> b >> c;
    int x, y;
    cin >> x >> y;
    int ans = INF;
    for (int i = 0; i < MAXN; i += 2) {
        ans = min(ans, i * c + max(0ll, (x - (i / 2))) * a + max(0ll, (y - (i / 2))) * b);
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define _USE_MATH_DEFINES
#include <math.h>
#include<iomanip>
using namespace std;
int A, B, H, M;



int main()
{	
	cin >> A >> B >> H >> M;
	long double jisin, funsin;
	jisin = (60 *(long double) H +(long double) M) / 2;
	funsin = 6 * M;
	long double c = jisin - funsin;
	long double ans = (long double)(A * A + B *B) - (long double)(2*A * B) * cosl(M_PI*c/180);
	
	cout << setprecision(12)<<pow(ans,0.5) << endl;
}


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

typedef pair<int, pair<int, int>> pi;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  sort(a.rbegin(), a.rend());

  ll ans = a[0];

  priority_queue<pi, vector<pi>, greater<pi>> pq;

  pq.push(make_pair(-1 * min(a[0], a[1]), make_pair(a[0], a[1])));
  pq.push(make_pair(-1 * min(a[0], a[1]), make_pair(a[0], a[1])));

  for (int i = 2; i < n; i++) {
    pi t = pq.top();
    pq.pop();
    ans += -1 * t.first;
    pq.push(make_pair(-1 * min(a[i], t.second.first),
                      make_pair(a[i], t.second.first)));
    pq.push(make_pair(-1 * min(a[i], t.second.second),
                      make_pair(a[i], t.second.second)));
  }

  cout << ans << endl;

  return 0;
}

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

typedef complex<double> P;

int main(){
	int n,s;
	while(cin >> n >> s and (n or s) ){
		int ans = 0;
		for(int i = 0 ; i < (1<<10) ; i++){
			int c = 0;
			int k = 0;
			for(int j = 0 ; j < 10 ; j++)
				if( i >> j & 1 ) c++, k += j;
			if( c == n and s == k ){
				ans++;
			}
		}	
		cout << ans << endl;	
	}
			
}

Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#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> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  int cnt = 0;
  rep(i, n){
    int a,b;
    cin >> a >> b;
    if(a == b) cnt++;
    else cnt = 0;
    if(cnt == 3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3628
while True:
    l = map(int,raw_input().split())
    if l == [0,0]:
        break
    else:
        n = l[0]
        p = l[1]
        l = []
        for i in range(n):
            l.append(0)
        a = 0
        b = p
        while True:
            if b == 0:
                b = l[a]
                l[a] = 0
            else:
                l[a] = l[a] + 1
                b = b - 1
                if l[a] == p:
                    print a
                    break
            if a == n - 1:
                a = 0
            else:
                a = a + 1

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}
          
  
int main() {
  int N, M;
  cin >> N >> M;
  vector <int> P(M), Y(M); 
  rep(i,M){
    cin >> P[i] >> Y[i];
    P[i]--;
  }
  
  vector<vector<int>> ans(N);
  rep(i,M){
    ans[P[i]].push_back(Y[i]);
  }
  
  rep(i,N){
  	sort(ans[i].begin(),ans[i].end());
  }
  
  rep(i,M){
    cout<< setfill('0') << setw(6) << P[i]+1;
    int num = lower_bound(ans[P[i]].begin(),ans[P[i]].end(),Y[i])-ans[P[i]].begin();
    cout<< setfill('0') << setw(6) << num+1 <<endl;
  }
}
  



Measured memory_bytes: 7808
#include<stdio.h>
int judgeExist(char ch, char chars[100])
{
	int i;
	for (i = 0; chars[i] != 0; i++)
	{
		if (chars[i] == ch)
			return 1;
	}
	chars[i] = ch;
	return 0;
}
int getCount(char chars[100]) {
	int i;
	for (i = 0; chars[i] != 0; i++);
	return i;
}
int main()
{
	int n,i,count;
	char ch;
	char chars[100];
	for (i = 0; i < 100; i++)
		chars[i] = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%c", &ch);
		while(ch < 'A' || ch > 'Z')
			scanf("%c", &ch);
		judgeExist(ch, chars);
	}
	count = getCount(chars);
	if (count == 3)
		printf("Three");
	if (count == 4)
		printf("Four");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>


#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;

using namespace std;


int main()   {
    cout.precision(17);
    ll modd = 1000 * 1000 * 1000 + 7;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
    ll infinit = 10000000000000000;


//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readll(a); readll(b); readll(m);
        vector<ll> aa;
        forr(i,0,a) {readll(ff); aa.push_back(ff);}
        vector<ll> bb;
        forr(j,0,b) {readll(ff); bb.push_back(ff);}

        vector<tuple<ll,ll,ll>> coupon;

        forr(i,0,m) { readll(x); readll(y); readll(z); coupon.push_back(make_tuple(x,y,z));  }

        ll mina = 10000000, minb = 100000000;
        forr(i,0,a) {  mina = min(mina, aa[i]);   }
        forr(i,0,b) {  minb = min(minb, bb[i]);   }

        ll minc = 100000000;
        forr(i,0,m) {
            minc = min(minc, -get<2>(coupon[i])+aa[get<0>(coupon[i])-1]+bb[get<1>(coupon[i])-1]);
        }

        cout << min(minc, mina+minb) << endl;

    }
    return 0;
}


Measured memory_bytes: 7024
#ABC047

w,h,n = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(n)]

x = [0,w,0,h]#[l,r,b,t]

for i in range(n):
    if l[i][2] == 1:
        x[0] = max(x[0],l[i][0])
    elif l[i][2] == 2:
        x[1] = min(x[1],l[i][0])
    elif l[i][2] == 3:
        x[2] = max(x[2],l[i][1])
    else:
        x[3] = min(x[3],l[i][1])
    
    #print(x)
    if x[0] >= x[1] or x[2] >= x[3]:
        print(0)
        break
        
        
if x[0] < x[1] and x[2] < x[3]:
    print((x[1]-x[0])*(x[3]-x[2]))

Measured memory_bytes: 3064
n,x=map(int,input().split())
l=list(map(int,input().split()))
if sum(l)<=x:
  print(n+1)
  exit()
i,d=1,0
while(i<n):
  d+=l[i-1]
  if d<=x:
    i+=1
  else:
    break
print(i)

Measured memory_bytes: 2940
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 100005
#define oo 1000000000000000007LL
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

bitset<4000005> bs;

int main () {
    int n; scanf("%d", &n);

    int sum = 0;
    bs[0] = 1;
    fto(i, 1, n) {
        int x; scanf("%d", &x);
        bs = bs | (bs<<x);
        sum += x;
    }

    for(int i = (sum+1)/2; ; ++i) {
        if (bs[i]) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 2176
def main():
    N = int(input())
    cell = [[int(a) for a in input().split()] for j in range(2)]
    mcandies = 0
    for i in range(N):
        s = sum(cell[0][:i+1]) + sum(cell[1][i:])
        if mcandies < s:
            mcandies = s
    print(mcandies)
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mxn= 1e6+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    rishabh();
    int n;
    cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    ll ans=0,mx=arr[0];
    for(int i=1;i<n;i++){
        if(arr[i]<mx){
            ans=ans+mx-arr[i];
        }
        else mx=arr[i];
    }
    cout<<ans;
}

Measured memory_bytes: 5172
N = int(input())
a = list(map(int,input().split()))
ma = max(a)
maketa = len(bin(ma))-2
#print(maketa)
res = 0
dic = {}
for i in range(maketa):
    dic[i] = 0
for i in range(0,maketa):
    num = 0
    for j in range(N):
        #print(a[j] & (2**i))
        dic[i] += int((a[j] & (2**i))>>i)
        #count += 1
for i in range(maketa):
    num = dic[i]
    res += num*(N-num)*(2**(i))
print(res%(10**9+7))


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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

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

int gcd(int a, int b){
    if (b==0) return a;
    return gcd(b, a%b);
}

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

    int n;
    cin>>n;
    int A[n], gcdL[n], gcdR[n];
    for (int i=0;i<n;++i) cin>>A[i];
    gcdL[0] = A[0];
    gcdR[n-1] = A[n-1];

    for (int i=1;i<n;++i) gcdL[i] = gcd(A[i], gcdL[i-1]);
    for (int i=n-2;i>=0;i--) gcdR[i] = gcd(A[i], gcdR[i+1]);

    int maxi = max(gcdR[1], gcdL[n-2]);
    for (int i=1;i<n-1;++i){
        int g = gcd(gcdL[i-1], gcdR[i+1]);
        maxi = max(maxi, g);
    }
    cout<<maxi<<endl;

    return 0;
}

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

using namespace std;

int main(void){
    int H, W;
    bool flag = true;
    cin >> H >> W;

    vector<vector<char>> s(H+2, vector<char>(W+2,'.'));

    for(int i = 1; i < H+1; i++){
        for(int j = 1; j < W+1; j++){
            cin >> s[i][j];
        }
    }

    for(int i = 1; i < H+1; i++){
        for(int j = 1; j < W+1; j++){
            if(s[i][j] == '#' && s[i-1][j] == '.' && s[i+1][j] == '.' && s[i][j-1] == '.' && s[i][j+1] == '.'){
                cout <<  "No" << endl;
                flag = !flag;
                break;
            }
        }
        if(!flag){
            break;
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int64_t>vec(N);
    for (int i=0; i < N; i++) {
        cin >> vec.at(i);
    }

    int64_t count = 0;
    for (int i=0; i < N; i++) {
        int64_t num = vec[i];
        while (num % 2 == 0) {
            count += 1;
            num = num / 2;
        }
    }

    cout << count << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  double ans = 0;
  rep(i,n,0){
    double x;
    string y;
    cin >> x >> y;
    if(y == "JPY") ans += x;
    else ans += x*380000.0;
  }
  printf("%.6f\n", ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
//#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
const int M=200005;
int a[30];
char s[M];
int main()
{

    while(scanf("%s",s)==1)
    {
        memset(a,0,sizeof(a));
        int len=strlen(s);
        for(int i=0;i<len;i++)
            a[s[i]-'a']++;
        ll ans=(ll)len*(len-1)/2;
        //sort(a,a+26);
        for(int i=25;i>=0;i--)
        {
            ans-=(ll)a[i]*(a[i]-1)/2;
        }
        printf("%lld\n",ans+1);
    }
    return 0;
}


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

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

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

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b, c, d);
    Cout(6-a-b);
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;



void main() {
    int input;
    immutable limitList = 500000;
    bool[] listNumbers = new bool[](limitList);
    int[] listPrimeNumbers;

    listNumbers.fill(true);
    foreach (i; 2..limitList.to!double.sqrt.to!int) {
        if (listNumbers[i]) {
            for (int j = i*2; j < limitList; j += i) listNumbers[j] = false;
        }
    }

    foreach (i; 2..listNumbers.length) {
        if (listNumbers[i]) {
            listPrimeNumbers ~= i.to!int;
        }
    }

    while ((input = readln.chomp.to!int) != 0) {
        ulong sum = 0;

        foreach (i; 0..listPrimeNumbers.length) {
            if (i == input) break;
            sum += listPrimeNumbers[i];
        }

        writeln(sum);
    }
}

Measured memory_bytes: 1496
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	int n, m;
	int p;
	string s;
	int correct, wrong;
	int i, j;


	correct = wrong = 0;
	cin >> n >> m;
	int *submit = new int[n + 1];
	for (i = 0; i <= n; i++) {
		submit[i] = 0;
	}

	for (i = 0; i < m; i++) {
		cin >> p >> s;
//		cout << "s = " << s << " "<<(bool)flg[p]<<endl;
		if (s == "WA") {
			if (submit[p] != -1) {
				submit[p]++;
			}
		}
		else {
			if (submit[p] != -1) {
				wrong += submit[p];
				correct++;
				submit[p] = -1;
			}
		}
	}
	cout << correct << " " << wrong << endl;
	return 0;
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

struct TopologicalSort {
  struct edge {
    int from, to;
    edge() {}
    edge(int from, int to) : from(from), to(to) {}
  };

  int n;
  vector<vector<edge>> G;
  vector<int> indeg;
  TopologicalSort() {}
  TopologicalSort(int n) : n(n), G(n), indeg(n) {}
  void add_edge(int f, int t) {
    G[f].emplace_back(f, t);
    indeg[t]++;
  }
  vector<int> query() {
    queue<int> que;
    for (int i = 0; i < n; i++) {
      if (indeg[i] == 0) que.emplace(i);
    }
    vector<int> res;
    while (!que.empty()) {
      int v = que.front(); que.pop();
      res.emplace_back(v);
      for (auto &e : G[v]) {
        if (--indeg[e.to] == 0) que.emplace(e.to);
      }
    }
    return res;
  }
};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int m, n;
  cin >> m >> n;
  TopologicalSort T(m);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    T.add_edge(x, y);
  }
  auto ans = T.query();
  for (auto i : ans) {
    cout << i + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX
double dp[3005][3005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    std::cout << std::setprecision(10) << std::fixed;
    long long int n,i,j;
    cin>>n;
    double a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    dp[0][0]=1;
    for(i=1;i<=n;i++)
    {
        dp[i][0]=dp[i-1][0]*(1-a[i-1]);
        for(j=1;j<=i;j++)
            dp[i][j]=(dp[i-1][j-1]*a[i-1])+(dp[i-1][j]*(1-a[i-1]));
    }
    double ans=0;
    // cout<<dp[n][1];
    for(i=(n/2)+1;i<=n;i++)
        ans=ans+dp[n][i];
    cout<<ans;
}

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

int main(int argc, char* argv[]) {
    int n;
    bool flag = false;
    cin >> n;
    int array[n];
    for (int i = 0; i < n; i++) cin >> array[i];
    for (int i = 0; i < n-1; i++) cout <<  array[i] << " ";
    cout << array[n-1] << "\n";

    for (int i = 1; i < n; i++){
        int v = array[i];
        int j = i - 1;
        flag = false;

        while (j >= 0 && array[j] > v){
            flag = true;
            array[j+1] = array[j];
            j--;
            array[j+1] = v;
        }
        for (int i = 0; i < n-1; i++){
            cout << array[i] << " ";
        }
        cout << array[n-1] << "\n";
    }
    return 0;
}



Measured memory_bytes: 3104
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int P = sc.nextInt();
        int Q = sc.nextInt();
        int R = sc.nextInt();
        int ans;

        ans = P+Q;

        if(ans >= Q+R){
            ans = Q + R;
        }
        if(ans >= R+P){
            ans = R + P;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 20948
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
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 () {
  int n = in();
  vi w(n);
  rep(i,n) w[i] = in();
  int sum = 0;
  rep(i,n) sum += w[i];
  int ans = INF;
  int s1 = 0;
  rep(i,n-1) {
    s1 += w[i];
    int s2 = sum - s1;
    chmin(ans, abs(s1-s2));
  }
  cout << ans << endl;
  return 0;
}

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

#define int long long
#define endl "\n"

using namespace std;

int32_t main()
{
    int n;
    cin >> n;
    
    if(n%2)
        cout << 0 << endl;
    else
    {
        n /= 2;
        
        int ans = 0;
        
        while(n > 1)
        {
            ans += n/5;
            n /= 5;
        }
        
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

s = S()
D = defaultdict(int)
D[0] = 1
ret = 0
ans = 0
j = 1
for i in range(len(s) - 1, -1, -1):
    ret = int(s[i]) * j + ret
    ans += D[ret % 2019]
    D[ret % 2019] += 1
    j = j * 10 % 2019

print(ans)





Measured memory_bytes: 78200
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		
		if (K % 2 == 1) {
			long count = 0;
			for (int i = 1; i <= N; i++) {
				if (i % K == 0) {
					count++;
				}
			}
			
			System.out.println(count * count * count);
		} else {
			long ans = 0;
			
			long count = 0;
			for (int i = 1; i <= N; i++) {
				if (i % K == 0) {
					count++;
				}
			}
			
			ans += count * count * count;
			
			count = 0;
			for (int i = 1; i <= N; i++) {
				if (i % K == K / 2) {
					count++;
				}
			}
			
			ans += count * count * count;
			
			
			
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void) {
	int i, a[3] = { 0 };
	string s;
	cin >> s;
	for (i = 0; i < s.size(); i++) {
		a[s[i] - 'a']++;
	}
	sort(a, a + 3);
	if (abs(a[0] - a[2]) < 2)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

Measured memory_bytes: 512
M,D = map(int,input().split())

ans = 0
for m in range(1,M+1):
    for d in range(10,D+1):
        d10 = d//10
        d1 = d%10
        ans += (d1 >= 2) and (d10 >= 2) and (d1 * d10 == m)

print(ans)



Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    string s, t;
    cin >> s >> t;

    if (n > s.size()+t.size()){
        cout << s.size()+t.size() << endl;
        return 0;
    }
    int mostOverlap = s.size() + t.size() - n;
    int minlen = s.size()+t.size();

    FOR(i, 1, mostOverlap+1){
        // cout << i << ": " << s.substr(s.size()-i, i) << " " << t.substr(0, i) << endl;
        if (s.substr(s.size()-i, i) == t.substr(0, i)){
            if (s.size()+t.size()-i < minlen) minlen = s.size()+t.size()-i;
        }
    }
    cout << minlen << endl;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}

struct Edge {
    int from, to; long cost;
}
void main() {
    int N, M; long X; readf("%s %s %s\n", &N, &M, &X);
    auto H = new long[N];
    foreach (i; 0 .. N) {
        H[i] = readln.chomp.to!long;
    }
    auto G = new Edge[][N];
    foreach (i; 0 .. M) {
        int a, b; long t; readf("%s %s %s\n", &a, &b, &t); a--; b--;
        G[a] ~= Edge(a, b, t);
        G[b] ~= Edge(b, a, t);
    }
    immutable INF = long.max / 4;
    struct P { int v; long cost; }
    BinaryHeap!(Array!P, "a.cost > b.cost") PQ;
    auto D = new long[N]; D[] = INF;
    PQ.insert(P(0, 0));
    D[0] = 0;
    long ans = INF;
    while (! PQ.empty) {
        auto c = PQ.front; PQ.removeFront;
        long cur_height = X - c.cost;
        if (cur_height < 0) cur_height = 0;
        assert(cur_height <= H[c.v]);
        foreach (e; G[c.v]) {
            if (e.cost > H[c.v]) continue; // cannot reach e.to
            long ncost = c.cost + e.cost + max( 0, cur_height - (H[e.to] + e.cost), e.cost - cur_height );
            if (D[e.to] > ncost) {
                D[e.to] = ncost;
                PQ.insert(P(e.to, ncost));
            }
        }
        if (c.v == N - 1) {
            ans = min(ans, c.cost + H[N - 1] - cur_height);
        }
    }
    if (ans >= INF) {
        writeln(-1);
    } else {
        writeln(ans);
    }
}

Measured memory_bytes: 30796
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

ll dp[52][52][2510];

int main() {
    int n, a; cin >> n >> a;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    rep(i,n) rep(j,n+1) rep(k,a*n+1) {
        dp[i+1][j][k] += dp[i][j][k];
        dp[i+1][j+1][k+x[i]] += dp[i][j][k];
    }
    ll ans = 0;
    repf(j,1,n+1) {
        ans += dp[n][j][a*j];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 53248
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
    ll N, K; cin >> N >> K;
    vector<ll> sums(N + 1);
    for (int i = 0; i < N; i++) {
        ll a; cin >> a;
        sums[i + 1] = sums[i] + a;
    }
    //set<vector<int>> bin;
    //map<vector<int>, int> cnt;
    int ct = 0;
    vector<vector<int>> biny(N * (N + 1) / 2, vector<int>(41));
    for (int i = 0; i <= N; i++) {
        for (int j = i + 1; j <= N; j++) {
            ll temp = sums[j] - sums[i];
            //vector<int> arr(41);
            for (int k = 0; temp > 0; k++) {
                biny[ct][k] = temp % 2;
                temp /= 2;
            }
            ct++;
        }
    }

    ll ans = 0, twos = pow(2, 40);
    for (int i = 40; i >= 0; i--) {
        ll tot = 0;
        for (int j = 0;j<N*(N+1)/2;j++) {
            if (biny[j][i] == 1) tot ++;
        }
        if (tot >= K) {
            ans += twos;
            for (int k = 0; k < N * (N + 1) / 2; k++) {
                if (biny[k][i] == 0) {
                    //cnt[y] = 0;
                    //bin.erase(y);
                    biny[k] = vector<int>(41);
                }
            }
        }
        twos /= 2;
    }
    cout << ans << endl;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li a[111];
li n;
li radius = 0;
li cnt[111];

bool solve() {
    li cnt_centroid = 0;
    rin{
        if (a[i] * 2 == radius) {
            cnt_centroid++;
        }
        if (a[i] * 2 < radius) {
            return false;
        }
        cnt[a[i]]++;
    }
    repp(i, (radius + 1) / 2, radius + 1) {
        if (i * 2 == radius) {
            if (cnt[i] != 1)return false;
        } else if (i * 2 - 1 == radius) {
            if (cnt[i] != 2)return false;
        } else {
            if (cnt[i] < 2)return false;
        }
    }
    return true;
}

int main() {
    cin >> n;
    rin{
        cin >> a[i];
        radius = max(radius, a[i]);
    }
    cout << (solve() ? "Possible" : "Impossible") << endl;

    return 0;
}

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

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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];

int main(){
    int n;
    cin>>n;
    using ppsii = pair<pair<string, int>,int>;
    vector<ppsii> vppsii;
    rep(i,n){string s;int a; cin>>s>>a; vppsii.push_back(make_pair(make_pair(s,-a),i+1));}
    sort(vppsii.begin(),vppsii.end());
    rep(i,n){
        cout<<vppsii.at(i).second<<endl;
    }
    return 0;
}




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

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF = 1e18;
const int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();

int main() {
	int a, b, c; cin >> a >> b >> c;
	cout << max(c - (a - b), 0);
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}


Measured memory_bytes: 256
N = gets.to_i

D = gets.chomp.split.map(&:to_i)

F = gets.chomp.split.map(&:to_i)

i = 0

result = 10000000000000000000000000000000

is = 0

while i < N
	if D[1] - (D[0]-0.006*F[i]) > 0
		if result > D[1] - (D[0]-0.006*F[i])
			result = D[1] - (D[0]-0.006*F[i])
			is = i
		end
	else
		if result > (D[0]-0.006*F[i]) - D[1]
			result = (D[0]-0.006*F[i]) - D[1]
			is = i
		end
	end
	i += 1
end
puts is+1

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
} 

const ll sqrtN = 512;
struct SqrtDecomposition {
  int N, K;
  vector<ll> data;
  vector<ll> bucketadd;
  vector<ll> bucketsum;
  SqrtDecomposition(int n) : N(n) {
    K = (N + sqrtN - 1) / sqrtN;
    data.assign(K * sqrtN, 0);
    bucketadd.assign(K, 0);
    bucketsum.assign(K, 0);
  }
  void add(int s,int t,ll x) {
    for(int k=0;k<K;++k){
        int l=k*sqrtN,r=(k+1)*sqrtN;
        if (r <= s || t <= l)
          continue;
        if (s <= l && r <= t) {
            bucketadd[k]+=x;
        } 
        else {
            for (int i = max(s, l); i < min(t, r); ++i) {
                data[i]+=x;
            }
            ll  sum=0;
            for(int i = l;i<r;i++){
                sum+=data[i];
            }
            bucketsum[k]=sum;
        }
    }
  }
  // [x, y)
  ll get(int s,int t) {
    ll ret=0;
    for(int k=0;k<K;++k){
        int l=k*sqrtN,r=(k+1)*sqrtN;
        if (r <= s || t <= l)
          continue;
        if (s <= l && r <= t) {
            ret+=bucketsum[k]+bucketadd[k]*sqrtN;
        } 
        else {
            for (int i = max(s, l); i < min(t, r); ++i) {
                ret+=data[i]+bucketadd[k];
            }
        }
    }
    return ret;
  }
};



int main(){
    ll n,q;cin >> n >> q;
    SqrtDecomposition sq(n);
    while(q--){
        ll a;cin >> a;
        if(a){
            ll s,t;cin >> s>>t;s--;
            cout << sq.get(s,t) <<endl;
        }
        else{
            ll s,t,x;cin >> s >> t>>x;s--;
            sq.add(s,t,x);
        }
    }
}


Measured memory_bytes: 3580
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
#define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
#define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/






int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.precision(10); cout << fixed;
#ifdef LOCAL
  freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
  int n, x, t; cin >> n >> x >> t;
  int ret = n/x*t;
  if (n % x != 0) ret += t;
  cout << ret << '\n';






/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
  return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


Measured memory_bytes: 3164
#include <stdio.h>

int main(void) {
    int n, ans, i;
    scanf("%d", &n);
    int a[n][2]; ans = 0;

    for (i = 0; i < n; i++) {
        scanf("%d", &a[i][0]);
        a[i][1] = i + 1 - ans;
        if (a[i][0] != a[i][1]) ans++;
    }

    if (ans == n) ans = -1;

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1664
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        int answer = 0;
        List<Integer> list1 = new ArrayList<>();
        List<Integer> list2 = new ArrayList<>();
        int array1[] = new int[5];
        int array2[] = new int[5];
        List<String> slist = new ArrayList<>();
        //入力
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int ruisekiwa[]=new int[N+1];
        //処理
        ruisekiwa[0]=0;
        for(int i=1;i<N+1;i++)
        {
            if(S.substring(i-1,i).equals("#"))
            {
                count++;
            }
            ruisekiwa[i]=count;
        }

        //System.out.println(Arrays.toString(ruisekiwa));

        for(int i=0;i<N+1;i++)
        {
            //System.out.println("-----"+i);
            int leftBlackCount=ruisekiwa[i]-ruisekiwa[0];
            int rightBlackCount=ruisekiwa[N]-ruisekiwa[i];
            int rightWhiteCount=N-i-rightBlackCount;
            //System.out.println("lbcount"+leftBlackCount);
            //System.out.println("rwcount"+rightWhiteCount);
            int sum=leftBlackCount+rightWhiteCount;
            //System.out.println("sum"+sum);
            if(sum<min)
            {
                min=sum;
            }
        }
        answer=min;
        //Collections.sort(a);
        //System.out.println(Arrays.toString(list1.toArray()));
        //System.out.println(Arrays.toString(array1));
		//System.out.println(Arrays.deepToString(a));
        System.out.println(answer);
    }
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int X;
    cin >> X;

    int ans = 1;
    rep(i, 101) {
        int tmp = i + 1;
        repd(j, 2, 100) {
             tmp *= i + 1;
            if (tmp <= X) ans = max(ans, tmp);
            else break;
        }
    }

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

Measured memory_bytes: 256
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #ここにコード
    #input
    N, M, Q = map(int, input().split())

    e = [[0]] * Q
    for i in range(Q):
        a, b, c, d = map(int, input().split())
        e[i] = [a, b, c, d] 

    #output
    import itertools
    #A[b-1] = A[a-1] + c
    L = [i+1 for i in range(M)]

    L = itertools.combinations_with_replacement(L, N)

    answer = 0
    for l in L:
        temp_answer = 0
        for i in range(Q):
            a = e[i][0]
            b = e[i][1]
            c = e[i][2]
            d = e[i][3]
            if l[b-1] - l[a-1] == c:
                temp_answer += d
                answer = max(answer, temp_answer)

    print(answer)

if __name__ == "__main__":
    main()

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

int main() {
ll n,k;
ll sum =0;
ll t;
std::vector<int>H;
scanf("%lld%lld",&n,&k);
rep(i,n){
	scanf("%lld",&t);
	H.push_back(t);
}
sort(H.begin(),H.end());

rep(i,n-k){
// printf("%lld",H.front());
	sum += H[i];
	// H.erase(H.begin());
}
printf("%lld",sum);

	return 0;
}

Measured memory_bytes: 1400
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

int n;
int A, B;
int a, b, c;

int main(){
	scanf("%d %d %d", &n, &A, &B);
	for(int i = 1, d; i <= n; i++){
		scanf("%d", &d);
		if(d <= A) a++;
		else if(d <= B) b++;
		else c++;
	}
	(a > b) ? (a = b) : 0;
	if(a > c) a = c;
	printf("%d\n", a);
	return 0;
}

Measured memory_bytes: 128