akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cassert>
#include<functional>
#include<algorithm>
#include<climits>
#include<map>

using namespace std;



int main(){

    int A,B,C;

    int K;

    cin >> A >> B >> C;

    int a[3];

    a[0] = A;
    a[1] = B;
    a[2] = C;

    int big = INT_MIN;

    for(int i = 0;i < 3;i++){
    	if(a[i] > big){
    		big = a[i];
    	}
    }

    cin >> K;

    int other = A + B + C - big;

    for(int i = 0;i < K;i++){
    	big = big*2;
    }

     cout << other + big << endl;

    return 0;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
    int a,b,c,sum=0,n;
    cin >> a >> b >>c;
    for(int i=0; ; i++){
        sum=i*a+i/7*b;
        if(c<=sum){
            cout << i << endl;
            break;
        }
    }
}


Measured memory_bytes: 3120
def examA():
    A, B = LI()
    ans = "Yay!"
    if A>8 or B>8:
        ans = ":("
    print(ans)




import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;


int main(){
    int n,d,a;
    vector<pll> vec;
    cin >> n >> d >> a;
    int x,h;
    rep(i,n){
        cin >> x >> h;
        vec.push_back(make_pair(x,h));
    }
    queue<pll> qu;

    sort(vec.begin(),vec.end());
    
    ll ans = 0;
    ll pos = 0;
    ll dmg = 0;

    rep(i,n){
        if(qu.size() > 0){
            while(qu.front().first < vec[i].first && qu.size() > 0){
                dmg -= qu.front().second;
                qu.pop();
            }
        }

        if(dmg < vec[i].second){
            pos = vec[i].first;
            int tmp2 = (vec[i].second-dmg);
            tmp2 = (tmp2 + a - 1)/a;
            ans += tmp2;
            dmg += tmp2*a;
            qu.push(make_pair(pos+2*d,tmp2*a) );
            pos = pos + 2*d;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int s, w;
  cin >> s >> w;
  cout << (s <= w ? "unsafe" : "safe") << endl;
  return 0;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	int n;
	cin >> n;
	vector<int> d(n+1,0);
	for(int i = 1; i <= n; i++){
		for(int j = i; j <= n; j+=i){
			d[j]+=1;
		}
	}
	long long int ans = 0;
	for(int i = 1; i <= n; i++)
		ans+= 1ll * i * d[i];
	cout << ans << "\n";	
	return 0;
}


Measured memory_bytes: 42204
#ifndef _TEMPLATE_ROOT
#define _TEMPLATE_ROOT
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define repl(i, a, b) for(ll i = a; i < (b); ++i)
#define repd(i, a, b) for(int i = a; i >= (b); --i)
#define repdl(i, a, b) for(ll i = a; i >= (b); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
#endif
#ifndef _TEMPLATE_IO
#define _TEMPLATE_IO

template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void writef(T ...tail) { write(tail...); cout << flush; }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  if (v.size()) {
    rep(i, 0, sz(v) - 1)
      out << v[i] << " ";
    out << v.back();
  }
  return out;
}
#endif
using namespace std;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  int n; string s; read(n, s);
  map<char, int> f;
  for (char c : s) f[c]++;
  ll ans = 1;
  constexpr ll mod = 1'000'000'007ll;
  for (auto p : f)
    ans = ans * (p.second + 1) % mod;
  ans = (ans + mod - 1) % mod;
  write(ans);
}



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

