akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n,h;cin >>n >> h;
	priority_queue<P> pq;
	rep(i,n){
		int a,b;cin >> a >> b;
		pq.push(P(a,1));
		pq.push(P(b,0));
	}
	int ret = 0;
	while(pq.size() && h>0){
		auto now = pq.top();pq.pop();
		int damage = now.first,type = now.second;
		if(type == 0){
			h -= damage;
			ret++;
		}
		else if(type == 1){
			int can = (h + damage -1)/damage;
			ret += can;
			h -= can*damage;

		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 7436
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	static final long MOD = 998244353;
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		long K = sc.nextLong();
		long[] fact = new long[N+1], inv = new long[N+1];
		fact[0] = 1;
		for (int i = 1; i <= N; i++) {
			fact[i] = (fact[i-1] * i) % MOD;
		}
		inv[N] = inv(fact[N]);
		for (int i = N - 1; i >= 0; i--) {
			inv[i] = (inv[i + 1] * (i + 1)) % MOD;
		}
		long ans = 0;
		long sumX = 0;
		for (int x = 0; x <= N && sumX <= K; x++, sumX += A) {
			long rem = K - sumX;
			if (rem % B == 0) {
				long y = rem / B;
				if (y <= N) {
					long tmp1 = (fact[N] * inv[x]) % MOD;
					tmp1 = (tmp1 * inv[N - x]) % MOD;
					long tmp2 = (fact[N] * inv[(int)y]) % MOD;
					tmp2 = (tmp2 * inv[N - (int)y]) % MOD;
					ans += (tmp1 * tmp2) % MOD;
				}
			}
		}
		ans %= MOD;
		out.println(ans);
		
		out.flush();
	}
	
	static long inv(long n) {
		return exp(n, MOD - 2);
	}
	
	static long exp(long b, long e) {
		if (e == 0) return 1;
		long tmp = exp(b, e / 2);
		tmp = (tmp * tmp) % MOD;
		if (e % 2 == 1) {
			tmp = (tmp * b) % MOD;
		}
		return tmp;
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 27220
import heapq
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    A = list(map(lambda x: x*(-1),A))

    heapq.heapify(A)

    for _ in range(M):
        max_value = heapq.heappop(A) * (-1)
        heapq.heappush(A,max_value//2 * (-1))

    print(sum(A) * (-1))

if __name__ == "__main__":
    main()

Measured memory_bytes: 19928
using System;
using System.Linq;

class p{
  static void Main(){
    int n = int.Parse(Console.ReadLine());
    int k = int.Parse(Console.ReadLine());
    int x = int.Parse(Console.ReadLine());
    int y = int.Parse(Console.ReadLine());
    
    Console.WriteLine(n <= k ? n * x : k * x + (n - k) * y);
    
  }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
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; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int m=0;string s;cin>>s;
  rep(i,s.size()){
    int c=0;
    reps(j,i,s.size()){
      if(s[j]=='A'||s[j]=='C'||s[j]=='G'||s[j]=='T'){
        c++;
      }else{
        break;
      }
    }
    chmax(m,c);
    i+=c;
  }
  cout<<m;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

string s;

int main(int argc, char const *argv[]) {
	cin >> s;
	FOR(i, s.size()) {
		for (int j = i+1; j < i+3 && j < s.size(); j++) {
			if (s[j] == s[i]) {
				cout << i+1 << " " << j+1 << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1" << endl;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main() {
    int count[4][3][10] = { 0 };
    int n, b, f, r, v, i, j, k;
    scanf("%d", &n);
    for (i = 0;i < n;i++) {
        scanf("%d %d %d %d", &b, &f, &r, &v);
            count[b-1][f-1][r-1] += v;
    }
    for (i = 0;i <= 3;i++) {
        for (j = 0;j <= 2;j++) {
            for (k = 0;k <= 9;k++) {
                    printf(" %d", count[i][j][k]);          
            }
            printf("\n");
        }
        if (i == 3) {
            break;
        }
        printf("####################\n");
    }
    return 0;
}


Measured memory_bytes: 2140
#import numpy as np
#import functools
#import operator
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm
#import collections as C #most_common
#import math
#import sympy

N = int(input())
#A,B= map(int,input().split())
#P = list(map(int,input().split()))
#S = str(input())
#T = str(input())
a=0
b=0
c=0
d=0
for i in range(N):
    S = str(input())
    if S=='AC':
        a+=1
    elif S=='WA':
        b+=1
    elif S=='TLE':
        c+=1
    else:
        d+=1

print('AC x',a)
print('WA x',b)
print('TLE x',c)
print('RE x',d)


Measured memory_bytes: 9200
#include "bits/stdc++.h"
using namespace std;

int main()
{
	int N;
	cin >> N;
	long ans=0;

	unordered_map<int, int> hashmap;
	int A;
	for (int i = 0; i < N; i++) {
		cin >> A;
		hashmap[A]++;
	}
	for (pair<int, int> p : hashmap) {
		ans = p.first * p.second+ ans;
	}

	int Q;
	cin >> Q;

	int B, C;
	long tmp;

	for (int i = 0; i < Q;i++) {
		cin >> B >> C;
		tmp = 0;
		auto itr = hashmap.find(B);
		if (itr != hashmap.end()) {
			tmp = hashmap[B];
			auto itrr = hashmap.find(C);
			if (itrr != hashmap.end()) {
				hashmap[C] = hashmap[C]+tmp;
			}
			else {
				hashmap[C]= tmp;
			}
			hashmap.erase(itr);
		}
		ans = ans - tmp * B + tmp * C;
		cout << ans << endl;
	}
	
}

Measured memory_bytes: 6604
#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <queue>


using namespace std;


int main(){
    int N;
    int a[200001];
    int b[200001] = {0};

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

    int M = 0;

    for(int i=N; i>N/2; i--){
        b[i] = a[i];
        M += b[i];
    }

    for(int i=N/2; i>=1; i--){
        int sum_right = 0;
        for(int j=2*i; j<=N; j+=i) {
            sum_right += b[j];
            sum_right %= 2;
        }
//        if(a[i] == sum_right){
//            cout << "-1" << endl;
//            return 0;
//        }

        b[i] = abs(a[i] - sum_right);
        M+=b[i];
    }

    cout << M << endl;
    for(int i=1; i<=N; i++){
        if(b[i]!=0)
            cout<< i << " ";
    }
    cout<<endl;
    return 0 ;

}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
long long mod = 1000000000+7;

int main(){

	int n,k;
	cin>>n>>k;
	int p[n];
	rep(i,n)cin>>p[i];

	int ans=0;
	sort(p,p+n);
	rep(i,k)ans+=p[i];
	cout<<ans<<endl;

	return 0;
}



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

ll solve() {
    ll N, s = 0;
    cin >> N;
    vector<ll> A(N), b(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
        s += A[i];
        b[i] = s;
    }
    ll m = s;
    for ( int i = 0; i < N; i++ ) {
        m = min(m, abs(b[i] - (s - b[i])));
    }
    ll ans = m;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3328
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int X;
int Y;
int main(){
  int res = 1073709056;
  rd(X);
  rd(Y);
  if(X <= Y){
    chmin(res, Y - X);
  }
  if(-X <= Y){
    chmin(res, Y + X + 1);
  }
  if(X <= -Y){
    chmin(res, -Y - X + 1);
  }
  if(-X <= -Y){
    chmin(res, -Y + X + 2);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191125-1

// --- original code ---
// int X, Y;
// {
//   int res = int_inf;
//   rd(X,Y);
//   if(X <= Y) res <?= Y - X;
//   if(-X <= Y) res <?= Y + X + 1;
//   if(X <= -Y) res <?= -Y - X + 1;
//   if(-X <= -Y) res <?= -Y + X + 2;
//   wt(res);
// }


Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)
ans = sum(P[:X]) + sum(Q[:Y])
x = X-1
y = Y-1
c = 0
x_flag = False
y_flag = False
while x >= 0 and y >= 0 and c < C:
    if x_flag == False:
        p = P[x]
    else:
        p = 10**9 + 1
    if y_flag == False:
        q = Q[y]
    else:
        q = 10**9 + 1
    r = R[c]
    if p <= q and p < r:
        ans = ans - p + r
        x -= 1
        c += 1
        if x == -1:
            x = 0
            x_flag = True
    elif q < p and q < r:
        ans = ans - q + r
        y -= 1
        c += 1
        if y == -1:
            y = 0
            y_flag = True
    else:
        break

print(ans)

Measured memory_bytes: 22720
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

//siny  cosx
double PI = 3.14159265359;

int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double rad1 = (h*30+m*30/60)/360*(2*PI);
    double rad2 = m*6/360*(2*PI);
    double ly = a*sin(rad2);
    double lx = a*cos(rad2);
    double sy = b*sin(rad1);
    double sx = b*cos(rad1);
    double dis = sqrt((ly-sy)*(ly-sy)+(lx-sx)*(lx-sx));
    printf("%.10f\n", dis);
    return 0;
}

Measured memory_bytes: 4040
import java.util.Scanner;
class Main
 {
   public static void main(String[] args)
      {
      Scanner stdln = new Scanner(System.in);
      int x,i=1;
      while(true){
      x = stdln.nextInt();
      if (x==0)break;
        System.out.printf("Case %d: %d\n", i++, x);
      }
 }
}



Measured memory_bytes: 63660
#include <iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if((abs(a-b)<=d && abs(b-c)<=d) || abs(a-c)<=d) cout << "Yes" << "\n";      
  else cout << "No" << "\n";
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(){
  string A,B,C;
  cin>>A>>B>>C;
  int x=A.size(),y=B.size(),z=C.size();
  vector<char> D(x+y+z+3,'-');
  for(int i=0;i<x+y+z+3;i++){
    if(i<x){
      D.at(i)=A.at(i);
    }
    else if(x+1<=i&&i<x+y+1){
      D.at(i)=B.at(i-x-1);
    }
    else if(x+y+2<=i&&i<x+y+z+2){
      D.at(i)=C.at(i-x-y-2);
    }
  }
  int i=0;
  int j=0;
  int k=0;
  int now=0;
  string ans;
  while(now!=x&&now!=x+y+1&&now!=x+y+z+2){
    if(now<x){
      i++;
      if(D.at(now)=='a'){
        now=i;
      }
      else if(D.at(now)=='b'){
        now=x+j+1;
      }
      else now=x+y+k+2;
    }
    else if(x+1<=now&&now<x+y+1){
      j++;
      if(D.at(now)=='a'){
        now=i;
      }
      else if(D.at(now)=='b'){
        now=x+j+1;
      }
      else now=x+y+k+2;
    }
    else if(x+y+2<=now&&now<x+y+z+2){
      k++;
      if(D.at(now)=='a'){
        now=i;
      }
      else if(D.at(now)=='b'){
        now=x+j+1;
      }
      else now=x+y+k+2;
    }
    if(now==x) ans="A";
    if(now==x+y+1) ans="B";
    if(now==x+y+z+2) ans="C";
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define INF 2000000000
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int n, a, b,ans;
	cin >> n >> a >> b;
	ans = modpow(2, n);
	ans -= com(n, a);
	if (ans < 0) ans += mod;
	ans -= com(n, b);
	if (ans < 0) {
		ans += mod;
	}
	cout << ans - 1 << endl;
}

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

int main(){
  int a,b,k;
  int count = 0;
  cin >> a >> b >> k;
  for(int i = min(a,b);i >=1 ;i--){
    if(a % i == 0 && b % i == 0){
      count++;
    }
    if(count == k){
      cout << i << endl;
      break;
    }
  }
  return 0;
}

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

int main() {
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<int> l(n), r(n);
	rep(i, q) cin >> l[i] >> r[i];

	vector<int> cnt(n - 1, 0);
	rep(i, n - 1) if (s[i] == 'A' && s[i + 1] == 'C') cnt[i] = 1;
	
	vector<int> sum(n + 1, 0);
	for (int i = 2; i < n + 1; i++) {
		sum[i] = sum[i - 1] + cnt[i - 2];
	}

	rep(i, q) {
		cout << sum[r[i]] - sum[l[i]] << endl;
	}

}

Measured memory_bytes: 2688
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
const int maxn = 55;
int a[maxn];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int len=0;
    for(int i=n-1;i>=n-k;i--)
    {
        len+=a[i];
    }
    cout<<len<<endl;
    return 0;
}



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

int main(){

  long long x,y;
  int ans = 0;

  scanf("%lld %lld", &x, &y);

  while(x <= y){
    x = x*2;
    ans++;
  }

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

  return 0;
}


Measured memory_bytes: 128
def make_divisors(n: int) -> list:
    return_list = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            return_list.append(i)
            if i != n // i:
                return_list.append(n//i)

    return return_list
N = int(input())
cnt = 0
for i in range(1,N+1,2):
    if len(make_divisors(i)) == 8:
        cnt += 1
print(cnt)

Measured memory_bytes: 9308
#include <iostream>

using namespace std;

char s[100];

int main(int argc, char *argv[]) {
	int n;
	while(cin>>n) {
		int y=0;
		for(int i=0;i<n;i++) {
			cin>>s[i];
			if(s[i]=='Y')
				y++;
		}
		if(y)
			cout<<"Four"<<endl;
		else
			cout<<"Three"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void YES()
{
	OUT("YES");
}
void NO()
{
	OUT("NO");
}
void YESNO(const bool cond)
{
	OUT(cond ? "YES" : "NO");
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}
void YesNo(const bool cond)
{
	OUT(cond ? "Yes" : "No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

// 階乗を計算 O(N) (N=10^7 で O(10^7))
ll factorial(ll n)
{
	for (ll i = n - 1; i > 1; --i)
		n *= i;
	return n;
}

// nCrを計算 O(N) (N=10^7 で O(10^7))
ll ncr(const ll n, ll r)
{
	if (r * 2 > n) r = n - r;

	ll dividend = 1, divisor = 1;

	for (ll i = 1; i <= r; ++i) {
		dividend *= n - i + 1;
		divisor *= i;
	}

	return dividend / divisor;
}

// 素数判定 O(sqrt(N)) (N=10^7 で O(10^3))
bool isprime(const ll num)
{
    if (num < 2) return false;
    if (num == 2) return true;
    if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0) return false;
    }

    return true;
}

// 各桁の和を計算 O(logN) (N=10^7 で O(7))
ll digsum(ll n)
{
	ll sum = 0;
	while(n != 0){
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

//////////////////////////////

void Main()
{
	inll a, b;
	
	return OUT((a - 1) * (b - 1));
}


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

int main(){
    string s;
    cin >> s;
    string S = "CODEFESTIVAL2016";
    int i;
    int h=0;
    for(i=0;i<s.size();i++){
        if(s.at(i)!=S.at(i)){
            h++;
        }
    }
    cout  << h << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main
{	
  	int a, b;
  
    Main(Scanner in, PrintWriter out)
    {
      a = in.nextInt()-1;
      b = in.nextInt()-1;
      out.print(a*b);
    }
	
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new	Main(in, out);
		out.close();
	} 
}

Measured memory_bytes: 22612
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			String line = reader.readLine();
			int n = Integer.parseInt(line);
			String ans = "No";

			for(int i = 1; i < 10; i++){
				for(int j = 1; j < 10; j++){
					if(n == i*j){
						ans = "Yes";
						break;
					}
				}
			}
			System.out.println(ans);
		} catch (IOException e) {
			System.out.println(e);
		} catch (NumberFormatException e) {
			System.out.println(e);	
		}
	}
}

Measured memory_bytes: 22868
# include <iostream>
# include <string>
# include <algorithm>

main()
{
    std::string s;
    std::cin >> s;
    int n = s.length();
    int flag = 0;
    for (int i=0; i<n; i++) {
        if (std::count(s.cbegin(), s.cend(), s[i]) != 2) {flag = 1;}
    }
    if (flag) {
        std::cout << "No" << std::endl;
    } else {
        std::cout << "Yes" << std::endl;
    }
}

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

#define ll long long
#define vi vector<int>
#define pi pair<int, int>

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int r;
	cin >> r;
	cout << r * r;
	return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n, t;
  cin >> n >> t;
  vi a(n);
  rep(i, n) cin >> a[i];
  int mini = a[0];
  vi v;
  loop(i, 1, n) {
    if (a[i] - mini > 0) v.pb(a[i] - mini);
    cmin(mini, a[i]);
  }
  cout << count(all(v), *max_element(all(v))) << endl;
}


Measured memory_bytes: 2168
import java.util.*;
public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t =sc.next();
        String t1 =t.substring(0,s.length());
        //System.out.println(t1);
        if(s.equals(t1)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }
}






Measured memory_bytes: 35756
X, Y, Z, K = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

N = []
for a in A:
    for b in B:
        N.append(a + b)
N.sort(reverse=True)
N = N[:K]

M = []
for n in N:
    for c in C:
        M.append(n + c)
M.sort(reverse=True)
M = M[:K]

print(*M, sep="\n")


Measured memory_bytes: 151772
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE FlexibleContexts #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Sequence as Seq
import Data.Sequence (Seq)
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO
import Data.Function
import Control.Monad.Primitive
import qualified Data.Vector.Primitive.Mutable as VPM
import qualified Data.Vector.Generic.Mutable as VGM
import Data.STRef

main :: IO ()
main = do
  k <- read <$> getLine :: IO Int
  if k == 1 then do
    print 1
    print 1
  else do
    let n = shiftR (k+3) 1 `clearBit` 0
    print n
    forM_ [0..n-1] $ \r ->
      putStrLn $ intercalate " "
      $ map show
      $ map (+1)
      $ (`map` [0..n-1])
      $ \c -> let rpc = r+c
                  rpcmn = if rpc >= n then rpc - n else rpc
              in if even r || rpcmn+n >= k then rpcmn else rpcmn+n


Measured memory_bytes: 1916
#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10**7)

# Override `input` function because `stdin.readline()` is 10x faster than built-in `input()`
input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def main():
    n, d = read_h()
    cov = 2 * d + 1

    import math
    ans = math.ceil(n / cov)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M);
}

int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    int n = s.length();
    vector<ll> a(n+1);
    vector<ll> c(n+1);
    vector<ll> r(n+1);
    vector<ll> l(n+1);
    a[0] = c[n] = r[n] = l[0] = 0;
    REP(i,n) {
        if(s[i] == 'A') a[i+1] = a[i]+1;
        else a[i+1] = a[i];
    }
    for (int i = n-1; i >= 0; --i) {
        if (s[i] == 'C') c[i] = c[i+1]+1;
        else c[i] = c[i+1];
    }
    REP(i,n) {
        if(s[i] == '?') l[i+1] = l[i]+1;
        else l[i+1] = l[i];
    }
    for (int i = n-1; i >= 0; --i) {
        if (s[i] == '?') r[i] = r[i+1]+1;
        else r[i] = r[i+1];
    }
    ll ans = 0;
    /*REP(i,n) {
        cout << a[i] << ", " << l[i] << ", " << c[i] << ", " << r[i] << std::endl;
    }*/
    for(int i = 0; i < n; ++i) {
        if(s[i] == 'B' || s[i] == '?') {
            ll A = a[i];
            ll C = c[i+1];
            ll L = l[i];
            ll R = r[i+1];
            A = A*RepeatSquaring(3, L, MOD)%MOD;
            if(L > 0) A = (A+L*RepeatSquaring(3, L-1, MOD))%MOD;
            C = C*RepeatSquaring(3, R, MOD)%MOD;
            if(R > 0) C = (C+R*RepeatSquaring(3, R-1, MOD))%MOD;
            ans = (ans+A*C%MOD)%MOD;
            //cout << A << ", " << C << std::endl;
        }
    }
    cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define rep(i,s,n) for(int i = (s);i<(n);i++)
#define repe(i,s,n) for(int i = (s);i<=(n);i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
const ll MOD=1000000007,INF=1e18;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};

int n,s;
 
int f(int b,int n){
    ll ans=0;
    while(n>0){
        if(n<b){
            ans+=n;
            break;
        }
        ans+=(n%b);
        n/=b;
    }
    return ans;
}

signed main(){
    cin>>n>>s;
    if(n==s){
        cout<<n+1<<endl;
        return 0;
    }
    int ans=INF;
    repe(i,2,sqrt(n)){
        if(f(i,n)==s)ans=min(ans,i);
    }
    rep(i,1,sqrt(n)){
        if(n<=s)continue;
        int b=(n-s)/i+1;
        if(b==1)continue;
        if(f(b,n)==s)ans=min(ans,b);
    }
    if(ans!=INF)cout<<ans<<endl;
    else if(s==1)cout<<n<<endl;
    else cout<<"-1"<<endl;
    return 0;
}

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

int main () {
  int n;
  cin >> n;
  int a[2 * n];
  for (int i = 0; i < 2 * n; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  sort(a, a + 2 * n);
  for (int i = 0; i < 2 * n; i++) {
    if (i % 2 == 0) {
      ans += a[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		int a = str.charAt(0) - '0';
		int b = str.charAt(1) - '0';
		int c = str.charAt(2) - '0';
		int d = str.charAt(3) - '0';
		if (a + b + c + d == 7) {
			System.out.println(a + "+" + b + "+" + c + "+" + d + "=7");
			return;
		}
		if (a + b + c - d == 7) {
			System.out.println(a + "+" + b + "+" + c + "-" + d + "=7");
			return;
		}
		if (a + b - c + d == 7) {
			System.out.println(a + "+" + b + "-" + c + "+" + d + "=7");
			return;
		}
		if (a - b + c + d == 7) {
			System.out.println(a + "-" + b + "+" + c + "+" + d + "=7");
			return;
		}
		if (a + b - c - d == 7) {
			System.out.println(a + "+" + b + "-" + c + "-" + d + "=7");
			return;
		}
		if (a - b + c - d == 7) {
			System.out.println(a + "-" + b + "+" + c + "-" + d + "=7");
			return;
		}
		if (a - b - c + d == 7) {
			System.out.println(a + "-" + b + "-" + c + "+" + d + "=7");
			return;
		}
		if (a - b - c - d == 7) {
			System.out.println(a + "-" + b + "-" + c + "-" + d + "=7");
			return;
		}
	}
}


Measured memory_bytes: 21844
#include<cstdio>
using namespace std;
typedef long long ll;
const int N=500+10;
int main()
{
    int n,s[N],t[N],T[N];
    while(~scanf("%d",&n)){
        n--;
        for(int i=1;i<=n;i++){
            scanf("%d%d%d",&s[i],&t[i],&T[i]);
        }
        for(int i=1;i<=n;i++){
            ll sum=s[i]+t[i];
            for(int j=i+1;j<=n;j++){
                if(sum>t[j]){
                    if(sum%T[j]!=0){
                        sum=(sum/T[j]+1)*T[j];
                    }
 
 
                }
                else sum=t[j];
                sum+=s[j];
            }
            printf("%lld\n",sum);
        }
        printf("0\n");
    }
 
 
    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	static String[] hash = new String[1000005];

	public static void main(String[] args) {
		try (
				BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
				PrintWriter pw = new PrintWriter(System.out);) {

			int n = Integer.parseInt(br.readLine());
			br.lines().limit(n).forEach(line -> {

				String[] str = line.split(" ");
				if (str[0].equals("insert")) {
					insert(str[1]);
				} else {
					String ans = find(str[1]) ? "yes" : "no";
					pw.write(ans);
					pw.write(System.lineSeparator());
				}

			});
			pw.flush();

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	// 文字から数値に変換
	static int getChar(char c) {
		switch (c) {
		case 'A':
			return 1;
		case 'C':
			return 2;
		case 'G':
			return 3;
		case 'T':
			return 4;
		default:
			return 0;
		}
	}

	// 文字列から数値に変換してkeyを生成する
	static long getKey(String str) {
		long sum = 0;
		for (int i = 0, p = 1; i < str.length(); i++, p *= 5) {
			sum += p * str.charAt(i);
		}
		return sum;
	}

	// ハッシュ関数
	static int h1(long key) {
		return (int) (key % hash.length);
	}

	static int h2(long key) {
		return (int) (key % hash.length - 1) + 1;
	}

	static boolean find(String str) {
		long key;
		int index;
		key = getKey(str);
		// TODO 配列エラーが起こるかもしれない
		for (int i = 0;; i++) {
			index = (h1(key) + i * h2(key)) % hash.length;
			if (hash[index] == null) {
				return false;
			} else if (hash[index].equals(str)) {
				return true;
			}
		}

	}

	static boolean insert(String str) {
		long key;
		int index;
		key = getKey(str);
		// TODO 配列エラーが起こるかもしれない
		for (int i = 0;; i++) {
			index = (h1(key) + i * h2(key)) % hash.length;
			// TODO 重複した文字列を格納して良いのか？
			if (hash[index] == null) {
				hash[index] = str;
				return true;
			} else if (hash[index].equals(str)) {
				return false;
			}
		}
	}

}



Measured memory_bytes: 193624
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <random>
#include <complex>
#include <random>
#include <functional>
 
using namespace std;

#define int long long

const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    map<char, int> cnt;
    for (auto t : s) {
        cnt[t]++;
    }
    int ans = 1;
    for (auto t : cnt) {
        ans *= t.second + 1;
        ans %= MOD;
    }
    cout << ans - 1 << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
int ans=0;
ll n;
void dfs(ll a, int t, int f, int s){
    if(n<a){
        return;
    }
    if(t&&f&&s){
        ans++;
    }
    dfs(a*10+3,t+1,f,s);
    dfs(a*10+5,t,f+1,s);
    dfs(a*10+7,t,f,s+1);
}
int main(){
    cin >> n;
    dfs(0,0,0,0);
    cout << ans << endl;
}

Measured memory_bytes: 256
import math

stack=[]
s=raw_input().split()

for i in s:
  if i=='+' or i=='-' or i=='*' or i=='/':
    x=stack.pop()
    y=stack.pop()
    stack.append(str(eval(y+i+x)))

  else:
    stack.append(i)

print stack[0]


Measured memory_bytes: 4704
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int[][][] vs = new int[4][3][10];
		int n = scanner.nextInt();
		for (int i = 0; i < n; ++i) {
			int b = scanner.nextInt();
			int f = scanner.nextInt();
			int r = scanner.nextInt();
			int v = scanner.nextInt();
			vs[b - 1][f - 1][r - 1] += v;
		}
		for (int i = 0; i < 4; ++i) {
			for (int j = 0; j < 3; ++j) {
				for (int k = 0; k < 10; ++k) {
					System.out.printf(" %d", vs[i][j][k]);
				}
				System.out.println();
			}
			if (i != 3) System.out.print("####################\n");
		}
	}
}



Measured memory_bytes: 29784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000001;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

struct edge{
	ll to,cost;
};
typedef pair<int,int> P; //firstは最短距離、secondは頂点の番号

int V; //頂点数
vector<edge> G[100010];
ll d[100010]; //頂点sからの最短距離
int previ[100010];

void dijkstra(int s) {
	//greater<P>を指定することでfirstが小さい順に取り出せる
	priority_queue<P,vector<P>,greater<P>> que;
	fill(d,d + V,INF);
	fill(previ,previ + V,-1);
	d[s] = 0;
	que.push(P(0,s));

	while(!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) {
			continue;
		}
		for(int i = 0;i < G[v].size();i++) {
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				previ[e.to] = v;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}

vector<int> get_path(int t) {
	vector<int> path;
	while(t != -1) {
		path.push_back(t);
		t = previ[t];
	}
	reverse(path.begin(),path.end());
	return path;
}

int main() {
    cin >> V;
    for(int i = 0;i < V - 1;i++) {
        ll A,B,C;
        cin >> A >> B >> C;
        G[A - 1].push_back(edge{B - 1,C});
        G[B - 1].push_back(edge{A - 1,C});
    }
    int Q,K;
    cin >> Q >> K;
    K--;
    dijkstra(K);
    for(int i = 0;i < Q;i++) {
        int A,B;
        cin >> A >> B;
        A--;
        B--;
        cout << d[A] + d[B] << endl;
    }
}

Measured memory_bytes: 10496
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	string s;
    rep(i, 4) {
        char c; cin >> c;
        s += c;
    }
    s += ' ';
    rep(i, 8) {
        char c; cin >> c;
        s += c;
    }
    cout << s << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))
y = x
y = sorted(y)
a = y[n // 2 -1]
b = y[n // 2]
for i in range(n):
  if x[i] <= a:
    print(b)
  elif x[i] >= b:
    print(a)

Measured memory_bytes: 30820
N = int(input())
Dice = [[int(i) for i in input().split()] for j in range(N)]

zorome = 0
for d1, d2 in Dice:
    if d1 == d2:
        zorome += 1
    else:
        zorome = 0
    if zorome == 3:
        print('Yes')
        break
else:
    print('No')

Measured memory_bytes: 9196
import collections
def c():
    n, k = map(int, input().split())
    h = []
    for i in range(n):
        h.append(int(input()))
    h.sort()
    d = collections.deque(maxlen = k)
    mins = []
    while len(d) < k:
        d.append(h.pop())
    while h:
        mins.append(d[0] - d[k-1])
        d.append(h.pop())
    mins.append(d[0] - d[k-1])
    print(min(mins))
c()



Measured memory_bytes: 7988
// from https://atcoder.jp/contests/dp/submissions/11261467
#include<bits/stdc++.h>

#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rrep(i,n) for(ll i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)
#define rrep1(i,n) for(ll i = (n); i > 0; i--)

#define ll long long
#define pi pair<ll, ll>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

struct Seg{
  vector<ll> sum;
  vector<ll> mx;
  Seg(){
    sum.resize(1<<19, 0);
    mx.resize(1<<19, 0);
  }

  void add_val(ll l, ll r, ll val, ll bottom=0, ll top=1<<18, ll pos=1){
    if(l <= bottom && top <=r){
      sum[pos] += val;
      return ;
    }
    if(r<=bottom || l>=top)return ;

    ll mid = (bottom + top)/2;
    add_val(l, r, val, bottom, mid, pos*2);
    add_val(l, r, val, mid, top, pos*2+1);
    mx[pos] = max<ll>(mx[pos*2] + sum[pos*2],  mx[pos*2+1] + sum[pos*2+1]);
  }

  ll max_val(ll l, ll r, ll bottom=0, ll top=1<<18, ll pos=1){
    if(l <= bottom && top <= r) return sum[pos] + mx[pos];
    if(r <= bottom || l>=top)return -INF;

    ll mid = (bottom+top)/2;
    return max<ll>(
      max_val(l, r, bottom, mid, pos*2),
      max_val(l, r, mid, top, pos*2+1)
    )+sum[pos];
  }
};

int main(){
  ll n,m;cin>>n>>m;
  vector<pi> its[n+1];
  rep(i, m){
    ll l,r,a;cin>>l>>r>>a;
    its[r].push_back({l, a});
  }

  Seg seg;
  rep1(i, n){
    ll mx = seg.max_val(0, i);
    seg.add_val(i, i+1, mx);
    for(auto p:its[i]){
      ll l = p.first;
      ll a = p.second;
      seg.add_val(l, i+1, a);
    }
  }

  cout<<seg.max_val(0, n+1)<<endl;
  

  return 0;
}


Measured memory_bytes: 22352
<?php
$n=(int)trim(fgets(STDIN));
$a=explode(' ',trim(fgets(STDIN)));

$mi=$mx=$sm=(int)$a[0];

for($i=1;$i<$n;$i++){
  $ai=(int)$a[$i];
  if($ai<$mi){$mi=$ai;}
  elseif($mx<$ai){$mx=$ai;}
  $sm+=$ai;
}

echo $mi,' ',$mx,' ',$sm;
?>

Measured memory_bytes: 16984
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		for(int i=0;i<N;i++)A[i]--;
		int cnt = 0;
		for(int i=0;i<N;i++){
			if(A[A[i]]== i)cnt++;
		}
		Console.WriteLine(cnt/2);
		
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int main() {
	int n,number[100];
	long long int dp[100][21] = {};
	
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> number[i];
	}

	dp[0][number[0]] = 1;
	for(int i = 1; i < n - 1; i++){
		for(int j = 0; j <= 20; j++){
			if(j + number[i] <= 20){
				dp[i][j] += dp[i - 1][j + number[i]];
			}
			if(j - number[i] >= 0){
				dp[i][j] += dp[i - 1][j - number[i]];
			}
		}
	}
	
	cout << dp[n - 2][number[n - 1]] << endl;
	
	return 0;
}

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

int main()
{
  int n;cin>>n;
  map<string,int>mp;
  while(n--)
  {
    string s;cin>>s;
    mp[s]++;
  }
  cout<<"AC x "<<mp["AC"]<<endl;
  cout<<"WA x "<<mp["WA"]<<endl;
  cout<<"TLE x "<<mp["TLE"]<<endl;
  cout<<"RE x "<<mp["RE"]<<endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstring>
#include <algorithm>
#include <list>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstdio>
#include <vector>

 
using namespace std;

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 2 * 1e5+5;

ll largest(ll a, ll b){
	return (a<b)?b:a;
}
ll smallest(ll a, ll b){
	if(a < b)return a;
	return b;
}
std::vector<int> a[MAXN];
int c[MAXN];
void dfs(int on, int par) {
	for(auto to : a[on]) {
		if(to == par) continue;
		c[to] += c[on];
		dfs(to, on);
	}
}

int main() {
	int n, q;
	cin >> n >> q;
	for(int i = 1; i < n; ++i){
		int u, v;
		cin >> u >> v;
		--u, --v;
		a[u].push_back(v);
		a[v].push_back(u);
	}
	while(q--){
		int p, x;
		cin >> p >> x;
		--p;
		c[p]+=x;
	}
	dfs(0,0);
	for(int i = 0; i < n; ++i){
		cout << c[i] << gap;
	}
	cout << endl;



    return 0;
}	

Measured memory_bytes: 23424
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

typedef long LONG;

LONG zip[3][200];
int M[3];

int a[50][6];
int N, K;

int O[200][200][200];

int main()
{
	scanf("%d %d", &N, &K);	
	memset(zip, -1, sizeof(zip));
	memset(M, 0, sizeof(M));
	memset(a, 0, sizeof(a));
	memset(O, 0, sizeof(O));
	
	for (int i = 0; i < N; i++){
		for (int j = 0; j < 6; j++){
			scanf("%d", &a[i][j]);
			
			bool f = true;
			for (int k = 0; k < M[j % 3]; k++){
				if (zip[j % 3][k] == a[i][j]){
					f = false;
					break;
				}
			}
			
			if (f){
				zip[j % 3][M[j % 3]] = a[i][j];
				M[j % 3]++;
			}
		}
	}
	
	for (int i = 0; i < 3; i++){
		sort(zip[i], zip[i] + M[i]);
	}
	
	for (int i = 0; i < N; i++){
		for (int j = 0; j < 6; j++){
			int l = 0;
			int r = M[j % 3] - 1;
			int m = (l + r) / 2;
			
			while (zip[j % 3][m] != a[i][j]){
				if (zip[j % 3][m] < a[i][j]){
					l = m + 1;
				}
				else {
					r = m - 1;
				}
				
				m = (l + r) / 2;
			}
			
			a[i][j] = m;
		}
	}
	
	for (int i = 0; i < N; i++){
		for (int x = a[i][0]; x < a[i][3]; x++){
			for (int y = a[i][1]; y < a[i][4]; y++){
				for (int z = a[i][2]; z < a[i][5]; z++){
					O[x][y][z]++;
				}
			}
		}
	}

	LONG sum = 0;
	
	for (int x = 0; x < 200; x++){
		for (int y = 0; y < 200; y++){
			for (int z = 0; z < 200; z++){
				if (O[x][y][z] >= K){
					sum += (zip[0][x + 1] - zip[0][x]) * 
					       (zip[1][y + 1] - zip[1][y]) *
					       (zip[2][z + 1] - zip[2][z]);
				}
			}
		}
	}
	
	printf("%ld\n", sum);
	
	return 0;
}

Measured memory_bytes: 32308