akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}


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

    int N; cin >> N;
    vel A(N); rep(i,N) cin >> A[i];
    map<ll ,int> ans;

    int cnt = 0;
    rep(i,N) {
        if(ans[ A[i] ] == 0)  {ans[A[i]]++; cnt++;}
        else {ans[ A[i] ]--; cnt--;}
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 7296
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

const ll mod = 1e9 + 7;

int main() {
    int h = 0, w = 0, k = 0;
    cin >> h >> w >> k;
    vector<vector<ll>> dp(h+1, vector<ll>(w, 0));
    dp.at(0).at(0) = 1;
    for (int i=1; i<h+1; i++) {
        for (int j=0; j<w; j++) {
            for (int k=0; k<(1<<(w-1)); k++) {
                bool out = false;
                for (int l=0; l<w-1; l++) {
                    if (((k>>l)&1) && ((k>>(l+1))&1)) {
                        out = true;
                        break;
                    }
                }
                if (out) continue;
                if (j > 0 && ((k>>(j-1))&1)) {
                    dp.at(i).at(j-1) += dp.at(i-1).at(j);
                    dp.at(i).at(j-1) %= mod;
                }
                else if (j < w-1 && ((k>>j)&1)) {
                    dp.at(i).at(j+1) += dp.at(i-1).at(j);
                    dp.at(i).at(j+1) %= mod;
                }
                else {
                    dp.at(i).at(j) += dp.at(i-1).at(j);
                    dp.at(i).at(j) %= mod;
                }
            }
        }
    }
    cout << dp.at(h).at(k-1) << endl;
    return 0;
}
 

Measured memory_bytes: 256
st = list(map(int,input().split()))
x = st[2] - st[0]
y = st[3] - st[1]
l1 = 'U'*y + 'R'*x
l2 = 'D'*y + 'L'*x
l3 = 'L' + 'U'*(y+1) + 'R'*(x+1) + 'D'
l4 = 'R' + 'D'*(y+1) + 'L'*(x+1) + 'U'
print(l1+l2+l3+l4)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,m;
	vector<int> yaku;
	cin >> n >> m;
	for(int i = 1;i * i <= m;i++){
		if(m % i == 0){
			yaku.pb(i);
			if(m / i != i) yaku.pb(m / i);
		}
	}
	sort(all(yaku),greater<int>());
	for(int v : yaku){
		if(v <= m / n){
			cout << v << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();

		System.out.println(gcd(a, b));

		scan.close();
		System.exit(0);
	}

	private static int gcd(int a, int b) {
		if (a < b) {
			int tmp = a;
			a = b;
			b = tmp;
		}
		if (b == 0)
			return a;
		else
			return gcd(b, a % b);
	}
}

Measured memory_bytes: 26400
#include <iostream>
#include <vector>

using namespace std;

#define int long long
struct Fast { Fast(){ std::cin.tie(0); std::cout.tie(0); ios::sync_with_stdio(false); }} fast;

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;



signed main(void) {

  int n, m; cin >> n >> m;
  vector<int> oks(n + 1, true);
  for (int i = 0; i < m; ++i) {
    int a; cin >> a;
    oks[a] = false;
  }

  vector<int> dp(n + 1);
  dp[0] = 1;
  for (int now = 0; now < n; ++now) {
    for (int next = now + 1; next <= min(n, now + 2); ++next) {
      if (oks[next]) {
        dp[next] += dp[now];
        dp[next] %= MOD;
      }
    }
  }

  cout << dp[n] << endl;
  
}


Measured memory_bytes: 1792
s=int(input())

def f(a):
  if (a%2)==0:
    return a//2
  else:
    return 3*a+1

result=[s]
for i in range(2,10000000):
  s=f(s)
  if s in result:
    print(i)
    exit()
  else:
    result.append(s)


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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;

int n, gA, sA, bA, gB, sB, bB;
bool calc0[5000 + 55];
ll memo0[5000 + 55];

ll dp0(int rem){
	if(calc0[rem]){
		return memo0[rem];
	}

	ll res = 0;

	if(rem - gA >= 0){
		res = max(res, dp0(rem - gA) + (gB - gA));
	}
	if(rem - sA >= 0){
		res = max(res, dp0(rem - sA) + (sB - sA));
	}
	if(rem - bA >= 0){
		res = max(res, dp0(rem - bA) + (bB - bA));
	}

	calc0[rem] = true;
	return (memo0[rem] = res);
}

bool calc1[5000 * 5000 + 55];
ll memo1[5000 * 5000 + 55];

ll go(int rem){
	if(calc1[rem]){
		return memo1[rem];
	}

	ll ans = 0;
	if(rem - gB >= 0){
		ans = max(ans, go(rem - gB) + (gA - gB));
	}
	if(rem - sB >= 0){
		ans = max(ans, go(rem - sB) + (sA - sB));
	}
	if(rem - bB >= 0){
		ans = max(ans, go(rem - bB) + (bA - bB));
	}

	calc1[rem] = true;
	return (memo1[rem] = ans);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n;
	cin >> gA >> sA >> bA;
	cin >> gB >> sB >> bB;
	
	ll x = n + dp0(n);
	cout << x + go(x) << '\n';

	return 0;
}

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

const int N=109;
const int M=19;

int d[M][M],dis[M][M],f[N][N],n=101,a,b;
inline void chkmax(int &a,int b){if(a<b)a=b;}
inline void chkmin(int &a,int b){if(a>b)a=b;}

int main()
{
	if(fopen("vj.in","r"))
	{
		freopen("vj.in","r",stdin);
		freopen("vj.out","w",stdout);
	}
	scanf("%d%d",&a,&b);
	for(int i=1;i<=a;i++)
		for(int j=1;j<=b;j++)
		{
			scanf("%d",&d[i][j]);
			dis[i][j]=1e9;
		}

	for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++)
			for(int k=1;k<=a;k++)
				for(int l=1;l<=b;l++)
					chkmax(f[i][j],d[k][l]-k*i-l*j);
	for(int i=1;i<=a;i++)
		for(int j=1;j<=b;j++)
			for(int k=0;k<=n;k++)
				for(int l=0;l<=n;l++)
					chkmin(dis[i][j],f[k][l]+i*k+j*l);
	for(int i=1;i<=a;i++)
		for(int j=1;j<=b;j++)
			if(dis[i][j]!=d[i][j])
				return puts("Impossible"),0;
	puts("Possible");
	printf("%d %d\n",n*2,n*n+2*n-2);
	for(int i=1;i<n;i++)
		printf("%d %d X\n",i,i+1);
	for(int i=1;i<n;i++)
		printf("%d %d Y\n",1+n+i,n+i);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			printf("%d %d %d\n",i,j+n,f[i-1][j-1]);
	printf("%d %d\n",1,n+1);
	return 0;
}


