akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
/* Type alias */
using ll = long long;
using ld = long double;

using vec_i = std::vector<int>;
using vec_ll = std::vector<ll>;
using vec_ld = std::vector<ld>;

using set_i = std::set<int>;
using set_ll = std::set<ll>;
using set_ld = std::set<ld>;

using uset_i = std::unordered_set<int>;
using uset_ll = std::unordered_set<ll>;
using uset_ld = std::unordered_set<ld>;

/* IO macros */
#define in(i)            int i; std::cin >> i
#define in2(i, j)        int i, j; std::cin >> i >> j
#define in3(i, j, k)     int i, j, k; std::cin >> i >> j >> k
#define in_(i)           std::cin >> i
#define in2_(i, j)       std::cin >> i >> j
#define in3_(i, j, k)    std::cin >> i >> j >> k
#define in_ll(i)         ll i; std::cin >> i
#define in2_ll(i, j)     ll i, j; std::cin >> i >> j
#define in3_ll(i, j, k)  ll i, j, k; std::cin >> i >> j >> k
#define in_ll_(i)        std::cin >> i
#define in2_ll_(i, j)    std::cin >> i >> j
#define in3_ll_(i, j, k) std::cin >> i >> j >> k
#define in_ld(i)         ld i; std::cin >> i
#define in2_ld(i, j)     ld i, j; std::cin >> i >> j
#define in3_ld(i, j, k)  ld i, j, k; std::cin >> i >> j >> k
#define in_ld_(i)        std::cin >> i
#define in2_ld_(i, j)    std::cin >> i >> j
#define in3_ld_(i, j, k) std::cin >> i >> j >> k
#define in_c(i)          char i; std::cin >> i
#define in2_c(i, j)      char i, j; std::cin >> i >> j
#define in3_c(i, j, k)   char i, j, k; std::cin >> i >> j >> k
#define in_c_(i)         std::cin >> i
#define in2_c_(i, j)     std::cin >> i >> j
#define in3_c_(i, j, k)  std::cin >> i >> j >> k
#define in_str(s)        std::string s; std::cin >> s

#define vec_in(v, n)    auto v=vec_i(n); for(auto &x:v){std::cin>>x;}
#define vec_in_ll(v, n) auto v=vec_ll(n);for(auto &x:v){std::cin>>x;}
#define vec_in_ld(v, n) auto v=vec_ld(n);for(auto &x:v){std::cin>>x;}

#define print(x)   std::cout << x
#define println(x) std::cout << x << "\n"
#define print_fixed(x)   std::cout << std::fixed << x
#define println_fixed(x) std::cout << std::fixed << x << "\n"
#define print_vec(v) for (auto &x:v) { std::cout << x << " ";}
#define println_vec(v) for (auto &x:v) { std::cout << x << " ";} std::cout << "\n";
#define print_long_vec(v) for (auto &x:v) { std::cout << x << "\n";}
#define println_long_vec(v) for (auto &x:v) { std::cout << x << "\n";} std::cout << "\n";

/* Loops */
#define rep(i, n) for (auto i = 0; i < n; ++i)
#define rep2(i, m, n) for (auto i = m; i < n; ++i)

/* Vector manipulation */
#define vec_sort(v) std::sort(v.begin(), v.end())

using namespace std;
/* Code Starts Here*/
int main () {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    in(N); vec_in_ll(A, N);
    rep(i, N) {
        if (A[i] == 0) { println(0); return 0; }
    }
    ll ans = 1;
    rep(i, N) {
        if (A[i] > ll(1e18) / ans) {
            println(-1); return 0;
        }
        ans *= A[i];
    }
    println(ans);
    return 0;
}


Measured memory_bytes: 3968
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

int N;
pair<ld,vector<int>> memo[1 << 15][20];
struct kura {
	int id;
	int d;
	ld w;
};
vector<kura>ks;
pair<ld,vector<int>> getans(bitset<15>used, int now,ld noww) {
	if (used.count() == N) {
		memo[used.to_ulong()][now] = make_pair(0,vector<int>(1,now));
	}
	else {
		if (memo[used.to_ulong()][now].first < -0.5) {
			pair<ld, vector<int>>ans=make_pair(1e18,vector<int>());
			for (int next = 0; next < N; ++next) {
				if (used[next])continue;
				used[next] = true;
				ld nextw = noww + ks[next].w;
				ld dis = abs(ks[now].d - ks[next].d);
				ld nextspeed = 2000.l / (70 + nextw);
				auto p = getans(used, next, nextw);
				ld nexttime = dis / (2000.l/(70+noww)) + p.first;
				auto v = p.second;
				v.push_back(now);
				ans = min(ans, make_pair(nexttime, v));
				used[next] = false;
			}
			memo[used.to_ulong()][now] = ans;
		}
	}
	return memo[used.to_ulong()][now];
}

int main() {
	cin >> N;
	for (int i = 0; i < (1 << 15); ++i) {
		for (int j = 0; j < 20; ++j) {
			memo[i][j] = make_pair(-1,vector<int>());
		}
	}
	for (int i = 0; i < N; ++i) {
		int s, d, v; cin >> s >> d >> v;
		ld w = v * 20;
		ks.push_back(kura{ s,d,w });
	}
	ks.push_back(kura{ -1,0,0 });
	bitset<15>bs;
	auto ans = getans(bs, N, 0);
	reverse(ans.second.begin(), ans.second.end());
	for (int i = 1; i < int(ans.second.size()); ++i) {
		cout << ks[ans.second[i]].id;
		if (i == int(ans.second.size()) - 1)cout << endl;
		else cout << " ";
	}
	return 0;
}

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

