akhauriyash/Code-Regression huggingface dataset:
#include <bits/extc++.h>

struct random : std::mt19937 {
  using std::mt19937::mt19937;
  using std::mt19937::operator();

  static int64_t gen_seed() {
    return std::chrono::steady_clock::now().time_since_epoch().count();
  }

  random() : std::mt19937(gen_seed()) {}

  template <class Int>
  auto operator()(Int a, Int b)
      -> std::enable_if_t<std::is_integral_v<Int>, Int> {
    return std::uniform_int_distribution<Int>(a, b)(*this);
  }
  template <class Real>
  auto operator()(Real a, Real b)
      -> std::enable_if_t<std::is_floating_point_v<Real>, Real> {
    return std::uniform_real_distribution<Real>(a, b)(*this);
  }
} rng;

int main() {
  using namespace std;
  cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n), b(n), ca(n + 1), cb(n + 1);
  for (auto&& e : a) cin >> e, ++ca[e];
  for (auto&& e : b) cin >> e, ++cb[e];
  for (int x = 1; x <= n; ++x)
    if (ca[x] + cb[x] > n) {
      cout << "No\n";
      exit(0);
    }
  cout << "Yes\n";
  vector<int> order(n);
  iota(begin(order), end(order), 1);
  sort(begin(order), end(order),
       [&](int x, int y) { return ca[x] + cb[x] > ca[y] + cb[y]; });
  vector<int> res(n);
  auto comp = [&](int i, int j) {
    int x = a[i], y = a[j];
    return pair{ca[x] + cb[x], -i} > pair{ca[y] + cb[y], -j};
  };
  vector<vector<int>> idx(n + 1);
  for (int i = 0; i < n; ++i) idx[a[i]].push_back(i);
  while (true) {
    int y = -1;
    [&] {
      set<int, decltype(comp)> se(comp);
      for (int i = 0; i < n; ++i) se.insert(i);
      for (int x : order) {
        vector<int> erased;
        for (int i : idx[x])
          if (se.count(i)) {
            se.erase(i);
            erased.push_back(i);
          }
        for (int _ = cb[x]; _--;) {
          if (empty(se)) {
            y = x;
            return;
          }
          auto it = begin(se);
          res[*it] = x;
          se.erase(it);
        }
        for (int i : erased) se.insert(i);
      }
      for (int i = 0; i < n; ++i) cout << res[i] << " \n"[i == n - 1];
      exit(0);
    }();
    shuffle(begin(order), end(order), rng);
    // swap(order.front(), *find(begin(order), end(order), y));
  }
}


Measured memory_bytes: 28584
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void solve(){
 	string s;
 	cin>>s;
 	if(s=="ARC")cout<<"ABC";
 	else cout<<"ARC";
    
}

int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

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

