akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

	private static void solve() {
		try (Scanner cin = new Scanner(System.in)) {

			String s = cin.next();
			System.out.println(s.substring(0, s.lastIndexOf("FESTIVAL")));
		} finally {
		}
	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <map>
#include <string>
using namespace std;
int main() {
    int n;
    string S, ans;
    cin >> n;
    vector<map<char, int>> vm(n);
    for (int i = 0; i < n; i++) {
        cin >> S;
        for (char c : S) {
            if (vm[i].find(c) != vm[i].end()) vm[i][c]++;
            else vm[i][c] = 1;
        }
    }
    for (char c = 'a'; c <= 'z'; c++) {
        int m = 51;
        bool f = true;
        for (int i = 0; i < n; i++) {
            int t = vm[i][c];
            if (t == 0) {
                f = false;
                break;
            }
            if (t < m) m = t;
        }
        if (f && m != 51) for (int i = 0; i < m; i++) ans += c;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>

using namespace std;

#define INF (1<<30)

int main(){
	int h,w,n;
	cin >> h >> w >> n;
	int sy, sx;
	cin >> sy >> sx;
	sx--;
	sy--;
	string s,t;
	cin >> s >> t;
	// int taka[1000];
	// int aoki[1000];
	// fill_n(taka,1000,0);
	// fill_n(aoki,1000,0);
	// for(int i = 0;i < n;i++){
	// 	taka[s[i]]++;
	// 	aoki[s[i]]++;
	// }
	bool win = true;
	int x = sx, y = sy;
	for(int i = 0;i < n;i++){
		if(s[i] == 'R')
			x++;
		if(x == w){
			win = false;
		}
		if(t[i] == 'L' && x >= 1)
			x--;
	}
	x = sx;
	y = sy;
	for(int i = 0;i < n;i++){
		if(s[i] == 'L')
			x--;
		if(x == -1){
			win = false;
		}
		if(t[i] == 'R' && x < w-1)
			x++;
	}

	x = sx;
	y = sy;
	for(int i = 0;i < n;i++){
		if(s[i] == 'D')
			y++;
		if(y == h){
			win = false;
		}
		if(t[i] == 'U' && y >= 1)
			y--;
	}

	x = sx;
	y = sy;
	for(int i = 0;i < n;i++){
		if(s[i] == 'U')
			y--;
		if(y == -1){
			win = false;
		}
		if(t[i] == 'D' && y < h-1)
			y++;
	}

	cout << (win?"YES":"NO") << endl;
}

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

const int MAX = 30;

int main(){
  int N,K;
  int num[MAX];  
  for(int i = 0 ; i < MAX ; i++)num[i] = 0;

  cin >> N >> K;
  for(int i = 0 ; i < N ; i++){
    string str; 
    cin >> str;
    num[str[0]-'A']++;
  }

  int res = 0;

  while(1){
    int sum = 0;
    sort(num,num+MAX);
    reverse(num,num+MAX);
    for(int i = 0 ; i < MAX ; i++){
      if(num[i] > 0){
	sum++;
	num[i]--;
      }
      if(sum == K){
	break;
      }
    }
    if(sum < K)break;
    res++;
  }
  cout << res << endl;
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    if( n % 1000 == 0) cout << 0 << endl;
    else cout << 1000 - n % 1000 << endl;
    
}

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

#define rep(a,b) for(ll ii=a;ii<b;ii++)
#define ll long long int
#define test() int tt; cin>>tt; while(tt--) 
#define fst_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl '\n'

int main()
{
  int n,i,j,k,c=0;
  cin>>n;
  ll a[n];
  rep(0,n) cin>>a[ii];
  
  sort(a, a+n);
  for(i=0;i<n;i++)
  {
    for(j=i+1;j<n;j++)
    {
      for(k=j+1;k<n;k++)
      {
        if(a[i]!=a[j]&&a[j]!=a[k])
        {
          if(a[i] + a[j] > a[k]) c++;
        }
      }
    }
  }
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 3628
i[100012], d[100012],s,w;
main()
{
  int n,a,x,y;
  w=scanf("%d",&n);
  for(a=0;a<n;a++)
    {
      scanf("%d%d",&x,&y);
      i[x]++;
      d[y]++;
    }
  for(a=2;a<=n+1;a++)
    {
      w+=i[a];
      if(w>=a)s=a-1;
      w-=d[a];
    }
  printf("%d\n",s);
  exit(0);
}

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

using namespace std;

int main()
{
    ll n,m,i,j,l,k;
    cin>>n>>m;
    k = 1;
    while(n--)k=k*100;

    for(i=1;i<=10000000;++i){
        if(i%k==0&&(i%(k*100)!=0)&&(i%(k*10000)!=0)&&(i%(k*1000000)!=0)&&(--m)==0){
            cout<<i;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    a=list(map(int,input().split()))
    a.sort()
    print(a[-1]-a[0])

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
class UnionFindTree:
    def __init__(self, size):
        self.parent = list(range(size))
        self.dist = [0] * size

    def find_root(self, x):
        if self.parent[x] == x:
            return x, 0
        else:
            self.parent[x], d = self.find_root(self.parent[x])
            self.dist[x] += d
            return self.parent[x], self.dist[x]

    def union(self, x, y, d):
        r1, d1 = self.find_root(x)
        r2, d2 = self.find_root(y)
        if r1 != r2:
            self.parent[r2] = r1
            self.dist[r2] = (d1 - d2) + d
        else:
            if (d2 - d1) != d:
                return False
        return True

def main():
    n, m = map(int, input().split())
    tree = UnionFindTree(n+1)
    for i in range(m):
        l, r, d = map(int, input().split())
        if not tree.union(l, r, d):
            print('No')
            return
    print('Yes')

main()


Measured memory_bytes: 9844
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();        
        int N = r.i();
        int[] A = r.ii();
        int[] B = r.ii();
        int[] C = r.ii();
        int sum = 0;
        for(int i = 0; i < N; i++){
            int id = A[i]-1;
            sum += B[id];
        }
        for(int i = 0; i < N-1; i++){
            if(A[i]+1 == A[i+1]){
                sum += C[A[i]-1];
            }
        }
        println(sum);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
int mod = 1e9 + 7;
int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    vector<pair<double, double>> coordinate(N);
    for (int i = 0; i < N; i++) cin >> coordinate[i].first >> coordinate[i].second;
    sort(coordinate.begin(), coordinate.end());
    double ans = 0;
    int count = 0;
    do {
        for (int i = 0; i < coordinate.size() - 1; i++) {
            ans += sqrt(pow(coordinate[i].first - coordinate[i + 1].first, 2) + pow(coordinate[i].second - coordinate[i + 1].second, 2));
        }
        ++count;
    } while (next_permutation(coordinate.begin(), coordinate.end()));
    cout << fixed << setprecision(10) << ans / count << endl;

 }

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MAX=2e5+5;
const ll MOD=1e9+7;

ll extgcd(ll a,ll b,ll& x, ll& y){
	ll d=a;
	if(b!=0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	}
	else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_inv(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}

ll ans(ll x,ll y,ll m){
	int w=mod_inv(y,m);
	return (x*w)%m;
}

ll r[MAX],s[MAX],t[MAX];

int main(){
	int B,W;
	cin>>B>>W;
	if(B==W){
		rep1(i,B+W){
			cout<<ans(1,2,MOD)<<endl;
		}
		return 0;
	}
	int a=min(B,W);
	int b=max(B,W);
	
	ll p[MAX],q[MAX];
	p[1]=1,q[1]=2;
	for(int i=2;i<=B+W;i++){
		p[i]=(p[i-1]*2)%MOD;
		q[i]=(q[i-1]*2)%MOD;
	}
	
	s[a+1]=1;
	rep1(i,b-1){
		s[a+i+1]=(s[a+i]*(a+i-1))%MOD;
		s[a+i+1]=(s[a+i+1]*mod_inv(i,MOD))%MOD;
	}
	t[b+1]=1;
	rep1(i,a-1){
		t[b+i+1]=(t[b+i]*(b+i-1))%MOD;
		t[b+i+1]=(t[b+i+1]*mod_inv(i,MOD))%MOD;

	}
	rep1(i,B+W)r[i]=(2*r[i-1]+s[i]-t[i]+MOD)%MOD;
	
	rep1(i,b){
		if(B>W)p[a+i]=(p[a+i]+r[a+i])%MOD;
		else p[a+i]=(p[a+i]-r[a+i]+MOD)%MOD;
	}
	rep1(i,B+W)cout<<ans(p[i],q[i],MOD)<<endl;
}

Measured memory_bytes: 8320
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int n;
	cin>>n;
	puts(n==3||n==5||n==7?"YES":"NO");
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int m, f, r, p;
	
	while(1) {
		scanf("%d %d %d", &m, &f, &r);
		if(m == -1 && f == -1 && r == -1) break;
		p = m + f;
		if(m == -1 || f == -1)
		    printf("F\n");
		else if(p >= 80)
		    printf("A\n");
		else if(p >= 65 && p < 80)
		    printf("B\n");
		else if(p >= 50 && p < 65 || r >= 50)
		    printf("C\n");
		else if(p >= 30 && p < 50)
		    printf("D\n");
		else if(m == -1 || f == -1 || p < 30)
		    printf("F\n");
	}
	return 0;
}

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


	
int main(){
	int n,k,l,m;
	cin>>n>>k>>l>>m;
	
	int count1 = 0;
	int count2 = 0;
	
	while(l > 0){
			l -= k;
			count1++;
	}
	
	
	while(n > 0){
			n -= m;
			count2++;
	}
	
	if(count1 <= count2)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}


Measured memory_bytes: 3636
#include <stdio.h>
int main()
{
    int d;
    scanf("%d", &d);
    if (d == 25)printf("Christmas\n");
    else if (d == 24)printf("Christmas Eve\n");
    else if (d == 23)printf("Christmas Eve Eve\n");
    else printf("Christmas Eve Eve Eve\n");
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>

#define LIM_S 200002
#define LIM_N 200001

char str[LIM_S];

int N, K;
int A[LIM_N];

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d %d", &N, &K);

	// for (size_t i = 0; i < N; i++) {
	// 	scanf("%d", &A[i]);
	// }
}

void initialize() {
}

int main(void) {
	receive_input();
	initialize();

	printf("%d\n", N - K + 1);

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=8e5+10;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,k,a[N],tag=0;
char s[N];
int main() {
    cin>>n>>k;scanf("%s",s+1);
    for(int i=1;i<=n;i++) a[i]=s[i]-'A';
    int l=1,r=n,cnt=0;
    while(k&&cnt<2*n) {
        k--;cnt++;
        if(a[l]==tag) a[l]^=1;
        else l++,r++,tag^=1,a[r]=tag;
    }
    if(k&1) {
        k--;cnt++;
        if(a[l]==tag) a[l]^=1;
        else l++,r++,tag^=1,a[r]=tag;
    }
    for(int i=l;i<=r;i++) putchar('A'+(a[i]^tag));
    return 0;
}


Measured memory_bytes: 2560
from collections import Counter

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

A_cnt = Counter(A)

x = 0
for i in A_cnt.values():
    x += i * (i-1) // 2

for a in A:
    ans = x - (A_cnt[a] * (A_cnt[a]-1) // 2)
    ans += (A_cnt[a]-1) * (A_cnt[a]-2) // 2
    print(ans)

Measured memory_bytes: 26780
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
	SpeedForce;
	
	cin >> n >> k;
	For (i, 1, k) {
		cin >> cur;
		For (j, 1, cur) {
			int x;
			cin >> x;
			u[x] = 1;
		}
	}

	For (i, 1, n) if (!u[i]) ++ans;
	cout << ans << '\n';

	return Accepted;
}

// B...a

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

using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b;
    cin >> a >> b;
    if(a < b)
    {
        for(int i = 0 ; i < b ; i++)
          cout << a ;
    }
    else
    {
        for(int i = 0 ; i < a ; i++)
          cout << b ;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
 int function( int n)
 {
     int i , j , flag ;
     if( n <= 2 )
        return n ;
     else
     {
         for( i = n ; i > 0 ; i++)
         {
             for( j = 2 , flag = 0 ; j < sqrt(i) ; j++)
             {
                 if( i % j == 0)
                 {
                     flag = 1 ;
                     break ;
                 }
                  
             }
             if( flag ==0)break ;
         }
     }
     return i ;
 }
 
 int main( )
 {
     int a , result ;
     scanf("%d" , &a);
     result = function(a);
     printf("%d" , result);
     return 0;
 }


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

#define int long long

const int MOD=1e9+7;

int bexp(int a,int b) {
	int res=1;
	while(b) {
		if(b&1) {
			res=(res*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return res;
}

void solve() {
	int n,k;
	cin>>n>>k;
	vector<int> dp(k+1);
	for(int i=k;i>=1;i--) {
		int t=k/i;
		dp[i]=bexp(t,n);
		for(int j=2*i;j<=k;j+=i) {
			dp[i]=(dp[i]-dp[j]+MOD)%MOD;
		}
	}
	int ans=0;
	for(int i=1;i<=k;i++) {
		ans=(ans+i*dp[i])%MOD;
	}
	cout<<ans<<"\n";
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--) {
		solve();
	}
}

Measured memory_bytes: 3972
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

ld solve(ld t, ld head, set<ll> &tails, const vec<ll> &v) {
  if (tails.empty()) {
    return (t + head) / 2.0;
  }
  ld m = -1;
  for (const auto &i : tails) {
    const ld u = (head + v[i]) / 2;
    cout << "u = " << u << endl;
    auto next_tails = tails;
    next_tails.erase(i);
    m = max(m, solve(u, v[i], next_tails, v));
  }
  return m;
}

int main() {
  ll N;
  cin >> N;
  vec<ll> v(N);
  REP(i, N) cin >> v[i];
  sort(ALL(v));

  ld answer = v[0];
  for (int i = 1; i < N; i++) {
    answer = (answer + v[i]) / 2.0;
  }
  cout << answer << endl;
  return 0;
}


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

int main() {
  int N, X, min_x = INT_MAX, sum = 0, count = 0; // ドーナツの種類, お菓子の素(グラム)
  cin >> N >> X;
  for(int i = 0; i < N; i++){
    int m;
  	cin >> m;
    sum += m;
    min_x = min(m, min_x);
    count++;
  }
  count += (X - sum) / min_x;
  cout << count << endl;
  return 0;
}

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

const int INFTY=INT_MAX;
const int maxn=500000;

int L[maxn/2+2],R[maxn/2+2];
int count;

void merge(int *Array,int left,int mid,int right) {
  int n1=mid-left;
  int n2=right-mid;
  for (int i=0; i<n1; i++) {
    L[i]=Array[left+i];
  }
  for (int i=0; i<n2; i++) {
    R[i]=Array[mid+i];
  }
  L[n1]=R[n2]=INFTY;
  int i=0,j=0;
  for (int k=left; k<right; k++) {
    count++;
    if (L[i]<=R[j]) {
      Array[k]=L[i++];
    }
    else {
      Array[k]=R[j++];
    }
  }
}
void mergeSort(int *Array,int left,int right) {
  if (left+1<right) {
    int mid=(left+right)/2;
    mergeSort(Array,left,mid);
    mergeSort(Array,mid,right);
    merge(Array,left,mid,right);
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  int n;
  cin>>n;
  int S[n];
  for (int i=0; i<n; i++) {
    cin>>S[i];
  }
  count=0;
  mergeSort(S,0,n);
  for (int i=0; i<n; i++) {
    if (i) {
      cout<<" "<<flush;
    }
    cout<<S[i]<<flush;
  }
  cout<<endl;
  cout<<count<<endl;
  return 0;
}



Measured memory_bytes: 7032
#include<stdio.h>
#include<math.h>
int main()
{
	char a[100];
	int i;
	char x[2]={'C','F'};
	while(gets(a)){
		int v=0;
	for(i=0;a[i]!='\0';i++){
		if(a[i]==x[v]){
			v++;
		}
		if(v==2){
			break;
		}
	}
	if(v==2){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define _Pi 3.1415926535
#define _MOD = 1e9+7;
using namespace std;
typedef long long ll;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(100000);
    rep(i,n) cin >> h[i];
    
    vector<int> cost(100000,1 << 30);
    cost[0] = 0;

    for(int i = 0; i < n; ++i){
       for(int j = 1; j <= k; ++j){
           cost[i+j] = min(cost[i+j],cost[i]+abs(h[i+j]-h[i]));
       }
    }

    cout << cost[n-1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
 
#define LOCAL 0
 
#define lli long long int
#define llu unsigned long long int
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define slli(n) scanf("%lld",&n);
#define ss(n) scanf("%s",n);
 
const long double EPS = 1e-10;
const lli MOD = 1000000007ll;
const lli mod1 = 1000000009ll;
const lli mod2 = 1100000009ll;
int INF = (int)1e9;
lli INFINF = (lli)1e18;
int debug = 0;
 
using namespace std;
 
void print(int a[],int s,int e){for(int i=s;i<=e;i++)cout<<a[i]<<" ";cout<<"\n";}
void print(vector<int> &v,int s,int e){for(int i=s;i<=e;i++)cout<<v[i]<<" ";cout<<"\n";}
void print(vector<int> &v){for(int x:v)cout<<x<<" ";cout<<"\n";}
 
lli bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
lli bit(lli _mask,lli _i){return (_mask&(1<<_i))==0?0:1;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli add(lli a,lli b,lli m=MOD){lli x=a+b;while(x>=m)x-=m;return x;}
lli sub(lli a,lli b,lli m=MOD){lli x=a-b;while(x<0)x+=m;return x;}
lli mul(lli a,lli b,lli m=MOD){lli x=a*b;x%=m;return x;}
 
lli H,W,N;
lli a[100010],b[100010];
set<pair<lli,lli> > Set,PO;
lli ans[10];
 
int main()
{
if(LOCAL){
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    debug = 1;
}
    srand (time(NULL));
 
    slli(H);slli(W);slli(N);
    for(lli i=1;i<=N;i++){
        slli(a[i]);slli(b[i]);
        lli x = a[i],y = b[i];
        PO.insert({x,y});
        Set.insert({x,y});
        Set.insert({x,y-1});
        Set.insert({x,y-2});
        Set.insert({x-1,y});
        Set.insert({x-1,y-1});
        Set.insert({x-1,y-2});
        Set.insert({x-2,y});
        Set.insert({x-2,y-1});
        Set.insert({x-2,y-2});
    }
    lli tot = (max(0ll,H-2)*max(0ll,W-2));
    for(set<pair<lli,lli> > ::iterator it = Set.begin();it != Set.end();it++){
        lli cnt = 0;
        lli x = (*it).F;
        lli y = (*it).S;
        if(x<1 || (x>H-2) || y<1 || y>(W-2))
            continue;
        for(lli i=0;i<=2;i++){
            for(lli j=0;j<=2;j++){
                if(PO.find({(*it).F+i,(*it).S+j}) != PO.end())
                    cnt++;
            }
        }
        ans[cnt]++;
    }
    lli sum = 0;
    for(lli i=1;i<=9;i++)
        sum += ans[i];
    ans[0] = tot - sum;
    for(lli i=0;i<=9;i++)
        cout<<ans[i]<<"\n";
 
    return 0;
}

Measured memory_bytes: 66304
H,W = $stdin.gets.split.map(&:to_i)
N = $stdin.gets.to_i
nums = $stdin.gets.split.map(&:to_i)

cols = []
H.times { |i|
  rest = W
  row = []
  # fill color
  while rest > 0
    #p [rest, nums]
    color = N - nums.size + 1
    n = [nums[0], rest].min
    row << [color] * n
    nums[0] -= n
    rest -= n
    nums.shift if nums[0] == 0
  end
  puts (i%2 == 0 ? row : row.reverse).join(" ")
}

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
int64 q, n;
const int MAXN = 200200;
vector <pair <int, int> > ad [MAXN];
vector <int64> cost (MAXN);
vector <bool> rs (MAXN);
vector <bool> visited (MAXN);
map <pair <int, int>, int > mp;
void solve(){

    return;
}

void dfs (int n){
    // ctn(n);
    if (!visited[n]){
        visited[n] = 1;
        for (int i = 0; i < ad[n].size(); i++){
            int cur = ad[n][i].first;
            int c = ad[n][i].second;
            if (!visited[cur]){
                cost[cur] = cost[n] + c;
                dfs(cur);
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++){
        int x,y,z;
        cin >> x >> y >> z;
        ad[x].push_back({y,z});
        ad[y].push_back({x,z});
    }
    dfs(1);
    for (int i = 1; i <= n; i++){
        // db(cost[i]);
        if (cost[i] % 2 == 0){
            ctn(0);
        }
        else{
            ctn(1);
        }
    }
    return 0;
}


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

ll f(int l, int r) {
  ll s = r - l;
  return s * (s + 1) / 2;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &e : a) {
    cin >> e;
    // cerr << bitset<20>(e) << endl;
  }
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }

  vector<int> s(n + 1), x(n + 1);
  for (int i = 0; i < n; i++) {
    s[i + 1] = s[i] + a[i];
    x[i + 1] = x[i] ^ a[i];
  }
  vector<pair<int, int>> p;
  int l = 0, r = 1;
  while (r + 1 < n + 1) {
    while (r + 1 < n + 1 && s[r + 1] - s[l] == (x[r + 1] ^ x[l])) {
      r++;
    }
    p.push_back(make_pair(l, r));
    l++;
  }
  // for (auto e : p) {
  //   cerr << e.first << " " << e.second << endl;
  // }

  ll c = 0;
  for (int i = 0; i < p.size(); i++) {
    c += f(p[i].first, p[i].second);
    if (i != 0 && p[i].first < p[i - 1].second) {
      c -= f(p[i].first, p[i - 1].second);
    }
  }
  cout << c << endl;
  return 0;
}


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

class SegTree{
private:
  int n;
  // 1-index (tree[0] is dummy), leaves are tree[n]-tree[2n-1]
  vector<int> tree;
  const int defVal = 2147483647;
public:
  SegTree(int _n){
    int t;
    t = 1;
    while (t<_n) t*=2;
    n = t;
    tree = vector<int>(2*n, defVal);
    //cerr << "finish init" << endl;
    //cerr << "tree size is " << 2*n << endl;
  }
  // stab function
  void update(int l, int r, int x){ return _update(l,r,x,1,0,n);}
  void _update(int l, int r, int x, int k, int kl, int kr){
//    cerr << "update: "<<l<<" "<<r<<" "<<x<<" "<<k<<" "<<kl<<" "<<kr<<endl;
    if (kr<=l || r<=kl) return;
    else if (l<=kl && kr<=r){
      tree[k] = x;
      return;
    } else {
      if (tree[k]!=defVal){
        tree[k*2]=tree[k]; tree[k*2+1]=tree[k];
        tree[k]=defVal;
      }
      _update(l,r, x, k*2, kl,(kl+kr)/2);
      _update(l,r, x, k*2+1, (kl+kr)/2,kr);
    }
  }
  int find(int i){
    return _find(i,1,0,n);
  }
  int _find(int i, int k, int kl, int kr){
//    cerr << "find: "<<i<<" "<<k<<" "<<kl<<" "<<kr<<endl;
    if (k>=n || tree[k]!=defVal) return tree[k];
    if (i<(kl+kr)/2) return _find(i, k*2, kl,(kl+kr)/2);
    else return _find(i, k*2+1, (kl+kr)/2,kr);
  }
  // debug
  void print(){
    cerr << "debug: ";
    for (int i=1; i<2*n; i++){
      if (i==n) cout << "| ";
      if (tree[i]==defVal) cout << "DV ";
      else cout << tree[i] << " ";
    }
    cout << endl;
  }
};

int main(void){
  int n,q;
  SegTree *st;
  
  cin >> n >> q;
  st = new SegTree(n);
  for (int i=0; i<q; i++){
    int c,s,t,x,id;
    cin >> c;
    if (c==0){
      cin >> s >> t >> x;
      st->update(s,t+1,x);
    }
    else if (c==1){
      cin >> id;
      cout << st->find(id) << endl;
    }
    else cout << "illegal command" << endl;
    //st->print();
  }
  return 0;
}


Measured memory_bytes: 4984
N,M = map(int, input().split())

s = []
c = []
for i in range(M):
    _s, _c = input().split(' ')
    s.append(int(_s)-1)
    c.append(_c)

first = (0 if N==1 else 10**(N-1))
lst = list(range(first, (10 ** N)))

result = -1
for num in lst:
    ok = True
    s_num = str(num)
    for i in range(M):
        if (s_num[s[i]] != c[i]):
            ok = False
            break
    if (ok):
        result = num
        break

print (result)


Measured memory_bytes: 3064
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        int h = sc.nextInt(), w = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
        Combination comb = new Combination(h + w + 10, MOD);

        long ans = comb.nck(h + w - 2, h - 1);
        debug(ans);
        long sum = 0;
        for (int i = 0; i < b; i++) {
            long x = comb.nck(h - a + i - 1, i);
            long c = x * comb.nck(a - 1 + w - i - 1, a - 1) % MOD;
            ans = (ans - c + MOD) % MOD;
            debug(i, c);

        }
        out.println(ans);

        out.flush();
    }

    public class Combination {
        int n;
        long mod;
        long[] facts;

        public Combination(int n, long mod) {
            this.n = n;
            this.mod = mod;
            facts = new long[n];
            facts[0] = 1;
            for (int i = 1; i < n; i++) {
                facts[i] = facts[i - 1] * i % mod;
            }
        }

        long modpow(long a, long b) {
            if (b == 0) return 1;
            else if (b == 1) return a;

            long x = modpow(a, b / 2);
            return b % 2 == 0 ? x * x % mod : x * (x * a % mod) % mod;
        }

        long inv(long n) {
            return modpow(n, mod - 2);
        }

        public long nck(int n, int k) {
            return n < k ? 0 : facts[n] * (inv(facts[n - k]) * inv(facts[k]) % mod) % mod;
        }
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 46476
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100000000000000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    string S;
    cin >> S;
    bool flag = 0;
    rep(i,S.size()){
        if(S[i] == 'C') flag = 1;
        if(flag && S[i] == 'F'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}




Measured memory_bytes: 256
var
	N,A,x,y,i,j,out,ans,nowt,nowf,ccc:Longint;
	F,T,gF,gT:Array[1..15]of Longint;
begin
	read(N);
	for i:=1 to N do begin
		read(A);
		for j:=1 to A do begin
			read(x,y);
			dec(x);
			if y=0 then F[i]:=F[i] or (1<<x)else T[i]:=T[i] or (1<<x);
		end;
	end;
	for i:=1 to N do begin
		nowt:=1<<(i-1);
		nowf:=0;
		for ccc:=1 to N do begin
			for j:=1 to N do begin
				if ((nowt>>(j-1))and 1)=1 then begin
					nowt:=nowt or T[j];
					nowf:=nowf or F[j];
				end;
			end;
		end;
		gF[i]:=nowf;
		gT[i]:=nowt;
		if(nowt and nowf)<>0 then out:=out or(1<<(i-1));
	end;
	i:=((1<<N)-1)and not out;
	ans:=0;
	while i>0 do begin
		ccc:=0;
		nowt:=i;
		nowf:=0;
		for j:=1 to N do begin
			if ((nowt>>(j-1))and 1)=1 then begin
				inc(ccc);
				nowt:=nowt or gT[j];
				nowf:=nowf or gF[j];
			end;
		end;
		if((nowt and nowf)=0)and(ans<ccc)then ans:=ccc;
		i:=(i-1)and not out;
	end;
	writeln(ans);
end.

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    int k,t;
    cin >> k >> t;
    int marx=-INF;
    REP(i,t){
        int tmp;
        scanf("%d",&tmp);
        marx = max(marx,tmp);
    }
    if(marx<=k/2) puts("0");
    else printf("%d\n",marx-(k-marx)-1);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout<<endl
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string> 
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

int main()
{
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	rep(i, sz(s) - 2)
	{
		if (s.substr(i, 3) == "ABC")ans++;
	}
	co(ans);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
int main()
{
  int n, d;
  cin >> n >> d;
  
  int ans = 1;
  int r = 2 * d + 1;
  while(r < n){
    ans++;
    r += 2 * d + 1;
  }
  cout << ans;
}

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

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main(){
	int a, b, c, ans;
	cin >> a >> b >> c;
	ans = b / a;
	if(ans > c){
		cout << c << endl;
	}else{
		cout << ans << endl;
	}
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n;
  cin >> n;
  int t[300001];
  rep(i, 0, n) cin >> t[i];

  int ik = 0;
  rep(i, 0, n) {
    if(i > ik) {
      cout << "no" << endl;
      return 0;
    }
    ik = max(ik, i + t[i] / 10);
  }
  ik = 0;
  dep(i, n - 1, 0) {
    if((n - 1) - i > ik) {
      cout << "no" << endl;
      return 0;
    }
    ik = max(ik, (n - 1) - i + t[i] / 10);
  }

  cout << "yes" << endl;
}



Measured memory_bytes: 5572
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}


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

    Int n, tmp;
    vector<Int> a;
    priority_queue<Int> aa;
    cin >> n;
    for(Int i=0; i<n; i++){
        cin >> tmp;
        a.push_back(tmp);
        aa.push(tmp);
    }
    for(Int i=0; i<n; i++){
        if(aa.top() == a[i]){
            aa.pop();
            cout << aa.top() << endl;
            aa.push(a[i]);
        }else{
            cout << aa.top() << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4964
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

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

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

int main()
{
	int N, M, X;
	cin >> N >> M >> X;

	vector<int> Ci(N, 0);
	vector<vector<int>> Aij(N, vector<int>(M, 0));

	rep(i, N)
	{
		cin >> Ci.at(i);
		rep(j, M)
		{
			cin >> Aij.at(i).at(j);
		}
	}

	int bit;
	int cost = (int)1e7;
	for (bit = 0; bit < (1 << N); ++bit)
	{
		vector<int> cat(M, 0);
		int c_cost = 0;

		for (int ck = 0; ck < N; ++ck)
		{
			if (bit & (1<<ck))
			{
				c_cost += Ci.at(ck);
				rep(k, M)
				{
					cat.at(k) += Aij.at(ck).at(k);
				}
			}
		}

		bool match = true;
		rep(k, M)
		{
			if (cat.at(k) < X)
			{
				match = false;
			}
		}

		if (match)
		{
			cost = min(cost, c_cost);
		}
	}

	if (cost != (int)1e7)
	{
		cout << cost << endl;
	}
	else
	{
		cout << "-1" << endl;
	}
	system("pause");
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main () {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int t, a;
    if (C % B != 0) {
        t = C / B + 1;
    }
    else {
        t = C / B;
    }
    if (A % D != 0) {
        a = A / D + 1;
    }
    else {
        a = A / D;
    }
    if (t <= a) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }


}


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

void Main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h*w);
    for (int i = 0; i < h; i++)
    {
        cin >> s[i];        
    }

    int maxl = 0;
    for (int i = 0; i < h*w; i++)
    {
        if(s[i/w][i%w]=='#') continue;
        vector<vector<int>> a(h, vector<int>(w, -1));
        queue<int> q;
        q.push(i);
        a[i/w][i%w] = 0;
        while (!q.empty())
        {
            int j = q.front(); q.pop();
            int x = j % w;
            int y = j / w;
            if(x-1>=0 && s[y][x-1]=='.' && a[y][x-1]==-1){
                a[y][x-1] = a[y][x]+1;
                q.push(y*w+(x-1));
                maxl = max(maxl, a[y][x-1]);
            }
            if(x+1<w && s[y][x+1]=='.' && a[y][x+1]==-1){
                a[y][x+1] = a[y][x]+1;
                q.push(y*w+(x+1));
                maxl = max(maxl, a[y][x+1]);
            }
            if(y-1>=0 && s[y-1][x]=='.' && a[y-1][x]==-1){
                a[y-1][x] = a[y][x]+1;
                q.push((y-1)*w+x);
                maxl = max(maxl, a[y-1][x]);
            }
            if(y+1<h && s[y+1][x]=='.' && a[y+1][x]==-1){
                a[y+1][x] = a[y][x]+1;
                q.push((y+1)*w+x);
                maxl = max(maxl, a[y+1][x]);
            }
        }
    }
    
    cout << maxl << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


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

int main() {
  int a,b;

  cin >> a >>b;
  if ((a+b)%2 == 0){
   cout << (a+b)/2<< endl;  
  }
  else{
  cout << (a+b)/2+1 << endl;
  }
}

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

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	if (N <= M)
	{
		for (size_t i = 0; i < M; i++)
		{

			cout << N;
		}
	}
	else {
		for (size_t i = 0; i < N; i++)
		{

			cout << M;
		}
	}

}

Measured memory_bytes: 256
x,y = map(int,input().split())
ans = 0
while True:
  if x == y:
    print(ans)
    break
  
  if x == -y:
    x = -x
    ans += 1
    continue

  if (abs(x)<abs(y) and x<0) or (abs(y)<abs(x) and 0<=x):
    x = -x
    ans += 1
    continue
  
  ans += abs(abs(x)-abs(y))
  x += abs(abs(x)-abs(y))

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

int main(){
    ll n;
    cin >> n;
    ll t[n],a[n];
    for(ll i=0;i<n;i++){
        cin >> t[i] >> a[i];
    }
    ll l=t[0],r=a[0];
    for(ll i=1;i<n;i++){
        if(t[i] < l || a[i] < r){
            ll m = max((l-1+t[i])/t[i],(r-1+a[i])/a[i]);
            l = t[i] * m;
            r = a[i] * m;
        }   
        else{
            l = t[i];
            r = a[i];
        }
    }
    cout << l+r << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    ll n, a, b; cin >> n >> a >> b;
    cout << (n/(a+b))*a + min(n%(a+b), a) << endl;
    
    return 0;
}

Measured memory_bytes: 256
N,S = map(int,input().split(" "))
a = list(map(int,input().split(" ")))

ans = float('inf')
l = 0
r = 0
sumv = 0
while True:
	while r < N and sumv < S:
		sumv += a[r]
		r += 1

	if sumv < S:
		break

	ans = min(ans,r-l)
	sumv -= a[l]
	l += 1

if ans == float('inf'):
	ans = 0
print(ans)




Measured memory_bytes: 16380
#if defined(LOCAL)
#define PROBLEM_NAME "c"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define I(x, ...) (x)
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define I(x, ...) (x)
#define C(x, ...) ;
#endif
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#include <iostream>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <limits>
#include <numeric>

using namespace std;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ii = pair<int,int>; using lu = unsigned long long; using l = long long;
using vs = vector<string>; using vii = vector<ii>;
using vl = vector<l>; using vvl = vector<vl>; using vvvl = vector<vvl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = 3.1415926;
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)
#define VVL(x, a, b, i) vvl x(a, vl(b, l(i)));
#define VVVL(x, a, b, c, i) vvvl x(a, vvl(b, vl(c, l(i))));

const l MOD = e9 + 7; // end of template

void solve(istream& in, ostream& out) {
  l n; string s; in >> n >> s;
  unordered_map<string, l> m;
  F(i, 0, 1 << n) {
    string red, blue;
    F(j, 0, n) {
      if ((1 << j) & i) {
        red += s[j];
      } else {
        blue += s[j];
      }
    }
    m[red + "#" + blue]++;
  }
  l z = 0;
  reverse(all(s));
  F(i, 0, 1 << n) {
    string red, blue;
    F(j, 0, n) {
      if ((1 << j) & i) {
        red += s[j];
      } else {
        blue += s[j];
      }
    }
    z += m[red + "#" + blue];
  }
  out << z << lf;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 39460
def main():
    a,b=map(int,input().split(' '))
    if a ==1:
        a += 13
    if b ==1:
        b += 13
    if a > b:
        print('Alice')
    elif a==b:
        print('Draw')
    else:
        print('Bob')
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
mod = 10 ** 6 + 3

W = [1] * (mod)
for i in range(mod - 1):
	W[i + 1] = ((i + 1) * W[i]) % mod

def rev(a):
	return pow(a, mod - 2, mod)

def f(x, d, n):
	if d == 0:
		return pow(x, n, mod)
	else:
		d_r = rev(d)
		xdr = d_r * x % mod
		if xdr == 0:
			return 0
		elif (xdr + n - 1) >= mod:
			return 0
		else:
			return (W[xdr + n - 1] * rev(W[xdr - 1]) % mod) * pow(d, n, mod) % mod

Q = int(input())
for i in range(Q):
	x, d, n = map(int, input().split())
	print(f(x, d, n))

Measured memory_bytes: 45044