akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cout << v << " ";                                                          \
  }                                                                            \
  cout << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int A, B;
  cin >> A >> B;
  vec< vec< char > > T(100, vec< char >(100, '.'));
  REP(i, 50) {
    REP(j, 100) { T[i][j] = '#'; }
  }
  A--, B--;

  REP(i, A) {
    int x = i % 50;
    int y = i / 50;
    T[y * 2][2 * x] = '.';
  }
  REP(i, B) {
    int x = i % 50;
    int y = i / 50;
    T[51 + y * 2][2 * x] = '#';
  }
  cout << 100 << " " << 100 << "\n";
  REP(i, 100) {
    REP(j, 100) { cout << T[i][j]; }
    cout << "\n";
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>

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

using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) {
        int ai;
        cin >> ai;
        --ai;
        a[i] = ai;
    }
    rep(i, n) cin >> b[i];
    rep(i, n-1) cin >> c[i];

    int ans = 0;

    rep(i, n) {
        int ai;
        ai = a[i];
        ans += b[ai];
        if (ai+1 == a[i+1]) ans+=c[ai];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
l = [int(x) for x in input().split()]
MOD = 1000000007
ans = 0
for d in range(60):
    ones = 0
    for a in l:
        if a >> d & 1:
            ones += 1
    zeroes = n - ones
    ans += pow(2, d, MOD) * ones % MOD * zeroes % MOD
    ans %= MOD
print(ans)


Measured memory_bytes: 122808
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

const ll MOD=1e9+7;

const int SIZE=1e6;

ll powm(ll x,ll k){
    ll res=1;
    while(k){
        if(k&1) res=res*x%MOD;
        k>>=1;
        x=x*x%MOD;
    }
    return res;
}
ll inv(ll x){
    return powm(x,MOD-2);
}
ll fact[SIZE];
ll invFact[SIZE];
void init(){
    fact[0]=1;
    for(int i=1;i<SIZE;i++){
        fact[i]=fact[i-1]*i%MOD;
    }
    invFact[SIZE-1]=inv(fact[SIZE-1]);
    for(int i=SIZE-2;i>=0;i--){
        invFact[i]=invFact[i+1]*(i+1)%MOD;
    }
}

ll comb(int n,int k){
    return fact[n]*invFact[k]%MOD*invFact[n-k]%MOD;
}
int main(){
    init();
    int n,m,l,r;
    cin>>n>>m>>l>>r;

    vector<ll> A(r+1);
    for(int i=0;i<=n-m;i++){
        for(int v=0;;v++){
            ll x=ll(v+1)*i+(v+1)*m;
            if(x>r) break;
            ll sig=(i%2==0 ? 1 : -1);
            A[x]+=sig*comb(n-m,i);
            A[x]%=MOD;
        }
    }
    for(int i=0;i<=n-m;i++){
        for(int v=0;;v++){
            ll x=ll(v)*i+(v+1)*m;
            if(x>r) break;
            ll sig=(i%2==0 ? 1 : -1);
            A[x]-=sig*comb(n-m,i);
            A[x]%=MOD;
        }
    }

    vector<ll> B(r+1);
    for(int i=0;i<=r;i++){
        B[i]=comb(n,m)*comb(i+n,n)%MOD;
    }
    
    ll res=0;
    for(int i=0 ;i<=r;i++){
        res+=A[i]*B[r-i]%MOD;
        res%=MOD;
    }
    for(int i=0;i<=l-1;i++){
        res-=A[i]*B[l-1-i]%MOD;
        res%=MOD;
    }
    ll sum=comb(r+n,n)-(l ? comb(l-1+n,n) : 0LL);
    res=sum-res;

    cout<<(res%MOD+MOD)%MOD<<endl;

    
    
    return 0;
}


Measured memory_bytes: 20608
x1,y1,x2,y2 = map(int, input().split())

dx = x2 - x1
dy = y2 - y1

x3 = x2 - dy
y3 = y2 + dx

x4 = x3 - dx
y4 = y3 - dy

print(x3,y3,x4,y4)

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

using namespace std;

const int MX = 5005;

int n;
char str[MX], tar[MX];

void input()
{
	scanf("%d", &n);
	scanf("%s", str+1);
	scanf("%s", tar+1);
}

vector<int> get_seq(char *s)
{
	vector<int> ret;
	for(int i=1; i<=n+1; i++)
		if(s[i] != s[i-1])
			ret.push_back(i);
	return ret;
}

int calc(vector<int> a, vector<int> b)
{
	int ret = 0;
	for(int i=1; i<=a.size()||i<=b.size(); i++)
	{
		int va = (i>a.size()) ? 1 : a[a.size()-i];
		int vb = (i>b.size()) ? 1 : b[b.size()-i];
		ret += abs(va-vb);
	}
	return ret;
}

void work()
{
	int ans = 1e9;
	vector<int> s0 = get_seq(str), t0 = get_seq(tar), s, t;
	for(int i=(str[n]!=tar[n]); i<=s0.size(); i+=2)
	{
		s = s0, t = t0;
		for(int j=1; j<=i; j++) s.push_back(n+1);
		ans = min(calc(s, t), ans);

		s = s0, t = t0;
		int tmp = 0;
		for(int j=1; j<=i; j++) tmp += abs(n+1-s.back()), s.pop_back();
		ans = min(calc(s, t)+tmp, ans);
	}
	printf("%d\n", ans);
}

int main()
{
	input();
	work();
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
int p=2000,j=2000,pa,ja,i,sum;
for(i=0;i<3;i++){
scanf("%d\n",&pa);
if(p>pa) p = pa;
}
for(i=0;i<2;i++){
scanf("%d\n",&ja);
if(j>ja) j = ja;
}
sum = p + j - 50;
printf("%d\n",sum);
return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
using namespace std;

int main(){
    int N,p=pow(10,9)+7;
    cin>>N;
    int dp[110][10];

    //初期化
    dp[3][0]=4;dp[3][1]=4;dp[3][2]=3;dp[3][3]=1;dp[3][4]=1;
    dp[3][5]=1;dp[3][6]=4;dp[3][7]=12;dp[3][8]=9;dp[3][9]=22;

    for(int i=4;i<=N;++i){
        dp[i][0]=(dp[i-1][1]+dp[i-1][7])%p;
        dp[i][1]=(((dp[i-1][0]+dp[i-1][3])%p+dp[i-1][5])%p+dp[i-1][8])%p;
        dp[i][2]=dp[i-1][7];
        dp[i][3]=dp[i-1][0];
        dp[i][4]=dp[i-1][0];
        dp[i][5]=dp[i-1][6];
        dp[i][6]=(dp[i-1][1]+dp[i-1][7])%p;
        dp[i][7]=(((((dp[i-1][1]+dp[i-1][2])%p+dp[i-1][4])%p+dp[i-1][6])%p+dp[i-1][7])%p+dp[i-1][9])%p;
        dp[i][8]=((((dp[i-1][3]+dp[i-1][4])%p+dp[i-1][5])%p+dp[i-1][8])%p+dp[i-1][9])%p;
        dp[i][9]=((((((((((dp[i-1][2]+dp[i-1][2])%p+dp[i-1][3])%p+dp[i-1][4])%p+dp[i-1][5])%p
                      +dp[i-1][6])%p+dp[i-1][6])%p+dp[i-1][8])%p+dp[i-1][8])%p+dp[i-1][9])%p+dp[i-1][9])%p;
    }
    
    int ans=0;
    for(int i=0;i<=9;++i){
        ans+=dp[N][i];
        ans=ans%p;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

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

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

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 1001002003004005006ll;
const ll INF = 1001001001;
const double pi = acos(-1);

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int MIN = 0;
    for (int i = 0; i < k; i++)
    {
        MIN += a[i];
    }
    cout << MIN << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	ll X,Y;
	scanf("%lld %lld",&X,&Y);

	int ans = 1;

	while(true){
		X *= 2;
		if(X <= Y)ans++;
		else{
			break;
		}
	}

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

	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size)scanf("%d",&(name)[i])

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI2(A,B);
    print(A*B-A-B+1);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int[] ary = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

		int K = sc.nextInt();

		System.out.println(ary[K-1]);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
const int N = 203;
int n, m, x[N], y[N], ans, flyx[N], flyy[N];
bool vis[N], edge[N][N];
set<int> S;
inline bool isp(int x){
	if(x <= 2) return false;
	for(Rint i = 2;i * i <= x;i ++)
		if(!(x % i)) return false;
	return true;
}
inline bool dfs(int x){
	for(Rint y = 1;y <= m;y ++)
		if(edge[x][y] && !vis[y]){
			vis[y] = true;
			if(!flyy[y] || dfs(flyy[y])){
				flyx[x] = y; flyy[y] = x; return true;
			}
		}
	return false;
}
int main(){
	scanf("%d", &n);
	for(Rint i = 1;i <= n;i ++){
		int v; scanf("%d", &v);
		if(S.count(v)) S.erase(v);
		else S.insert(v);
		if(S.count(v + 1)) S.erase(v + 1);
		else S.insert(v + 1);
	}
	n = m = 0;
	for(int v : S)
		if(v & 1) x[++ n] = v;
		else y[++ m] = v;
	for(Rint i = 1;i <= n;i ++)
		for(Rint j = 1;j <= m;j ++)
			edge[i][j] = isp(abs(x[i] - y[j]));
	for(Rint i = 1;i <= n;i ++) if(!flyx[i]){
		memset(vis, 0, sizeof vis); ans += dfs(i);
	}
	printf("%d\n", n + m + (n - ans & 1) - ans);
}

Measured memory_bytes: 256
let s = read_line () in
let n = String.length s in
let rec loop i =
    if i = n then true else (
        match i mod 2, s.[i] with
        | 0, 'h'
        | 1, 'i' -> loop (i + 1)
        | _ -> false
    )
in
(if n mod 2 = 0 && loop 0 then "Yes" else "No") |> print_endline

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#include <stdlib.h>
#include <time.h>
#include <chrono>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll d;
vector<ll> c(26 + 1, 0);
vector<vector<ll>> s(365 + 1, vector<ll>(26 + 1, 0));

ll scoring(vector<int> t)
{
    ll ans = 0;
    vector<ll> last(26 + 1, 0);

    for (int i = 1; i <= d; i++)
    {
        ans += s[i][t[i]];
        ans -= c[t[i]] * (i - last[t[i]]) * (i - last[t[i]] - 1) / 2;
        last[t[i]] = i;
    }

    for (int i = 1; i <= 26; i++)
    {

        ans -= c[i] * (d - last[i] + 1) * (d - last[i]) / 2;
    }

    return ans;
}

int main(void)
{
    srand(time(NULL));
    cin >> d;

    for (int i = 1; i <= 26; i++)
    {
        cin >> c[i];
    }

    for (int i = 1; i <= d; i++)
    {
        for (int j = 1; j <= 26; j++)
        {
            cin >> s[i][j];
        }
    }

    vector<int> BestT(d + 1, 1);

    for (int i = 1; i <= d; i++)
    {
        BestT[i] = rand() % 26 + 1;
    }

    double BestScore = scoring(BestT);
    double score;

    auto start = chrono::system_clock::now();
    vector<int> t(d + 1, 1);

    double T0 = 1e6;
    double T1 = 1e3;
    double TL = 1980;

    ll count = 0;

    while (1)
    {
        ll msec;

        if (count % 100 == 0)
        {
            msec = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - start).count();
        }

        if (msec >= TL)
        {
            break;
        }

        double T = powf(T0, 1 - msec / TL) * powf(T1, msec / TL);

        t = BestT;

        t[rand() % d + 1] = rand() % 26 + 1;

        score = scoring(t);

        double p = exp((score - BestScore) / T);

        if (p > (double)rand() / RAND_MAX)
        {
            BestT = t;
            BestScore = score;
        }

        count++;
    }

    for (int i = 1; i <= d; i++)
    {
        printf("%d\n", BestT[i]);
    }
}


Measured memory_bytes: 4312
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using ll = long long;
using namespace std;

int main()
{
  int n;
  ll d;
  cin >> n >> d;
  int ans = 0;
  rep(i, n)
  {
    ll x, y;
    cin >> x >> y;
    if (x * x + y * y <= d * d)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long ans = 0;
	int rem = 0;
	for (int i = 0; i < n; i++) {
		long long x = a[i];
		x += rem;
		ans += x / 2;
		rem = x % 2;
		if (a[i] == 0) rem = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  map<int, int> mp;
  for(int i=0;i<3;i++){
    cin >> a >> b;
    mp[a]++;
    mp[b]++;
  }
  for(int i=1;i<=4;i++){
    if(mp[i]<1 or mp[i]>2){
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include<iomanip>
#include<functional>
using namespace std;
typedef long long ll;


long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}


int main() {
    ll N;
    cin >> N;
    int cnt = 0;
    while (N) {
        N /= 2;
        cnt++;
    }
    ll ans = pow(2, cnt) - 1;
    cout << ans << endl;
}


Measured memory_bytes: 4012
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int N, K, d, A;
  cin >> N >> K;
  vector<int> X(N, 1);
  for (int i = 0; i < K; i++) {
    cin >> d;
    for (int i = 0; i < d; i++) {
      cin >> A;
      X.at(A - 1) = 0;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += X.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
import java.util.Scanner;
 
public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        for(;;)
        {
            int N = sc.nextInt(), P = sc.nextInt();
            if (N==0 && P==0) break;
             
            int[] s = new int[N];
            for (int n = 0; ; n = (n + 1) % N)
            {
                if (P != 0)
                {
                    P--;
                    s[n]++;
                    if (P == 0)
                    {
                        boolean win = true;
                        for (int i = 0; i < N; i++)
                        {
                            if (i != n && s[i] != 0)
                            {
                                win = false;
                                break;
                            }
                        }
                        if (win)
                        {
                            System.out.println(n);
                            break;
                        }
                    }
                }
                else
                {
                    P = s[n];
                    s[n] = 0;
                }
            }
        }
    }
}

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

int main() {
    int N, Y;
    cin >> N >> Y;
    int res10000 = -1, res5000 = -1, res1000 = -1;
    for (int i=0; i<=N; i++) {
        for (int j=0; j<=N-i; j++) {
            int k = N-i-j;
            int total = 10000*i+5000*j+1000*k;
            if (total==Y) {
                res10000 = i;
                res5000 = j;
                res1000 = k;
            }
        }
    }
    cout << res10000 << " " << res5000 << " " << res1000 << endl;
    return 0;
}

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

int main() {
    int n, m;
    while (cin >> n >> m, n) {
        vector<int> h(n);
        for (auto &hi: h) cin >> hi;
        vector<int> y(n + 1);
        for (int i = 0; i < n; i++) y[i + 1] = y[i] + h[i];
        vector<int> w(m);
        for (auto &wi: w) cin >> wi;
        vector<int> x(m + 1);
        for (int i = 0; i < m; i++) x[i + 1] = x[i] + w[i];
        map<int, int> diag;
        for (int i = 0; i < n + 1; i++) for (int j = 0; j < m + 1; j++) {
            diag[y[i] - x[j]]++;
        }
        int cnt = 0;
        for (auto &p: diag) cnt += p.second * (p.second - 1) / 2;
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 29888
#include<iostream>

int main() {
	int S;
	int h, m, s;
	std::cin >> S;
	h = S / 3600;
	m = S % 3600 / 60;
	s = (S % 3600) % 60;
	std::cout << h << ":" << m << ":" << s << "\n";
	return 0;
}

Measured memory_bytes: 1164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.LinkedList;

public class Main {
    public static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

    public static int nextInt() {
        try {
            in.nextToken();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return (int) in.nval;
    }

    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        in.nextToken();
        String s = in.sval;
        LinkedList<Character> st = new LinkedList<Character>();
        int len = s.length();
        for (int i = 0; i < len; i++)
            st.add(s.charAt(i));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int n = nextInt();
        boolean a = false;
        for (int i = 0; i < n; i++) {
            int op = nextInt();
            if (op == 1)
                a = !a;
            else {
                int x = nextInt();
                in.nextToken();
                String c = in.sval;
                if ((x == 1 && !a) || (x == 2 && a))
                    st.addFirst(c.charAt(0));
                else
                    st.addLast(c.charAt(0));
            }
        }
        if (!a)
            while (!st.isEmpty())
                out.print(st.pollFirst());
        else {
            while (!st.isEmpty())
                out.print(st.pollLast());
        }
        out.flush();
    }

}


Measured memory_bytes: 60464
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
    if (A.size() == n + 1) {
        // calculate score
        int temp_score = 0;
        for (int i = 0; i < q; i++) {
            if (A[b[i]] - A[a[i]] == c[i]) {
                temp_score += d[i];
            }
        }
        ans = max(ans, temp_score);
        return;
    }

    A.push_back(A.back());
    while (A.back() <= m) {
        dfs(A);
        A.back()++;
    }
}

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

    a = vector<int>(q);
    b = vector<int>(q);
    c = vector<int>(q);
    d = vector<int>(q);
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    dfs(vector<int>(1, 1));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
//#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

#pragma GCC optimize("Ofast")
#pragma target("sse", "sse1")

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

mt19937 gen(34);

int n;
string s;

char sdvig(char c)
{
	c += n;
	if (c > 'Z')
		c -= 26;
	return c;
}

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//	freopen("memory.in", "r", stdin);
	//	freopen("memory.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> s;
	for (int i = 0; i < s.length(); i++)
		cout << sdvig(s[i]);
	return 0;
}

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

ll to_int(char& c)
{
  return (c-'0');
}
string rep9(int n)
{
  string ret="";
  for (int i = 0; i < n; ++i)
  {
    ret.push_back('9');
  }
  return ret;
}

string del0(string s)
{
  while(s[0]=='0')
  {
    s=s.substr(1);
  }
  return s;
}

ll solve1(string n)
{
  if(n=="") return 0;
  ll ans=(n.size()-1)*9;
  ans+=to_int(n[0]);
  return ans;
}

ll solve2(string n)
{
  if(n=="") return 0;
  // start with 0
  ll ans=(n.size()-1)*(n.size()-2)/2*81;
  // start with 1 ~ (n[0]-1)
  ans+=(to_int(n[0])-1)*solve1(rep9(n.size()-1));
  // start with n[0]
  ans+=solve1(del0(n.substr(1)));
  return ans;
}

ll solve3(string n)
{
  // start with 0
  ll ans=(n.size()-1)*(n.size()-2)*(n.size()-3)/6*729;
  // start with 1 ~ (n[0]-1)
  ans+=(to_int(n[0])-1)*solve2(rep9(n.size()-1));
  // start with n[0]
  ans+=solve2(del0(n.substr(1)));
  return ans;
}

int main()
{
  string n;
  int k;
  cin>>n>>k;
  if(n.size()<k)
  {
    cout<<0;
    return 0;
  }
  if(k==1) cout<<solve1(n);
  else if(k==2) cout<<solve2(n);
  else cout<<solve3(n);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
#include <map>
#include <numeric>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,k; cin >> n >> k;
	vector<int> p(n);
	vector<double> q(n);
	for(int i=0;i<n;i++){
		cin >> p[i];
		q[i]=(double)(1+p[i])/2.0;
	}
	double ma=0;
	double sum=0;
	for(int i=0;i<k;i++){
		sum+=q[i];
	}
	ma=sum;
	for(int i=k;i<n;i++){
		sum+=q[i];
		sum-=q[i-k];
		ma=max(ma,sum);
	}
	printf("%.8f\n",ma);
}

Measured memory_bytes: 2560
a = int(input())
b = int(input())
c = int(input())
x = int(input())
res = 0
for i in range(0, a + 1):
    for j in range(0, b + 1):
        for k in range(0, c + 1):
            if i * 500 + j * 100 + k * 50 == x:
                res += 1
print(res)


Measured memory_bytes: 40176
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxn = 50 + 2;
const int MOD = 1000000007;

inline int inc(int a, int b) { return (a + b >= MOD) ? (a + b - MOD) : (a + b); }
inline int dec(int a, int b) { return (a >= b) ? (a - b) : (a + MOD - b); }
inline int mul(int a, int b) { return 1LL * a * b % MOD; }
 
inline void updata(int &x, int y) { x = inc(x,y); }
 
inline int power(int x, int k) {
  int tmp = 1;
  while(k) {
    if(k & 1) tmp = mul(tmp,x);
    x = mul(x,x);
    k >>= 1;
  }
  return tmp;
}

int n, C[maxn][maxn], dp[maxn][maxn];
int main() {
	scanf("%d", &n);
	C[0][0] = 1;
	for(int i = 1;i <= n;i ++) {
		C[i][0] = 1;
		for(int j = 1;j <= i;j ++) C[i][j] = inc(C[i - 1][j],C[i - 1][j - 1]);
	}
	dp[1][0] = dp[1][1] = n;
	for(int i = 1;i < n;i ++) {
		for(int j = 0;j <= i;j ++) {
			for(int k = max(1,j);k <= n - i;k ++) {
				if((k - j) & 1) continue;
				int now = (k - j) / 2;
				for(int x = 0;x <= k;x ++) {
					int xs = mul(C[n - i][k],C[k][x]);
					updata(dp[i + k][abs(now - x)],mul(xs,dp[i][j]));
				}
			}
		}
	}
	int Ans = dp[n][0];
	printf("%d\n", Ans);
	return 0;
}


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


using namespace std;

int main()
{
    ll t,n,item,temp,a,b,c,x,y,z,sum,flag;
    string s,s1,s2;
    vector<ll>v;
    vector<string>vs;
    map<ll,ll>mp;
   vector< pair<char,ll> >p;
    cin>>n>>a;
    for(ll i=0;i<n;i++)
    {
        cin>>s;
        p.push_back(make_pair(s[0],i));
        vs.push_back(s);

    }
    sort(vs.begin(),vs.end());
string ans="";
    for(ll i=0;i<n;i++)
    {

        ans+=vs[i];
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(){
	int n;
	cin >> n;
	int distance = 0;
	vector<int> v;
	set<int> s;
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		s.insert(k);
	}
	for (auto number : s) {
		v.push_back(number);
	}
	for (int i = 1; i < s.size(); i++) distance += v[i] - v[i - 1];
	cout << distance << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    public static void Main(string[] args)
    {
        int N = int.Parse(System.Console.ReadLine());
        var parms = System.Console.ReadLine().Split();

        int min = 1000, max = 0;

        for(int i = 0; i < parms.Length; i++)
        {
            int val = int.Parse(parms[i]);
            min = min > val ? val : min;
            max = max < val ? val : max;
        }

        int ans = max - min;

        System.Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
class Dice:
    def __init__(self):
        self.u=1
        self.w=2
        self.s=3
        self.e=4
        self.n=5
        self.d=6
        self.dic={"W":0,"S":1,"E":2,"N":3}
     
    def __init__(self,u,w,s,e,n,d):
        self.u=u
        self.w=w
        self.s=s
        self.e=e
        self.n=n
        self.d=d
        self.dic={"W":0,"S":1,"E":2,"N":3}
 
    def rot(self,way):
        if isinstance(way,str):
            way=self.dic[way]
 
        if(way==0):
            c=self.u
            self.u=self.e
            self.e=self.d
            self.d=self.w
            self.w=c
        elif way==1:
            c=self.u
            self.u=self.n
            self.n=self.d
            self.d=self.s
            self.s=c
        elif way==2:
            c=self.u
            self.u=self.w
            self.w=self.d
            self.d=self.e
            self.e=c
        else :
            c=self.u
            self.u=self.s
            self.s=self.d
            self.d=self.n
            self.n=c
 
import random
u,s,e,w,n,d=map(int,input().split())
dice=Dice(u,w,s,e,n,d)
q=int(input())
for i in range(q):
    a,b=map(int,input().split())
    while True:
        dice.rot(random.randint(0,3))
        if(dice.u==a and dice.s==b):
            print(dice.e)
            break


Measured memory_bytes: 8184
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int merge(vector <int> &A, vector <int> &buf, int low, int mid, int high){
	int i=low, j=low, k=mid;

	while (j<mid && k<high){
		if (A[j] < A[k])
			buf[i] = A[j++];
		else
			buf[i] = A[k++];
		i++;
	}

	if (j<mid)
		for(int h=j; h<mid; h++,i++)
			buf[i] = A[h];
	else
		for (int h=k; h<high; h++,i++)
			buf[i] = A[h];

	for (int i=low; i<high; i++)
		A[i] = buf[i];

	return high-low;
}

int mergesort(vector <int> &A, vector <int> &buf, int low, int high ){

	int m=(high+low)/2, counter=0;
	if (low+1 >= high){
		return 0;
	}

	counter += mergesort(A, buf, low, m );
	counter += mergesort(A, buf, m, high );
	counter += merge(A, buf, low, m, high);
	return counter;
}

int vector_out(vector <int> &A){
    int n=A.size();
    for (int i=0; i<n; i++){
        cout << A[i];
        if (i!= n-1) cout<<" ";
        else cout<<endl;
    }
    return 0;
}

int main(void){
	int n, counter;
	cin >> n;
	vector <int> A(n);
	vector <int> buf(n);
	for (int i=0; i<n; i++){
		cin >> A[i];
		buf[i]=0;
	}
		
	counter = mergesort(A, buf, 0, n);
	vector_out(A);
	cout << counter << endl;

	return 0;
}

Measured memory_bytes: 4968
#include<bits/stdc++.h>
#define LL long long
#define SZ(x) (int)x.size()-1
#define F(i,a,b) for (int i=a;i<=b;++i)
#define DF(i,a,b) for (int i=a;i>=b;--i)
#define pb push_back
#define ms(a,b) memset(a,b,sizeof a)
using namespace std;
int read(){
    char ch=getchar(); int w=1,c=0;
    for (;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
    for (;isdigit(ch);ch=getchar()) c=(c<<3)+(c<<1)+(ch^48);
    return w*c;
}
const int M=500+10;
int n,m,k;
int a[M][M],bl[M];
char ch[M];
bool f[M];
int main(){
	n=read(); m=read(); k=read();
	int ct=0,fi=0;
	bool oo=0;
	F(i,1,n){
		scanf("%s",ch+1);
		bool o=0;
		int fir=0;
		F(j,1,m){
			if (ch[j]=='.')	;
			else {
				if (!o) fir=j;
				o=1;
				a[i][j]=++ct;
			}
		}
		if (!o) {
			
			f[i]=1;
		}
		else{
			bl[i]=i;
			if (!oo) fi=i;
			oo=1;
			F(j,1,fir){
				a[i][j]=a[i][fir];
			}
			F(j,fir+1,m) {
				if (!a[i][j]) a[i][j]=a[i][j-1];
			}
		}
	}
	F(i,1,fi){
		bl[i]=fi;
	}
	F(i,fi+1,n){
		if (f[i]) bl[i]=bl[i-1];
	}
	F(i,1,n){
		if (bl[i]){
			F(j,1,m) cout<<a[bl[i]][j]<<" ";
		}
		else {
			F(j,1,m){
				cout<<a[i][j]<<" ";
			}
		}
		cout<<"\n";
	}
    return 0;
}



Measured memory_bytes: 1408
#pragma GCC optimize ("O3")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define dbg1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define dbg2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define dbg3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	if(s=="MON")
		cout << "6";
	else if(s=="TUE")
		cout << "5";
	else if(s=="WED")
		cout << "4";
	else if(s=="THU")
		cout << "3";
	else if(s=="FRI")
		cout << "2";
	else if(s=="SAT")
		cout << "1";
	else
		cout << "7";
}

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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(a) begin(a), end(a)
#define SZ(a) ((int)(a).size())
#define rep(i, n) for (int i = 0; i < n; i++)

#ifdef __DEBUG
#define debug if (true)
#else
#define debug if (false)
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T> struct vector2 : public vector<vector<T>> { vector2(int n, int m, const T& k = T()) : vector<vector<T>>(n, vector<T>(m, k)) {} };
template <typename T> struct vector3 : public vector<vector2<T>> { vector3(int n, int m, int k, const T &l = T()) : vector<vector2<T>>(n, vector2<T>(m, k, l)) {} };

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, inc, dec;
  cin >> n >> inc >> dec;
  bool rev = inc < dec;
  if (rev) {
    debug puts("REV");
    swap(inc, dec);
  }
  if (dec == 0) {
    puts("-1");
    return 0;
  }
  if (inc + dec - 1 > n) {
    puts("-1");
    return 0;
  }
  if (1LL * inc * dec < n) {
    puts("-1");
    return 0;
  }
  int rem = n - inc;
  int last = 0;
  vi ans;
  for (int iter = 0; iter < inc; iter++) {
    int take = min(dec - 1, rem);
    rem -= take;
    for (int i = last + take + 1; i > last; i--) {
      debug printf("PB %d\n", i);
      ans.push_back(i);
    }
    last = last + take + 1;
  }
  if (rev) {
    for (int &i : ans) i = n + 1 - i;
  }
  assert(SZ(ans) == n);
  for (int i = 0; i < SZ(ans); i++) {
    printf("%d%c", ans[i], i == SZ(ans) - 1 ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 3440
def main()
day, num = gets.split
h = gets.split
day = day.to_i
num = num.to_i
h = h.map!(&:to_i)
i = 0
for i in h
    day = day - i
    if(day < 0)
        return -1
    end
end
return day
end

p main()

Measured memory_bytes: 14512
//#include <bits/stdc++.h>
//
//using namespace std;
//
//int main() {
//    int a[200];
//    bool vis[200];
//    memset(vis,0,sizeof(vis));
//    for(int i = 1; i <= 3; i++) cin >> a[i];
//    long long ans = 1e18;
//    for(int i = 1; i <= 3; i++) {
//        memset(vis,0,sizeof(vis));
//        vis[i] = 1;
//        for(int j = 1; j <= 3; j++) {
//        long long sum = 0;
//            if(!vis[j]) {
//                vis[j] = 1;
//                sum += abs(a[i] - a[j]);
//                for(int k = 1; k <= 3; k++) {
//                    if(!vis[k]) sum += abs(a[j] - a[k]),ans = min(ans,sum);;
//                }
//                vis[j] = 0;
//            }
//        }
//        vis[i] =0;
//
//    }
//    cout << ans << endl;
//    return 0;
//}




#include <bits/stdc++.h>

using namespace std;

int main() {
    string s,t;
    while(cin >> s >> t) {
        int len = s.size();
        for(int i = 0; i < len; i++) {
            string s1 = s.substr(0,1);
            string s2 = s.substr(1,len - 1);
            s2 += s1;
            s = s2;
            if(s2 == t){
                printf("Yes\n");
                return 0;
            }
        }
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

int A, B, C;
int main(void){
    cin >> A >> B >> C;
    if (A==B and A!=C) cout << "Yes" << endl;
    else if (A==C and A!=B) cout << "Yes" << endl;
    else if (C==B and A!=C) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    ans = (N + 1) // 2 / N
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9148
#include<iostream> 
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 1000010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
int n,q,m,a[N],b[N],c[N];
char s[N];
int main()
{
	n=read();scanf("%s",s+1);
	for (int i=1;i<=n;i++)
	if (s[i]=='D') a[i]=0;
	else if (s[i]=='M') a[i]=1;
	else if (s[i]=='C') a[i]=2;
	else a[i]=-1;
	q=read();
	while (q--)
	{
		m=read();
		int hb=1,tb=0,hc=1,t=0,tc=0;ll ans=0,cur=0;
		for (int i=1;i<=n;i++) if (a[i]==2) b[++tb]=i;
		for (int i=1;i<=n;i++)
		if (a[i]==1) ans+=cur;
		else if (a[i]==0)
		{
			c[++tc]=i;
			while (t<tb&&b[t+1]-i+1<=m) t++;
			cur+=t-hb+1; 
		}
		else if (a[i]==2)
		{
			while (hc<=tc&&i-c[hc]+1>m) hc++;
			cur-=tc-hc+1;
			hb++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 12928
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if ((s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) || (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) || (s[0] == s[3] && s[1] == s[2] && s[0] != s[1] ))
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return false;
}

Measured memory_bytes: 256
//itp1_2_d

#include <iostream>
using namespace std;

int main(){
 int w,h,x,y,r;
 cin>>w>>h>>x>>y>>r;

 bool inner=false;
 if((x>=r && x<=w-r) && (y>=r && y<=h-r) && (h>=r*2 && w>=r*2))
  inner=true;
 
 if(inner) cout<<"Yes"<<endl;
 else cout<<"No"<<endl;

 return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct node{
    int key;
    struct node *p, *l, *r;
}Node;

Node *tmp, *NIL;

void insert(int);
void inorder(Node *);
void preorder(Node *);
Node *find(Node *, int);
void Delete(Node *);
Node *min(Node *);
Node *Nextpoint(Node *);

int main()
{
    int m, i, k;
    char c[1000];
    Node *judge;
    
    scanf("%d", &m);
    
    for( i = 0 ; i < m ; i++ ){
        scanf("%s", c);
        if( strcmp(c, "find") == 0 ){
            scanf("%d", &k);
            judge = find(tmp, k);
            if( judge != NIL ) printf("yes\n");
            else printf("no\n");
        }
        else if( strcmp(c, "insert") == 0 ){
            scanf("%d", &k);
            insert(k);
        }
        else if( strcmp(c, "print") == 0 ){
            inorder(tmp);
            printf("\n");
            preorder(tmp);
            printf("\n");
        }
	else if( strcmp(c, "delete") == 0 ){
	  scanf("%d", &k);
	  Delete(find(tmp, k));
	}
    }
    
    return 0;
}

void insert(int k){
    Node *y = NIL;
    Node *x = tmp;
    Node *z;
    
    z = malloc(sizeof(Node));
    z->key = k;
    z->l = NIL;
    z->r = NIL;
    
    while( x != NIL ){
        y = x;
        if( z->key < x->key ) x = x->l;
        else x = x->r;
    }
    
    z->p = y;
    if( y == NIL ) tmp = z;
    else if( z->key < y->key ) {
        y->l = z;
    } else y->r = z;
    
}

void inorder(Node *u){
    if( u == NIL ) return;
    inorder(u->l);
    printf(" %d", u->key);
    inorder(u->r);
}

void preorder(Node *u){
    if( u == NIL ) return;
    printf(" %d", u->key);
    preorder(u->l);
    preorder(u->r);
}

Node *find(Node *x, int k)
{
    while( x != NIL && k != x->key ){
        if( k < x->key ) x = x->l;
        else x = x->r;
    }
    
    return x;
}

void Delete(Node *z){
  Node *x, *y;

  if( z->l == NIL || z->r == NIL ) y = z;
  else y = Nextpoint(z);

  if( y->l != NIL ) x = y->l;
  else x = y->r;

  if( x != NIL ) x->p = y->p;

  if( y->p == NIL ) tmp = x;
  else {
    if( y == y->p->l ) y->p->l = x;
    else y->p->r = x;
  }

  if( y != z ) z->key = y->key;

  free(y);
}

Node *Nextpoint(Node *x)
{
  if( x->r != NIL ) return min(x->r);
  Node *y = x->p;

  while( y != NIL && x == y->r ){
    x = y;
    y = y->p;
  }
  return y;
}

Node *min(Node *x)
{
  while( x->l != NIL ) x = x->l;
  return x;
}

Measured memory_bytes: 19364
n = int(input())
wk = wkmax = 0
si = {}
for i in range(n):
    st = input()
    if st in si:
        si[st] = si[st] + 1
    else:
        si[st] = 1
    wk = si[st]
    wkmax = max(wk,wkmax)
sl = sorted(si.items())
for i in range(len(sl)):
    if wkmax == sl[i][1]:
        print(sl[i][0])

Measured memory_bytes: 44196
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    string S;
    while (1)
    {
        cin >> S;
        if (S == "#")
            break;
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--, c--, d--;
        int field[20][20] = {};
        vector<string> s;
        string t = "";
        rep(i, S.size())
        {
            if (S[i] == '/')
                s.push_back(t), t = "";
            else
                t += S[i];
        }
        s.push_back(t);
        int H = s.size(), W;
        rep(i, s.size())
        {
            string ss = s[i];
            int pos = 0;
            rep(j, ss.size())
            {
                if ('0' <= ss[j] && ss[j] <= '9')
                    pos += ss[j] - '0';
                else
                    field[i][pos++] = 1;
            }
            W = pos;
        }
        field[a][b] = 0;
        field[c][d] = 1;
        string ans = "";
        // rep(i, H)
        // {
        //     rep(j, W)
        //     {
        //         cout << field[i][j] << " ";
        //     }
        //     cout << endl;
        // }
        rep(i, H)
        {
            string tmp = "";
            int cnt = 0;
            rep(j, W)
            {
                if (field[i][j])
                {
                    if (cnt != 0)
                        tmp += '0' + cnt;
                    tmp += 'b';
                    cnt = 0;
                }
                else
                    cnt++;
            }
            if (cnt != 0)
                tmp += '0' + cnt;
            if (i == 0)
                ans += tmp;
            else
                ans += '/' + tmp;
        }
        cout << ans << endl;
    }
}


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

using namespace std;

void solve() {
    double x = 100;
    long long n; cin >> n;
    int ans = 0;
    while (x < n) {
        x += 0.01 * x;
        x = (long long)x;
        //cout << x << " " << ans << endl;
        ans++;
    }
    cout << ans;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


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

void dfs_visit(int u, int N, vector<vector<int>> &M, vector<string> &color,
               int &tt, vector<int> &start, vector<int> &finish) {
    color[u] = "GRAY";
    tt++;
    start[u] = tt;
    for (int v = 0; v < N; v++) {
        // if (M[u][v] == 0);
        //     continue;
        // cout << v << endl;
        if (M[u][v] == 1 && color[v] == "WHITE")
        {
            dfs_visit(v, N, M, color, tt, start, finish);
        }
    }
    color[u] = "BLACK"; // 訪問完了
    tt++;
    finish[u] = tt;
}

void dfs(int N, vector<vector<int>> &M, vector<string> &color,
         int &tt, vector<int> &start, vector<int> &finish) {

    tt = 0;
    // cout << "hee" << endl;
    for (int u = 0; u < N; u++)
    { // uが未訪問ならば
        if (color[u] == "WHITE") {
            // cout << u << " " << tt << endl;
            dfs_visit(u, N, M, color, tt, start, finish);
        }
    }
    for (int u = 0; u < N; u++) {
        cout << u + 1 << " " << start[u] << " " << finish[u] << endl;
    }
}

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

    vector<vector<int>> M(N, vector<int>(N, 0));
    vector<string> color(N, "WHITE");
    int tt = 0;
    vector<int> start(N, 0);
    vector<int> finish(N, 0);

    int u, k, v;
    for (int i = 0; i < N; i++)
    {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    dfs(N, M, color, tt, start, finish);
}


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

int main(void) {
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    for (int i = 0; i < N; ++i) {
        cout << S[i] << T[i];
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 256
a,b,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

from itertools import accumulate

A = list(accumulate(A))
B = list(accumulate(B))
A = [0] + A
B = [0] + B

ans = 0
num = b
for i in range(a+1):
    if A[i] > k:
        continue
    while True :
        if A[i] + B[num] > k:
            num -=1
        else:
            ans = max(ans,i+num)
            break
print(ans)

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

int main() {
  int64_t H, W;
  cin >> H;
  cin >> W;
  
  if (H == 1 || W == 1) {
    cout << 1 << endl;
  } else {
    if (H % 2 == 0) {
      cout << H * W / 2 << endl;
    } else {
      if (W % 2 == 0) {
        cout << H * W / 2 << endl;
      } else {
        cout << H * (W - 1) / 2 + (H + 1) / 2 << endl;
      }
    }
  }
}


Measured memory_bytes: 256