akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
template<class T>inline bool chmax(T& a, T b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T& a, T b){if(a > b){a = b; return 1;}return 0;}
const ll INF = 1LL<<60;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    string o, e; cin >> o >> e;
    ll sz1 = min(o.size(), e.size()), sz2 = max(o.size(), e.size());
    REP(i, sz1){
        cout << o[i] << e[i];
    }
    if(sz1 == sz2) cout << endl;
    else{
        cout << o[sz2-1] << endl;
    }
}

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

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

#define ff first
#define ss second
#define pb push_back

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

const int N = 1005;
const int mod = 1e9+7;

int cnt[22];
int n, k, a[22];
int dp[22][N];
ll comb[N][N];

ll C(int x, int y){
	if(!x || !y || x == y) return 1;
	if(comb[x][y]) return comb[x][y];
	return comb[x][y] = (C(x-1, y) + C(x-1, y-1)) % mod;
}

int mul(ll aa, ll b){
	return int(aa * b % mod);
}

int add(int aa, int b){
	return (aa + b) % mod;
}

int f(int d, int q){
	if(q < 0) return 0;
	if(d == k) return q == 0;
	int &ret = dp[d][q];
	if(~ret) return ret;
	ret = 0;
	for(int i = 0; i <= a[d]; i++){
		ret += mul(mul(f(d+1, q - i), C(q, i)), C(n - i, a[d] - i));
		ret %= mod;
	}
	return ret;
}

int main() {
	scanf("%d %d", &n, &k);
	int sum = 0;
	for(int i = 0; i < k; i++){
		scanf("%d", a+i);
		sum += a[i];
	}
	memset(dp, -1, sizeof dp);
	printf("%d\n", f(0, n));
	return 0;
}


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

int main() {
    int A, B, C, K;
    int ans;
    cin >> A >> B >> C >> K;
    if(A >= K) ans = K;
    else if(A + B >= K) ans = A;
    else ans = A + (K-A-B)*(-1);

    cout << ans << endl;
}

Measured memory_bytes: 3636
import sys
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