typedef long long LL;
int main(){
   // freopen("input", "r", stdin);
    LL a,b,c;
    cin>>a>>b>>c;
    c=c%b;
    LL i=1;
    while((i++)*a<100000)
    {
      if((i*a)%b==c){cout<<"YES"<<endl;return 0;}
    }
    cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

bool solver(const string& s){
    if(s[0]!='A'){ return false; }

    uint numOfLC=0;
    for(uint i=2; i<s.size()-1; ++i){
        if(s[i]=='C'){ ++numOfLC; }
    }
    if(numOfLC!=1){ return false; }
    
    uint numOfL=0;
    for(uint i=0; i<s.size(); ++i){
        if('A'<=s[i] && s[i]<='Z'){ ++numOfL; }
    }
    if(numOfL!=2){ return false; }
    
    return true;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s; cin >> s;
    cout << (solver(s) ? "AC":"WA") << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n + 1), b(n + 1), c(n);
  rep1 (i, n) cin >> a[i];
  rep1 (i, n) cin >> b[i];
  rep1 (i, n - 1) cin >> c[i];
  int sum = 0;
  rep1 (i, n) {
    sum += b[a[i]];
    if (a[i] == a[i - 1] + 1) sum += c[a[i - 1]];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/extc++.h>
#ifdef _debug 
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#include<bits/stdc++.h>
#define dout(i) 0&&0
#endif
#pragma GCC optimize("unroll-loops,no-stack-protector,O3")
#define eout(i) {cout << (i) << '\n';exit(0);}
#define rout(i) {return cout << (i) << '\n', 0;}
#define priority_queue __gnu_pbds::priority_queue
#define unordered_map __gnu_pbds::gp_hash_table
#define rep(a, b) {for(int _i = a;_i > 0;--_i){b;}}
#define multe int _T;for(cin >> _T;_T--;)
using namespace std;
using ll = long long;using ull = unsigned long long;using ul = unsigned;using db = double;
using __gnu_pbds::null_type;
template<typename T> void read(int n, T s){while(n--)cin >> *s, ++s;}
template<typename T> void write(int n, T s){while(n--)cout << *s << " \n"[n==0], ++s;}
template<typename T> using rbtree = __gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T> inline ostream& operator << (ostream &ou, const vector<T> &a){for(auto it = a.begin();it != a.end();++it)ou << (it != a.begin() ? " " : "") << *it;return ou;}
template<typename T1, typename T2>inline istream& operator >> (istream &in, pair<T1, T2> &a){return in >> a.first >> a.second;}
template<typename T1, typename T2>inline ostream& operator << (ostream &ou, const pair<T1, T2> &b){return ou << b.first << ' ' << b.second;}
template<typename T> inline long long pow(long long v, long long t, const T &p){long long res = 1;for(;t;t >>= 1, v = v * v % p)if(t & 1)res = res * v % p;return res;}
const int maxn = 300010;
#define int ll
int a, b, c, x, y;
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> a >> b >> c >> x >> y;
	int res = a*x + b*y;
	dout(res)<<'\n';
	for(int i = 2;i/2 <= 1e5;i += 2){
		res = min(res, c*i + max(0ll, x-i/2) * a + max(0ll, y-i/2) * b);;
	}
	cout << res << '\n';
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {

		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		StringTokenizer stk;
		int[] k1=new int[3];
		int i=0;
		try {
			while(true) {

				str = bfr.readLine();

				if(str==null) {
					System.exit(0);
				}

				stk=new StringTokenizer(str," ");

				while(stk.hasMoreTokens()) {
					k1[i]=Integer.parseInt(stk.nextToken());
					i++;
				}
				i=0;

				int kariiregaku=k1[2]-k1[0];
				if(kariiregaku<0) {
					kariiregaku=0;
				}

				if(k1[1]>=kariiregaku) {
					System.out.println(kariiregaku);
				}
				else {
					System.out.println("NA");
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}



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

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

    int a[3][n];
    for(int i = 0; i < n; i++){
        cin >> a[0][i] >> a[1][i] >> a[2][i];
    }

    ll ans[3][n];
    ll min = 0;
    for(int i= 0; i < 3; i++){
        for(int j = 0; j < n; j++){
            ans[i][j] = min;
        }
    }

    ans[0][0] = a[0][0];
    ans[1][0] = a[1][0];
    ans[2][0] = a[2][0];

    for(int i = 1; i < n; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(j != k){
                    if(ans[k][i - 1] + a[j][i] > ans[j][i]){
                        ans[j][i] = ans[k][i - 1] + a[j][i];
                    }
                }
            }
        }
    }

    int re_ans = 0;
    for(int i = 0; i < 3; i++){
        if(re_ans < ans[i][n - 1]){
            re_ans = ans[i][n - 1];
        }
    }

    cout << re_ans << endl;
}

Measured memory_bytes: 3712
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		ArrayList<String> list = new ArrayList<String>();
		while((str=br.readLine())!=null){
			list.add(check(Double.parseDouble(str)));
		}
		for(String d : list){
			System.out.println(d);
		}
		
	}
	public static String check(double weight){
		if(weight > 91.0){
            return "heavy";
        }
        else if(weight > 81.0){
            return "light heavy";
        }
        else if(weight > 75.0){
            return "middle";
        }
        else if(weight > 69.0){
            return "light middle";
        }
        else if(weight > 64.0){
            return "welter";
        }
        else if(weight > 60.0){
            return "light welter";
        }
        else if(weight > 57.0){
            return "light";
        }
        else if(weight > 54.0){
            return "feather";
        }
        else if(weight > 51.0){
            return "bantam";
        }
        else if(weight > 48.0){
            return "fly";
        }
        else{
            return "light fly";
        }
	}
}

Measured memory_bytes: 16900
#include <bits/stdc++.h>
#define ll long long
#define ld long double