Measured memory_bytes: 384
/*
 * a.cc:
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
#include<iomanip>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int M;
  M=S.size();

  

  for (int i=0;i<M;i++){
    if (i==0 && S.at(i)=='L'){
      cout<<"No"<<endl;
      return 0;
      
    }

    
    if(i%2==0 && S.at(i)=='L'){
      cout<<"No"<<endl;
      return 0;
    }

    if(i%2==1 && S.at(i)=='R'){
      cout<<"No"<<endl;
      return 0;
    }





  }

  cout<<"Yes"<<endl;
  return 0;
  
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
int main(){

  int q;
  vector <int> a;
  cin>>q;
  for(int i=0;i<q;i++){
    int n,x;
    cin>>n;
    if(n==1){
      cin>>x;
      cout<<a[x]<<endl;
    }
    else if(n==0){
      cin>>x;
      a.push_back(x);
    }
    else{
      a.pop_back();
    }
  }
  return 0;

}



Measured memory_bytes: 3896
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;

int main() {
    int N, M;
    cin >> N >> M;
    vector<pii> islands(M);
    for (int i=0; i<M; i++) {
        int a, b;
        cin >> a >> b;
        islands[i] = make_pair(b, a);
    }
    sort(islands.begin(), islands.end());

    int bridge_left = -1;
    int ans = 0;
    for (int i=0; i<M; i++) {
        int left, right;
        left = islands[i].second; right = islands[i].first;
        if (bridge_left < left) {
            bridge_left = right-1;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
inline char tc(){
  static char fl[100],*A=fl,*B=fl;
  return A==B&&(B=(A=fl)+fread(fl,1,100,stdin),A==B)?EOF:*A++;  
}
inline int read(){
  int a=0;static char c;
  while((c=tc())<48||c>57);
  while(c>=48&&c<=57)a=a*10+c-48,c=tc();
  return a;
}

int main(){
  int n,i;
  n=read();
  int a,count4=0,odd=0;
  for(i=0;i<n;++i){
    a=read();
    if(a%2){
      odd++;
    }else if(a%4==0){
      count4++;
    }
  }
  if(odd==0||odd+((n-count4-odd)?1:0)<=count4+1){
    printf("Yes\n");
    return 0;
  }
  printf("No\n");
}

Measured memory_bytes: 128
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    vector<int> a;
    int q;
    cin >> q;
    while (q--) {
        int t;
        cin >> t;
        if (t == 0) {
            int x;
            cin >> x;
            a.push_back(x);
        } else if (t == 1) {
            int p;
            cin >> p;
            cout << a[p] << endl;
        } else {
            a.pop_back();
        }
    }
}



Measured memory_bytes: 3884
N,K =[int(i)for i in input().split()]

Knum =[0]*40
K2 = 0 #桁数

while K != 0:
    Knum[K2] = K%2
    K = K//2
    K2 += 1
K2 -= 1
if K2 == -1:
    K2 = 0

num =[0]*40
for i in input().split():
    A =int(i)
    m = 0
    while A!=0:
        if A%2==1:
            num[m] += 1
        A = A//2
        m += 1

fmax =[0]*40
for i,j in enumerate(num):
    fmax[i] = fmax[i-1] +(2**i)*max(j,N-j)

ans =[]
karians = 0
for i in range(40):
    j =39 - i
    if Knum[j] == 0:
        karians += (2**j)*num[j]
    elif j !=0:
        ans.append(karians+(2**j)*num[j]+fmax[j-1])
        karians += (2**j)*(N-num[j])
    else:
        ans.append(karians+(2**j)*num[j])
        karians += (2**j)*(N-num[j])
ans.append(karians)
print(max(ans))


Measured memory_bytes: 12788
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int main(){
    ll K, A, B; cin >> K >> A >> B;
    if(B<=A+1){
        cout << K+1 << endl;
        return 0;
    }
    
    if((K-A+1)%2){
        cout << (K-A)/2*B - ((K-A)/2-1)*A + 1 << endl;
    } else {
        cout << (K-A+1)/2*B - ((K-A+1)/2-1)*A << endl;
    }
    return 0;
}


Measured memory_bytes: 256
MOD = 10**9+7

def comb_mod(a: int, b: int, mod: int = MOD) -> int:
    """Returns Comb(a, b) % mod
    Precondition: mod is prime
    Complexity: O(min(a-b, b))
    :param a:
    :param b:
    :param mod: a prime number
    :return:
    """
    b = min(b, a-b)

    res = 1
    for x in range(a-b+1, a+1):
        res = res * x % mod

    # Using Fermat's little theorem
    # a^{p-1} = 1 mod p
    # a^{p-2} = a^{-1} mod p
    for x in range(1, b+1):
        res = res * pow(x, mod-2, mod) % mod

    return res


def main():
    X, Y = [int(x) for x in input().split()]
    m = (X+X-Y)//3
    n = X - 2*m

    if n+2*m != X or 2*n+m != Y or n < 0 or m < 0:
        print(0)
        return
    print(comb_mod(n+m, n))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	//helper functions
	public static void print_arr(String[] arr) {
		int i = 0;
		while(i < arr.length) {
			System.out.print(arr[i]);
			if(i < arr.length - 1) {
				System.out.print(" ");
			}else {
				System.out.print("\n");
			}
			i++;
		}
	}
	
	
	
	public static int extract(String str) {
		return (int)(str.charAt(1) - '0');
	}
	
	public static boolean selection_sort(String[] arr, HashMap<Integer, Integer> boundary) {
		int i = 0;
		int n = arr.length;
		boolean stability = true; // initial as stable
		while(i < n) {
			int min = i;
			for(int j = i+1; j < n; j++) {
				if(extract(arr[min]) > extract(arr[j])) {
					min = j;
				}
			}
			
			
			if(boundary.containsKey(i)) {
				//swap cross the boundary
				if(min > boundary.get(i)) {
					stability = false;
				}
			}
			
			String tmp = arr[i];
			arr[i] = arr[min]; //swap
			arr[min] = tmp;
			i++;
		}	
		
		return stability;
	}
	
	
	
	
	// bubble sort is always stable
	public static void bubble_sort(String[] arr) {
		int i = 0;
		int n = arr.length;
		while(i < n) {
			for(int j = n-1; j > i; j--) {
				if(extract(arr[j]) < extract(arr[j-1])) {
					//swap
					String tmp = arr[j];
					arr[j]  = arr[j-1];
					arr[j-1] = tmp;
				}	
			}
			i++;
		}
		return;
	
	}
	
	// collect the possible stability boundary in the original decker ordering
	public static HashMap<Integer, Integer> collect_bd(String[] deckers){
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		int [] pos = new int[10]; // store the stability boundary(possible)
		Arrays.fill(pos, -1);
		
		int i = 0;
		while(i < deckers.length) {
			int val = extract(deckers[i]);
			if(pos[val] >= 0) {
				map.put(pos[val], i);
				pos[val] = -1;
			}else {
				// just put it into the buffer
				pos[val] = i;
			}
			
			i++;
		}
		
		return map;
	}
	
	
	
	
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int len = cin.nextInt();
		String [] deckers = new String[len];
		String [] copy = new String[len];
		for(int i = 0; i < len; i++) {
			deckers[i] = cin.next();
			copy[i] = deckers[i];
		}
		
	
		
		HashMap<Integer, Integer> boundary = collect_bd(deckers);
		bubble_sort(copy);
		boolean stability = selection_sort(deckers, boundary);
		print_arr(copy);
		System.out.println("Stable");
		print_arr(deckers);
		if(stability)
			System.out.println("Stable");
		else
			System.out.println("Not stable");
		
		
		cin.close();
		
		
	}
}

Measured memory_bytes: 26244
from collections import defaultdict


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

ans = 0
for a in A:
    count_dic[a] += 1

for key, count in count_dic.items():
    if count < key:
        ans += count

    else:
        ans += count - key

print(ans)


Measured memory_bytes: 18676
q = int(input())


from math import sqrt
M = 10**6
p = [1]*(M+1)
p[0] = p[1] = 0
for x in range(2, int(sqrt(M))+1):
    if p[x]:
        for y in range(x*x, M+1, x):
            p[y] = 0


ansl = []
ans = 0

for i in range(10**5+1):
    if i % 2 == 1:
        if p[i] == 1 and p[(i+1) // 2] == 1:
            ans += 1
    ansl.append(ans)

for _ in range(q):
    l,r = map(int,input().split())
    print(ansl[r] - ansl[l-1])



Measured memory_bytes: 58844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if (a >= k) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}

}


Measured memory_bytes: 46804
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <numeric>
#include <regex>
#include <locale>
#include <fstream>
#include <stdlib.h>
#include <cctype>

//#include <map>

using namespace std;

int main()
{
	while (1)
	{
		string str;
		int m;
		vector<int> vn;

		getline(cin, str);
		if (str == "-")break;

		cin >> m;
		cin.ignore();
		for (int i = 0; i < m; i++)
		{
			int t;
			cin >> t;
			cin.ignore();
			vn.push_back(t);
		}

		string temp1, temp2;

		for (int i = 0; i < m; i++)
		{
			temp1 = temp2 = str;
			int t = vn.at(i);
			temp1.erase(0, t);
			temp2.erase(t, temp2.size());
			str = temp1 + temp2;
		}
		cout << str << endl;
	}
}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
#define rep(i, x) for (ll i = 0; i < (x); i++)

using namespace std;
typedef long long int ll;

int main(void) {
  ll a;
  cin >> a;
  cout << (a + a * a + a * a * a) << endl;
  return 0;
}


Measured memory_bytes: 3460
#include<stdio.h>

int main()
{
    int a[200],n,x,an[2]={0,1000000000};

    scanf("%d",&n);

    for(x=0;x<n;x++){
        scanf("%d",&a[x]);
        if(a[x]<0)
            a[x]*=-1;
        if(an[0]<a[x])
            an[0]=a[x];
        if(an[1]>a[x])
            an[1]=a[x];
    }

    printf("%d\n",an[0]-an[1]);



    return 0;
}


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

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

int main(){
    string s;
    cin>>s;
    int c1=0,c2=0;
    int n=s.size();
    rep(i,n){
        if(i%2==1 && s[i]=='0') c1++;
        else if(i%2==0 && s[i]=='1') c1++;
    }
    rep(i,n){
        if(i%2==0 && s[i]=='0') c2++;
        else if(i%2==1 && s[i]=='1') c2++;
    }
    cout<<min(c1,c2)<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    string s;cin>>s;
    if(s.at(2)==s.at(3) && s.at(4)==s.at(5))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3588
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

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

	public Main() {
		FasterScanner sc = new FasterScanner(System.in);

		int n = sc.nextInt();
		int[] parent = new int[n+1];
		for (int i = 2; i <= n; i++) {
			parent[sc.nextInt()]++;
		}
		for (int i = 1; i <= n; i++) {
			System.out.println(parent[i]);
		}
		
		sc.close();
	}
	
	class FasterScanner {
		private InputStream mIs;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FasterScanner() {
			this(System.in);
		}

		public FasterScanner(InputStream is) {
			mIs = is;
		}

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = mIs.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public String nextString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		public void close() {
			try {
				mIs.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}


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

int n;
P d[200000];
vector<int>E[200000];
int sz[200000];
ll dp1[200000];
vector<pair<int,int>>ans;

void dfs1(int v){
	for(int u:E[v]){
		dfs1(u);
		ans.push_back({v+1,u+1});
		dp1[v]+=dp1[u]+sz[u];
	}
}

int main(){
	scanf("%d",&n);
	rep(i,n){
		scanf("%lld",&d[i].first);
		d[i].second=i;
	}
	rep(i,n)sz[i]=1;
	sort(d,d+n);
	for(int i=n-1;i>0;i--){
		ll c=d[i].first-n+2*sz[d[i].second];
		int id=lower_bound(d,d+n,P(c,0))-d;
		if(id==n||d[id].first!=c){
			puts("-1");return 0;
		}
		E[d[id].second].push_back(d[i].second);
		sz[d[id].second]+=sz[d[i].second];
	}
	dfs1(d[0].second);
	if(dp1[d[0].second]!=d[0].first){
		puts("-1");return 0;
	}
	for(auto p:ans){
		printf("%d %d\n",p.first,p.second);
	}
}

Measured memory_bytes: 16244
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

        
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var  input = Reads();
            var d = input[0];
            var n = input[1];
     
            long answer = 0;
            long cc = 0;
            for (long i = 1;; i++)
            {
                long count = 0;
                var m = i;
                while (m>=100&&m%100==0)
                {
                    count++;
                    m /= 100;
                }
                
                if (count==d)
                {
                    cc++;
                }
                if (cc == n)
                {
                    answer = i;
                    break;
                }

            }
            Console.WriteLine(answer);

            
           
            Console.Out.Flush();
        }
    }
}

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

int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
    a[i]-=(i+1);
  }
  sort(a.begin(), a.end());
  if(n%2){
    long long s=0;
    for(int i=0; i<n; i++){
      s+=abs(a[i]-a[(n-1)/2]);
    }
    cout << s;
  }
  else {
    int a1=a[n/2-1], a2=a[n/2];
    long long s1=0, s2=0;
    for(int i=0; i<n; i++){
      s1+=abs(a[i]-a1);
      s2+=abs(a[i]-a2);
    }
    cout << min(s1, s2);
  }
  return 0;
}


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

int main()
{
    int n, w;
    cin >> n >> w;
    vector <int> values(n+1, 0);
    vector <int> weights(n+1, 0);
    for(int i = 1; i <= n; i++){

        cin >> weights[i];
        cin >> values[i];
    }
    long long dp[n+1][w+1];
    for(int i = 0; i < w+1; i++)
        dp[0][i] = 0;
    for(int i = 0; i < n+1; i++)
        dp[i][0] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= w; j++){
            dp[i][j] = 0;
            if(j >= weights[i]){

                dp[i][j] = dp[i-1][j - weights[i]] + values[i];
                //cout << dp[i][j] << " H\n";
            }
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
        }
    }
    // for(int i = 1; i <= n; i++){
    //     for(int j = 1; j <= w; j++){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << "\n";
    // }
    cout << dp[n][w] << "\n";
}

Measured memory_bytes: 79104
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

bool sortfunc(const tuple<int, int, int> &a, const tuple<int, int, int> &b) {
	if(get<0>(a) == get<0>(b)) return get<1>(a) < get<1>(b);
	return get<0>(a) < get<0>(b);
}

bool sortfunc2(const tuple<int, int, int> &a, const tuple<int, int, int> &b) {
	return get<2>(a) < get<2>(b);
}

struct CityID {
	char str[100000][13];
	int str_size = 0;
	vector<tuple<int, int, int> > raw;

	CityID(int n, int m, vector<tuple<int, int, int> > & r) {
		raw = r;
		str_size = m;
	}

	void createId() {
		sort(raw.begin(), raw.end(), sortfunc);
		int id = 0, pref = -1;
		for(auto &x: raw) {
			id++;
			if(pref != get<0>(x)) {
				id = 1;
				pref = get<0>(x);
			}
			sprintf(str[get<2>(x)], "%06d%06d", pref, id);
		}
	}

	void printId() {
			for(int i = 0; i < str_size; i++) {
				cout << str[i] << endl;
			}
	}

};

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

	vector<tuple<int, int, int> > p(M);

	for(int i = 0; i < M; i++) {
		pair<int, int> x;
		cin >> x.first >> x.second;
		p[i] = make_tuple(x.first, x.second, i);
	}

	CityID ids(N, M, p);
	ids.createId();
	ids.printId();
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
//template to keep things straight
 
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define sc(n) scanf("%d",&n)
#define scL(n) scanf("%lld",&n)
 
//#define cinL(n) scanf("%lld",&n)
//#define coutL(n) printf("%lld ",n);
 
#define pr(n) printf("%d\n",n);
#define prL(n) printf("%lld\n",n);
#define newl printf("\n")
//#define mp make_pair
#define pb push_back
#define pf pop_front
#define in insert
#define ll long long 
#define F first
#define S second
//#define MOD 100000000
#define mp make_pair
using namespace std;
#define tv(container, it)  for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define boost  ios::sync_with_stdio(false)//;cin.tie(0)
#define MOD 1000000007

int main()
{
	string s,s1,s11,s22;
	cin>>s;
	int len=s.length();
	int ans=0;
	FOR(i,1,len)
	{
		s1=s.substr(0,len-i);
		//cout<<s1<<"\n";
		if(s1.length()%2==0)
		{
			int len1=s1.length();
			s11=s1.substr(0,len1/2);
			s22=s1.substr(len1/2,len1-(len1/2));
		//	cout<<s11<<" "<<s22<<"\n";
			if(s11==s22)
				{
					ans=max(ans,len1);
				}
		}
	}
	cout<<ans<<"\n";
}
		

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;

    pair<long long int, int> inp[100100];
    for (int i = 0; i < n; i++)
        cin >> inp[i].first >> inp[i].second;

    sort(inp, inp + n);

    long long int ans = 0;
    for (int i = 0; i < n; i++){
        if (m == 0)
            break;

        ans += min(inp[i].second, m) * inp[i].first;
        m -= min(inp[i].second, m);
    }

    cout << ans << '\n';

    return 0;
}


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

struct Point 
{
    double x, y;
    Point(double x=0, double y=0) : x(x), y(y) {}
    
	double distance (const Point &o) const 
	{
        return sqrt((x - o.x) * (x - o.x) + (y - o.y) * (y - o.y));
    }

    Point operator+(const Point &o) const 
	{
        return Point(x+o.x, y+o.y);
    }
 
    Point operator-(const Point &o) const 
	{
        return Point(x-o.x, y-o.y);
    }
 
    Point operator*(const double m) const 
	{
        return Point(x*m, y*m);
    }
 
    Point operator/(const double d) const 
	{
        return Point(x/d, y/d);
    }
 
    double cross(const Point &o) const 
	{
        return x * o.y - y * o.x;
    }
 
    double dot(const Point &o) const 
	{
        return x * o.x + y * o.y;
    }
 
    double atan() const 
	{
        return atan2(y, x);
    }

    double norm() const 
	{
        return dot(*this);
    }

	double area(const Point &a,const Point &b) const
	{
		double t = (a.x - x) * (b.y - y);
		double t2 = (a.y - y) * (b.x - x);
		double areas = abs(t-t2);
		return  areas/2;
	}
};

int main()
{
	Point p1,p2;
	cin >> p1.x >> p1.y >> p2.x >> p2.y;
	cout << fixed;
	cout.precision(6);
	cout << p1.distance(p2) << endl;

	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int a[26]={};
  for(int i=0;i<4;i++){
    a[s.at(i)-65]++;
  }
  int cnt=0;
  for(int i=0;i<26;i++){
    if(a[i]>0&&a[i]==2){
      cnt++;
    }
  }
  if(cnt==2) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int selectionsort(int *A, int N){
  int cnt = 0;
  for(int i = 0; i < N -1; i++){
    int minj = i;
    for(int j = i; j < N; j++){
      if(A[j] < A[minj]) minj = j;
    }
    if(i != minj){
      int tmp = A[minj];
      A[minj] = A[i];
      A[i] = tmp;
      cnt++;
    }
  }
  return cnt;
}

int main(){
  int A[100], n, cnt;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> A[i];
  cnt = selectionsort(A, n);
  for(int i = 0; i < n; i++) cout << A[i] << (i == n - 1 ? '\n' : ' ');
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3096
var lines = [];
var MOD = Math.pow(10, 9) + 7;

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {

    lines.shift()
    var spans = lines.map(value => value.split(' ').map(value => Number(value)));

    spans.sort((a, b) => a[1] - b[1]);

    var broken = 0; var result = 0;

    for (var span of spans) {
        var start = span[0]; var end = span[1];
        if (broken <= start) {
            result++;
            broken = end;
        }
    }
    console.log(result);
});

Measured memory_bytes: 54860
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fs first
#define sc second
using namespace std;
typedef double D;
typedef pair<D,D> pdd;
typedef vector<D> vd;
const D EPS = 1e-8;
const D PI = acos(-1);

int n,k;
pdd p[2000];
vector<pdd> v;
int max_r[2000], max_l[2000];

inline D modify(D seta){
  if(seta>PI)seta-=2*PI;
  if(seta<-PI)seta+=2*PI;
  return seta;
}

inline bool in_upper(D seta){
  seta = modify(seta);
  return (EPS<seta && seta<PI-EPS);
}

bool comp(const pdd &a, const pdd &b){
  return abs(a.fs-b.fs)<EPS?a.sc+EPS<b.sc:a.fs<b.fs;
}

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

  cin >> n >> k;
  rep(i,n){
    D x,y,r;
    cin >> x >> y >> r;
    complex<D> c(x,y);
    D d = abs(c), s = arg(c), a = sqrt(d*d-r*r);
    D ds = acos( (d*d + a*a - r*r)/(2*d*a) );
    
    D start = modify(s-ds), end = modify(s+ds);
    pdd tmp = pdd(in_upper(start)?start:0, in_upper(end)?end:PI);
    if(tmp.fs<EPS && PI-EPS<tmp.sc)continue;
    v.push_back(tmp);
  }

  sort(v.begin(),v.end(),comp);

  rep(i,v.size())rep(j,v.size()){
    if(i==j)continue;
    if(v[j].fs-EPS<v[i].fs && v[i].sc<v[j].sc+EPS){
      v.erase(v.begin()+i);
      i--;
      break;
    }
  }

  int m = v.size();
  rep(i,m){
    pdd dummy(v[i].sc,0);
    max_l[i] = upper_bound(v.begin(),v.end(),dummy,comp) - v.begin();
    max_r[i] = max_l[i]-1;
  }
  
  vector<vd> dp1(m+1,vd(k+1,0)), dp2 = dp1;

  rep(i,m){
    rep(j,k+1){
      dp1[i+1][j] = max(dp1[i+1][j], dp1[i][j]);
      if(j+1<=k){
	D use = max(dp1[i][j], dp2[i][j]);
	dp1[max_l[i]][j+1] = max(dp1[max_l[i]][j+1], use + v[i].sc-v[i].fs);
	if(max_r[i]!=i){
	  dp2[max_r[i]][j+1] = max(dp2[max_r[i]][j+1], use + v[max_r[i]].fs-v[i].fs);
	}
      }
    }
  }

  D ans = 0;
  rep(i,k+1){
    ans = max(ans, max(dp1[m][i], dp2[m][i]) );
  }
  cout << fixed << setprecision(10) << ans/PI << "\n";
}

Measured memory_bytes: 36644
h,w=map(int,input().split())
sl=[list(input()) for i in range(h)]

for i in range(h) :
  #print(i)
  for j in range(w) :
    #print(j)
    chk=[]
    if sl[i][j]=="." :
      continue
    #if sl[max(0,i-1)][j]=="."sl[][]sl[][]sl[][]
    if not i-1<0 :
      chk.append(sl[i-1][j])
    if not i+1>h-1 :
      chk.append(sl[i+1][j])
    if not j-1<0 :
      chk.append(sl[i][j-1])
    if not j+1>w-1 :
      chk.append(sl[i][j+1])
    #print(chk)
    if chk.count("#")==0 :
      print("No")
      exit()
    
print("Yes")

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

Node *find(Node *u, int k) {
	while (u != NIL && k != u->key) {
		if (k < u->key) u = u->left;
		else u = u->right;
	}

	return u;
}

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;

	z = (Node*)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}

	z->parent = y;
	if (y == NIL) {
		root = z;
	}
	else {
		if (z->key < y->key) {
			y->left = z;
		}
		else {
			y->right = z;
		}
	}
}

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

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

int main() {
	int n, i, x;
	string com;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		cin >> com;
		if (com[0] == 'f') {
			scanf("%d", &x);
			Node *t = find(root, x);
			if (t != NIL) printf("yes\n");
			else printf("no\n");
		}
		else if (com == "insert") {
			scanf("%d", &x);
			insert(x);
		}
		else if (com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}


Measured memory_bytes: 21928
import java.util.Scanner;

class Main {
   public static void main(String[] args){
	  Scanner s=new Scanner(System.in);
	  int a[]={s.nextInt(),s.nextInt(),s.nextInt(),s.nextInt(),s.nextInt(),s.nextInt()};
	  String c=s.next();
	  s.close();
	  Dicelabel q=new Dicelabel(a[0],a[3],a[2],a[4],a[1],a[5]);
	  for(int i=0;i<c.length();i++){
	    q=q.diceRoll(c.charAt(i));
	  }
	  System.out.println(q.number);
	  System.exit(0); 
   }
}


class Dicelabel{
	int number;
    int eroll;
    int wroll;
    int nroll;
    int sroll;
    int under;
    Dicelabel(int number,int e,int w,int s,int n,int under){
    	this.number=number;
    	this.eroll=e;
    	this.wroll=w;
    	this.sroll=s;
    	this.nroll=n;
    	this.under=under;
    }
	
	Dicelabel diceRoll(char direction){
		if(direction=='E'){
			return new Dicelabel(eroll,under,number,sroll,nroll,wroll);
		}
		if(direction=='W'){
			return new Dicelabel(wroll,number,under,sroll,nroll,eroll);
		}
		if(direction=='S'){
			return new Dicelabel(sroll,eroll,wroll,under,number,nroll);
		}
		if(direction=='N'){
			return new Dicelabel(nroll,eroll,wroll,number,under,sroll);
		}
		return null;
	}
}

Measured memory_bytes: 26396
//A - 和風いろはちゃんイージー / Iroha and Haiku (ABC Edition)
#include<stdio.h>
int main(int argc, char const *argv[]) {
  int a,b,c;
  int flag5=2;
  int flag7=1;

  scanf("%d %d %d",&a,&b,&c);

 if(a==5){
   flag5 = flag5 -1;
 }else if(a==7){
   flag7 = flag7 - 1;
 }

 if(b==5){
    flag5 = flag5 -1;
 }else if(b==7){
    flag7 = flag7 -1;
 }

 if(c==5){
   flag5 = flag5 -1;
 }else if(c==7){
   flag7 = flag7 -1;
 }

 if(flag5==0 && flag7==0){
   printf("YES\n");
 }else{
   printf("NO\n");
 }

  return 0;
}


Measured memory_bytes: 128
n=int(input())
A=list(map(int, input().split()))
box=[0]*n
for i in range(n-1,-1,-1):
    if n//(i+1)<=1 and A[i]==1:
        box[i]=1
    elif n//(i+1)<=1 and A[i]==0:
        pass
    elif n//(i+1)>1:
        if A[i]==sum(box[2*(i+1)-1::(i+1)])%2:
            pass
        elif A[i]!=sum(box[2*(i+1)-1::(i+1)])%2:
            box[i]=1
ans=""
cnt=0
for i in range(n):
    if box[i]==1:
        ans+=str(i+1)+" "
        cnt+=1
if cnt==sum(box):
    print(sum(box))
    print(ans)
else:print("-1")

Measured memory_bytes: 9140
import bisect

def main():
    n = int(input())
    a = sorted([int(s) for s in input().split()])
    b = sorted([int(s) for s in input().split()])
    c = sorted([int(s) for s in input().split()])
    print(solve(n, a, b, c))

def solve(n, a, b, c):
    d = [c, b, a]
    dp = []
    dp.append([n - i for i in range(n)])
    dp.append([0 for _ in range(n)])
    dp.append([0 for _ in range(n)])

    for i in range(1, 3):
        for j in reversed(range(n)):
            k = bisect.bisect(d[i-1], d[i][j])
            if k == n:
                continue

            dp[i][j] = dp[i-1][k]
            if j != n - 1:
                dp[i][j] += dp[i][j+1]

    return dp[2][0]


def ilen(it):
    c = 0
    for _ in it:
        c += 1
    return c

main()


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

#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)

#define INF 1e9 + 1;
#define MOD 1e9 + 7;


//#define int long long;
//typedef long long ll;


//functions 
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}

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

    string S;

    cin >> S;
    int K;
    cin >> K;
    string ans = "1";
    REP(i, 0, S.size()){
        if(S[i] == '1'){
            K -= 1;
            if(K == 0) break;
        }else{
            ans = S[i];
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
ori = gets.split.map(&:to_i)
K = gets.to_i
pat = [0, 1, 2].repeated_permutation(K).to_a
ans = "No"
(pat.length).times do |i|
	arr = ori.dup
	K.times do |j|
		if pat[i][j] == 0
			arr[0] *= 2
		elsif pat[i][j] == 1
			arr[1] *= 2
		else
			arr[2] *= 2
		end
	end
	if arr[1] > arr[0] && arr[2] > arr[1]
		ans = "Yes"
		break
	end
end

puts ans

Measured memory_bytes: 14372
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int a,b,i,n,p,q;
	cin >> a >> b;
	for(i=0; i<2000; ++i){
		p = (i*8)/100;
		q = (i*10)/100;
		if(a==p && b==q){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
   
public class Main {
     
    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
     
    public void exec() throws IOException {
        SimpleInputUtil in = new SimpleInputUtil();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.readInt();
        int[] S = in.readIntArray(new int[n+1],n);
        int q = in.readInt();
        int[] T = in.readIntArray(new int[q],q);
        int C = 0;
        for(int i=0; i<q; i++) {
        	int j=0;
        	for(S[n] = T[i]; T[i]!=S[j]; j++);
        	if(j<n) C++;
        }
        out.println(C);
        out.flush();
    }
}
 
class SimpleInputUtil {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
    public int readInt() throws NumberFormatException, IOException{
        return Integer.parseInt(br.readLine());
    }
     
    public int[] readIntArray(int[] a, int num) throws NumberFormatException, IOException{
        int i=0;
        while(i<num) {
            for(String s: br.readLine().split(" ")){
                if(i<num) {
                    a[i++] = Integer.parseInt(s);
                }
            }
        }
        return a;
    }
 
     
}

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

vector<int> x(10);
vector<int> y(10);

double dist(int i, int j){
    double dx = x.at(i) - x.at(j);
    double dy = y.at(i) - y.at(j);
    return pow(dx * dx + dy * dy, 0.5);
}

int main(){
    int n;
    double s = 0.0;
    cin >> n;
    rep(i,n) cin >> x.at(i+1) >> y.at(i+1);
    vector<int> v(n);
    rep(i,n) v.at(i) = i + 1;
    do{
        rep(i,n-1) s += dist(v.at(i),v.at(i+1));
    } while(next_permutation(v.begin(),v.end()));
    int f = 1;
    rep(i,n) f *= (i + 1);
    cout <<fixed << setprecision(10) << s / f << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;


int main(){
    ll A, V, B, W, T;

    cin >> A >> V >> B >> W >> T;

    ll dist = abs(A - B);
    ll chase = V - W;

    if(chase * T >= dist){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 3604
import qualified Data.ByteString.Char8 as B
main=getLine>>B.getLine>>=B.putStrLn.f
f xs=B.replicate l '('`B.append`xs`B.append`B.replicate r ')'where(l,r)=B.foldl' h(0,0)xs
h(l,r)x
 |x=='('=(l,r+1)
 |r>0=(l,r-1)
 |otherwise=(l+1,r)

Measured memory_bytes: 380
n = int(input())
c = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}

for i in range(n):
    s = input()
    c[s] = c[s] + 1

for s in ['AC', 'WA', 'TLE', 'RE']:
    print(s + " x " + str(c[s]))


Measured memory_bytes: 9152
/* 実行時間1s制限の場合10^6 1,000,000 : 余裕をもって間に合う10^7
  10,000,000 : おそらく間に合う10^8 100,000,000 : 非常にシンプルな処理
  でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

const ll INF = LONG_MAX;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    //std::ifstream in(string(argv[0]) + ".txt");
    std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int n;
    cin >> n;

    int ans = 1;

    rep(i, sqrt(n)+1) {
        if (i*i > n) break;
        ans = i*i;
    }

    cout << ans;


    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



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

int main() {
    int N, D, cnt = 0;
    cin >> N >> D;
    double X[N], Y[N];

    for (int i=0; i<N; i++) {
        cin >> X[i] >> Y[i];
        if (sqrt(X[i]*X[i] + Y[i]*Y[i]) <= D) cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 6940
from math import log2,ceil
N,K=map(int,(input().split()))
l=m=0
if N<K:
    for k in range(1,N+1):
        x=(0.5**ceil(log2(K/k)))/N
        l+=x
if N>=K:
    for k in range(1,K):
        x=(0.5**ceil(log2(K/k)))/N
        l+=x
    m=(N-K+1)/N
print (l+m)

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

using namespace std;

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, max1, max2, idx;
    max1 = max2 = 0;
    cin >> n;
    for(int i =1 ; i<=n; i++){
        int a;
        cin >> a;
        if(a >= max1){
            idx = i;
            max2 = max1;
            max1 = a;
        }
        else if(max2 <= a){
            max2 = a;
        }
    }
    for(int i = 1; i<=n; i++){
        if(i == idx){
            cout << max2 << "\n";
        }
        else{
            cout << max1 << "\n";
        }
    }
}


Measured memory_bytes: 1664
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val Array(y, m, _) = sc.nextLine.split("/").map(_.toInt)

    if (y >= 2020) {
      println("TBD")
    } else if (y == 2019) {
      if (m >= 5) {
        println("TBD")
      } else {
        println("Heisei")
      }
    }
    else {
      println("Heisei")
    }
  }
}

Measured memory_bytes: 25788