C = Counter(A)
C = sorted(C.items(), key=lambda x: x[0])
if N % 2 == 0:
    s = 1
    for k, v in C:
        if k != s or v != 2:
            print(0)
            sys.exit()
        s += 2
    print(pow(2, (N // 2), MOD))
else:
    s = 0
    for k, v in C:
        if k == 0:
            if k != 0 or v != 1:
                print(0)
                sys.exit()
            s += 2
            continue
        if k != s or v != 2:
            print(0)
            sys.exit()
        s += 2
    print(pow(2, (N - 1) // 2, MOD))

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    string s,t;
    cin >>s>>t;

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << t+s << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

using namespace std;

int main()
{
	int r;
	cin >> r;
	if (r < 1200)
		cout << "ABC" << endl;
	else if (r < 2800)
		cout << "ARC" << endl;
	else
		cout << "AGC" << endl;

	return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "700 600 780" ].parse.expand.solve == 1300 );
	assert( [ "10000 10000 10000" ].parse.expand.solve == 20000 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto abc = input.front.split.to!( long[] );
	return tuple( abc );
}

auto solve( long[] abc )
{
	return abc.sort().take( 2 ).sum;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
  int n;
  int ans=0;
  cin >> n;
  REP(i,n){
    int a;
    cin >> a;
    if(a!=i+1){
      ans++;
    }
  }
  if(ans<=2){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc163/tasks/abc163_c
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
  ll N; cin>>N;
  vector<ll> an(N+1);
  vector<ll> ans(N+1);
  FOR(i,2,N+1){
    ll a; cin>>a;
    ans.at(a)++;
  }
  FOR(i,1,N+1){
    cout<<ans.at(i)<<endl;
  }

  return 0;
}

Measured memory_bytes: 6408
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int solve(){
  int n;
  cin>>n;
  vector<string> vec(n);
  rep(i,n) cin>>vec[i];

  bool white=true;
  rep(i,n) rep(j,n) if(vec[i][j]=='#') white=false;
  if(white) return -1;

  int ncol=0; // まっくろな列数
  rep(j,n){
    int cnt=0;
    rep(i,n) if(vec[i][j]=='#') cnt++;
    if(cnt==n) ncol++;
  }
  if(ncol==n) return 0;

  int ans=INF;
  rep(i,n){
    // 最初にi行を埋める
    int cnt=0;
    rep(j,n) if(vec[i][j]=='.') cnt++;
    bool okCol=false;
    rep(j,n) if(vec[j][i]=='#') okCol=true;

    ans = min(ans, (n-ncol) + cnt + !okCol);
  }

  return ans;
}

int main(){
  cout << solve()<<endl;

  return 0;
}


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


int main(){
 
  int a,b,k; cin>>a>>b>>k;
  vector<int> vec;

  for(int i=1;i<=100;i++){
    
    if(a%i==0&&b%i==0)vec.push_back(i);
    
  }
  cout<<vec.at(vec.size()-k)<<endl;
  
}

Measured memory_bytes: 256
#include<stdio.h>
#define sizeH 500000

const int INF = 999999999;

typedef long int lint;

void maxHeap(lint H[], int i, int n){
  lint left,right;
  lint largeVal;
  lint temp;
  
  left = i*2;
  right = i*2+1;

  if(left <= n && H[left] > H[i]){
    largeVal = left;
  }
  else{
    largeVal = i;
  }

  if(right <= n && H[right] > H[largeVal]){
    largeVal = right;
  }

  if(largeVal != i){
    temp = H[i];
    H[i] = H[largeVal];
    H[largeVal] = temp;

    maxHeap(H, largeVal, n);
  }
}

void buildMaxHeap(lint H[], int n){
  int i;
  for(i = n/2;i > 0;i--){
    maxHeap(H, i, n);
  }
}

int main()
{
  int i;
  int n;
  lint key;
  lint H[sizeH*2+1]={};
  
  scanf("%ld",&n);

  for(i = 1;i < n+1;i++){
    scanf("%ld",&key);
    H[i] = key;
  }
  
  buildMaxHeap(H, n);

  for(i = 1; i <= n; i++){
    printf(" %ld",H[i]);
  }
  printf("\n");
  
  return 0;
}



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

int main() {
    int N, M;
    while (cin >> N >> M, N || M) {
	vector<int> max_num(M);
	for (int i = 0; i < N; i++) {
	    int d, v;
	    cin >> d >> v;
	    max_num[d-1] = max(max_num[d-1], v);
	}

	int sum = 0;
	for (auto i : max_num) sum += i;
	cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 2964
#長方形ができるかの判定を行いながら、長方形の面積を求める
N=int(input()) 
A=list(map(int,input().split()))
A.sort() 
max1=0
max2=0
if A[0]==A[1]:
        a=max1
        max1=A[0]
        max2=a     
for i in range(2,len(A)-1): 
    if A[i]==A[i+1] and (A[i]!=A[i-1] or  A[i]==A[i-1]==A[i-2]):
        a=max1
        max1=A[i]
        max2=a 
print(max1*max2)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

const int INF = 1<<30;

int main(){
    int h, w;
    cin >> h >> w;
    int ch, cw, dh, dw;
    cin >> ch >> cw >> dh >> dw;
    ch--; cw--; dh--; dw--;
    vector<string> s(h);
    rep(i,h) cin >> s[i];

    queue<P> q, q_warp, q_tmp;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    vector<vector<int>> ok(h, vector<int>(w, -1));
    q_warp.push(make_pair(ch, cw));
    dist[ch][cw] = 0;
    while(!q_warp.empty()){
        P pos_warp = q_warp.front(); q_warp.pop();
        if (ok[pos_warp.first][pos_warp.second] != -1) continue;
        ok[pos_warp.first][pos_warp.second] = 1;
        q.push(pos_warp);
        q_tmp.push(pos_warp);
        while(!q.empty()){
            P pos = q.front(); q.pop();
            int sx = pos.second;
            int sy = pos.first;
            rep(i, 4){
                int x = sx + dx[i];
                int y = sy + dy[i];
                if (x < 0 || x >= w) continue;
                if (y < 0 || y >= h) continue;
                if (s[y][x] == '#') continue;
                if (ok[y][x] != -1) continue;
                dist[y][x] = min(dist[y][x], dist[sy][sx]);
                ok[y][x] = 1;
                q.push(make_pair(y, x));
                q_tmp.push(make_pair(y, x));
            }
        }
        while(!q_tmp.empty()){
            P pos = q_tmp.front(); q_tmp.pop();
            int sx = pos.second;
            int sy = pos.first;
            for(int x = sx-2; x <= sx+2; x++){
                for(int y = sy-2; y <= sy+2; y++){
                    if (x < 0 || x >= w) continue;
                    if (y < 0 || y >= h) continue;
                    if (s[y][x] == '#') continue;
                    if (ok[y][x] != -1) continue;
                    dist[y][x] = min(dist[y][x], dist[sy][sx]+1);
                    q_warp.push(make_pair(y, x));
                }
            }
        }
    }
    if (ok[dh][dw] == -1) cout << -1 << endl;
    else cout << dist[dh][dw] << endl;
    return 0;
}

Measured memory_bytes: 13452
import math
a, b, h, m = map(int, input().split())

w_h = math.radians((h * 30) + (m * 0.5))
w_m = math.radians(m * 6)

x = (a ** 2) + (b ** 2) - (2 * a * b * math.cos(w_m - w_h))

print(math.sqrt(x))


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

using namespace std;

#define forn(i, n) for (int i = 0; i < n; i++)
#define sz(a) (int)a.size()
#define re return
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

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

const ll ma = 131072, inf = 10LL * ((ll)1e9);
ll a, b;

int main() {
	iostream::sync_with_stdio(0), cin.tie(0);
	//freopen("a.in", "r", stdin);
	//freopen(".out", "w", stdout);
	cin >> a >> b;
	if (a <= 0 && b >= 0) {
		cout << "Zero\n";
		re 0;
	}	
	if (b < 0 && (b - a + 1LL) % 2) {
		cout << "Negative\n";
	} else
		cout << "Positive\n";
	re 0;
}




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

typedef long long ll;
typedef tuple<ll, ll, ll> mytuple;
const ll INF = 1e9;
const ll MOD = 1000000007;
const double pi = 3.141592653589793238;

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) { if (b == 0) {return a;} else {return GCD(b, a % b);} }
// a と b の最小公倍数を返す関数
long long LCM(long long a, long long b) { return a/GCD(a,b)*b; }

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

int main() {
  int S, W; cin >> S >> W;

  if(S <= W) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }

  return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main() {
  int number_of_hotels, i, j, count = 0;
  scanf("%d", &number_of_hotels);
  int height[number_of_hotels];
  for(i = 0; i < number_of_hotels; i++) {
    scanf("%d", &height[i]);
  }
  for(i = 0; i < number_of_hotels; i++) {
    for(j = 0; j <= i; j++) {
      if(height[i] < height[j]) {
        break;
      }
      if(i == j) {
        count++;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 128
// Problem C

#include <stdio.h>
#include <iostream>
#include <vector>
#include <string.h>
#include <cassert>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <queue>
#include <stack>

#define MAXN 300000
#define pb push_back
#define mp make_pair

using namespace std;

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

int N;
ll A[MAXN];

int main() {
  cin >> N;
  for (int i=0; i<N; i++) cin >> A[i];
  ll m = A[0];
  ll res = 0;
  for (int i=1; i<N; i++) {
    if (A[i] < m)
      res += (m-A[i]);
    else
      m = A[i];
  }
  
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 5156
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define reps(i,n) for(int i=1;i<=(int)n;i++)
#define all(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
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 A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    int A,B,K; cin >>A >> B >> K;
    rep(i,K){
        if(i % 2 == 0){
            if(A % 2 != 0){
                A--;
            }
            A /= 2;
            B += A;
        }else{
            if(B % 2 != 0){
                B--;
            }
            B /= 2;
            A += B;
        }
    }
    cout << A << " " << B << enld;
    return 0;
}

Measured memory_bytes: 3632
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int p[] = new int[n];
            for (int i = 0; i < n; i++) {
                p[i] = Integer.parseInt(in.next());
            }

            int ans = 0;
            for (int i = 0; i < n; i++) {
                if (p[i] != i + 1) ans++;
            }

            // 出力
            if (ans <= 2) out.println("YES");
            else out.println("NO");

        }

    }
}



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

int main() {
    ll a, b;
    cin >> a >> b;
    
    ll x = a* b;
    if (a < b) swap(a,b);

    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    cout << x/b << endl;
}


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

bool dp[4001][16001];
int x,y,tx,ty,ax[4001],ay[4001];

void dfsx(int t,int n){
	if(dp[t][n+8000]) return;
	if(t<tx){
		dfsx(t+1,n+ax[t]);
		dfsx(t+1,n-ax[t]);
	}
	dp[t][n+8000]=1;
}

void dfsy(int t,int n){
	if(dp[t][n+8000]) return;
	if(t<ty){
		dfsy(t+1,n+ay[t]);
		dfsy(t+1,n-ay[t]);
	}
	dp[t][n+8000]=1;
}

int main()
{
	string s;
	cin>>s>>x>>y;
	bool fx=1;
	
	for(int i=0;i<s.length();i++){
		if(s[i]=='F'){
			if(fx) ax[tx]++;
			else ay[ty]++;
		}
		else{
			if(fx) fx=0,tx++;
			else fx=1,ty++;
		}
	}
	if(s[s.length()-1]=='F'){
		if(fx) tx++;
		else ty++;
	}
	
	dfsx(1,ax[0]);
	bool xx=dp[tx][8000+x]==1?1:0;
	
	memset(dp,0,sizeof(dp));
	dfsy(0,0);
	
	bool yy=dp[ty][8000+y]==1?1:0;
	
	if(xx&&yy) 
		cout<<"Yes";
	else 
		cout<<"No";
	return 0;
}

Measured memory_bytes: 62976
#include <bits/stdc++.h>
using namespace std;
int n;
long long a,c=1;
char t[10];
string s[123456],k;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++)cin>>t[j];
		sort(t,t+10);
		s[i]={t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9]};
	}
	sort(s,s+n);
	k=s[0];
	for(int i=1;i<n;i++){
		if(s[i]==k)c++;
		else{
			a+=(c*(c-1)/2);
			c=1;
			k=s[i];
		}
	}
	a=a+(c*(c-1)/2);
	cout<<a<<endl;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
const int SQRT = 100005, MAXN = 100005;
typedef long long int LL;

bool isComp[SQRT]; int pcnt, n, ord[MAXN];
LL a[MAXN], p1[SQRT], p2[SQRT], p3[SQRT], reci[MAXN], val[MAXN];

inline bool cmp(const int &u, const int &v){
	return a[u] < a[v];
}
int main(){
	int i, j, ans = 0; LL mx = 0LL, c, d, t;
	scanf("%d", &n);
	for(i = 1; i <= n; ++ i){
		scanf("%lld", &a[i]);
		if(a[i] > mx) mx = a[i];
		reci[i] = 1;
	}
	for(c = 1; LL(c) * c <= mx; ++ c) ;
	for(i = 2; i < c; ++ i){
		if(!isComp[i]) p1[++ pcnt] = i;
		for(j = 1; i * p1[j] < c; ++ j)
			isComp[i * p1[j]] = true;
	}
	for(i = 1; i <= pcnt; ++ i){
		p2[i] = p1[i] * p1[i];
		p3[i] = p2[i] * p1[i];
	}
	for(i = 1; i <= n; ++ i){
		for(j = 1, t = a[i]; j <= pcnt && t >= p3[j]; ++ j){
			while(t % p3[j] == 0)
				t /= p3[j], a[i] /= p3[j];
			if(t % p2[j] == 0)
				t /= p2[j], reci[i] *= p1[j];
			else if(t % p1[j] == 0)
				t /= p1[j], reci[i] *= p2[j];
		} d = int(sqrt(t * 1.0) + 1e-5);
		if(d * d == t) reci[i] *= d;
		else reci[i] *= t * t;
		ord[i] = i;
	} sort(ord + 1, ord + 1 + n, cmp);
	for(i = 1; i <= n; ++ i) val[i] = a[ord[i]];
	ans = int(val[1] == 1LL) * 2;
	for(i = 1; i <= n && val[i] == 1; ++ i) ;
	for(; i <= n; i = j){
		for(j = i; val[i] == val[j]; ++ j) ;
		t = upper_bound(val + 1, val + 1 + n, reci[ord[i]]) - lower_bound(val + 1, val + 1 + n, reci[ord[i]]);
		if(t) ans += max(LL(j - i), t);
		else ans += (j - i) * 2;
	} printf("%d\n", ans / 2);
	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
int main(){
	int n,i;
	int fib[45];
	fib[0] = 1;
	fib[1] = 1;

	
	for(i=2; i<=44; i++){
		fib[i] = fib[i-1]+fib[i-2];
	}
	scanf("%d",&n);
	printf("%d\n",fib[n]);
	return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    vi a(n);
    vi b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    a.push_back(x);
    b.push_back(y);
    sort(all(a));
    sort(all(b));
    cout << (a.back() < b.front() ? "No War" : "War") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
  char s[100];
  if(scanf("%s",s)==1){}
  int len = strlen(s);
  int cmp=1;
  int i;
  for(i=0;i<len;i++){
    if(i%2==0 && s[i]=='L'){
      cmp=0;
    }else if(i%2==1 && s[i]=='R'){
      cmp=0;
    }
  }
  if(cmp==0){
    printf("No");
  }else{
    printf("Yes");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <functional>

using namespace std;

const int N = 100100;
int a[N]={0};


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

	int n;

	cin >> n;

	int ans = 0;

	while (n--) {
		int x;
		cin >> x;
        if (x >= N) {
			ans++;
			continue;
		}
		a[x]++;
	}
	for (int i = 1; i < N; i++) {
		if (a[i] < i)
			ans += a[i];
		else
			ans += a[i] - i;
	}
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;


main(){
    int n,k;cin>>n>>k;
    ll a[n+1];
    for(int i=1;i<=n;i++) cin>>a[i];
    ll sum=0;
    for(int i=1;i<=k;i++) sum+= a[i];
    ll prev = sum;
    for(int i=(k+1);i<=n;i++){
        sum-= a[i-k];
        sum+= a[i];
        if(sum>prev) cout<<"Yes\n";
        else cout<<"No\n";
        prev = sum;
    }
}

Measured memory_bytes: 5140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	string s, t;
    int n;
    cin >> n;
	cin >> s >> t;
	int pre = (s[0]==t[0]?0:1);
	int now = (s[0]==t[0]?1:2);
	ll ans = (s[0]==t[0]?3:6);
	while(now!=n){
		if(s[now]==t[now]){
			ans*=(2-pre);
			ans %= MOD;
			now++;
			pre = 0;
		}else{
			ans *= (2+pre);
			ans %= MOD;
			now += 2;
			pre = 1;
		}
	}
	cout << ans << endl;  	
}

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


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

    int a[n];
    int maxval = 0;
    int second = 0;
    int maxcount = 1;
    int maxindex = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if(a[i] > maxval){
            second = maxval;
            maxindex = i;
            maxval = a[i];
            maxcount = 1;
        }else if(a[i] == maxval){
            maxcount++;
        }else{
            if(a[i] > second){
                second = a[i];
            }
        }
    }

    //
    if(maxcount > 1){
        for (int i = 0; i < n; i++) {
            cout << maxval << endl;
        }
    }else{
        for (int i = 0; i < n; i++) {
            if(i == maxindex){
                cout << second << endl;
            }else{
                cout << maxval << endl;
            }
        }
    }

    //std::cout << ans << std::endl;
    //for (int i=0;i<n;i++){
    //    std::cout << vec.at(i) << std::endl;
    //}


    return 0;
}

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

int main(){

  int N,t1=0,t2,x1=0,x2,y1=0,y2,ans=0;
  scanf("%d",&N);
  for (int i = 0; i < N; i++)
  {
    scanf("%d%d%d",&t2,&x2,&y2);
    if (t2-t1>=abs(x2-x1)+abs(y2-y1))
    {
      if(((t2-t1)-(x1-x2+y1-y2))%2==0){
        t1=t2; x1=x2; y1=y2;
        continue;
      }else{
        ans=1;
        break;
      } 
    }else{
      ans=1;
      break;
    }
  }

  ans > 0 ? puts("No"):puts("Yes");

  return 0;
}

Measured memory_bytes: 1588
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define mod 1000000007
#pragma GCC optimize ("O3")
#define endl '\n'
using namespace std;
typedef long long int ll ;
#define MAX 1005
vector<pair<ll,ll>> v;
set<pair<ll,ll>> st;
int main()
{
    ll n,d,a;
    cin>>n>>d>>a;
    for(int i=1;i<=n;i++){
        ll a, b;
        cin>>a>>b;
        v.push_back({a,b});
    }
    sort(v.begin(),v.end());
    ll ans=0;
    ll total=0;
    for(int i=0;i<v.size();i++){
        ll x=v[i].first;
        ll val=v[i].second;
        while(true){
            auto it=st.begin();
            if(it==st.end())  break;
            if(x<=(*it).first){
                break;
            }
            else{
                total-=(*it).second;
                st.erase(it);
            }
            
        }
        val-=total;
        if(val>0){
            ll cnt=(val/a);
            if(val%a!=0) cnt++;
            ans+=cnt;
            st.insert({x+(2*d),(cnt*a)});
            total+=cnt*a;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 10092
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
	return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
	mem(isprime,true);
	for(ll p=2;p*p<=n;p++)
	{
		if(isprime[p]==true)
		{
			for(ll i=p*p;i<=n;i+=p)
				isprime[i]=false;
		}
	}
}
ll lcm(ll a,ll b)
{
	return (a/__gcd(a,b))*b;
}
pll find(ll n)
{
	ll b=n%10;
	ll a=n;
	while(n!=0)
	{
		a=n;
		n=n/10;
	}
	return {a,b};
}
void solve()
{
	ll n,k;
	cin>>n>>k;
	ll a[n];
	rep(i,0,n)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	ll ans=0;
	for(ll i=0;i<n-k;i++)
	{
		ans+=a[i];
	}
	cout<<ans;
}	

int main()
{
	IOS
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#pragma optimizer(O2)
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
//#define MXN 300000
#define N 100005
LL cal(LL u,LL d,LL l){
  //  printf("%d %d %d\n",u,d,l);
    if(l==0)return 0;
    LL res=(u-1)/l*l*2+l+((u-1)%l+1);
    u%=l;
    LL tmpd=l;
    LL tmpl=u;
    LL tmpu=l-u;
    return res+cal(tmpu,tmpd,tmpl);
}
int main(){
    LL n,x;
    scanf("%lld %lld",&n,&x);
    printf("%lld\n",cal(x,n,n-x)+x);
}

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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
#define smaller_queue_p  priority_queue <pll, vector<pll>, greater<pll> >
//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a, b;
    cin >> a >> b;
    int cnt = 0;

    rep(i, n) {
        int c;
        cin >> c;
        if (c < a || b <= c) cnt++;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
#define MP make_pair
#define PB push_back
#define ll long long
#define int long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define ld long double
#define mod 1000000007


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	cout<<(n-2)*180<<endl;
	
	return 0;
}

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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

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

const long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}


string S;

int main()
{
    cin>>S;
    if(S=="ABC"){
        cout<<"ARC"<<endl;
    }else{
        cout<<"ABC"<<endl;
    }
    return 0;

}




Measured memory_bytes: 3632
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    int a[3];
    for(int i=0;i<3;i++)
    cin>>a[i];
    sort(a,a+3);
    if(a[0]==5&&a[1]==5&&a[2]==7)
    cout<<"YES";
    else
    cout<<"NO";}
    

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

int main()
{
    int N;
    cin >> N;
    if (N > 81)
    {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 1; i <= 9; i++)
    {
        if (N % i == 0 && N / i <= 9)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
T = []
K = []
for i in range(N):
    a = i - A[i] + 1
    if a >= 1:
        T.append(a)
hiku = Counter(T)

ans = 0
for j in range(N):
    a = j - A[j] + 1
    b = j + A[j] + 1
    ans += hiku[b]
    hiku[a] -= 1

print(ans)

Measured memory_bytes: 114620
# 平文
N = int(input())
S = input()

# 秘密鍵
KEY = N

# 以下に、記述してください。
enc = ""

for char in list(S):
    ASCII = ord(char)
    num = ASCII - 65
    num = (num + KEY) % 26
    ASCII = num + 65
    enc += chr(ASCII)

print(enc)

Measured memory_bytes: 3316
s = input()
skip = False
ans = [s[0]]
n = 0
for i in range(len(s))[1:]:
    if skip == True:
        skip = False
        continue
    elif ans[n] == s[i] and i+1 < len(s):
        ans.append(s[i]+s[i+1])
        skip = True
        n += 1
    else:
        ans.append(s[i])
        n += 1
res = len(ans)
if ans[-1] == ans[-2]:
    res -= 1
print(res)

Measured memory_bytes: 8068
n = int(input())
a = [int(num) for num in input().split()]

a.sort()
count = []
for i in range(100001 + 1):
    count.append(0)

for num in a:
    count[num] += 1

max = 0
for i in range(1, 100001):
    res = count[i - 1] + count[i] + count[i + 1]
    if (res > max):
        max = res

print(max)

Measured memory_bytes: 13964
#include<cstdio>  
#include<cstring>  
#include<algorithm>  
#include<iostream>  
#include<string>  
#include<vector>  
#include<stack>  
#include<bitset>  
#include<cstdlib>  
#include<cmath>  
#include<set>  
#include<list>  
#include<deque>  
#include<map>  
#include<queue>
using namespace std;
typedef long long ll;
const ll inf=1<<29;
const ll Maxn=1e6;

struct node{
	int x,y;
}n[Maxn];

int h,w,d;
int z;
int q,l,r;
int a=1,b=1;
int sum=0;
int c[Maxn];

int jdz(int u,int v){
	if(u>=v) return u-v;
	else return v-u;
}

int main(){
	scanf("%d %d %d",&h,&w,&d);
	for(int i=1;i<=h*w;i++){
		scanf("%d",&z);
		if(b>w){
			a++;
			b=1;
		}
		n[z].x=a;
		n[z].y=b;
		b++;
	}
	for(int i=1;i<=d;i++){
		int j=i;
		int k=i+d;
		sum=0;
		while(k<=h*w){
			sum+=(jdz(n[k].x,n[j].x));
			sum+=(jdz(n[k].y,n[j].y));
			c[k]=sum;
			j=k;
			k+=d;
		}
	}
	scanf("%d",&q);
	while(q--){
		scanf("%d %d",&l,&r);
		int ans=c[r]-c[l];
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1LL<<60;
template<class T> bool inline chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool inline chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
vector<long long> dp(100010,INF);
int main(){
int N;cin>>N;
dp[0]=0;
int vi=6;
int vi3=9;
for(int i=1;i<=N;i++){
    chmin(dp[i],dp[i-1]+1);
    while(i>=vi){
        chmin(dp[i],dp[i-vi]+1);
        vi*=6;
    }
    while(i>=vi3){
        chmin(dp[i],dp[i-vi3]+1);
        vi3*=9;
    }
    vi=6;
    vi3=9;
}
cout<<dp[N]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template<int MOD = 1000000007>
struct Mint{
  int v;
  Mint():v(0){}
  Mint(int v):v(v){}
  Mint(int v,bool f):v(v){if(f) v%=MOD;}

  Mint pow(int k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }
  
  Mint inv(){return pow(MOD-2);}
  
  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}
  
  Mint operator+(Mint a){return Mint(v)+=a;};
  Mint operator-(Mint a){return Mint(v)-=a;};
  Mint operator*(Mint a){return Mint(v)*=a;};
  Mint operator/(Mint a){return Mint(v)/=a;};

  Mint operator-(){return v?MOD-v:v;}

  Mint operator==(Mint a){return v==a.v;}
  Mint operator!=(Mint a){return v!=a.v;}
  
  vector<Mint> fact(int n){
    vector<Mint> res(n+1,1);
    for(int i=1;i<=n;i++) res[i]=res[i-1]*Mint(i);
    return res;
  }
  
  vector<Mint> finv(int n){
    vector<Mint> res(n+1,1);
    for(int i=1;i<=n;i++) res[i]=res[i-1]*Mint(i);
    res[n]=Mint(1)/res[n];
    for(int i=n;i>=1;i--) res[i-1]=res[i]*Mint(i);
    return res;
  }

  vector<Mint> invs(vector<Mint> &a,vector<Mint> &b){
    int n=a.size()-1;
    vector<Mint> res(n+1,0);
    for(int i=1;i<=n;i++) res[i]=b[i]*a[i-1];
    return res;
  }
};

template<int MOD>
istream& operator>>(istream &is, Mint<MOD>& a){
  is>>a.v;
  return is;
} 
template<int MOD>
ostream& operator<<(ostream &os, Mint<MOD>& a){
  os<<a.v;
  return os;
} 
//END CUT HERE

template<typename T> 
map<T, int> factorize(T x){
  map<T, int> res;
  for(int i=2;i*i<=x;i++){
    while(x%i==0){
      x/=i;
      res[i]++;
    }
  }
  if(x!=1) res[x]++;
  return res;
}

//INSERT ABOVE HERE
signed main(){
  int n;
  Mint<> m;
  cin>>n>>m;
  
  auto fact=m.fact(n+100);
  auto finv=m.finv(n+100);
  
  auto C=[&](int n,int k){
	   if(n<k||k<0) return Mint<>(0);
	   return fact[n]*finv[n-k]*finv[k];
	 };
  auto H=[&](int n,int k){return C(n+k-1,n);};

  Mint<> ans(1);
  auto x=factorize(m.v);
  for(auto p:x) ans*=H(p.second,n);
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;

int n, m, a[maxn];
int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1;i <= n + n;i ++) scanf("%d", &a[i]), a[i] %= m;
	sort(a + 1,a + n + n + 1);
	int l = 0, r = n, pos = n;
	while(l <= r) {
		int mid = (l + r) >> 1;
		int flag = 1;
		for(int i = 2 * mid + 1;i <= n + n;i += 2) {
			if(a[i] + a[n + n - i + 2 * mid + 1] < m) flag = 0;
			if(a[i + 1] + a[n + n - i + 2 * mid] < m) flag = 0;
		}
		if(flag) pos = mid, r = mid - 1;
		else l = mid + 1;
	}
	int Mx = 0;
	for(int i = 1, j = 2 * pos;i < j;i ++, j --) {
	  Mx = max(Mx,a[i] + a[j]);
	}
	for(int i = 2 * pos + 1, j = n + n;i < j;i ++, j --) {
		Mx = max(Mx,a[i] + a[j] - m);
	}
	printf("%d\n", Mx);
	return 0;
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

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

    while(true){
        int R0, W0, C, R;
        std::cin >> R0 >> W0 >> C >> R;
        if(!R0){break;}

        int x = max(C * W0 - R0, 0),
            res = (x + R - 1) / R;

        std::cout << res << std::endl;
    }
}



Measured memory_bytes: 3140
#include<cstdio>
const int MAXN = 1000;
int m[MAXN + 5][MAXN + 5];
int H, W, A, B;
int main() {
	scanf("%d%d%d%d", &H, &W, &A, &B);
	for(int i=1;i<=B;i++)
		for(int j=1;j<=W;j++)
			m[i][j] = 1;
	for(int i=1;i<=H;i++)
		for(int j=1;j<=A;j++)
			m[i][j] ^= 1;
	for(int i=1;i<=H;i++) {
		for(int j=1;j<=W;j++)
			printf("%d", m[i][j]);
		puts("");
	}
}

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

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

int main(void) {
	int n;
scanf("%d", &n);
	call(n);
	return 0;
}

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

int n, A[50];

int solve (int i, int m){
    if(m==0)return 1;
    if(i>=n)return 0;
    int res = solve(i+1, m) || solve(i+1,m-A[i]);
    return res;
}

int main(){
    int q,M,i;
    scanf("%d", &n);
    for(i=0; i<n; i++)scanf("%d", &A[i]);
    scanf("%d", &q);
    for(i=0; i<q; i++){
        scanf("%d", &M);
        if(solve(0,M))printf("yes\n");
        else printf("no\n");
    }
    return 0;
}



Measured memory_bytes: 3152
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <numeric>

using namespace std;

typedef long long ll;
typedef long double ld;

#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define file_name(a) (freopen(((string)(a) + ".in").c_str(),"r",stdin), freopen(((string)(a) + ".out").c_str(),"w",stdout))


int nxt() {
	int x;
	cin >> x;
	return x;
}

int main() {
	int k = nxt(), a = nxt(), b = nxt();
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK\n";
			return 0;
		}
	}
	cout << "NG\n";
	return 0;
}

Measured memory_bytes: 3632
L,R = input().split()
L = int(L)
R = int(R)

if L == 0:
    if R >= 1868 and R <= 1911:
        K = int(R) - 1867
        print("M" + str(K))
    elif R >= 1912 and R <= 1925:
        K = int(R) - 1911
        print("T" + str(K))
    elif R >= 1926 and R <= 1988:
        K = int(R) - 1925
        print("S" + str(K))
    elif R >= 1989 and R <= 2016:
        K = int(R) - 1988
        print("H" + str(K))
elif L == 1:
    K = int(R) + 1867
    print(K)
elif L == 2:
    K = int(R) + 1911
    print(K)
elif L == 3:
    K = int(R) + 1925
    print(K)
elif L == 4:
    K = int(R) + 1988
    print(K)




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

const int MAX_N = (int)1e5 + 5;

int n;
int a[MAX_N];

int ans = -1;
unordered_map<int, int> mp;

int main(void){
  // Here your code !
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);

  for (int i = 0; i < n; ++i) {
    auto itr = mp.find(a[i]);
    if(itr != mp.end()) {
        mp[a[i]] += 1;
    }
    else {
        mp[a[i]] = 1;
    }
  }

  vector<int> keys = {};
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) keys.push_back(itr->first);

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

  for (int i = 0; i < keys.size(); ++i) {
    vector<int> could = {};
    vector<int> base = {};

    base.push_back(keys[i]);
    could.push_back(keys[i] - 1); could.push_back(keys[i]); could.push_back(keys[i]);

    for (int b = i - 1; b >= 0; --b) {
      if (keys[b] + 1 >= keys[i] - 1) {
        base.push_back(keys[b]);
        could.push_back(keys[b] - 1); could.push_back(keys[b]); could.push_back(keys[b]);
      }
      if (keys[b] + 1 < keys[i] - 1) break;
    }

    for (int f = i + 1; f < keys.size(); ++f) {
      if (keys[f] - 1 <= keys[i] + 1) {
        base.push_back(keys[f]);
        could.push_back(keys[f] - 1); could.push_back(keys[f]); could.push_back(keys[f]);
      }
      if (keys[f] -1 > keys[i] + 1) break;
    }

    sort(could.begin(), could.end());
    could.erase(unique(could.begin(), could.end()), could.end());

    for (int ic = 0; ic < could.size(); ++ic) {
      int tmpsize = 0;
      for (int j = 0; j < base.size(); ++j) {
        if (base[j] - 1 <= could[ic] && could[ic] <= base[j] + 1) {
          tmpsize += mp[base[j]];
        }
      }
      ans = max(ans, tmpsize);
    }
  }

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 4132
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(void) {
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> cnt(100001, 0);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    cnt[a] += b;
  }
  for (int i = 1; i <= 100001; i++) {
    if (k <= cnt[i]) {
      cout << i << endl;
      break;
    }
    k -= cnt[i];
  }
  return 0;
}

Measured memory_bytes: 1024
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;

    bool all_zero = true;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
        all_zero &= (A[i] == 0);
    }

    if(all_zero) cout << "Yes" << endl;
    else {
        map<int, int> cnt;
        for(auto e : A) cnt[e]++;

        if(cnt.size() > 3 or N % 3) {
            cout << "No" << endl;
        }
        else {
            int M = N / 3;
            sort(A.begin(), A.end());
            vector<int> v = {A[0], A[M], A[2*M]};

            bool ok = true;
            for(int k=0; k<30; k++) {
                int cnt0 = 0, cnt1 = 0;
                for(int i=0; i<3; i++) {
                    int c = (v[i] >> k) & 1;
                    (c ? cnt1 : cnt0)++;
                }
                ok &= (cnt0 == 3 or (cnt0 == 1 and cnt1 == 2));
            }

            for(int i=0; i<M; i++) {
                ok &= (A[0] == A[i]);
                ok &= (A[M] == A[M+i]);
                ok &= (A[2*M] == A[2*M+i]);
            }

            cout << (ok ? "Yes" : "No") << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int x,y,z,count = 0;
    std::cin >> x >> y >> z;
    x = x - 2 * z;
    if(x >= y){
        x = x - y;
        count++;
    }
    count = count + (x / (y + z));
    std::cout <<count<<std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<math.h>
using namespace std;

int main() {
	int n,m,time,pow;
	pow = 1;
	cin >> n;
	cin >> m;
	time = (n-m)*100+m*1900;
	for(int p = m;p>0;p--) pow=pow*2;
	cout << pow * time << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.LongStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			long x = scanner.nextLong();
			long[] array = LongStream.range(0, 6000).map(i -> i * i * i * i * i).toArray();
			for (int i = 0; i < 6000; i++) {
				int a;
				if ((a = Arrays.binarySearch(array, x + array[i])) >= 0) {
					System.out.println(a + " " + i);
					break;
				} else if ((a = Arrays.binarySearch(array, x - array[i])) >= 0) {
					System.out.println(a + " -" + i);
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 38912
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s;
    cin >> t;
    vint dps((int)s.size()+1,0);
    vint dpt((int)t.size()+1,0);
    REP(i,(int)s.size()){
        dps[i+1] = dps[i];
        if(s[i]=='A'){
            dps[i+1]++;
        }
    }
    REP(i,(int)t.size()){
        dpt[i+1] = dpt[i];
        if(t[i]=='A'){
            dpt[i+1]++;
        }
    }
    int q;
    cin >> q;
    REP(i,q){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        a--; b--;
        c--; d--;
        int sa = dps[b+1]-dps[a];
        int sb = b-a+1-sa;
        int ta = dpt[d+1]-dpt[c];
        int tb = d-c+1-ta;
        int x = ((sa-sb)%3+3)%3;
        int y = ((ta-tb)%3+3)%3;
        //cout << x << "-" << y;
        if(x==y){
            cout << "YES\n";
        }else{
            cout << "NO\n";
        }
    }
    return 0;
}

Measured memory_bytes: 4188