using namespace std;

int main(){
    ll a, b, c, d;
    vector <ll> x;

    cin >> a >> b >> c >> d;

    x.push_back(b*d);
    x.push_back(a*c);
    x.push_back(a*d);
    x.push_back(b*c);
    cout << *max_element(x.begin() , x.end()) << endl;
    
    return 0;
}

Measured memory_bytes: 3628
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

A, B = LI()
print(A*B)


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

int main()
{
    int n;
    cin>>n;
    int a[10000];
    int count=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        while(a[i]%2==0){
            a[i]/=2;
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
// vim: shiftwidth=2 expandtab foldmethod=marker

// include {{{
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <utility>
#include <cstdlib>
#include <random>
#include <chrono>
// }}}

// debug(...) {{{
#ifdef LOCAL_DEBUG
#include "./debug.h"
#else
#define debug(...)
#define debugn(...)
#define debug_reset()
#endif

#include <cstdio>

template<class T>
std::string bin(int bits, const T& x) {
  char buf[bits + 1];
  buf[bits] = '\0';
  for(int i = 0; i < bits; i++) {
    if((x >> i) & 1) {
      buf[bits - i - 1] = '1';
    } else {
      buf[bits - i - 1] = '0';
    }
  }
  return std::string(buf);
}
std::string bin(int x) {
  if(x < 0) return bin(32, x);
  for(int i = 4; i < 31; i++) {
    int y = 1 << i;
    if(x < y) return bin(i, x);
  }
  return bin(32, x);
}
// }}}

// misc {{{
using namespace std;
template<class T, class U>

using umap = unordered_map<T, U>;
template<class T>
using uset = unordered_set<T>;

typedef long long ll;

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

template<class T>
void sort(T& arr) {
  std::sort(arr.begin(), arr.end());
}
template<class T, class By>
void sort_by(T& arr, By by) {
  std::sort(arr.begin(), arr.end(), [by](auto l, auto r){return  by(l) < by(r); });
}

template<class T>
void reverse(T& arr) {
  std::reverse(arr.begin(), arr.end());
}

class Random {
  public:
  std::uniform_int_distribution<> uniform_int;
  std::mt19937 rnd;
  std::bernoulli_distribution bern_dist;
  int uniform(int l, int r) {
    return uniform_int(rnd, std::uniform_int_distribution<>::param_type(l, r));
  }
  int next(int N) {
    return uniform(0, N - 1);
  }
  int bern(double p) {
    return bern_dist(rnd, std::bernoulli_distribution::param_type(p));
  }
};
// }}}

// main {{{
void solve();
int main() {
  solve();
}
// }}}

void solve() {
  string s;
  cin >> s;
  string ans;
  if(s == "Sunny") ans = "Cloudy";
  else if(s == "Cloudy") ans = "Rainy";
  else if(s == "Rainy") ans = "Sunny";
  cout << ans << endl;
}


Measured memory_bytes: 888
import java.util.Scanner;

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

        if (A < 10 && B < 10) {
            System.out.println(A * B);
        } else {
            System.out.println(-1);
        }
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
//桁
int kt(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a;
  cin>>a;
  string b;
  cin>>b;
  
  int c=1;
 rep(i,a-1){
 if(b[i]!=b[i+1]){
 c++;
 }
 }
   cout<<c;
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main()
{
    int a,b,c,x,y,price=0,price1=0;
    cin>>a>>b>>c>>x>>y;
    if((a>c)&(b>c)) //混合组价格最便宜
    {
        if(x<y)
        {
            price=2*x*c;
            y-=x;
            if((2*c)<b)
            {
                price=price+y*c*2;
            }
            else
            {
                price=price+y*b;
            }
        }
        else
        {
            price=2*y*c;
            x-=y;
            if((2*c)<a)
            {
                price=price+x*c*2;
            }
            else
            {
                price=price+x*a;
            }
        }
    }
    else if((c>a)&(c>b))  //混合组最贵
    {
        price=x*a+y*b;
    }
    else //仅南比混合贵
    {
        price1=y*b+a*x;//先管北，再管南
        int price2=0;
        if(y>x){
            price=2*c*x+(y-x)*b;//以混合为主
            price2=2*c*y;
        }else{
            price2=2*c*y+(x-y)*a;
            price=2*c*x;
        }

        if(price1<price)
            price=price1;
        if(price2<price)
            price=price2;
    }
    cout<<price<<endl;
    return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = List.fill(n)(sc.nextInt())

  def shiftCount(n: Int, res: Int = 0) : Int = {
    if (n % 2 == 0) {
      shiftCount(n / 2, res + 1)
    } else {
      res
    }
  }

  println(a.map(shiftCount(_)).min)
}


Measured memory_bytes: 55648
X=int(input())
D={}
D[0]=0
for i in range(1,200001):
    D[i**5]=i
    D[-i**5]=-i
#print(len(L))
for i in range(-200000,200001):
    if X+i**5 in D:
        print(D[X+i**5],i)
        exit()
        

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//切り上げ除算
long long cutup(long long a,long long b){return (a+b-1)/b;}

//累乗
template<typename t>
constexpr t my_pow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
    }
    return x;
}
#define pow my_pow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,d,a;
    cin>>n>>d>>a;
    vp xh(n);
    rep(i,n)cin>>xh[i].fi>>xh[i].se;
    sort(all(xh));
    vl dh(n+1,0);
    ll res=0;
    rep(i,n){
        if(i)dh[i]+=dh[i-1];
        pll p=mp(xh[i].first+2*d+1,0);
        int ind=lower_bound(all(xh),p)-xh.begin();
        xh[i].se-=dh[i];
        ll k=0;
        if(xh[i].se>0)k+=cutup(xh[i].se,a);
        res+=k;
        dh[i]+=k*a;
        dh[ind]-=k*a;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 7888
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
const ll MOD = 1e9+7;
vi alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z'};

int main() {
    ll n, k;
    cin >> n >> k;
    ll count = 0;
    for (ll b = k + 1; b <= n; b++) {
        ll c = n / b;
        count += (b - k) * c;
        if (n % b >= k) count += n % b - k + 1;
    }
    if (k != 0) {
        cout << count << endl;
    }
    else cout << count - n << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			String S = scan.next();
			
			long K = scan.nextLong();
			
			int one_count = 0;
			boolean one = false;
			
			for(int i = 0;i<S.length();i++) {
				if(!S.substring(i,i+1).equals("1")) {
					break;}
				one_count++;
			}
			
			
			//System.out.println(one_count);
			
			
			if(one_count==0) {//一文字めが１ではなかった
				System.out.println(S.substring(0, 1));
			}else {//一文字目が１でone_countの値が一が続く個数
				if(one_count<K) {
					System.out.println(S.substring(one_count, one_count+1));
				}else{
					 System.out.println("1");
				}
			}
			
			
			/*if(S.substring(0, 1).equals("1")) {
				if(K==1) System.out.println("1");
				else System.out.println(S.substring(1, 2));
			}else{
				System.out.println(S.substring(0, 1));
			}*/
			
			
			
		}
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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 h, w;
string s[110];
vector<vector<int>> dp(110, vector<int>(110, INF));

signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	cin >> h >> w;
	rep(i, h) {
		cin >> s[i];
		rep(j, w) {
			if(i == 0 && j == 0) {
				dp[i][j] = s[i][j] == '#';
			} else {
				if(j > 0) {
					chmin(dp[i][j], dp[i][j-1] + (s[i][j-1] == '.' && s[i][j] == '#'));
				}
				if(i > 0) {
					chmin(dp[i][j], dp[i-1][j] + (s[i-1][j] == '.' && s[i][j] == '#'));
				}
			}
		}
	}
	cout << dp[h-1][w-1] << endl;
	// rep(i, h) {
	// 	rep(j, w) cout << dp[i][j] << " ";
	// 	cout << endl;
	// }
	return 0;
}

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

using namespace std;

int main(){
	auto comb = [](int n, int r){
        int res = 1;
        while(n > 0 || r > 0){
            if(n%2 < r%2) return 0;
            n /= 2;
            r /= 2;
        }
        return 1;
	};
    int N;
    while(cin >> N){
        string S; cin >> S;
        for(auto& c : S) --c;
        auto isOdd = [&](){
            int res = 0;
            for(int i=0;i<N;i++){
                if(comb(N-1, i)) res = (res+S[i]-'0')%2;
            }
            return res == 1;
        };
        if(isOdd()){
            cout << 1 << endl;
        } else {
            if(any_of(S.begin(), S.end(), [](char c){ return c == '1'; })){
                cout << 0 << endl;
            } else {
                for(auto& c : S) if(c == '2') c = '1';
                cout << (isOdd() ? 2 : 0) << endl;
            }
        }
    }
}

Measured memory_bytes: 1412
#include<stdio.h>
int main(){
	unsigned short set;            	/* 使用できる最大値格納用変数 */
	unsigned long tag;            	/* 目標値格納用変数 */
	signed short mid;            	/* 計算用変数 */
	unsigned short agg[100];       	/* 計算結果格納用配列 */
	unsigned short i, j;           	/* ループ変数 */
	unsigned short input_count = 0;	/* 入力数カウンタ */
	unsigned short num_count = 0;  	/* 目標を満足する値のカウンタ */
	
	/* 配列の初期化 */
	for(i = 0;i < 100;i++){
		agg[i] = 0;
	}
	
	/* 数値の入力、演算を無限ループ */
	while(1){
		/* 使用できる最大値、目標値の入力 */
		scanf("%d %ld", &set, &tag);
		
		/* 終了処理 */
		if(set == 0 && tag == 0){
			break;
		}
		/* カウンタをリセット */
		num_count = 0;
		
		/* 目標を満足する値をカウント */
		for(i = 1;i < set;i++){
			for(j = i;j <= set;j++){
				/* i + j と目標値の差をmidに代入 */
				mid = tag - (i + j);
				/* midがiとjの間にある場合カウント*/
				if(mid > i && mid < j){
					num_count++;
				}
			}
		}
		
		/* カウントした結果を格納 */
		agg[input_count] = num_count;
		/* 入力数をカウント */
		input_count++;
	}
	
	/* 結果の出力 */
	for(i = 0;i < input_count;i++){
		printf("%d\n", agg[i]);
	}
	
	return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 1000003;
ll n,a,b;
//vector<ll> a,b;
ll ketawa(ll x){
	ll ans=0;
	while(x){
		ans+=x%10;
		x/=10;
	}
	return ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	ll ans=0;
	ans=ketawa(n-1)+ketawa(1);
	FOR(i,1,n){
		ans=min(ans,ketawa(i)+ketawa(n-i));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin >> s;
    int cnt(0), mx = 0;
    for (auto i : s) {
        if (i == 'S')
            mx = max(mx, cnt), cnt = 0;
        else
            cnt++;
    }
    mx = max(mx, cnt);
    cout << mx;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef struct pair<int,int> P;
typedef long long ll;
bool k[100001]={};
int a[100001]={};
int main() {
	int b[27];
	for(int i=0;i<27;i++)b[i]=100;
	int n;
	cin>>n;
	string s;
	for(int i=0;i<n;++i){
		cin>>s;
		int a[27]={};

		int ls=s.length();
		for(int j=0;j<ls;++j){
			int c=s[j]-97;
			a[c]++;
		}
		for(int j=0;j<27;++j){
			b[j]=min(a[j],b[j]);
		}
	}
	for(int i=0;i<27;i++){
		int k=i+97;
		char chr=k;
		for(int j=0;j<b[i];++j){
			cout<<chr;
		}
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void trace(int A[],int N) {
    int i;
    for(i=0;i<N;i++) {
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}

void insertionSort(int A[], int N) {
    int i,j,v;
    for(i=1;i<N;i++) {
        v=A[i];
        j=i-1;
        while(j>=0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1]=v;
        trace(A,N);
    }
}

int main(void)
{
    int N, i;
    int A[100];
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);
    
    trace(A,N);
    insertionSort(A,N);
    return 0;
}



Measured memory_bytes: 2064
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            pass System Test!
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

template <typename T>
std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
  if (!v.empty()) {
    out << '[';
    std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
    out << "\b\b]";
  }
  return out;
}

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

  ll N;
  cin >> N;
  vector<int> T(N);
  T.resize(N);
  for (int i = 0; i < N; ++i) cin >> T[i];
  sort(T.begin(), T.end());
  int sum = accumulate(T.begin(), T.end(), 0);

  const int S = 900;
  vector<vector<vector<bool>>> dp(
      N + 1, vector<vector<bool>>(S, vector<bool>(S, false)));
  dp[0][0][0] = true;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < S; ++j) {
      for (int k = j; k < S; ++k) {
        if (!dp[i][j][k]) continue;
        if (j + T[i] < S)
          dp[i + 1][j + T[i]][k] = dp[i + 1][j + T[i]][k] || dp[i][j][k];
        if (k + T[i] < S)
          dp[i + 1][j][k + T[i]] = dp[i + 1][j][k + T[i]] || dp[i][j][k];
        dp[i + 1][j][k] = dp[i + 1][j][k] || dp[i][j][k];
      }
    }
  }
  int mi = 10000;
  for (int j = 0; j < S; ++j) {
    for (int k = j; k < S; ++k) {
      if (dp[N][j][k]) {
        int ma = max(j, k);
        ma = max(ma, sum - j - k);
        mi = min(mi, ma);
      }
    }
  }
  cout << mi << endl;
}

Measured memory_bytes: 10884
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

ll m = 998244353;

int main(){
	int n; cin >> n; string s; cin >> s;
	ll cs[3]={0,0,0}, nm[3]={0,0,0}, p; ll an=1;
	for(int i=0; i<3*n; i++) {
		if (s[i] == 'R') p=0;
		else if (s[i] == 'G') p=1;
		else if (s[i] == 'B') p=2;
		if (cs[p] == nm[0]);
		else if (cs[p] == nm[1]) an = an * (nm[0] - nm[1]) % m;
		else if (cs[p] == nm[2]) an = an * (nm[1] - nm[2]) % m;
		cs[p]++; for(int j=0; j<3; j++) nm[j] = cs[j]; sort(nm, nm+3, greater<int>());
	}
	for(ll i=1; i<=n; i++) {
		an = an * i % m;
	}
	cout << an << endl;
}

Measured memory_bytes: 900
#include <iostream>
using namespace std;
using ll = long long;
ll n,k,a=0,i,j,m=1e9+7,v[2<<20];
ll f(ll k){return (k * (k + 1) / 2) % m;}

main()
{
    cin >> n >> k;
    for(i=0;i<n;i++)cin >> v[i];
    for(i=0;i<n;i++)for(j=0;j<n;j++)
    {
            if (i == j)
                continue;

            if (v[i] > v[j])
            {
                if (i < j)a +=k;
                (a += f(k - 1))%=m;
            }
    }
    cout << a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main()
{
  int N; cin >> N;
  
  string ans = "No";
  for (int A = 1; A <= 9; A++)
  {
    for (int B = 1; B <= 9; B++)
    {
      if (N == A * B)
      {
        ans = "Yes";
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder1
{
    class Program
    {
        static void Main(string[] args)
        {
            string num = Console.ReadLine();
            if(num.Contains("7"))
            {
                Console.WriteLine("{0}", "Yes");
            } else
            {
                Console.WriteLine("{0}", "No");
            }

        }
    }
}

Measured memory_bytes: 25872
#include<bits/stdc++.h>
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> x >> a >> b;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------

  if(abs(a-x) < abs(b-x)) anss = "A";
  else anss = "B";
  
  cout << anss << endl;

}

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

using namespace std;

signed main(){
    int n;
    cin >> n;
    int cnt = 0;
    set<int> s;
    for(int i = 1;i<=sqrt(n);i++){
        int n1 = n;
        int c = 0;
        if(i > 1){
        while(n1%i==0){
            n1 /= i;
            c++;
        }
        if(n1%i == 1){ s.insert(i);cnt++;}
        }
        n1 = n;
        c = 0;
        int i1 = n1/i;
        if(i1 > 1){
        while(n1%i1==0){
            n1 /= i1;
            c++;
        }
        if(n1%i1 == 1){ s.insert(i1);cnt++;}
        }
    }
    --n;
    for(int i = 1;i<=sqrt(n);i++){
        int n1 = n;
        int c = 0;
        if(i > 1){
        while(n1%i==0){
            n1 /= i;
            c++;
        }
        if(c){ s.insert(i);cnt++;}
        }
        n1 = n;
        c = 0;
        int i1 = n1/i;
        if(i1 > 1){
        while(n1%i1==0){
            n1 /= i1;
            c++;
        }
        if(c){ s.insert(i1);cnt++;}
        }
    }

    cout << s.size();
}


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

int main(){
  int count0=0,count1=0;
  string s;
  cin>>s;
  for(int i=0;i<s.length();i++){
    if(s[i]=='0'){
      count0++;
    }
    else{
      count1++;
    }
  }
  cout<<min(count0,count1)*2<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x,y) for(ll i=x;i<=y;i++)
#define imin INT_MIN
#define pll pair<ll,ll>
#define imax INT_MAX
int mod =1e9+7;

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

	ll d,t,k;
	cin>>d>>t>>k;
	if(k*t>=d) cout<<"Yes\n";
	else cout<<"No\n";
	
	return 0;
}


Measured memory_bytes: 3640
// They can't break me, as long as I know who I am...

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxn = 2e5 + 10, inf = 1e9;

int a[maxn], ans[maxn];
bool col[maxn], mark[maxn];
vector<int> v[maxn], g[maxn], vid[maxn], gid[maxn];
map<int, vector<int> > mp;

void dfs(int u, int w){
    mark[u] = 1;
    for(int i = 0; i < sz(g[u]); i++){
	if(mark[g[u][i]])
	    continue;
	col[ g[u][i] ] = col[u] ^ 1;
	ans[ gid[u][i] ] = w;
	dfs(g[u][i], w);
    }
}

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

    int n ,m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
	cin >> a[i];
	mp[a[i]].PB(i);
    }
    for(int i = 0; i < m; i++){
	int x, y;
	cin >> x >> y;
	if(a[x] > a[y])
	    swap(x, y);
	if(a[x] < a[y])
	    v[y].PB(x), vid[y].PB(i);
	else
	    g[x].PB(y), g[y].PB(x), gid[x].PB(i), gid[y].PB(i);
    }
    for(int u = 1; u <= n; u++){
	if(g[u].empty() && v[u].empty())
	    return cout << -1 << endl, 0;
    }

    fill(ans, ans + m, inf);
    
    for(auto it : mp){
	for(int u : it.S){
	    if(mark[u] == 0){
		if(g[u].empty())
		    col[u] = col[ v[u].back() ], ans[ vid[u].back() ] = a[u] - a[ v[u].back() ];
		else
		    dfs(u, it.F);
	    }
	}
    }
    for(int i = 1; i <= n; i++)
	cout << (col[i] ? 'B' : 'W');
    cout<<endl;
    for(int i = 0; i < m; i++)
	cout << ans[i] << "\n";
    return 0;
}
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


Measured memory_bytes: 39552
#include "iostream"
#include "math.h"
#include "algorithm"
#include "string"
#include "vector"
#include "deque"
#include "cmath"
using namespace std;
typedef long long ll;

int main() {
	string str;
	cin >> str;
	int cnt = 0, max = 0;
	for (int i = 0; i < 3; i++) {
		if (str[i] == 'R') {
			cnt++;
			if (cnt > max) {
				max = cnt;
			}
		}
		else {
			cnt = 0;
		}
	}
	cout << max << endl;
}

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

int main(){
  int n;

  while(cin >> n){
    if(n == 0){
      break;
    }

    pair<pair<int,int>,pair<int,char> > t[n];

    for(int i = 0; i < n; i++){
      t[i].second.first = i;
      cin >> t[i].second.second;

      t[i].first.first = 0;
      t[i].first.second = 0;

      for(int j = 0; j < n - 1; j++){
        int x;
        cin >> x;

        if(x == 0) t[i].first.first--;
        else if(x == 1) t[i].first.second++;
      }
    }

    sort(t, t + n);

    for(int i = 0; i < n; i++){
      cout << t[i].second.second << endl;
    }
  }
}

Measured memory_bytes: 1156
N=int(input())
A=list(map(int,input().split()))
mod=10**9+7
gyaku=[0]*(N+1)
Nkai=1
for i in range(1,N+1):
    gyaku[i]=pow(i,mod-2,mod)
    Nkai=Nkai*i%mod
ruiseki=[0]*(N+1)
ruiseki[1]=1
for i in range(2,N+1):
    ruiseki[i]=(ruiseki[i-1]+gyaku[i])%mod
ans=0
for j in range(N):
    now=(ruiseki[j+1]+ruiseki[N-j]-1)%mod
    now=(now*A[j]*Nkai)%mod
    ans=(ans+now)%mod
print(ans)

Measured memory_bytes: 15292
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,c,d,n;
    cin >> n >> a >> b >> c >> d;
    cout << n - max((a+c-1)/c,(b+d-1)/d) << enld;
    return 0;
}


Measured memory_bytes: 3196
//
// Created by yamunaku on 2019/07/20.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int n,d;
    cin >> n >> d;
    d=2*d+1;
    cout << (n+d-1)/d << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

// 0-indexed bottom up Segment Tree
// UNIT is the identity element of operation func
template <typename T = int>
struct SegmentTree {
    using F = function<T(T, T)>;
    int n;
    vector<T> dat;
    F func;
    T UNIT;

    SegmentTree(int n_, F func_, T UNIT_) : func(func_), UNIT(UNIT_) {
        n = 1;
        // full binary tree: num of leaves = n = 2^k >= n_
        while (n < n_)
            n *= 2;
        dat.assign(2 * n - 1, UNIT);
    }
    SegmentTree(vector<T> v_, F func_, T UNIT_) : func(func_), UNIT(UNIT_) {
        n = 1;
        while (n < v_.size())
            n *= 2;
        dat.assign(2 * n - 1, UNIT);
        for (int i = 0; i < v_.size(); ++i) {
            dat[n - 1 + i] = v_[i];
        }
        for (int i = n - 2; i >= 0; --i) {
            dat[i] = func(dat[2 * i + 1], dat[2 * i + 2]);
        }
    }
    void update(int k, T a) {
        // leaves are at index n-1 to 2*n-2
        k += n - 1;
        dat[k] = a;
        while (k > 0) {
            // k -> parent node
            k = (k - 1) / 2;
            // func(child nodes)
            dat[k] = func(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }
    // get result of func() in [l, r)
    T query(int l, int r) {
        l += n - 1;
        r += n - 1;
        T ret = UNIT;
        while (l < r) {
            if ((l & 1) == 0)
                ret = func(ret, dat[l]);
            if ((r & 1) == 0)
                ret = func(ret, dat[r - 1]);
            l = l / 2;
            r = (r - 1) / 2;
        }
        return ret;
    }
};

int main() {
    ll n, x;
    cin >> n >> x;
    vl a(n);
    auto f = [](ll l, ll r) { return min(l, r); };
    SegmentTree<ll> st(2 * n, f, INF);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        st.update(i, a[i]);
        st.update(i + n, a[i]);
    }
    ll ret = INF;
    for (int i = 0; i < n; ++i) {
        ll temp = x * i;
        for (int j = n; j < 2 * n; ++j) {
            temp += st.query(j - i, j + 1);
        }
        chmin(ret, temp);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

int main()
{
    int a[101],b[1001],k,n,x,i,t,j,cost=114514;
    scanf("%d%d",&n,&t);
    for(i=0;i<n;i++){
        scanf("%d%d",&a[i],&b[i]);
    }
    for(i=0;i<n;i++){
        if(b[i]<=t&&a[i]<cost){
        cost=a[i];}
    }
    if(cost==114514){
        printf("TLE");
    }else{
        printf("%d",cost);
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <map>
using namespace std;

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

const int N = 100000 + 5;
const int MOD = (int)1e9 + 7;
int a[N], b[N];
long long C[N], INV[N];
int pow(int x, int n) {
	long long y = 1;
	while(n) {
		if(n & 1) y = y * x % MOD;
		n /= 2;
	}
	return y % MOD;
}
inline long long extend_gcd(long long a,long long b,long long &x,long long &y)
{
    if(a==0&&b==0)
        return -1ll;
    if(b==0)
    {
        x=1ll;
        y=0ll;
        return a;
    }
    long long d=extend_gcd(b,a%b,y,x);
    y-=a/b*x;
    return d;
}
inline long long mod_reverse(long long a,long long n)
{
    long long x,y,d=extend_gcd(a,n,x,y);
    if(d==1)
        return (x%n+n)%n;
    else
        return -1ll;
}
int main(){
	int n, x;
	cin >> n;
	rep(i,0,n+1) {
		cin >> b[i];
		a[b[i]-1]++;
		if(a[b[i]-1]>1) x = b[i];
	}
	//cout << x << endl;
	n++;
	C[0] = 1;
	INV[0] = 1;
	rep(i,1,n+1) C[i] = C[i-1] * i % MOD; 
	rep(i,1,n+1) INV[i] = mod_reverse(C[i], MOD);
	//rep(i,1,n+1) INV[i] = pow(C[i], MOD-2);
	int y = 0, z = 0;
	rep(i,0,n) {
		if(b[i] != x) y++;
		else break;
	}
	for(int i=n-1; i>=0; --i) {
		if(b[i] != x) z++;
		else break;
	}
	//cout << y << " " << z << endl;
	rep(i,1,n) {
		if(i==1) cout << n - 1 << endl;
		else if(y + z >= i - 1) {
			long long t = (C[n] * INV[i] % MOD) * INV[n-i] % MOD;
			long long tt = (C[y+z] * INV[i-1] % MOD) * INV[y+z-i+1] % MOD;
			cout << (t - tt + MOD) % MOD << endl;
		} else {
			cout << (C[n] * INV[i] % MOD) * INV[n-i] % MOD << endl;		
		}
	}
	cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long int
#define N 100000
#define M 1000000007
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define mp make_pair
#define bs binary_search
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
  * @author :: Rishabh
  *
  */
int main()
{
	ibs;
	cti;
	ll n;
	cin>>n;
	ll a[n];
	ll c[N+1]={0};
	ll m=0;
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		ans=ans+a[i];
		c[a[i]]=c[a[i]]+1;
		if(a[i]>m)
		m=a[i];
	}
	sort(a,a+n);
	ll q;
	cin>>q;
	while(q--)
	{
		ll p,b;
		cin>>p>>b;
		c[b]=c[b]+c[p];
		ans=ans+((b-p)*c[p]);
		c[p]=0;
		// for(ll i=1;i<=N;i++)
		// {
		// 	//cout<<c[i]<<" ";
		// 	ans=ans+(c[i]*i);
		// }
		cout<<ans<<"\n";
	}
	return 0;
}

Measured memory_bytes: 5188