akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

bool dpx[4010][16060];
bool dpy[4010][16060];

int main() {
    string S;
    cin >> S;
    int x, y;
    cin >> x >> y;
    dpx[0][8000] = 1;
    dpy[0][8000] = 1;
    vector<int> movex, movey;
    int state = 0, cnt = 0;
    rep(i, S.size()) {
        if(S[i] == 'F') {
            cnt++;
        } else {
            if(!state) {
                movex.pb(cnt);
            } else {
                movey.pb(cnt);
            }
            state = 1 - state;
            cnt = 0;
        }
    }
    if(!state) {
        movex.pb(cnt);
    } else {
        movey.pb(cnt);
    }
    int M = movex.size(), N = movey.size();
    for(int i = 0; i < M; i++) {
        for(int j = 0; j < 16010; j++) {
            if(j - movex[i] >= 0)
                dpx[i + 1][j] = dpx[i + 1][j] || dpx[i][j - movex[i]];
            if(i > 0 && j + movex[i] <= 16010)
                dpx[i + 1][j] = dpx[i + 1][j] || dpx[i][j + movex[i]];
        }
    }
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 16010; j++) {
            if(j - movey[i] >= 0)
                dpy[i + 1][j] = dpy[i + 1][j] || dpy[i][j - movey[i]];
            if(j + movey[i] <= 16010)
                dpy[i + 1][j] = dpy[i + 1][j] || dpy[i][j + movey[i]];
        }
    }
    if(dpx[M][8000 + x] && dpy[N][8000 + y]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 125440
#include <stdio.h>
#include <stdlib.h>

int init_z(int e){
        int i;
        for(i = 0;i * i * i <= e;i++);
        return i-1;
}

int init_y(int e){
        int i;
        for(i = 0;i * i <= e;i++);
        return i-1;
}


int m_min(int e){
        int m = 1000000;;
        int z = init_z(e);
        
        for(;z>=0;z--){
                int y = init_y(e-(z*z*z));
                for(;y>=0;y--){
                        int x = e - (z*z*z + y*y);
                        if(m > x + y + z){
                                m = x + y + z;
                        }
                }
        }
        return m;
}

int main(){
        int x, y, z;
        int e;
        
        
        while(1){
                scanf("%d",&e);
                if(e==0){
                        break;
                }
                printf("%d\n",m_min(e));
        }
        return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
const double eps = 1e-8;
const double pi = acos(-1.0);
typedef long long ll;
int sgn(double x){
    if(fabs(x)<eps){
        return 0;
    }
    if(x<0){
        return -1;
    }else{
        return 1;
    }
}
struct Point{
    double x,y;
    Point(){}
    Point(double _x,double _y){
        x = _x;
        y = _y;
    }
    void input(){
        scanf("%lf%lf",&x,&y);
    }
    Point operator+(const Point &b)const{
        return Point(x+b.x,y+b.y);
    }
    Point operator -(const Point &b)const{
        return Point(x-b.x,y-b.y);
    }
    double operator *(const Point &b)const{
        return x*b.x+y*b.y;
    }
    Point operator *(const double &k)const{
        return Point(x*k,y*k);
    }
    double operator ^(const Point &b)const{
        return x*b.y-y*b.x;
    }
    Point operator /(const double &k)const{
        return Point(x/k,y/k);
    }
    bool operator <(const Point &b)const{
        return sgn(x-b.x)==0?sgn(y-b.y)<0:x<b.x;
    }
};
struct Line{
    Point s,e;
    Line(){}
    Line(Point _s,Point _e){
        s = _s;
        e = _e;
    }
    //两线段相交判断
    // 2 规范相交
    // 1 非规范相交
    // 0 不相交
    int segcrossseg(Line v){
        int d1 = sgn((e-s)^(v.s-s));
        int d2 = sgn((e-s)^(v.e-s));
        int d3 = sgn((v.e-v.s)^(s-v.s));
        int d4 = sgn((v.e-v.s)^(e-v.s));
        if((d1^d2) == -2 && (d3^d4)==-2){
            return 2;
        }
        return (d1==0&&sgn((v.s-s)*(v.s-e))<=0)||(d2==0&&sgn((v.e-s)*(v.e-e))<=0)||(d3==0&&sgn((s-v.s)*(s-v.e))<=0)||(d4==0&&sgn((e-v.s)*(e-v.e))<=0);
    }
};
int main(){
    int q;
    Point p0,p1,p2,p3;
    scanf("%d",&q);
    while(q--){
        p0.input();
        p1.input();
        p2.input();
        p3.input();
        Line line1(p0,p1);
        Line line2(p2,p3);
        int tmp = line1.segcrossseg(line2);
        if(tmp == 1 || tmp == 2){
            printf("1\n");
        }else{
            printf("0\n");
        }
    }
 
    return 0;
}



Measured memory_bytes: 3248
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class Main {
	static Scanner sc = new Scanner(System.in);
	
	public static void main (String [] args){
		ArrayList <Integer> list = new ArrayList<Integer>();
//		String [][] boad = new String[4][4];
		double a = Double.parseDouble(sc.next());
		double b = Double.parseDouble(sc.next());

//		int c = Integer.parseInt(sc.next());
//		int d = Integer.parseInt(sc.next());
		double count = 0;
		
		count = a/b;
		
		
		System.out.println(count);
		System.out.flush();
		sc.close();

	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
int main(){
  int l,r,d;
  cin>>l>>r>>d;
  int ans=0;
  for(int i=1;i<=100;i++){
    if(l<=d*i && d*i<=r){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3620
import math
def generate_primes(num):
    primes = list(range(2, num + 1))
    i, p = 0, 1
    while p <= math.sqrt(num):
        if primes[i] != 0:
            p = primes[i]
            primes = [prime if prime % p != 0 else 0 for prime in primes]
            primes[i] = p
        i += 1
    return [p for p in primes if p != 0]
x = int(input())
for i, p in enumerate(generate_primes(100003)):
    if p >= x:
        print(p)
        break

Measured memory_bytes: 118240
import numpy as np
import itertools

H, W, K = list(map(int, input().split())) 
c = [input().split() for l in range(H)]
b=[]
d=[]
for m in range(len(c)):
  for item in c[m]:
    item_mod = item.replace("."  , "0")
    item_mod = item_mod.replace("#" , "1")
    item_mod = list(item_mod)
    b.append(item_mod)
  d.append(b)
  b=[]

C_arr = np.array(d , dtype = "int")
C_arr = C_arr.reshape((H, W))

In = np.array(list(itertools.product([0,1] , repeat=H)))
Out = np.array(list(itertools.product([0,1] , repeat=W)))

ans = 0
for i in range(2**H):
  for j in range(2**W):
    In_matrix = np.diag(In[i])
    Out_matrix = np.diag(Out[j])

    In_C = np.dot(In_matrix , C_arr)
    In_C_Out = np.dot(In_C , Out_matrix)

    ICO = In_C_Out.flatten()
    ICO = ICO.tolist()

    if ICO.count(1) == K:
      ans += 1

print(ans)


Measured memory_bytes: 27028
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INT_INF 1000000000
#define DOUBLE_INF 1e18
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD
#define MAX_N 52

using namespace std;

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

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  return s;
}

int main()
{
  ll N, A;
  ll x[MAX_N];
  cin >> N >> A;
  for (int i = 0; i < N; i++) {
    cin >> x[i];
    x[i] -= A;
  }

  ll dp[MAX_N][2 * MAX_N * MAX_N];

  fill(dp[0], dp[0] + 2 * MAX_N * MAX_N, 0);
  dp[0][MAX_N * MAX_N] = 1;

  for (int i = 0; i < N; i++) {
    for (int s = -MAX_N * MAX_N; s < MAX_N * MAX_N; s++) {
      if (-MAX_N * MAX_N <= s + x[i] &&
          s + x[i] < MAX_N * MAX_N) {
        dp[i+1][s + MAX_N * MAX_N] += dp[i][s + MAX_N * MAX_N];
        dp[i+1][s + x[i] + MAX_N * MAX_N] += dp[i][s + MAX_N * MAX_N];
      }
    }
  }

  cout << dp[N][MAX_N * MAX_N] - 1 << endl;

  return 0;
}


Measured memory_bytes: 2432
n, q = gets.chomp.split.map(&:to_i)
s = gets.chomp.split("")
a = []
cnt_a = 0
(n-1).times do |i|
  if s[i] == "A" && s[i+1] == "C"
    cnt_a += 1
  end
  a[i] = cnt_a
end
q.times do
  l, r = gets.chomp.split.map(&:to_i)
  if l == 1
    puts a[r-2]
  else
    puts a[r-2] - a[l-2]
  end
end

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

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  if (s < t) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>m;

	cout<<max(n+m,max(n-m,n*m))<<endl;



}


Measured memory_bytes: 3668
s = list(input())
n = len(s) - 1

total = 0

for i in range(2**n):
    l = [""] * n
    for j in range(n):
        if (i >> j) & 1 :
            l[j] = "+"
    formula = ""
    for p, q in zip(s, l+[""]):
        formula += p + q
    total += eval(formula)

print(total)

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

int SUM(string s){
	int sum=0;
	for(int i=0;i<s.size();i++){
		sum+=int(s[i])-48;
	}
	return sum;
}

int main(){
	string s;
	int i,y[10000]={};
	for(i=0;;i++){
		cin>>s;
		if(s=="0") break;
		y[i]=SUM(s);
	}
	for(int j=0;j<i;j++) cout<<y[j]<<endl;
	return 0;
}



Measured memory_bytes: 3264
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

long long int counter(vector<int>& L1, vector<int>& L2, vector<int>& L3) {
    long long int ans = 0;
    auto L2size = L2.size();
    auto L3size = L3.size();
    for (int ir : L1) {
        auto _j = std::lower_bound(L2.begin(), L2.end(), ir) - L2.begin();
        for (int j = _j; j < L2size; j++) {
            auto ig = L2[j];
            auto _k = std::lower_bound(L3.begin(), L3.end(), ig) - L3.begin();
            auto ng = ig + (ig - ir);
            ans += (L3size - _k);
            if (std::find(L3.begin(), L3.end(), ng) != L3.end())
                ans -= 1;
        }
    }

    return ans;
}

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

    vector<int> iR, iG, iB;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'R') iR.push_back(i);
        if (S[i] == 'G') iG.push_back(i);
        if (S[i] == 'B') iB.push_back(i);
    }

    long long int c1 = counter(iR, iG, iB);
    long long int c2 = counter(iR, iB, iG);
    long long int c3 = counter(iG, iR, iB);
    long long int c4 = counter(iG, iB, iR);
    long long int c5 = counter(iB, iR, iG);
    long long int c6 = counter(iB, iG, iR);
    cout << (c1 + c2 + c3 + c4 + c5 + c6) << endl;
    return 0;
}

Measured memory_bytes: 3668
import java.util.Scanner;		
public class Main {		
		
   public static void main(String[] args){		
    int intput1;		
    Scanner in = new Scanner(System.in);		
		    intput1 = in.nextInt();
	 if (1 <= intput1 & intput1 <= 100){	
     System.out.println(intput1*intput1*intput1);     		
    }
 }
}


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

typedef pair<int, int> P;

P p[200000];
int ans[200000];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N;
	cin >> N;
	for(int i = 0; i < N; i++){
		int a;
		cin >> a;
		p[i] = { a, i };
	}
	sort(p, p + N);

	for(int i = 0; i < N; i++){
		int id = p[i].second;
		if(i < N / 2) ans[id] = p[N / 2].first;
		else ans[id] = p[N / 2 - 1].first;
	}

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


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

int main() {
  
  int n, m, c;
  cin >> n >> m >> c;
  
  vector<int> b(m);
  REP(i,m) cin >> b[i];
  
  int a, sum, ans = 0;
  REP(i,n) {
    sum = 0;
    REP(j,m) {
      cin >> a;
      sum += a * b[j];
    }
    sum += c;
    if (sum > 0) ans++;
  }
  
  cout << ans << endl;
  
}     

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define MN 25000
#define MM 400
#define mod 1000000007
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
bool vis[MM+5];
int f[MN+5][MM+5],g[MN+5][MM+5],a[MN+5],n,K,m,ans,p[MN+5],inv[MN+5];
inline int pw(int x,int k)
{
    int res=1;
    for(;k;k>>=1,x=1LL*x*x%mod) if(k&1) res=1LL*res*x%mod;
    return res;
}
inline int P(int n,int m){return n<m?0:1LL*p[n]*inv[n-m]%mod;}
int main()
{
    n=read();K=read();m=read();p[0]=p[1]=inv[0]=inv[1]=1;
    for(int i=2;i<=MN;++i) p[i]=1LL*p[i-1]*i%mod,inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
    for(int i=2;i<=MN;++i) inv[i]=1LL*inv[i-1]*inv[i]%mod;
    for(int i=1;i<=m;++i) a[i]=read();
    for(int i=K;i<=m;++i)
    {
        memset(vis,0,sizeof(vis));int kind=0;
        for(int j=i-K+1;j<=i;++j) kind+=!vis[a[j]],vis[a[j]]=1;
        if(kind==K) return 0*printf("%d\n",1LL*(n-m+1)*pw(K,n-m)%mod);
    }
    int l1=-1,l2;
    memset(vis,0,sizeof(vis));
    for(int i=1;i<=m;++i)
        if(vis[a[i]]) {l1=i-1;break;}
        else vis[a[i]]=1;
    memset(vis,0,sizeof(vis));
    for(int i=m;i;--i)
        if(vis[a[i]]) {l2=m-i;break;}
        else vis[a[i]]=1;
    for(int i=1;i<K;++i) f[0][i]=1,g[0][i]=i;
    for(int i=1;i<=n;++i) for(int j=1;j<K;++j)
    {
        f[i][j]=1LL*f[i-1][j+1]*(K-j)%mod;
        f[i][j]=(f[i][j]+g[i-1][j])%mod;
        g[i][j]=(g[i][j-1]+f[i][j])%mod;
    }
    if(l1!=-1) for(int i=1;i+m-1<=n;++i) ans=(ans+1LL*f[i-1][l1]*f[n-(i+m-1)][l2])%mod;
    else
    {
        for(int i=1;i+m-1<=n;++i) 
        {
            for(int j=i-1;j&&i-j+m<=K;--j)
            {
                int len=i-j+m-1;
                ans=(ans+1LL*P(K-m,i-j-1)*g[j-1][len]%mod*f[n-(i+m-1)][len])%mod;
            }
            if(i-1+m<K) ans=(ans+1LL*P(K-m,i-1)*f[n-(i+m-1)][i+m-1])%mod;
        }
    }
    ans=(1LL*(n-m+1)*pw(K,n-m)%mod-ans+mod)%mod;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 79616
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<utility>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
 
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+9
#define EPS 1e-9
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < (k); i++)
typedef long long ll;
int main(){
    int n;
    while(scanf("%d",&n),n){
	map<int,int>data;
	rep(i,n){
	    int c1,m1,s1,m2,s2,m3,s3,m4,s4;
	    int sum = 0;
	    scanf("%d%d%d%d%d%d%d%d%d",&c1,&m1,&s1,&m2,&s2,&m3,&s3,&m4,&s4);
	    sum = (m1+m2+m3+m4)*60+(s1+s2+s3+s4);
	    data[sum] = c1;
	}
	int cnt = 0;
	map<int,int>::iterator it = data.begin();
	while(cnt < 2){
	    cout << (*it).second << endl;
	    it++;
	    cnt++;
	}
	it = data.end();
	it--;
	it--;
	cout << (*it).second << endl;
    }
    return 0;
}

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

int main(){
  
 int n;
  cin>>n;
 int sum=0;
  int max=0;
 //int arr[n]; 
  int a;
  for(int i=0;i<n;i++){
    
   cin>>a; 
   if(a>=max) max=a;
   sum+=a;
    
  }
  int b=sum-max;
  if(max<b) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}


Measured memory_bytes: 256
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<set>

using namespace std;

int n, k;
vector<int> av;
vector<int> grundy;
int main()
{
    cin >> n >> k;
    grundy.resize(k + 1, -1);
    grundy[0] = 0;
    
    REP(i, n) {
        int ai;
        cin >> ai;
        av.push_back(ai);
    }
    for(int i = 1; i <= k; ++i) {
        set<int> tmp;
        for (int j = 0; j < n; ++j) {
            if (av[j] > i) break;
            tmp.insert(grundy[i - av[j]]);
        }
        int mex = 0;
        while (tmp.find(mex) != tmp.end()) {
            mex++;
        }
        grundy[i] = mex;
    }
    cout << (grundy[k] != 0 ? "First" : "Second") << endl;
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

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

    int n;
    cin >> n;
    pair<int, int> p[n];
    int x, l;
    for (int i = 0; i < n; i++) {
        cin >> x >> l;
        p[i] = {x - l, x + l};
    }
    sort(p, p + n);
    int ans = 0, mx = 0;
    for (int i = 0; i < n; i++) {
        if (mx == 0) mx = p[i].second;
        else if (mx > p[i].first) mx = min(mx, p[i].second);
        else ans++, mx = p[i].second;
    }
    cout << ans + 1 << "\n";
    return 0;
}

Measured memory_bytes: 1024
fun main(args:Array<String>){
    val line = readLine()!!.split(" ").map{it.toInt()}
    val a = line[0]
    val b = line[1]
    val result = when(a){
        in 0..5 ->0
        in 6..12 -> b/2
        else -> b
    }
    println(result)
}

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

int main()
{
    vector<int> X(10000);
    for (int i = 0; i < X.size(); i++) {
        
        cin >> X.at(i);
        cout << "Case " << i + 1 << ":" << " " << X.at(i) << endl;
    }
}


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
  int t;
  cin>>t;
  for(int i=0;i<t;i++){
    int n,d;
    cin>>n>>d;
    if(n%2) cout<<127*(n-1)+d<<endl;
    else cout<<127*n-d<<endl;
  }
  return 0;
}

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

int main() {
        ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int n, d; cin >> n >> d;
        int cnt = 0, lst = -100;
        for(int i = d + 1; i <= n; i += 2 * d + 1) ++cnt, lst = i;

        cout << cnt + (n - lst > d) << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  while(n!=0||x!=0){
    int i,j,k;
    int o=0;
    for(i=1;i<=n;i++){
      for(j=i+1;j<=n;j++){
    for(k=j+1;k<=n;k++){
      if(i+j+k==x) o++;
    }
      }
    }
 
    cout << o << endl;
 
    cin >> n >> x;
  }
 
 
  return 0;
}


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

int main() {

  int N;
  cin >> N;
  int sum =0;
  

  for (int i = 0; i < N; i++) {
    int L, R;
    cin >> L >> R;
    sum += R-L+1;
  }
  
    cout << sum << endl;
}


Measured memory_bytes: 384
import sys
#input = sys.stdin.buffer.readline
from collections import defaultdict
from operator import itemgetter

def main():
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        s = input()
        d[s] -= 1

    cnt = list(d.items())
    cnt.sort(key=itemgetter(1,0))
    
    mc = cnt[0][1]
    for x,y in cnt:
        if y == mc:
            print(x)
        else:
            break
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 59612
a, b, x = gets.split.map(&:to_i)
if a >= 2 * b
    puts (x / 500.0).ceil * b
else
    ka = (x / 1000.0).floor
    y = x - 1000 * ka
    if y == 0
        puts ka * a
    else
        puts ka * a + [a, (y / 500.0).ceil * b].min
    end
end


Measured memory_bytes: 6872
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(const T arr[], int n){std::cout << "["; for(int i = 0; i < n; ++i){ std::cout << arr[i] << ", "; } std::cout << "]" << std::endl;}
template<typename T> void view(T e){std::cout << e << std::endl;}
using namespace std;
typedef long long ll;

const int MAX_N = 1e5 + 5;

int n, k;
int sd[MAX_N];
int pnt[3];

ll memo[MAX_N][4];

//0:r, 1:s, 2:p
ll calc(int i, int p=-1) {
    if(memo[i][p+1] >= 0) return memo[i][p+1];

    ll res = 0;
    if(i+k >= n) {
        if(sd[i] == p) res = 0;
        else res = pnt[sd[i]];
    } else {
        rep(j, 3) {
            if(j != p) {
                if(sd[i] == j) {
                    res = max(res, calc(i+k, j) + pnt[j]);
                } else {
                    res = max(res, calc(i+k, j));
                }
            }
        }
    }

    return memo[i][p+1] = res;
}

int main() {
    cin >> n >> k;
    int r, s, p;
    cin >> r >> s >> p;
    pnt[0] = r;
    pnt[1] = s;
    pnt[2] = p;
    string t;
    cin >> t;
    rep(i, n) {
        if(t[i] == 'r') sd[i] = 2;
        else if(t[i] == 's') sd[i] = 0;
        else sd[i] = 1;
    }
    rep(i,n) rep(j,4) memo[i][j] = -1;
    ll ans = 0;
    for(int i = 0; i < k; ++i) {
        ans += calc(i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10112
n = int(input())
ans = [[-1] * (n - i - 1) for i in range(n - 1)]
s = [(0, n, 1)]
while s:
    p, q, t = s.pop()
    if p + 1 == q:
        continue
    m = (q - p) // 2 + p
    for i in range(p, m):
        for j in range(m, q):
            ans[i][j - i - 1] = t
    s.append((p, m, t + 1))
    s.append((m, q, t + 1))
for row in ans:
    print(' '.join(map(str, row)))


Measured memory_bytes: 4212
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

LL a, b, x;

int main(){
	cin >> a >> b >> x;
	int ans = HINF<int>();
	REP(i, 50)REP(j, 50){
		int num = 1000 * i + 500 * j;
		int num2 = a * i + b * j;
		if(num >= x)ans = min(ans, num2);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

map<int,int> prime(ll n){
    map<int,int> mp;
    for(ll i=2;i*i<=n;i++){
        while(n%i==0){
            mp[i]++;
            n/=i;
        }
    }
    if(n!=1)mp[n]++;
    return mp;
}

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

int main(){
    int n;
    cin>>n;
    ll a[n];
    map<int,int> m;
    for(int i=0;i<n;i++){
        cin>>a[i];
        auto mp=prime(a[i]);
        for(auto e:mp){
            m[e.first]=max(e.second,m[e.first]);
        }
    }
    ll lcm=1;
    for(auto e:m){
        lcm=(lcm*modpow(e.first,e.second))%MOD;
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ans=(ans+lcm*modpow(a[i],MOD-2))%MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 768
/*
Hello don't you know me
I'm the dirt beneath your feet
The most important fool you forgot to see
I've seen how you give it
Now I want to receive
I know that you
Would do the same for me

I know I'm headed for the bottom
But I'm riding you all the way

For all of your kisses turned
To spit in my face
For all that reminds me
Which is my place
For all the times when
You made me disappear
This time I'm sure you will
Know that I'm here

I know I'm headed for the bottom
But I'm riding you all the way

My place was beneath you
But now I'm above
And now I send you a message
Of love
A simple reminder of what
You won't see
A future so holy without me

I know I'm headed for the bottom
But I'm riding you all the way
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-11
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 100031;

int n,m,k,ans;

int ttl[N];
int T[N];
int cnt[500][500];

pair<int,int> w[500][500];

pair<int,int>get(int a,int b){
	if (w[a][b]==make_pair(a,b))
		return make_pair(a,b);
	return w[a][b]=get(w[a][b].first,w[a][b].second);
}

void merge(int x1,int y1,int x2,int y2){
	pair<int,int> p1=get(x1,y1);
	pair<int,int> p2=get(x2,y2);
	if (p1==p2)
		return;
	w[p1.first][p1.second]=p2;
}

int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin>>n>>m;
	for (int i=0;i<n;i++){
		string st;
		cin>>st;
		for (int j=0;j<m;j++){
			ttl[st[j]]++;
		}
	}

	for (int i=0;i<n;i++)
	{
		for (int j=0;j<m;j++){
			w[i][j]=make_pair(i,j);
		}
	}

	for (int i=0;i<n;i++)
	{
		for (int j=0;j<m;j++)
		{
			merge(i,j,i,m-j-1);
			merge(i,j,n-i-1,j);
		}
	}

	for (int i=0;i<n;i++)
	{
		for (int j=0;j<m;j++)
		{
			pair<int,int> p=get(i,j);
			cnt[p.first][p.second]++;
		}
	}

	for (int i=0;i<n;i++)
	{
		for (int j=0;j<m;j++)
		{
			T[cnt[i][j]]++;
		}
	}

	for (int i='a';i<='z';i++)
	{
		for (int j=4;j>=1;--j)
		{
			while (ttl[i]>=j&&T[j]>0){
				T[j]--;
				ttl[i]-=j;
			}
		}
		if (ttl[i]>0){
			cout<<"No"<<endl;
			return 0;
		}
	}

	cout<<"Yes"<<endl;

	cin.get(); cin.get();
	return 0;
}


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

bool isprime(long long n)
{
  for(int i=2;i<=n/i;i++)
    if(n%i==0) return 0;
  return 1;
}

int main()
{
	int n, ans = 1;
  	long long m;
	scanf("%d %lld", &n, &m);
  	if(m>100000 && isprime(m)) return 0*printf("1\n");
	for(long long i=n;i<m;i++)
		if(m%i==0){
          ans = m/i;
          break;
        }
  	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int main() {
    
    string s, t;
    cin >> s >> t;
    int c = 0;
    rep(i, 3) if (s[i] == t[i]) c++;
    cout << c << endl;
    
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s; cin>>s;
    int N=s.size();

    REP(S,1<<(N-1)){
        int sum=s[0]-'0';
        REP(i,N-1){ 
            if(S>>i&1) sum+=s[i+1]-'0'; 
            else sum-=s[i+1]-'0';
        }
        if(sum==7){
            string t; t+=s[0];
            REP(i,N-1){ 
                if(S>>i&1) t=t+'+'+s[i+1]; 
                else t=t+'-'+s[i+1];
            }
            t+="=7"; 
            cout<<t<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
using namespace std;
#define ll long long
int main(){
	ll A,B,r,t;
	cin >> A >> B;
	r=1;
	while(r!=0){
		r=B%A;
		B=A;
		A=r;
	}
	ll i=2;
	ll cnt=1;
	while(i*i<=B){
		if(B%i==0)cnt++;
		while(B%i==0){
			B=B/i;
		}
		i++;
	}
	if(B!=1)cnt++;
	cout << cnt;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
typedef long long ll;
template <class T>
inline void _read(T &x)
{
    x = 0;
    char t = getchar();
    while (!isdigit(t) && t != '-') t = getchar();
    if (t == '-')
    {
        _read(x);
        x *= -1;
        return ;
    }
    while (isdigit(t))
    {
        x = x * 10 + t - '0';
        t = getchar();
    }
}
struct edge
{
	int v, nxt, w;
} e[MAXN << 1];
int h[MAXN], cnt = 1;
inline void ae(int u, int v, int w)
{
	e[cnt] = (edge)
	{
		v, h[u], w
	};
	h[u] = cnt++;
}
struct Edge
{
	int u, v;
	ll w;
} E[MAXN * 50];
bool operator<(Edge a, Edge b)
{
	return a.w < b.w;
}
int Size, mx, rt, size[MAXN];
bool vis[MAXN];
int n, m, W[MAXN];
void Getroot(int u, int ff)
{
	int ret = 0;
	size[u] = 1;
	for(int i = h[u]; i; i = e[i].nxt)
	{
		int v = e[i].v;
		if(vis[v] || v == ff)continue;
		Getroot(v, u);
		size[u] += size[v];
		ret = max(ret, size[v]);
	}
	ret = max(ret, Size - size[u]);
	if(ret < mx)mx = ret, rt = u;
}
int P;
ll Val;
void dfs(int u, int ff, ll dep)
{
	if(dep + W[u] < Val)Val = dep + W[u], P = u;
	for(int i = h[u]; i; i = e[i].nxt)
		if(!vis[e[i].v] && e[i].v != ff)
			dfs(e[i].v, u, dep + e[i].w);
}
void Link(int u, int ff, ll dep)
{
	E[++m] = (Edge)
	{
		u, P, Val + dep + W[u]
	};
	for(int i = h[u]; i; i = e[i].nxt)
		if(!vis[e[i].v] && e[i].v != ff)
			Link(e[i].v, u, dep + e[i].w);
}
void Divide(int u)
{
	vis[u] = true;
	Val = 1e18;
	P = 0;
	dfs(u, 0, 0);
	Link(u, 0, 0);
	for(int i = h[u]; i; i = e[i].nxt)
	{
		int v = e[i].v;
		if(vis[v])continue;
		Size = mx = size[v];
		Getroot(v, u);
		Divide(rt);
	}
}
int f[MAXN];
ll ans;
int getf(int x)
{
	return x == f[x] ? x : f[x] = getf(f[x]);
}
int main()
{
	_read(n);
	for(int i = 1; i <= n; ++i) _read(W[i]);
	for(int i = 1, u, v, w; i < n; ++i)
	{
		_read(u), _read(v), _read(w);
		ae(u, v, w);
		ae(v, u, w);
	}
	Size = mx = n;
	Getroot(1, 0);
	Divide(rt);
	sort(&E[1], &E[m + 1]);
	for(int i = 1; i <= n; ++i)f[i] = i;
	for(int i = 1; i <= m; ++i)
	{
		int u = getf(E[i].u), v = getf(E[i].v);
		if(u == v)continue;
		ans += E[i].w;
		f[u] = v;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 74624
#include <stdio.h>

int main(void)
{
	int N,H,W;
	int i,cnt=0;
	int A[1000],B[1000];
	scanf("%d %d %d",&N,&H,&W);
	for(i=0;i<N;i++){
		scanf("%d %d",&A[i],&B[i]);
		if(A[i]>=H && B[i]>=W){
			cnt+=1;
		}
	}
	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 128
import sys

x, y = map(int, input().split())

inf = 10**9+7

if (x+y)%3 != 0:
    print(0)
    sys.exit()
    
a = (2*x-y)//3
b = (2*y-x)//3

if a<0 or b<0:
    print(0)
    sys.exit()

def nCr(n, r):
    r = min(r, n - r)
    if r == 0: return 1;
    if r == 1: return int(n%inf);
    numerator = [n - r + i + 1 for i in range(r)]
    denominator  = [i + 1 for i 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 = (result*numerator[k])%inf
    return int(result)

print(nCr(a+b, a))

Measured memory_bytes: 44148
#include<cstdio>
#include<cmath>

using namespace std;

const double pi = acos(-1);
double a, b, x;

int main(){
	scanf("%lf%lf%lf", &a, &b, &x);
	double h = x / a / a;
	if(2 * h >= b)
		printf("%.10f\n", atan((2*b-2*h)/a)*180/pi);
	else
		printf("%.10f\n", atan(b*b*a/2/x)*180/pi);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define modulo 1000000007
typedef long long int ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;


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

	return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
  i64 A, P;
  cin >> A >> P;
  i64 n = 3 * A + P;
  cout << n / 2 << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt(), b = scanner.nextInt();
			int c = scanner.nextInt(), d = scanner.nextInt();
			int e = scanner.nextInt(), f = scanner.nextInt();
			// 水の組合せ
			Set<Integer> waters = new HashSet<>();
			IntStream.range(0, f / a / 100 + 1)
					.forEach(i -> IntStream.range(0, (f - 100 * a * i) / b / 100 + 1).forEach(j -> {
						int water = 100 * a * i + 100 * b * j;
						if ((water <= f) && (water > 0)) {
							waters.add(water);
						}
					}));
			// 砂糖の組合せ
			Set<Integer> sugars = new HashSet<>();
			IntStream.range(0, (f - a) / c).forEach(i -> IntStream.range(0, (f - a - i) / d).forEach(j -> {
				int sugar = c * i + d * j;
				if ((sugar <= (f - a))) {
					sugars.add(sugar);
				}
			}));
			double maxRatio = -0.1d;
			int maxWater = 0, maxSugar = 0;
			for (int water : waters) {
				for (int sugar : sugars) {
					if ((water + sugar) <= f) {
						double radio = calcRadio(water, sugar, e);
						if (radio > maxRatio) {
							maxRatio = radio;
							maxWater = water;
							maxSugar = sugar;
						}
					}
				}
			}
			System.out.println((maxWater + maxSugar) + " " + maxSugar);
		}
	}

	/**
	 * @param water    水の量
	 * @param sugar    砂糖の量
	 * @param maxRadio 最大濃度
	 * @return 現在の濃度（最大濃度を超えた場合は0）
	 */
	private static double calcRadio(int water, int sugar, int maxRadio) {
		int maxSugar = water / 100 * maxRadio;
		if (sugar > maxSugar) {
			return 0.0d;
		} else {
			return 100.0 * sugar / water;
		}
	}
}


Measured memory_bytes: 43448
import java.util.Scanner;

class Main{

	static long ans = 0;
	static int N;
	static long M;

	public static void main(String[] args) {



		Scanner sc = new Scanner(System.in);			//文字の入力

		int n = sc.nextInt();
		int[] v = new int[n];
		int[] odd= new int[n/2];
		int[] even= new int[n/2];


		int j = 0;
		for(int i=0;i < n;i++){
			if(i%2==1){
				odd[j] = sc.nextInt();
				j++;
			}else{
				even[j] = sc.nextInt();;
			}
		}


		boolean flag = false;				//全部一緒か見る

//
//		for(int i=0;i < n/2-1;i++){
//			if(odd[i] != even[i] || odd[i] != odd[i+1] || even[i] != even[i+1]){
//				flag = true;
//			}
//		}
//		if(!flag){
//			System.out.println(odd.length);
//			return;
//		}
		j=0;


		//
		//		for(int i= 0;i < n/2;i++){
		//			System.out.println(odd[i]);
		//		}

		int[] odddata = new int[100001];
		for(int i = 0;i < n/2;i++){			//各数をカウント
			odddata[odd[i]]++;
		}
		int maxodd = 0;
		int firstodd = 0;
		int secondodd = 0;

		for(int i = 1;i < 100001;i++){			//最頻数の数値をえる
			if(maxodd<=odddata[i]){
				firstodd = i;
				maxodd = odddata[i];
			}
		}
		maxodd = 0;
		for(int i = 1;i < 100001;i++){
			if(maxodd<=odddata[i] && i != firstodd){
				secondodd = i;
				maxodd = odddata[i];
			}
		}



		int[] evendata = new int[100001];
		for(int i = 0;i < n/2;i++){
			evendata[even[i]]++;
		}
		int maxeven= 0;
		int firsteven = 0;
		int secondeven = 0;

		for(int i = 1;i < 100001;i++){
			if(maxeven<=evendata[i]){
				firsteven = i;
				maxeven = evendata[i];
			}
		}
		maxeven = 0;
		for(int i = 1;i < 100001;i++){
			if(maxeven<=evendata[i] && i != firsteven){
				secondeven = i;
				maxeven = evendata[i];
			}
		}
		
		
		//	System.out.println("firsteven "+firsteven);

		if(firsteven !=firstodd){
			int ans =0 ;
			j = 0;
			for(int i= 0;i < n;i++){
				if(i%2==1){
					if(odd[j] != firstodd){
						ans++;
					}
					j++;
				}else{
					if(even[j] != firsteven){
						ans++;
					}

				}
			}
			System.out.println(ans);
			return;
		}

		
		

		j = 0;
		int count = 0;
		for(int i= 0;i < n;i++){
			if(i%2==1){
				if(odd[j] != firstodd){
					count++;
				}
				j++;
			}else{
				if(even[j] != secondeven){
					count++;
				}

			}
		}

		j = 0;
		int subcount = 0;
		for(int i= 0;i < n;i++){
			if(i%2==1){
				if(odd[j] != secondodd){
					subcount++;
				}
				j++;
			}else{
				if(even[j] != firsteven){
					subcount++;
				}

			}
		}

		System.out.println(Math.min(count, subcount));








	}


}





Measured memory_bytes: 60376
/*
ID:dyx_6661
TASK:
LANG:
*/
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
#include<deque>
#include<set>
#include<map>
#include<vector>
#include<iostream>
using namespace std;
typedef long long int ll;
typedef double db;
typedef string str;
typedef pair<int,int> pa;
typedef vector<int> vec;

const int n_size=2e5+5;
int n,q,cnt,nex[2*n_size],head[n_size],to[2*n_size],ans[n_size];

void add(int a,int b){
	to[++cnt]=b;
	nex[cnt]=head[a];
	head[a]=cnt;
}

void dfs(int u,int fa,int ret){
	for(int i=head[u],v;i;i=nex[i]){
		v=to[i];
		if(v!=fa){
			ans[v]+=ret;
			dfs(v,u,ans[v]);
		}
	}
}

int main(){
//  freopen(".in","r",stdin);
//  freopen(".out","w",stdout);
	scanf("%d%d",&n,&q);
	for(int i=1,a,b;i<n;i++){
		scanf("%d%d",&a,&b);
		add(a,b);add(b,a);
	}
	for(int i=1,a,b;i<=q;i++){
		scanf("%d%d",&a,&b);
		ans[a]+=b;
	}
	dfs(1,0,ans[1]);
	for(int i=1;i<=n;i++) printf("%d ",ans[i]);
	return 0;
}


Measured memory_bytes: 16512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<string, string> sP;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second



int main() {
	string s, ans;
	cin >> s;
	for (int i = 0;i < s.size();i++) {
		if (s[i] == '0') {
			ans.pb('0');
		}
		else if (s[i] == '1') {
			ans.pb('1');
		}
		else {
			if (!ans.empty())
				ans.pop_back();
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N, D, X;
int A[200];

int main() {
  cin >> N >> D >> X;
  int ans = X;
  rep(i, 0, N) {
    int a;
    cin >> a;
    ans += (D - 1) / a + 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>

using namespace std;



int main() {

//  int N = 2;
//  long long nums[] = {3, 1, 4, 1, 5, 9};
//  int N = 1;
//  long long nums[] = {1, 2, 3};
//  int N = 3;
//  long long nums[] = {8, 2, 2, 7, 4, 6, 5, 3, 8};

  int N;
  cin >> N;
  long long nums[N*3];
  for (int i = 0; i < N*3; ++i) {
    cin >> nums[i];
  }


  auto cmp_descending = [](long long a, long long b) { return a > b; };
  auto cmp_ascending = [](long long a, long long b) { return a < b; };
  vector<long long> front_sums, back_sums;

  //
  long long front_sum = 0;
  priority_queue<long long, vector<long long>, function<bool(long long, long long)>> front_queue(cmp_descending);
  for (int i = 0; i < N; ++i) {
    front_queue.push(nums[i]);
    front_sum += nums[i];
  }
  front_sums.push_back(front_sum);

  //
  long long back_sum = 0;
  priority_queue<long long, vector<long long>, function<bool(long long, long long)>> back_queue(cmp_ascending);
  for (int i = 2 * N; i < 3 * N; ++i) {
    back_queue.push(nums[i]);
    back_sum += nums[i];
  }
  back_sums.push_back(back_sum);

  //
  for (int i = N; i < 2 * N; ++i) {
    front_queue.push(nums[i]);
    int remove = front_queue.top();
    front_queue.pop();
    front_sum += (nums[i] - remove);
    front_sums.push_back(front_sum);
  }


  //
  for (int i = 2 * N - 1; i >= N; i--) {
    back_queue.push(nums[i]);
    int remove = back_queue.top();
    back_queue.pop();
    back_sum += (nums[i] - remove);
    back_sums.push_back(back_sum);
//    cout << "remove " << remove << endl;
  }
  reverse(back_sums.begin(), back_sums.end());


  long long max_sum = -50000000000000000;
  for (int i = 0; i < front_sums.size(); ++i) {
//    cout << front_sums[i] << " " << back_sums[i] << front_sums[i] - back_sums[i] << endl;
    max_sum = max(max_sum, front_sums[i] - back_sums[i]);
//    cout << "front_sums " << front_sums[i] << endl;
//    cout << "back_sums " << back_sums[i] << endl;
//    cout << " " << (front_sums[i] - back_sums[i]) << endl;
  }

  cout << max_sum << endl;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N, M; cin >> N >> M;
  VL xs(N);
  REP(i,N) cin >> xs[i];

  int lcm = N * M / __gcd(N, M);
  LL ans = 0;
  set<int> q;
  for(int i=0;i<lcm;++i){
	q.insert(xs[i%N]);
	if((i+1)%M == 0){
	  ans += *--end(q) - *begin(q);
	  q.clear();
	}
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3200