int n, k;
double sum;
int main() {
	int i, j, c;
	cin>>n>>k;
	for(i=1; i<=n; i++) {
		for(j=i, c=1; j<k; j*=2, c*=2);
		sum += 1./c;
	}
	printf("%.10f", sum / n);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
long long n, m;
long long a[1000], b[1000];
int aa[1000], bb[1000];
long long p = 1000000007;
long long l, r;
long long ans = 1;
int main() {
	scanf("%lld%lld", &n, &m);
	for (int i = 0; i < n; i++)scanf("%lld", a + i);
	for (int i = 0; i < m; i++)scanf("%lld", b + i);
	std::sort(a, a + n);
	std::sort(b, b + m);
	if (a[n - 1] != n * m || b[m - 1] != n * m) {
		printf("0\n");
		return 0;
	}
	l = n - 1; r = m - 1;
	for (long long i = n * m; i > 0; i--) {
		while (l > 0 && a[l - 1] >= i)l--;
		while (r > 0 && b[r - 1] >= i)r--;
		if ((n - l)*(m - r) <= (n*m - i))ans = 0;
		if (a[l] == i && b[r] == i) {
			aa[l]++;
			bb[r]++;
		}
		else {
			if (a[l] == i) {
				aa[l]++;
				ans *= m - r;
				ans %= p;
				
			}
			if (b[r] == i) {
				bb[r]++;
				ans *= n - l;
				ans %= p;
			}
			if (a[l] > i && b[r] > i) {
				ans *= (n - l)*(m - r) - (n*m - i);
				ans %= p;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (aa[i] == 0) {
			printf("0\n");
			return 0;
		}
	}
	for (int i = 0; i < m; i++) {
		if (bb[i] == 0) {
			printf("0\n");
			return 0;
		}
	}
	printf("%lld\n", ans%p);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

bool solve(vector<int> a) {
  sort(all(a));
  int n = (int)a.size();
  auto mini = a.front();
  auto maxi = a.back();
  if (maxi - mini >= 2) {
    return false;
  }
  if (maxi == mini) {
    if (maxi + 1 == n || 2 * maxi <= n) {
      return true;
    }
    return false;
  }

  int cnt = 0;
  rep(i, n)if (a[0] == a[i])cnt++; else break;

  if (cnt == mini) {
    return (n - cnt >= 2);
  }
  if (cnt < mini) {
    return 2 * (maxi - cnt) <= (n - cnt);
  }
  if (cnt != 1) {
    return false;
  }

  if (2 * mini <= n - 1) {
    return true;
  }
  return false;
}


void Calc() {

  int n = in;
  auto a = in.Array(n);

  if (solve(a)) cout << ("Yes") << endl;
  else cout << ("No") << endl;
}


Measured memory_bytes: 1024
import statistics as st

n = int(input())
ab = []

for i in range(n):
  ab.append(list(map(int, input().split())))

temp = []
temp2 = []
for i in range(len(ab)):
  temp.append(ab[i][0])
  temp2.append(ab[i][1])
  
min = st.median(temp)
max = st.median(temp2)

if n % 2 == 0:
  print(int((max-min)/0.5)+1)
else:
  print(int(max-min)+1)

Measured memory_bytes: 52616
from _collections import deque


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
#https://atcoder.jp/contests/arc081/tasks/arc081_b
#D - Coloring Dominoes
"""
need to consider the case that ticket is not enough to lower everything
"""

N = gi()
S1 = gw()
S2 = gw()

i = 1
ans = 3

if (N > 1 and S1[0] == S1[1]):
    i = 2
    ans = 6

while i < N:
    isV = S1[i - 1] == S2[i - 1]
    if S1[i] == S2[i]:
        if isV:
            ans *= 2
            ans %= MOD
        i += 1
    else:
        if isV:
            ans *= 2
        else:
            ans *= 3
        ans %= MOD
        i += 2

print(ans)


Measured memory_bytes: 12516
import sys

# O(k)
def binomial_p(n, k, p):
    # k >= 0ならOK
    k = min(k, n - k)
    numer = 1
    denom = 1
    for i in range(k):
        numer = numer * (n - i) % p
        denom = denom * (k - i) % p
    return numer * pow(denom, p - 2, p) % p

S = int(input())
p = 10 ** 9 + 7

if S <= 2:
    print(0)
    sys.exit(0)

ans = 0
for i in range(1, S // 3 + 1):
    ans = (ans + binomial_p(S - 2 * i - 1, i - 1, p)) % p

print(ans)

Measured memory_bytes: 9200
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>

#define repd(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define rep(i,n) repd((i),0,(n))
typedef long long ll;

using namespace std;

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template <typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}
bool pairCompare(const pair<int,int>& firstElof,const pair<int,int>& secondElof){
	return firstElof.second > secondElof.second;
}


int main(){
	int n;
	cin >> n;
	vector<int> v_even;
	vector<int> v_odd;
	rep(i,n){
		int temp;
		cin >> temp;
		if(i%2==0){
			v_even.push_back(temp);
		}else{
			v_odd.push_back(temp);
		}
	}
	map<int,int> even_map,odd_map;
	vector<int> even_key,odd_key;

	rep(i,v_even.size()){
		if(even_map[v_even[i]]==0){
			even_map[v_even[i]]=1;
			even_key.push_back(v_even[i]);
		}else{
			even_map[v_even[i]]++;
		}
	}
	rep(i,v_odd.size()){
		if(odd_map[v_odd[i]]==0){
			odd_map[v_odd[i]]=1;
			odd_key.push_back(v_odd[i]);
		}else{
			odd_map[v_odd[i]]++;
		}
	}

	vector<pair<int,int>> even_pair,odd_pair;
	even_pair.push_back(make_pair(-1,0));
	odd_pair.push_back(make_pair(-1,0));

	rep(i,even_key.size()){
		even_pair.push_back(make_pair(even_key[i],even_map[even_key[i]]));
	}
	sort(even_pair.begin(),even_pair.end(),pairCompare);

	rep(i,odd_key.size()){
		odd_pair.push_back(make_pair(odd_key[i],odd_map[odd_key[i]]));
	}
	sort(odd_pair.begin(),odd_pair.end(),pairCompare);

	ll ans=0;
	if(even_pair[0].first!=odd_pair[0].first){
		ans=n-even_pair[0].second-odd_pair[0].second;
}else{
		ll temp1=n-even_pair[1].second-odd_pair[0].second;
		ll temp2=n-even_pair[0].second-odd_pair[1].second;
		ans=min(temp1,temp2);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6904
#include<iostream>
#include<algorithm>
using namespace std;
#define INF ( 1 << 30 )
int main(){
  int h, m, s, H, M, S;
  while(cin >> h >> m >> s >> H >> M >> S ){
    int tim = H * 3600 + M * 60 + S - h * 3600 - m * 60 - s;
    cout << tim / 3600 << " " << tim % 3600 / 60 << " " << tim % 60 << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main()
{
    bool chk=false;
    string A;
    cin >> A;
    sort(A.begin(),A.end());
    if((A.at(0)==A.at(1))&&(A.at(2)==A.at(3))&&(!(A.at(1)==A.at(2))))
    {
        chk=true;
    }
    if(chk)
    {
        cout << "Yes" <<endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N, K, Q = map(int, input().split())
A = tuple([int(input()) for q in range(Q)])
# N人参加、初期状態で全員がKポイント
# 誰かが正解すると、それ以外の全員が1ポイント下がる
# i番目に正解したのはAi
counts = [0 for i in range(N)]
for a in A:
  counts[a-1] += 1

for i in range(N):
  print('Yes' if (K - (Q - counts[i])) >= 1 else 'No')

Measured memory_bytes: 87636
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#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 rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main() {
  string s;
  cin >> s;
  int MOD = 1000000007;
  int N = 13;
  int len = s.length();
  int mul = 1;

  vvi dp(N, vi(len + 1, 0));
  dp[0][0] = 1;
  reverse(s.begin(), s.end());

  srep(i, 1, len + 1) {
    char c = s[i - 1];
    if(c == '?') {
      rep(k, 10) {
        rep(x, N) {
          int am = (x + k * mul) % N;
          dp[am][i] += dp[x][i - 1];
          dp[am][i] %= MOD;
        }
      }
    } else {
      int k = c - '0';
      rep(x, N) {
        int am = (x + k * mul) % N;
        dp[am][i] += dp[x][i - 1];
        dp[am][i] %= MOD;
      }
    }

    mul *= 10;
    mul %= N;
  }

  int ans = dp[5][len];
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6016
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = 200005;
typedef long long ll;
ll a[maxn]={0};
int n;
inline ll find1(ll m){
    ll ret=0;
    ll num=0;
    long double f = 1.0;
    for(int i=0;i<n;++i){
        if(a[i]<0){
            num=lower_bound(a,a+n,f*m/a[i])-a;
            num=n-num;
        }
        else if(a[i]==0){
            if(m>=0)
                num=n;
            else
                num=0;
        }
        else
            num=upper_bound(a,a+n,f*m/a[i])-a;
        ret+=num;
        if(a[i]*a[i]<=m)
            ret--;
    }
    return ret/2;
}
inline ll find2(ll m){
    ll ret=0;
    ll num=0;
    long double f = 1.0;
    for(int i=0;i<n;++i){
        if(a[i]<0)
            num=upper_bound(a,a+n,f*m/a[i])-a;
        else if(a[i]==0){
            if(m<=0)
                num=n;
            else
                num=0;
        }
        else{
            num=lower_bound(a,a+n,f*m/a[i])-a;
            num=n-num;
        }
        ret+=num;
        if(a[i]*a[i]>=m)
            --ret;
    }
    return ret/2;
}
int main()
{
    ll k;
    scanf("%d%lld",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    ll l = -1e18,r=1e18;
    ll m = (l+r)/2;
    ll ans = 0 ;
    ll ans1,ans2;
    while(l<=r){
        m=(l+r)/2;
        ans1=find1(m);
        ans2=find2(m);
        if(ans1>=k&&ans2>=(1ll*n*(n-1)/2-k+1)){
            ans = m ;
            break;
        }
        else if(ans1>=k)
            r=m-1;
        else
            l=m+1;
        
    }
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	if (n == 25) {
		cout << "Christmas\n";
		return 0;
	}
	if (n == 24) {
		cout << "Christmas Eve\n";
		return 0;
	}
	if (n == 23) {
		cout << "Christmas Eve Eve\n";
		return 0;
	}
	if (n == 22) {
		cout << "Christmas Eve Eve Eve\n";
		return 0;
	}
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String arg[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    int ans = 0;
    if(b>a){
      ans =  a*c;
    }else{
      ans = (b*c+(a-b)*d);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22228
// C - Shopping Street

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int F[100];
int P[100][11]; // P[i][j]: 店iと両方が営業している時間帯の個数がjの時の利益

int count_common_bit(int a, int b, int N) {
	int c = a & b;
	int result = 0;
	for (int i=0; i<N; i++) {
		if (c & (1<<i)) result++;
	}

	return result;
}

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

	for (int i=0; i<N; i++) {
		for (int j=0; j<10; j++) {
			int f;
			cin >> f;
			F[i] |= (f<<j);
		}
	}

	for (int i=0; i<N; i++) {
		for (int j=0; j<=10; j++) {
			cin >> P[i][j];
		}
	}

	int ans = -INF;
	for (int bit=1; bit<(1<<10); bit++) {
		int tot_P = 0;
		for (int i=0; i<N; i++) {
			int c = count_common_bit(bit, F[i], 10);
			//cout << bitset<10>(bit) << " "; // **** debug ****
			//cout << bitset<10>(F[i]) << " "; // **** debug ****
			//cout << c << " "; // **** debug ****
			//cout << P[i][c] << endl; // **** debug ****
			tot_P += P[i][c];
		}
		ans = max(ans, tot_P);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
mod = 10**9+7
dp = [defaultdict(int) for i in range(n+1)]
dp[0][x] = 1
for i in range(1,n+1):
  for j in dp[i-1].keys():
    k = j%a[i-1]
    dp[i][j] = (dp[i][j]+dp[i-1][j]*(n-i))%mod
    dp[i][k] = (dp[i][k]+dp[i-1][j])%mod
ans = 0
for i,x in dp[n].items():
  ans = (ans+i*x)%mod
print(ans)

Measured memory_bytes: 137992
#include<iostream>
using namespace std;
int n,cnt[1<<17],a,b;
void calc(int b,int xs,int fn)
{
	if(cnt[fn^((1<<n)-1)]==1) {printf("%d %d ",xs,xs^b);return;}
	for(int i=0;i<n;i++)
		if(!(fn&(1<<i))&&(b&(1<<i)))
			for(int j=0;j<n;j++)
				if(!(fn&(1<<j))&&i!=j)
				{
					calc(1<<j,xs,fn|(1<<i));
					calc(b^(1<<j)^(1<<i),xs^(1<<j)^(1<<i),fn|(1<<i));
					return;
				}
}
int main()
{
	for(int i=1;i<1<<17;i++) cnt[i]=cnt[i>>1]+(i&1);
	cin>>n>>a>>b;
	if(cnt[a^b]&1) {puts("YES");calc(a^b,a,0);puts("");}
	else puts("NO");
}


Measured memory_bytes: 1536
N,M = map(int,input().split())
edge = []
p = 'POSSIBLE'
i = 'IMPOSSIBLE'
for _ in range(M):
    edge.append(tuple(map(int,input().split())))

from1 = set()
is_reach = False
for go,to in sorted(edge,key=lambda x:x[0]):
    if go == 1:
        from1.add(to)
    else:
        if go in from1 and to == N:
            is_reach = True
            break
print(p if is_reach else i)

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

using namespace std;

struct Mo_3D
{
  vector< int > left, right, index, order;
  vector< bool > v;
  int width;
  int nl, nr, time, ptr;

  Mo_3D(int n) : width((int) pow(n, 2.0 / 3.0)), nl(0), nr(0), ptr(0), time(0), v(n) {}

  void insert(int idx, int l, int r) /* [l, r) */
  {
    left.push_back(l);
    right.push_back(r);
    index.push_back(idx);
  }

  void build()
  {
    order.resize(left.size());
    iota(begin(order), end(order), 0);
    sort(begin(order), end(order), [&](int a, int b)
    {
      if(left[a] / width != left[b] / width) return left[a] < left[b];
      if(right[a] / width != right[b] / width) return right[a] < right[b];
      return bool((index[a] < index[b]) ^ (right[a] / width % 2));
    });
  }

  int process()
  {
    if(ptr == order.size()) return (-1);
    const auto id = order[ptr];
    while(time < index[id]) addquery(time++);
    while(time > index[id]) delquery(--time);
    while(nl > left[id]) distribute(--nl);
    while(nr < right[id]) distribute(nr++);
    while(nl < left[id]) distribute(nl++);
    while(nr > right[id]) distribute(--nr);
    return (index[order[ptr++]]);
  }

  inline void distribute(int idx)
  {
    v[idx].flip();
    if(v[idx]) add(idx);
    else del(idx);
  }

  void add(int idx);

  void del(int idx);

  void addquery(int idx);

  void delquery(int idx);
};


int N, Q, A[100000], B[100000], C[100000];
int D[100000];
int ans[100000], sum;

void Mo_3D::add(int idx)
{
  sum += D[idx];
}

void Mo_3D::del(int idx)
{
  sum -= D[idx];
}

void Mo_3D::addquery(int idx)
{
  if(A[idx] == 1) return;
  if(v[B[idx]]) {
    distribute(B[idx]);
    D[B[idx]] += C[idx];
    distribute(B[idx]);
  } else {
    D[B[idx]] += C[idx];
  }
}

void Mo_3D::delquery(int idx)
{
  if(A[idx] == 1) return;
  if(v[B[idx]]) {
    distribute(B[idx]);
    D[B[idx]] -= C[idx];
    distribute(B[idx]);
  } else {
    D[B[idx]] -= C[idx];
  }
}

int main()
{

  scanf("%d %d", &N, &Q);

  Mo_3D mo(N);
  for(int i = 0; i < Q; i++) {
    scanf("%d %d %d", &A[i], &B[i], &C[i]);
    --B[i];
    if(A[i] == 1) mo.insert(i, B[i], C[i]);
  }

  mo.build();

  int idx;
  while((idx = mo.process()) != -1) {
    ans[idx] = sum;
  }

  for(int i = 0; i < Q; i++) {
    if(A[i] == 1) printf("%d\n", ans[i]);
  }

}

Measured memory_bytes: 5908
import bisect
a, b, q = map(int, input().split())
s = []
for i in range(a):
    s.append(int(input()))
t = []
for j in range(b):
    t.append(int(input()))
inf = 10 ** 18
s = [-inf] + s + [inf]
t = [-inf] + t + [inf]
for k in range(q):
    x = int(input())
    s_r, t_r = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = inf
    for s_ in [s[s_r], s[s_r - 1]]:
        for t_ in [t[t_r], t[t_r - 1]]:
            d = min(abs(x-s_), abs(x-t_)) + abs(s_ - t_)
            res = min(d, res)
    print(res)

Measured memory_bytes: 12776
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>v(n);
  rep(i,n){
    cin>>v.at(i);
  }
  sort(all(v),greater<int>());
  int a=0,b=0;
  
  rep(i,n-1){
    if(v.at(i)==v.at(i+1)){
      if(a==0){
        a=v.at(i);
        i++;
        continue;
       }
      else{
        b=v.at(i);
        break;
      }
    }
  }
  
  cout<<(ll)a*b;
}


Measured memory_bytes: 640
using System;
class main
{
    static void Main(string[] args)
    {
            string s = Console.ReadLine();
            if (s != null)
            {
                int n = int.Parse(s);
                for (int i = 1; i <= n; ++i)
                {
                string s2 = Console.ReadLine();

                    if (s2 != null)
                    {
                        string[] t = s2.Split(' ');
                        int[] a = new int[3];
                        a[0] = int.Parse(t[0]);
                        a[1] = int.Parse(t[1]);
                        a[2] = int.Parse(t[2]);

                        Array.Sort(a);
                        if ((a[2] * a[2]) == (a[1] * a[1] + a[0] * a[0]))
                        {
                            Console.WriteLine("YES");
                        }
                        else
                        {
                            Console.WriteLine("NO");
                        }
                    }
                }
            }
        //Console.ReadKey();
    }
}

Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int red = 0;
  rep(i,n){
    if(s[i] == 'R')red++;
  }

  int cnt = 0;
  rep(i,red){
    if(s[i] == 'R')cnt++;
  }
  ll ans = min(red-cnt,red);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3720
#include<stdio.h>

int main(void){

    int N = 0;
	int i;
	int cntr = 0;
	
	scanf("%d", &N);
	if(N<10000 && N>999){	
	    do{
			if(N % 10 == 2){
				cntr++;
			}
			N /= 10;
		}while(N > 0);
		
	    printf("%d\n", cntr);
		
		return 0;
	}
}

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

using namespace std;

using ll = long long;

ll dfs(string &S, vector<vector<ll>>& memo, int n, bool carry) {
  int d = S[n] - '0';
  if (n == S.length() - 1) {
    if (carry) {
      return 10 - d;
    } else {
      return d;
    }
  }

  int p = carry ? 1 : 0;

  if (memo[n][p] < 0) {
    if (carry) {
      d = 10 - d;
      memo[n][p] = min(
          (d - 1) + dfs(S, memo, n + 1, true),
          d + dfs(S, memo, n + 1, false)
      );
    } else {
      memo[n][p] = min(
          d + 1 + dfs(S, memo, n + 1, true),
          d + dfs(S, memo, n + 1, false)
      );
    }
  }

  return memo[n][p];
}

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

  vector<vector<ll>> memo(S.length(), vector<ll>(2, -1));
  ll ans = min(1 + dfs(S, memo, 0, true), dfs(S, memo, 0, false));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 134020
import sys
input = sys.stdin.readline

N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()
now = 0
ans = 0

while now<N:
    ans += 1
    lim = T[now]+K
    
    for _ in range(C):
        if T[now]<=lim:
            now += 1
        else:
            break
        
        if now==N:
            break

print(ans)

Measured memory_bytes: 43996
#include <stdio.h>

int main(void)
{
  char str1[3], str2[3], str3[3];
  
  scanf("%s", str1);
  scanf("%s", str2);
  scanf("%s", str3);
  
  printf("%c%c%c", str1[0], str2[1], str3[2]);
  
  return 0;
}

Measured memory_bytes: 128
n,k = map(int, input().split())
p = list(map(int, input().split()))
m = max(p)
h = [0]*(m+1)
h[1] = 1
for i in range(1,m):
    h[i+1] = h[i]+0.5
ans = sum = 0
for i in range(n):
    if i>=k:
        sum = sum-h[p[i-k]]+h[p[i]]
        if ans<sum: ans=sum
    else:
        sum += h[p[i]]
        if i==k-1: ans=sum
print(ans)

Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    char r, g, b;
    cin >> r >> g >> b;
    string s;
    s += r;
    s += g;
    s += b;
    int n = stoi(s);
    if(n%4 == 0)
        cout << "YES\n";
    else
        cout << "NO\n";

    return 0;
}


Measured memory_bytes: 256
def f(n):
    mx = 0
    dp = [0] * (n * 10 ** 4 + 1)
    bs = [list(map(int, input().split())) for _ in range(n)]
    bs.sort(key=lambda x: x[0] + x[1])
    for w, s, v in bs:
        for i in range(w + s, w - 1, -1):
            dpw = dp[i - w] + v
            if dpw > dp[i]:
                dp[i] = dpw
                if dpw > mx:
                    mx = dpw
    print(mx)


n = int(input())
f(n)


Measured memory_bytes: 82036
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    int n;
    cin >> n;
    struct DATA
    {
        int c, s, f;
        DATA(int c = 0, int s = 0 ,int f = 0):c(c), s(s), f(f){}
    };
    vector<DATA> X(n);
    rep(i, n-1){
        int c, s, f;
        cin >> c >> s >> f;
        X[i].c = c;
        X[i].f = f;
        X[i].s = s;
    }
    vi cost(n, 0);
    rep(i, n-1){
        cost[i] += X[i].c + X[i].s;
        rep2(j, i+1, n-1){
            if(cost[i] < X[j].s){
                cost[i]  = X[j].s;
            }else{
                int r = cost[i]%X[j].f;
                if(r != 0){
                    int m = cost[i]/X[j].f;
                    cost[i] = X[j].f*(m+1);
                }
            }
            cost[i] += X[j].c;
        }
    }
    rep(i, n){
        cout << cost[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3504
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sync ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD  1000000007 
#define lld long long
lld powm(lld base,lld exp,lld mod=MOD) {lld ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
int32_t main()
{
	int a,b;
	cin>>a>>b;
	int ans=INT_MIN;
	ans=max(a+b,max(a-b,a*b));
	cout<<ans<<endl;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  
  vector<int>price(N);
  
  for(int i = 0; i< N; i++){
    cin >> price.at(i);
  }
  sort(price.begin(), price.end());
  
  int C;
  C = 0;
  
  for(int i =0; i<K; i++){
    C += price.at(i);
  }
  
  cout << C << endl;
    
}

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

int main()
{
    int a[5];
    int n = 5;
    for(int i = 0; i < n; i++) cin >> a[i];
    int k;
    cin >> k;
    for(int i = 0; i < n; i++)
    {
        for(int j = i+1; j < n; j++)
        {
            if(a[j] - a[i] > k)
            {
                cout << ":(\n";
                return 0;
            }
        }
    }

    cout << "Yay!\n";
    return 0;
}


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

int main()
{
    int A, B, f = 1, i = 0; 
    cin >> A >> B;
    while(f < B)
    {
        f += A - 1;
        i++;
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ABC_081_B
		Scanner sc = new Scanner(System.in);
		int ret = 0;

		int N = sc.nextInt();
		int[] A = new int[N];
		int i = 0;
		boolean flag = true;

		for(i=0; i<N; i++) {
			A[i] = sc.nextInt();
		}
	    // Scannerクラスのインスタンスをクローズ
		sc.close();

		while(flag) {
			for(i=0; i<N; i++) {
				if(A[i] % 2 == 1) {
					flag = false;
					break;
				} else {
					A[i] = A[i] / 2;
					if(i == N-1) {
						ret++;
					}
				}
			}
		}

		System.out.println(ret);
	}

}


Measured memory_bytes: 36220
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

template<typename T>
bool chmax(T &a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T &a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    priority_queue<int> que;

    string m;
    while(cin >> m, m != "end"){
        if(m == "insert"){
            int k;
            cin >> k;
            que.push(k);
        }else if(m == "extract"){
            cout << que.top() << endl;
            que.pop();
        }
    }

    return 0;
}


Measured memory_bytes: 7156
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define int long long
#define lb long double
#define  maxn 200005
#define pb push_back
#define forup(i,a,b) for(int i=(a);i<=(b);i++)  
#define fordown(i,a,b) for(int i=(a);i>=(b);i--)
int n,m,d;//nÖµÓò£¬m³¤¶È£¬d¾ø¶ÔÖµ²î 
void work1()
{
 int  k=n-d;
 int  ans=2*(m-1)*(k);
  lb tmp=(lb)ans/(n*n);
  printf("%.8Lf",tmp);
// cout<<(lb)ans/(n*n);
}
void work2()
{ int k=n;
  int ans=(m-1)*(k);
  cout<<ans/(lb)(n*n);
}
signed main()
{cin>>n>>m>>d;
if(d!=0)
  work1();
else
  work2();

  return 0;
}

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

int main(){
  int input;
  int counter = 1;
  bool flag = true;

  while(flag){
    cin >> input;
    if(input != 0){
      cout << "Case " << counter << ": " << input << "\n";
      counter++;
    }
    else{
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  int offset = 0;
  bool ok = true;
  for(int i = 'a';'z' >= i; i++){
    if(s[offset] == NULL){
      cout << (char)i << endl;
      ok = false;
      break;
    }
    if(i == s[offset]){
      offset++;
      continue;
    }else if(i > s[offset]){
      i--;offset++;
    }else{
      cout << (char)i << endl;
      ok = false;
      break;
    }
  }
  if(ok)cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int , int>
#define fast ios_base::sync_with_stdio(0)
#define mx 100005
int arr[102],n,k;
int dp[mx] = {0};
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=0; i<n; i++) scanf("%d",&arr[i]);
    sort(arr, arr+n);
    dp[0] = 0;
    for(int i=1; i<=k; i++){
        int win = 0;
        for(int j=0; j<n; j++){
            int mov = i - arr[j];
            if(mov>=0 && dp[mov]==0)
                win = 1;
            if(arr[j]==i) win = 1;
        }
        dp[i] = win;
    }
    if(dp[k]) printf("First\n");
    else printf("Second\n");
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool t[1000000]={};
int n=1000000;
int teck(int x){
	int counta=2;
	while(x>counta){
		if(!t[counta]){
			//cout<<counta<<endl;
			int countb=counta;
			while(n>countb){
				//cout<<countb<<" ";
				t[countb]=true;
				countb+=counta;
			}
		}
		counta++;
	}
	int k=x;
	while(t[k]){
		k++;
		//cout<<k<<" ";
		if(k>n){
			return 0;
		}
	}
	return k;
}	
				

int main(){
	int x;
	cin>>x;
	cout<<teck(x)<<endl;
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
#define inf (ll)1e9

#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x, i, j) cerr << #x << "------------" << "\n";cerr << "from " << i << " to " << j << "\n";for(ll k=i; k<=j; k++) cerr << x[k] << " ";cerr << "\n"; cerr.flush();

#define MAXN 100010

vi edges[MAXN];
vi costs[MAXN];

int color[MAXN];
int parent[MAXN];

void dfs(int node, int col){
	color[node] = col;
	for(int i= 0; i<edges[node].size(); i++){
		if(edges[node][i] != parent[node]){
			parent[edges[node][i]] = node;
			if(costs[node][i] %2 == 0){
				dfs(edges[node][i], col);
			}
			else{
				dfs(edges[node][i], col ^ 1);
			}
		}
	}
}

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

	int n;
	cin >> n;
	for(int i=0; i<n-1; i++){
		int u, v, c;
		cin >> u >> v >> c;
		edges[u].push_back(v);
		edges[v].push_back(u);
		costs[u].push_back(c);
		costs[v].push_back(c);
	}	

	dfs(1, 0);
	for(int i=1; i<=n; i++){
		cout << color[i] << "\n";
	}
	return 0;
}


Measured memory_bytes: 15616
<?php

$inp = trim( fgets( STDIN ) );
$str_len = strlen( $inp );
$str_i = 0;
$ans_i = 0;
$ans = [];

while( $str_i < $str_len ) {
  if ( $inp[$str_i] === 'B' ) {
    $ans_i = $ans_i < 0 ? 0 : $ans_i - 1;
    $ans[$ans_i] = '';
  } else {
    $ans[$ans_i] = $inp[$str_i];
    $ans_i++;
  }
  $str_i++;
}

echo implode( '', $ans );

?>

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

int N;
int A[1000000];
const long long mod = 1e9 + 7;
int num_cnt[100000], sub_num_cnt[100000];

int main(){
    long long ret = 1;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        num_cnt[A[i]]++;
        sub_num_cnt[A[i]]++;
        if(num_cnt[A[i]] > 3){
            ret *= 0;
        }
        if(A[i] > 0){
            ret *= sub_num_cnt[A[i] - 1];
            sub_num_cnt[A[i] - 1]--;
            ret %= mod;
        }
    }

    if(num_cnt[0] >= 2 && num_cnt[0] <= 3){
        ret *= 6;
        ret %= mod;
    }else if(num_cnt[0] == 1){
        ret *= 3;
        ret %= mod;
    }

    cout << ret << endl;
}

Measured memory_bytes: 1408
import java.util.*;


class Main {
    public static void main(String[] args) {
   		Scanner sc=new Scanner(System.in);
   		String str=sc.next();
   		int num=0;
   		for(int i=0;i<str.length();i++){
   			num+=Character.getNumericValue(str.charAt(i));
   		}
   		if(Integer.parseInt(str)%num==0)System.out.println("Yes");
   		else System.out.println("No");
   		sc.close();
    }
}

Measured memory_bytes: 35592
N = int(input())
A = list(map(int, input().split()))

count = 0
for item in A:
  if item % 2 == 0:
    if item % 3 == 0 or item % 5 == 0:
      count += 1
  else:
    count += 1

if count == N:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 8876
using System;
class quizgames{
  public static void Main(){
    String[] str = Console.ReadLine().Split(' ');
    int n = int.Parse(str[0]);
    int k = int.Parse(str[1]);
    int q = int.Parse(str[2]);
    int[] count = new int[n];
    for(int i=0; i<q; i++){
      count[int.Parse(Console.ReadLine())-1]++;
    }
    for(int i=0; i<n; i++){
      if(q-count[i] >= k){
        Console.WriteLine("No");
      }
      else{
        Console.WriteLine("Yes");
      }
    }
  }
}


Measured memory_bytes: 15708
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize
    }

    let factor = factor_table(n);
    let mut ans = 1usize;
    for i in 2..=n {
        let mut i2 = i;
        let mut res = 1;
        let mut prev = 1;
        let mut count = 0;
        while i2 != 1 {
            let f = factor[i2];
            if f != prev {
                res *= count + 1;
                count = 1;
                prev = f;
            } else {
                count += 1;
            }
            i2 /= f;
        }
        res *= count + 1;
        ans += i * res;
    }
    println!("{}", ans);
}

#[allow(dead_code)]
pub fn factor_table(max_n: usize) -> Vec<usize> {
    let mut res = vec![0; max_n + 1];
    for i in 2..max_n + 1 {
        if res[i] == 0 {
            let mut j = i;
            while j <= max_n {
                res[j] = i;
                j += i;
            }
        }
    }
    res
}


Measured memory_bytes: 80196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX = 100;

int H, W, N;
int a[MX*MX];
int grid[MX][MX];
int color = 1;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> H >> W >> N;
	for (int i = 0; i < N; i++) cin >> a[i];
	
	for (int i = 0; i < H; i++) {
		if (i % 2 == 0) {
			for (int j = 0; j < W; j++) {
				if (a[color - 1] > 0) {
					grid[i][j] = color;
					a[color - 1]--;
				} else {
					color++;
					grid[i][j] = color;
					a[color - 1]--;
				}
				// cout << i << " " << j << " " << color << "\n";
			}
		} else {
			for (int j = W - 1; j >= 0; --j) {
				if (a[color - 1] > 0) {
					grid[i][j] = color;
					a[color - 1]--;
				} else {
					color++;
					grid[i][j] = color;
					a[color - 1]--;
				}					
			}
		}
	}
	
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << grid[i][j] << " ";
		}
		cout << "\n";
	}
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, x;
	cin >> n >> x;

	vector<int> mi(n);
	int sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> mi[i];
		sum += mi[i];
	}

	int least = *min_element(mi.begin(), mi.end());
	cout << n + (x - sum) / least << "\n";

	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
int main() {
	double N;
	cin >> N;
	int n = (int)N;
	double odd = ((N+1)/2)/ N;
	
	if (n == 1)cout << "1.0000000000";
	else
	
	if (n % 2 == 0)cout <<"0.5000000000";

	else cout << setprecision(12) << odd;

	
}

Measured memory_bytes: 256
def solve():

    N = int(input())
    A = list(map(int, input().split()))

    Odd = 0

    for i in range(N):
        if A[i]%2 == 1:
            Odd += 1

    if Odd%2 == 0:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    solve()


Measured memory_bytes: 19972
#include<iostream>
#include<cstdio>
#include<string>
int main(){

    int a,b,c,result;
    std::string op;
   // int op;

    for(c=1;;c++){

    std::cin>>a>>op>>b;

        result=0;

        if(op=="?") break;
        if(op=="+") result=a+b;
        if(op=="-") result=a-b;
        if(op=="*") result=a*b;
        if(op=="/") result=a/b;
        
        printf("%d\n",result);

    }

    return 0;

}


Measured memory_bytes: 3288
using System;
public class Hello{
    public static void Main(){
        string s = Console.ReadLine();
        string t = Console.ReadLine();
        
        if(s.Length > t.Length){
            Console.WriteLine("GREATER");
        }else if(s.Length < t.Length){
            Console.WriteLine("LESS");
        }else{
            for(var i = 0;i < s.Length;i++){
                if(s[i] > t[i]){
                    Console.WriteLine("GREATER");
                    return;
                }else if(s[i] < t[i]){
                    Console.WriteLine("LESS");
                    return;
                }else{
                    
                }
            }
            Console.WriteLine("EQUAL");
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint INF = 1e18;

signed main(){
  string s, t; cin >> s >> t;
  lint N = s.size(), M = t.size();
  vector<vector<lint> > dp(N + 1, vector<lint> (M + 1, 0));
  for(lint i = 0; i < N; i++){
    for(lint j = 0; j < M; j++){
      if(s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] +1;
      else dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
    }
  }
  string ans = "";
  lint i = N, j = M;
    while (i > 0 && j > 0){
      if (dp[i][j] == dp[i - 1][j]) i--; 
      else if (dp[i][j] == dp[i][j - 1]) j--;
      else ans = s[i - 1] + ans, i--, j--; 
    }
  cout << ans << endl;
}


Measured memory_bytes: 70784
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int M,N;
char a[60][60],b[60][60];
void solve(){
  int i=0,ii=0;
  bool f=true;
  while(i+M<=N){
    ii=0;
    while(ii+M<=N){
      f=true;
      rep(j,M){
	rep(k,M){
	  if(a[j+i][k+ii]!=b[j][k]) f=false;
	}
      }
      if(f){
	prin("Yes");
	return ;
      }
      ii++;
    }
    i++;
  }
  prin("No");
  return ;
}
int main(){
  cin>>N>>M;
  rep(i,N){
    rep(j,N){
      cin>>a[i][j];
    }
  }
  rep(i,M){
    rep(j,M){
      cin>>b[i][j];
    }
  }
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		System.out.println(S.replaceAll(",", " "));
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Pair {
		private int key;
		private int value;

		public Pair(int key, int value) {
			super();
			this.key = key;
			this.value = value;
		}

		public int getKey() {
			return key;
		}

		public int getValue() {
			return value;
		}

		public void setValue(int value) {
			this.value = value;
		}

		@Override
		public String toString() {
			return "{" + key + ", " + value + "}";
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


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

int main() {
  int A = 0;
  cin >> A;
  A = A % 10;
  if(A == 2 || A  == 4 || A == 5 || A == 7 || A == 9){
    cout << "hon";
  }
  if(A == 0 || A == 1 || A == 6 || A == 8){
  cout << "pon";
  }
  if(A == 3){
    cout << "bon";
  }
}

Measured memory_bytes: 3624
n = int(input())
arr = list(map(int, input().split()))

cost = [0]*n

cost[0] = 0
cost[1] = abs(arr[1]-arr[0])
for i in range(2, n):
  cost[i] = min(cost[i-1] + abs(arr[i] - arr[i-1]), cost[i-2] + abs(arr[i] - arr[i-2]))
  
print(cost[-1])

Measured memory_bytes: 20636