using namespace std;

typedef long long int ll;

const ll MAXN = 205;

vector < vector < ll > > d(MAXN, vector < ll > (MAXN, 1e16));

vector < ll > v, r;
vector < bool > used(MAXN, false);

ll ans = LLONG_MAX;

void dfs(){
  bool ok = true;
  for(auto i : r){
    if(!used[i]) ok = false;
  }
  if(ok){
    ll sum = 0;
    for(int i = 1; i < v.size(); i++){
      sum += d[v[i]][v[i - 1]];
    }
    ans = min(ans, sum);
  }
  for(auto i : r){
    if(!used[i]){
      v.push_back(i);
      used[i] = true;
      dfs();
      v.pop_back();
      used[i] = false;
    }
  }
}

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

  ll n, m, nr;
  cin >> n >> m >> nr;
  for(int i = 0; i < nr; i++){
    ll a;
    cin >> a;
    r.push_back(a);
  }
  for(int i = 0; i < m; i++){
    ll u, v, wt;
    cin >> u >> v >> wt;
    d[u][v] = wt;
    d[v][u] = wt;
  }

  for(int k = 1; k <= n; k++){
    for(int i = 1; i <= n; i++){
      for(int j = 1; j <= n; j++){
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  dfs();

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
ll n,a,b,c,d;
map<ll,ll> memo;

ll PtW(ll x){
  if(x==0) return 0;
  if(x==1) return d;
  if(memo.count(x)) return memo[x];
  ll res = (ll)9e18;
  if(x<res/d) res = x*d;
  ll l2=(x/2)*2;
  ll r2=((x+1)/2)*2;
  ll l3=(x/3)*3;
  ll r3=((x+2)/3)*3;
  ll l5=(x/5)*5;
  ll r5=((x+4)/5)*5;
  res = min(res,(ll)abs(x-l2)*d+a+PtW(l2/2));
  res = min(res,(ll)abs(x-r2)*d+a+PtW(r2/2));
  res = min(res,(ll)abs(x-l3)*d+b+PtW(l3/3));
  res = min(res,(ll)abs(x-r3)*d+b+PtW(r3/3));
  res = min(res,(ll)abs(x-l5)*d+c+PtW(l5/5));
  res = min(res,(ll)abs(x-r5)*d+c+PtW(r5/5));
  memo[x] = res;
  return res;
}

int main(){
  int t;
  cin >> t;
  for(int i=0;i<t;i++){
    memo.clear();
    cin >> n >> a >> b >> c >> d;
    cout << PtW(n) << endl;
  }
}


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

int main()
{
    int a,b,c,d,e;
    scanf("%1d%1d%1d%1d",&a,&b,&c,&d);

    if(a+b+c+d==7)
    {
        printf("%d+%d+%d+%d=%d",a,b,c,d,a+b+c+d);
        return 0;
    }
    if(a+b+c-d==7)
    {
        printf("%d+%d+%d-%d=7",a,b,c,d);
        return 0;
    }
    if(a+b-c+d==7)
    {printf("%d+%d-%d+%d=7",a,b,c,d);return 0;}
    if(a+b-c-d==7) {printf("%d+%d-%d-%d=7",a,b,c,d);return 0;}
    if(a-b+c+d==7) {printf("%d-%d+%d+%d=7",a,b,c,d);return 0;}
    if(a-b+c-d==7) {printf("%d-%d+%d-%d=7",a,b,c,d);return 0;}
    if(a-b-c+d==7) {printf("%d-%d-%d+%d=7",a,b,c,d);return 0;}
    if(a-b-c-d==7) {printf("%d-%d-%d-%d=7",a,b,c,d);return 0;}

}

Measured memory_bytes: 128
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1000000007;

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

  vll l(n);
  ll sum = 0;

  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    sum += b;
    l[i] = a + b;
  }

  Sort(l);
  Reverse(l);
  ll ans = 0;
  for (ll i = 0; i < n; i += 2) {
    ans += l[i];
  }
  ans -= sum;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
// /*
//   GOOD is not Enough
//   You've got to be GREAT.
// */
// #include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// // #include<boost/multiprecision/cpp_int.hpp>
// // using namespace boost::multiprecision;
// using namespace __gnu_pbds;
// using namespace std;
// #define int long long
// #define mod 1000000007
// #define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
// #define f(i,n) for(int i=0;i<n;i++)
// #define fp(i,k,n) for(int i=k;i<=n;i++)
// #define fr(i,k,n) for(int i=k;i>=n;i--)
// #define pb push_back
// #define pii pair<int,int>
// #define dbg(x) cout << (#x) << " is " << (x) << '\n' 
// #define F first
// #define S second
// #define all(a) a.begin(),a.end()
// typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}

ll inv(ll base) {
    int g = MOD, r = base, x = 0, y = 1;
    while (r != 0) {
        int q = g / r;
        g %= r; swap(g, r);
        x -= q * y; swap(x, y);
    }
    return x < 0 ? x+MOD : x;
}

ll mul(ll A, ll B) {
	return (A*B)%MOD;
}

ll add(ll A, ll B) {
	return (A+B)%MOD;
}

ll dvd(ll A, ll B) {
    return mul(A, inv(B));
}

ll sub(ll A, ll B) {
    return (A-B+MOD)%MOD;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
    int N;  int P; P=2019;
    string S; cin >> S;
    N=S.length();

    ll counts[P]; F0R(i, P) counts[i] = 0;
    counts[0] = 1;
    int cur = 0;
    MOD = P;
    F0R(i, N) {
        cur *= 10; cur += S[i] - '0'; cur %= MOD;
        int val = modExp(10, N-1-i) * cur; val %= MOD;
        counts[val]++;
    }

    ll ans = 0;
    F0R(i, P) ans += (counts[i] * (counts[i] - 1)) / 2;

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



Measured memory_bytes: 3804
N = int(input())
number = list(map(int,input().split()))
x = sum(number)


a = []
i = 0
while True:
  a.append(number[i])
  s1 = sum(a)
  s2 = x -s1
  if s1 >= s2:
    
    break
  i += 1  

if 2 * (s1 - s2 - number[i]) >= 0:
  print(s2 - s1 + 2 * number[i])
else:
  print(s1 - s2)

Measured memory_bytes: 3064
N = int(input())
xyh = [tuple(map(int, input().split())) for _ in range(N)]

for e in xyh:
    if e[2] != 0:
        t = e

candidates = []
for cy in range(101):
    for cx in range(101):
        candidates.append((cx, cy, t[2] + abs(t[0] - cx) + abs(t[1] - cy)))

for e in xyh:
    nc = []
    for c in candidates:
        if e[2] == max(c[2] - abs(e[0] - c[0]) - abs(e[1] - c[1]), 0):
            nc.append(c)
    candidates = nc

print(*candidates[0])


Measured memory_bytes: 4212
s = str(input())

n = len(s)

g_num = 0
p_num = 0
win = 0
lose = 0



for i in range(n):
    if s[i] == "g" and g_num >= p_num+1:
        p_num+=1
        win+=1
    elif s[i] == "g":
        g_num +=1
    elif s[i] == "p" and g_num >= p_num+1:
        p_num +=1
    else:
        g_num +=1
        lose+=1


print(win-lose)
    


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


int main() {
long long N, M;
cin >> N >> M;
long long ans;
if(N == 1 || M == 1) ans = 1;
else if(N % 2 == 0) ans = M*N/2;
else if(M % 2 == 0) ans = M*N/2;
else ans =  M*(N-1)/2 + (M+1)/2;

cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

void bubble(int *angka,int len){
	for(int i=0; i<len ;i++){
		for(int j=i+1; j<len; j++){
			if(angka[i]>angka[j]){
				int temp=angka[i];
				angka[i]=angka[j];
				angka[j]=temp;
			}	
		}
	}
	
}

int main(){
	int loop;
	int angka[105];
	scanf("%d", &loop);
	
	for(int i=0; i<loop; i++){
		scanf("%d",&angka[i]);
	}
	bubble(angka,loop);
	
	printf("%d\n", angka[loop-1]-angka[0]);
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*

fun main(args: Array<String>){

    var N = readLine()!!.toInt()
    var A = readLine()!!.split(" ").map{it.toLong()}.toLongArray()
    Arrays.sort(A)
    var size = A[0]
    var candidate = 0
    for(i in 0 until N-1){
        if(size * 2 < A[i+1]){
            candidate = i+1
        }
        size += A[i+1]

    }
    println(N - candidate)





}

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

ll quickmodpow(ll a,ll b,ll mod){
  ll ans=1%mod;
  while(b){	
    if(b&1) ans=(ans*a)%mod;
    a=(a*a)%mod;
    b=b>>1; 
  }
  return ans;
  }

int main(){
  ll N,K;
  ll mod = 1e9+7;
  cin >> N >> K;
  vector<ll> cnt_gcd(2*K+10,0);
  ll ans = 0;
  cnt_gcd[K] = 1;
  for(ll i=K-1;i>=1;--i){
    cnt_gcd[i] = quickmodpow(ll(K/i),N,mod);
    for(ll j=2*i;j<=K;j=j+i){
      if(cnt_gcd[j]>=1) cnt_gcd[i] = (cnt_gcd[i] - cnt_gcd[j] + mod)%mod;
    }
  }
  for(ll i=1;i<=K;++i){
    ans = (ans + (cnt_gcd[i] * i)) % mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4844
#include <iostream>

using namespace std;

int main () {
    int A, B, C, D;

    cin >> A >> B >> C >> D;

    if(A+B > C + D) cout << "Left" << endl;
    else if (A + B < C + D) cout << "Right" << endl;
    else cout << "Balanced" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int D;
int N;
int main(){
  int i, j, k;
  rd(D);
  rd(N);
  for(i=1;;i++){
    j = i;
    k = 0;
    while(j%100==0){
      j/=100;
      k++;
    }
    if(k==D){
      N--;
    }
    if(N==0){
      break;
    }
  }
  wt_L(i);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int D, N;
// {
//   int i, j, k;
//   rd(D,N);
//   for(i=1;;i++){
//     j = i;
//     k = 0;
//     while(j%100==0) j/=100,k++;
//     if(k==D) N--;
//     if(N==0) break;
//   }
//   wt(i);
// }


Measured memory_bytes: 256
main = do
  s <- getLine
  li <- getLine
  let n = read li
  (dir,s1,s2) <- loop n True "" ""
  putStrLn $ format dir s s1 s2

format True s s1 s2 = s1 ++ s ++ reverse s2
format False s s1 s2 = s2 ++ reverse s ++ reverse s1

{-
dir : 現在の向きが開始時点と同じときTrue
s1 : 開始時点の文字列の前に接続された文字列
s2 : 開始時点の文字列の後に追加された文字列の逆順
-}

loop :: Int -> Bool -> String -> String -> IO (Bool,String,String)
loop 0 dir s1 s2 = return (dir,s1,s2)
loop n dir s1 s2 = do
  q <- getLine
  let n1 = pred n
  if q !! 0 == '1' then loop n1 (not dir) s1 s2 else
    if (q !! 2 == '1') == dir then loop n1 dir (q !! 4 : s1) s2 else loop n1 dir s1 (q !! 4 : s2)


Measured memory_bytes: 103036
import sys

input = sys.stdin.readline


def main():
    N, H = map(int, input().split())
    a = [0] * N
    b = [0] * N
    for i in range(N):
        a[i], b[i] = map(int, input().split())

    a.sort()
    b.sort()

    atk = 0
    ans = 0
    for i in reversed(range(N)):
        if b[i] < a[-1]:
            break
        else:
            atk += b[i]
            ans += 1
            if atk >= H:
                break

    if atk < H:
        rem = H - atk
        q, r = divmod(rem, a[-1])
        ans += q
        ans += 1 if r > 0 else 0

    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 11312
using System;

class Program
{
    static void Main()
    {
            int a, b, d, r;
            decimal a2,b2,f;
            string inp = Console.ReadLine();
            string[] data = inp.Split();
            a = int.Parse(data[0]);
            b = int.Parse(data[1]);
            d = a / b;
            r = a % b;
            a2 = int.Parse(data[0]);
            b2 = int.Parse(data[1]);
            f = a2/b2;
            Console.WriteLine("{0} {1} {2}",d, r, f);
    }
}


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

int main(){
    int n;
    cin >> n;
    vector<int> in(n);
    rep(i,n) cin >> in.at(i);
    int count = 0;
    rep(i,n - 2){
        if(in.at(i) < in.at(i + 1) && in.at(i + 1) < in.at(i + 2)) count++;
        else if(in.at(i) > in.at(i + 1) && in.at(i + 1) > in.at(i + 2)) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 764
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int t[101];
int pri[26];
int res = 0;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[y] = px;
	}
	else {
		pr[x] = py;
	}
	return true;
}
struct edge {
	int to;
	bool use = false;
	edge(int _to) : to(_to) {}
};

void solv() {

	int H, W;
	cin >> H >> W;
	int h, w;
	cin >> h >> w;
	cout << ((H - h) * (W - w)) << endl;

}


int main() {
	solv();

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
const int INF = 100100100;
using namespace std;

int main()
{
  char S[11];
  cin >> S;
  int N=strlen(S);
  int res=0;;

  int len=0;
  rep(i,N){
    if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T'){
      len++;
      res=max(res,len);
    }
    else len = 0;
  }

  cout << res << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

def main():
    n, k = map(int,input().split())
    h = list(map(int,input().split()))

    dp = [0]*n

    dp[1] = abs(h[1] - h[0])
    for i in range(2, n):
        dp[i] = dp[i-1] + abs(h[i] - h[i-1])
        for j in range(2, k+1):
            if i-j < 0:
                continue
            dp[i] = min(dp[i-j] + abs(h[i] - h[i-j]), dp[i])

    print(dp[-1])



if __name__ == '__main__':
    main()

Measured memory_bytes: 84176
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define MAXN 100005
#define eps 1e-8
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const db PI = acos(-1.0);
int N,top;
db ans[105];
bool dcmp(db a,db b) {
    return fabs(b - a) <= eps;
}
struct Point {
    db x,y;int id;
    Point(db _x = 0.0,db _y = 0.0) {
	x = _x;y = _y;
    }
    friend Point operator + (const Point &a,const Point &b) {
	return Point(a.x + b.x,a.y + b.y);
    }
    friend Point operator - (const Point &a,const Point &b) {
	return Point(a.x - b.x,a.y - b.y);
    }
    friend Point operator * (const Point &a,const db &d) {
	return Point(a.x * d,a.y * d);
    }
    friend db operator * (const Point &a,const Point &b) {
	return a.x * b.y - a.y * b.x;
    }
    friend db dot(const Point &a,const Point &b) {
	return a.x * b.x + a.y * b.y;
    }
    db norm() {
	return sqrt(x * x + y * y);
    }
}P[105],sta[105];

bool cmp(Point a,Point b) {
    db d = (a - P[1]) * (b - P[1]);
    if(dcmp(d,0.0)) {return (a - P[1]).norm() < (b - P[1]).norm();}
    else return d > 0;
}
int main() {
    int x,y;
    read(N);
    if(N == 1) {puts("1.0");return 0;}
    for(int i = 1 ; i <= N ; ++i) {read(x);read(y);P[i] = Point(x,y);P[i].id = i;}
    for(int i = 2 ; i <= N ; ++i) {
	if(P[i].x < P[1].x || (P[i].x == P[1].x && P[i].y < P[1].y)) swap(P[1],P[i]);
    }
    sort(P + 2,P + N + 1,cmp);
    sta[++top] = P[1];
    for(int i = 2 ; i <= N ; ++i) {
	while(top >= 2 && (P[i] - sta[top - 1]) * (sta[top] - sta[top - 1]) >= 0.0) --top;
	sta[++top] = P[i];
    }
    if(top == 2) {
	ans[sta[1].id] = 0.5;
	ans[sta[2].id] = 0.5;
    }
    else {
	Point a,b;
	sta[0] = sta[top];sta[top + 1] = sta[1];
	for(int i = 1 ; i <= top ; ++i) {
	    a = sta[i + 1] - sta[i];
	    b = sta[i - 1] - sta[i];
	    ans[sta[i].id] = (PI - acos( dot(a,b) / (a.norm() * b.norm()) ) ) / (2 * PI); 
 	}
    }
    for(int i = 1 ; i <= N ; ++i) {
	printf("%.10lf\n",ans[i]);
    }
    return 0;
}

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

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

int f(const vector<int> &b, const vector<int> &a){
  int n=b.size();
  {
    int s1=0, s2=0;
    rep(i, n) s1+=b[i], s2+=a[i];
    if(s1!=s2) return 10000000;
  }
  vector<int> c=b;
  int s=0;
  rep(i, n)if(c[i]!=a[i]){
    int j=i;
    while(c[j]!=a[i]) j++;
    s+=(j-i);
    for(int k=j; k>i; k--) swap(c[k-1], c[k]);
  }
  return s;
}

int main(){

  int n, m; cin>> n>> m;
  vector<int> b(n);
  rep(i, n) cin>> b[i];
  vector<int> p(m);
  rep(i, m) cin>> p[i];

  vector<int> a0, a1;
  rep(i, m){
    rep(_, p[i]){
      a0.push_back(i%2);
      a1.push_back((i%2)^1);
    }
  }

  cout<< min(f(b, a0), f(b, a1))<< endl;

  return 0;
}


Measured memory_bytes: 3164
class UnionFind():
    def __init__(self, n):
        self.n = n  # 要素の総数．
        self.parents = [-1] * n  # 各要素の親要素の番号を格納するリスト．要素がrootの場合は-(そのグループの要素数)を返す

    def find(self, x):
        """要素xが属するグループの根を返す"""
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        """要素xが属するグループと要素yが属するグループとを併合する"""
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        """要素xが属するグループの要素数を返す"""
        return -self.parents[self.find(x)]

    def same(self, x, y):
        """要素x, yが同じグループに属するかどうかを返す"""
        return self.find(x) == self.find(y)

    def members(self, x):
        """要素xが属するグループに属する要素をリストで返す"""
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        """全ての根の要素をリストで返す"""
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        """グループの数を返す"""
        return len(self.roots())

    def all_group_members(self):
        """{ルート要素: [そのグループの要素のリスト]} の辞書を返す"""
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    N, M, K = map(int, input().split())
    cnt = [0] * N
    uf = UnionFind(N)

    for _ in range(M):
        A, B = map(lambda x: int(x)-1, input().split())
        cnt[A] += 1
        cnt[B] += 1
        uf.union(A, B)

    for _ in range(K):
        C, D = map(lambda x: int(x)-1, input().split())
        if uf.same(C, D):
            cnt[C] += 1
            cnt[D] += 1

    for i in range(N):
        print(uf.size(i) - cnt[i] - 1, end=" ")


if __name__ == '__main__':
    main()



Measured memory_bytes: 8592
#include<stdio.h>
void sort(int n,int a[])
{
  int i,j,tmp;
  for(i=0; i<n; i++)
    for(j=i+1; j<n; j++)
      if(a[i]<a[j]){
        tmp=a[i];
        a[i]=a[j];
        a[j]=tmp;
      }
}
int find(int a[], int n)
{
  int i,A,B;
  A=B=0;
  for(i=0; i<n; i++)
    {
      if(i%2==0)
        A+=a[i];
      else
        B+=a[i];
    }
  A-=B;
  return A;
}
int main()
{
  int i,n,result;
  scanf("%d",&n);
  int a[n];
  for(i=0; i<n; i++)
    scanf("%d",&a[i]);
  sort(n,a);
  result=find(a,n);
  printf("%d\n",result);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> T;
typedef pair<long double , ll> Ps;
typedef pair<ll, bool> Pb;

const ll INF = 1e18;
const ll fact_table = 3200008;
long double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll, vector<ll>, greater<ll> > pqls;
priority_queue <P, vector<P>, greater<P> > pqps;
//small priority queue
//top pop

ll dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
ll dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
char dir[] = "DRUL";
//↓,→,↑,←

/*
#define endl "\n"
#ifdef ENJAPMA
#undef endl
#endif
*/
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)();
#define pc(x) cout << x << ",";
#define rep(i, n) for (ll i = 0; i < (n); i ++)

// const ll mod = 998244353ll;
const ll mod = 1000000007ll;

ll mypow(ll a, ll b, ll mod) {ll x = 1; while (b) {while (!(b & 1)) {(a *= a) %= mod; b >>= 1;}(x *= a) %= mod; b--;} return x;}
void YES(bool cond) { if (cond) { p("YES");} else { p("NO");} return;}
void Yes(bool cond) { if (cond) { p("Yes");} else { p("No");} return;}
void line() { p("--------------------"); return;}

/*
ll fact[fact_table + 5], rfact[fact_table + 5];

void c3_init() {
    fact[0] = rfact[0] = 1;
    for (ll i = 1; i <= fact_table; i++) {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table], mod - 2, mod);
    for (ll i = fact_table; i >= 1; i--) {
        rfact[i - 1] = rfact[i] * i;
        rfact[i - 1] %= mod;
    }
    return;
}
ll c3(ll n, ll r) {
    return (((fact[n] * rfact[r]) % mod ) * rfact[n - r]) % mod;
}
*/

bool multicase = false;

ll n, k, num, a, b, c, d, e, h, q, ans, sum;

typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

ll cost[505];
ll table[400][30];
ll last[50];

ll score_sum;

string s, t;

const ll m = 26;
void solve() {
    cin >> d;
    for(ll i=0;i<m;i++){
        cin >> cost[i];
    }
    for(ll i=0;i<d;i++){
        for(ll j=0;j<m;j++){
            cin >> table[i][j];
        }
    }
    for(ll i=0;i<d;i++){
        // この日、何を選ぶか？
        ll index = -1, maxi = -INF;
        for(ll j=0;j<m;j++){
            ll score = table[i][j] + ((i + 1) - last[j]) * cost[j];
            if (score > maxi){
                maxi = score;
                index = j;
            }
        }
        // score_sum += maxi;
        last[index] = i + 1;
        p(index + 1);
    }

    return;
}

int main() {
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if (multicase) {
        cin >> q;
    } else {
        q = 1;
    }
    while (q--) {
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}



Measured memory_bytes: 3748
MOD = 10**9 + 7
def main():
    n, k = map(int, input().split())
    ans = 0
    x = 0
    y = 0
    for i in range(n, n-k, -1):
        x += i
        y += n - i
    for i in range(k, n+2):
#        print(x, y)
        ans += (x - y + 1)%MOD
        ans %= MOD
        x += n - i
        x %= MOD
        y += i
        y %= MOD
#    print(x, y)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9208
#include <iostream>
#include <vector>
#include <map>
using namespace std;

const int divisor = 1000000007;

int main(){
	vector<int> ansvec;

	// 100000!までの数をdivisorで割った余りを格納しておく
	long long* factmodary = new long long[100001];
	long long fact = 1;
	for (int i = 1; i <= 100000; i++){
		fact *= i;
		fact %= divisor;
		factmodary[i] = fact;
	}

	int* word = new int[100000];

	for (;;){
		int N, R;
		cin >> N;
		if (N == 0) break;
		cin >> R;

		for (int i = 0; i < N; i++) word[i] = i + 1; //まず0番目の単語を入れておく

		for (int i = 0; i < R; i++){
			int s, t;
			cin >> s >> t;
			/* swap */
			int tmp = word[s - 1]; word[s - 1] = word[t - 1]; word[t - 1] = tmp;
		}

		//word[i]をkey, word[i]より小さい数がそれ以前にいくつ使われていたかをvalueとして格納するmap
		map<int, int> bubblehist;
		bubblehist[word[0]] = 0;

		long long ans = factmodary[N-1] * (word[0] - 1);

		for (int i = 1; i < N; i++){
			int facttime = word[i] - 1;
			int bubblenum;
			map<int, int>::iterator it = bubblehist.lower_bound(word[i]);

			if (it != bubblehist.end()){
				bubblenum = it->second;
			}
			else {
				bubblenum = bubblehist.rbegin()->second + 1;
			}
			pair<int, int> p;
			p.first = word[i];
			p.second = bubblenum;
			bubblehist.insert(--it, p);
			//word[i]より大きい数はすべてvalueが1増える
			for (map<int, int>::iterator it2 = bubblehist.upper_bound(word[i]); it2 != bubblehist.end(); it2++) ++(it2->second);

			facttime -= bubblenum;
			ans += factmodary[N - (i + 1)] * facttime;
			ans %= divisor;
		}
		ansvec.push_back((int)ans);
	}

	for (vector<int>::iterator it = ansvec.begin(); it != ansvec.end(); it++) cout << *it << "\n";

	delete[] word;
	delete[] factmodary;
	return 0;
}

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

int main(){

 while(1){
  int h,w;
  cin >> h >> w;
  if(h==0 && w==0) break;
 
  for (int i=1;i<=h;++i){
   for (int j=1;j<=w;++j){
    cout << "#";
   }
   cout << endl;
  }
  cout << endl;
 }
  return 0;
}

Measured memory_bytes: 3068
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
*/

ll a,b;

int main(void){
	cin>>a>>b;
	if(b%a==0){
		cout<<a+b<<endl;
	}else{
		cout<<b-a<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  import std.numeric;

  int n;
  rd(n);
  long l = 1;
  long lcm(long a, long b) {
    return a / gcd(a, b) * b;
  }

  while (n--) {
    long t;
    rd(t);
    l = lcm(l, t);
  }
  writeln(l);
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  cout << a[0] << b[0] << c[0] << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
int yakusu(int n) {
    int cnt=0;
    for(int i=1;i<=n;++i) {
        if(n%i==0) ++cnt;
    }
    return cnt;
}

int main() {
    int n;
    cin >> n;
    int ans=0;
    for(int i=1;i<=n;++i) {
        if(i%2==1) {
            int a=yakusu(i);
            if(a==8) ++ans;
        }

    }
    cout << ans << endl;
}


Measured memory_bytes: 256
# 0や1のケースに注意
# index out of range
# 貪欲

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    for i in a:
        if i == 0:
            print(0)
            exit()
    res = 1
    for i in a:
        res *= i
        if res > 10**18:
            print(-1)
            break
    else:
        print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 89744
package main

import (
	"fmt"
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	
	a := make([]string, h)
	for i := 0; i < h; i++ {
		fmt.Scan(&a[i])
	}
	
	row := make([]bool, h)
	col := make([]bool, w)
	
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if a[i][j] == '#' {
				row[i] = true
				col[j] = true
			}
		}
	}
	for i := 0; i < h; i++ {
		if row[i] {
			for j := 0; j < w; j++ {
				if col[j] {
					fmt.Printf(string(a[i][j]))
				}
			}
			fmt.Println()
		}
	}
}

Measured memory_bytes: 1908
#include<stdio.h>
int BinarySearch(int [],int,int);

int main(){
  int i, n, q, key, number=0, S[100000];

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  for(i = 0 ; i < q ; i++){
    scanf("%d",&key);
    if(BinarySearch(S,n,key) != 0) number++;
  }

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

  return 0;
}

int BinarySearch(int A[], int x, int y){
  int left=0, right=x, mid;

  while(left < right){
    mid = (left + right) / 2;
    if(A[mid] == y) return 1;
    if(A[mid] > y) right = mid;
    else if(A[mid] < y) left = mid + 1;
  }

  return 0;
}

    



Measured memory_bytes: 2120
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <tuple>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG

int main(void){

    int N;
    cin >> N;
    while(1){
        N -= 1000;
        if(N <= 0){
            break;
        }
    }

    N = abs(N);

    cout << N << endl;

}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>

using namespace std;

typedef map<char, int> mci;

int main(void) {
    string w;
    cin >> w;

    mci chars;
    for (char c: w) {
        chars[c] ^= 1;
    }

    for (auto item: chars)
        if (item.second) {
            cout << "No\n";
            return 0;
        }

    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
# 解説PDFを見たけどこれでいいかまだ分からない
n = gets.to_i
x = []
y = []
h = []
count = 0
ii = nil
n.times do |i|
  x[i], y[i], h[i] = gets.split.map(&:to_i)
  if h[i] > 0
    ii = i
    count += 1
  end
end
if count == 1
  puts "#{x[ii]} #{y[ii]} #{h[ii]}"
else
  ok = false
  (0..100).each do |cy|
    (0..100).each do |cx|
      height = nil
      ok = true
      n.times do |i|
        hh = h[i] + (x[i] - cx).abs + (y[i] - cy).abs
        if h[i] > 0
          if height.nil?
            height = hh
          elsif height != hh
            ok = false
            break
          end
        else
          if !height.nil? && hh < height
            ok = false
            break
          end
        end
      end
      if ok
        puts "#{cx} #{cy} #{height}"
        break
      end
    end
    break if ok
  end
end


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

int a[101];

int main(){
	int n;
	cin >> n;
	
	for(int i=0; i<n; i++) cin >> a[i];
	
	int ans = 0;
	for(int i=0; i<101; i++){
		int sum = 0;
		for(int j=0; j<101; j++){
			sum += (a[j] >= i);
		}
		if(sum >= i) ans = i;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3104
#include<stdio.h>
#include<string.h>
#define MAX 1002
int lcs[MAX][MAX];

int max(int a,int b){
  if(a > b){
    return a;
  }
  else return b;
}

int lcscheck(char a[],char b[]){
  int i,j,ans =0;
  int al = strlen(a);
  int bl = strlen(b);
  for(j=1;j<bl;j++)
  for(i=1;i<al;i++){
    if(a[i] == b[j]){
      lcs[i][j] = lcs[i-1][j-1] + 1;
    }else{
      if(lcs[i][j-1] > lcs[i-1][j])lcs[i][j] = lcs[i][j-1];
      else lcs[i][j] = lcs[i-1][j];
    }
    ans = max(lcs[i][j],ans);
  }
  return ans;
}

int main(){
  int datanum,temp;
  char dataA[MAX+1];
  char dataB[MAX+1];
  char tempdata[MAX];
  scanf(" %d",&datanum);
  for(int i=0;i<datanum;i++){
    scanf(" %s",tempdata);
    strcpy(dataA," ");
    strcat(dataA,tempdata);
    scanf(" %s",tempdata);
    strcpy(dataB," ");
    strcat(dataB,tempdata);
    // printf("%s\n%s\n",dataA,dataB);
    printf("%d\n",lcscheck(dataA,dataB));
  }
  return 0;
}



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

bool is_prime(int u) {
    if (u <= 1)
        return false;
    if (u == 2 || u == 3)
        return true;
    if (u % 2 == 0)
        return false;
    int m = (int) sqrt(u);
    for (int i = 3; i <= m; i += 2)
        if (u % i == 0)
            return false;
    return true;
}

int main(int argc, char const *argv[]) {
  int N;
  int input;
  int res = 0;
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> input;
    if(is_prime(input)){
      res++;
    }
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
	int n,x,a = 0,ans = 0;
	cin >> n >> x;
	if(a <= x) ans++;
	for(int i = 0;i < n;i++){
		int l;
		cin >> l;
		a += l;
		if(a <= x) ans++;
	}
	cout << ans << endl;
}

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

int main(){
  int N,A,B,C,D;
  cin >> N;
  D = N%10;
  N /= 10;
  C = N%10;
  N /= 10;
  B = N%10;
  N /= 10;
  A = N%10;
  N /= 10;
  if(A+B+C+D == 7){cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;return 0;}
  if(A+B+C-D == 7){cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;return 0;}
  if(A+B-C-D == 7){cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;return 0;}
  if(A-B-C-D == 7){cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;return 0;}
  if(A+B-C+D == 7){cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;return 0;}
  if(A-B-C+D == 7){cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;return 0;}
  if(A-B+C+D == 7){cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;return 0;}
  if(A-B+C-D == 7){cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;return 0;}
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int hit,blow,i,j;
	int a[4],b[4];
	while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3]) != EOF)
	{
		hit = 0;
		blow = 0;
		for(i=0;i<4;i++)
		{
			scanf("%d",&b[i]);
		}
		for(i=0;i<4;i++)
		{
			if(a[i] == b[i])hit++;
		}
		for(i=0;i<4;i++)
		{
			for(j=0;j<4;j++)
			{
				if(a[i] == b[j] && i!= j)blow++;
			}
		}
		printf("%d %d\n",hit,blow);
	}
	return 0;
}

Measured memory_bytes: 596
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

int gcd(int x, int y){
	return x ? gcd(y % x, x) : y;
}

void Main()
{
	int N, X;
  	cin >> N >> X;
  	vector<int> x(N);
  	rep(i,N) {
      	cin >> x[i];
    	x[i] -= X;
      	x[i] = abs(x[i]);
    }
  	// gcd x(N) を求める
  	int g = 0;
  	rep(i,N) g = gcd(g,x[i]);
  	cout << g << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>

using namespace std;
#define REP(i,e,s) for(register int i=e; i<=s; i++)
#define DREP(i,e,s) for(register int i=e; i>=s; i--)
#define DE(...) fprintf(stderr,__VA_ARGS__);
#define DEBUG(a) DE("DEBUG: %d\n",a)
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define ll long long

int read() {
	int x=0,f=1,ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int INF=0x3f3f3f;

int main() {
	int k=read(),x=read();
	REP(i,1,2*k-1) printf("%d ",x-k+i);
	return 0;
}



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

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

}


Measured memory_bytes: 640
A, B, C, D, E, F = map(int, input().split())
# A *= 100
# B *= 100

max_solvent = 0
max_solute = 0
max_strength = 0.0

for na in range(0, 31):
    for nb in range(0, 31):
        for nc in range(0, 101):
            for nd in range(0, 101):

                solute = nc * C + nd * D
                solvent = 100 * na * A + 100 * nb * B

                # if not (any([na, nb]) and any([nc, nd])):
                    # continue
                if solvent == 0:
                    break

                if solute + solvent > F:
                    # print("exceeded")
                    break

                else:
                    # if (solvent/100) * E < solute:
                    if solvent/100 * E >= solute:
                    # print("exceeded2")
                    # break
                        strength = 100 * solute / (solute + solvent)
                        # print(strength, solvent+solute, solute)
                        if max_strength <= strength:
                            max_strength = strength
                            max_solute = solute
                            max_solvent = solute + solvent

print(max_solvent, max_solute)

Measured memory_bytes: 3064
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

string ntos(long long n){
  string s;
  stringstream ss;
  ss << n;
  ss >> s;
  return s;
}

int main(){
  ll n,m;
  cin>>n>>m;
  vector<pair<ll,ll> > vp;
  rep(i,0,m){
    ll a,b;
    cin>>a>>b;
    vp.pb(mp(a,b));
  }
  rep(i,0,1000){
    string s = ntos(i);
    if(s.sz!=n)continue;
    ll flag = 1;
    rep(j,0,m){
      if(s[vp[j].fi-1]-'0'!=vp[j].se)flag = 0;
    }
    if(flag==1){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
ll chmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,h;cin>>h>>n;
    vector<ll>dp(h+1,inf);
    dp[0]=0;
    rep(i,n){
        ll a,b;cin>>a>>b;
        rep(j,h+1){
            if(j+a>h)dp[h]=chmin(dp[h],dp[j]+b);
            else dp[j+a]=chmin(dp[j+a],dp[j]+b);
        }
    }
    cout<<dp[h]<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int n;
    cin >> n;
    int ans[n];
    rep(i, n) {
        ans[i] = 0;
    }
    rep(i, n - 1) {
        int enter;
        cin >> enter;
        ans[enter - 1]++;
    }
    rep(i, n) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5196
#include <iostream>
#include <math.h>

int main()
{
	int K, S;
	int count = 0;

	std::cin >> K >> S;

	
	for (int i = 0; i <= K; i++) {
		for (int j = 0; j <= K; j++) {
			int z = S - i - j;
				if (0 <= z and z <= K)
					count++;
			
		}
	}
	std::cout << count << std::endl;

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool aoki_flg = false;
    while(1) {
        if ( aoki_flg ) {
            a -= d;
        } 
        else {
            c -= b;
        }
        if ( a <= 0 ) {
            cout << "No" << endl;
            return 0;
        }
        else if ( c <= 0 ) {
            cout << "Yes" << endl;
            return 0;
        }
        aoki_flg = !aoki_flg;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void) {
	int x;
	int yakusimaru_hiroko;
	if (scanf("%d", &x) != 1) return 1;
	fputs("ai1333", stdout);
	for (yakusimaru_hiroko = 0; yakusimaru_hiroko + 100 <= x; yakusimaru_hiroko += 100) {
		putchar('3');
	}
	putchar('\n');
	return 0;
}



Measured memory_bytes: 2140