akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define LOCAL 0
#define lli long long int
const lli mod=1e9+7;
const lli pINF=LLONG_MAX;
const lli nINF=-LLONG_MAX;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
#define S second
const int INF=0x3f3f3f3f;
#define Pa pair<int,int>
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define ld long double
#define printli(n) printf("%lld\n",n)
#define all(v) v.begin(),v.end()
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}

int main() {
    string a,b;
    cin>>a>>b;
    string s=a+b;
    
    int num=0;
    
    for(int i=0;i<s.size();i++) num=(num*10)+(s[i]-'0');
    
    int r=sqrt(num);
    
    if(r*r==num) cout<<"Yes\n";
    else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
using namespace std;

int main(){
	int i;
	stack<int> s;
	while (cin >> i) {
		if (i == 0) {
			cout << s.top() << endl;
			s.pop();
		} else {
			s.push(i);
		}
	}
	return 0;
}

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

int main(){
  int n,m;
  cin>>n>>m;
  vector<int>a(n);
  int c=0;
  long long sum=0;
  
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    sum += a.at(i);
  }
  
  for(int i=0;i<n;i++){
    if(a.at(i)>=sum/(4.0*m)){
      c++;
    }
  }
  if(c>=m)
    cout <<"Yes"<<endl;
  else
    cout <<"No"<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> void printv(vector<T> v){ for (T t : v) {cout << t << " " ;} cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int height(int cx, int cy, int x, int y, int h){
    return max(h-abs(x-cx)-abs(y-cy),0);
}

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

     int N;
     cin >> N;

    
    vi vx(N), vy(N), vh(N);
    REP(i,N) {
        int x, y, h;
        cin >> x >> y >> h;
        vx[i] = x;
        vy[i] = y;
        vh[i] = h;
    }


    REP(ix,101) REP(iy,101){
        int tmp_h = -1;
        REP(i,N) {
            int t;
            if (vh[i] > 0) {
                t = vh[i] + abs(vx[i]-ix) + abs(vy[i]-iy);
                if (tmp_h == -1) tmp_h = t;
                else if (tmp_h != t) {
                    tmp_h = -2;
                    break;
                }
            } 
        }
        if (tmp_h == -2) continue;

        bool all_ok = true;
        REP(i,N) { 
            if (max(tmp_h-abs(ix-vx[i])-abs(iy-vy[i]),0) != vh[i]) all_ok = false;
        }

        if (all_ok) {
            cout << ix << " " << iy << " " << tmp_h << endl;
            return 0;
        }

    }
    
     
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if X//n:
    return Base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def Base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
N = inputI()
S = inputS()

x = 0
MAX = 0

for i in range(N):
  if S[i] == "I":
    x += 1
    MAX = max(MAX,x)
    
  else:
    x -= 1
print(MAX)

Measured memory_bytes: 38256
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double EPS = 1e-10;

bool rec(int n, vector<int>& num, vector<bool>& isPlus) {
  // ベースケース
  if (n == (int) isPlus.size()) {
    int ans = num[0];
    rep(i, (int) isPlus.size()) {
      if (isPlus[i]) {
        ans += num[i + 1];
      } else {
        ans -= num[i + 1];
      }
    }

    if (ans == 7) {
      cout << num[0];
      rep(i, (int) isPlus.size()) {
        if (isPlus[i]) {
          cout << '+' << num[i + 1];
        } else {
          cout << '-' << num[i + 1];
        }
      }
      cout << "=7" << endl;
      return true;
    }

    return false;
  }

  // 再帰ステップ
  isPlus[n] = true;
  if (rec(n + 1, num, isPlus)) return true;
  isPlus[n] = false;
  if (rec(n + 1, num, isPlus)) return true;

  return false;
}


int main(void) {
  int ABCD;
  cin >> ABCD;
  vector<int> num(4);
  rep(i, 4) {
    num[i] = ABCD % 10;
    ABCD /= 10;
  }

  reverse(num.begin(), num.end());

  vector<bool> isPlus(3, true);
  rec(0, num, isPlus);
  
  return 0;
}

Measured memory_bytes: 3548
#!/usr/bin/env python3
a = [0] + list(map(int, list(input())))
n = len(a)
dp = [[10 ** 9] * 2 for _ in range(n + 1)]
dp[0][0] = 0
dp[0][1] = 1
for i in range(n):
    dp[i + 1][0] = min(dp[i][0] + a[i], dp[i][1] + 10 - a[i])
    dp[i + 1][1] = min(dp[i][0] + a[i] + 1, dp[i][1] + 10 - a[i] - 1)
print(dp[n][0])


Measured memory_bytes: 151552
#include<stdio.h>
int main(){
  int n,x,i;
  do{
    scanf("%d%d",&n,&x);
    if(x==0&&n==0||n<3||100<n)
      return 0;

    int j,k,l;
    i=0;
    for(j=1;j<=n;j++){
      for(k=1;k<j;k++){
        for(l=1;l<k;l++){
          if(j+k+l==x)
            i++;
        }
      }
    }
    printf("%d\n",i);
  }while(n!=0||x!=0);

  return 0;
}

Measured memory_bytes: 600
#include <cstdio>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a > b){
        printf("a > b");
    }else if(a < b){
        printf("a < b");
    }else if(a == b){
        printf("a == b");
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2700
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def primes(N, n):
    L = [v for v in range(3, N+1)]
    primes = []
    while L:
        p = L.pop(0)
        if p % 10 == n:
            primes.append(p)
        L = list(filter(lambda x: x % p != 0, L))
    return primes


N = int(input())
ans = primes(3000, 1)[:N]
print(" ".join(map(str, ans)))


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
using namespace std;
const int num = 16, ud[] = { -1, 1, 0, 0 }, lr[] = { 0, 0, 1, -1 }, nd = 4;
int md[num][num];
struct puzzle {
	int sp, p[num], mdp, cost;
	bool operator < (const puzzle &pu) const {
		for (int i = 0; i < num; i++) {
			if (p[i] == pu.p[i]) continue;
			return p[i] < pu.p[i];
		}
		return false;
	}
};
struct state {
	puzzle pu;
	int es;
	bool operator < (const state &s) const {
		//return pu.mdp + pu.cost > s.pu.mdp + s.pu.cost;
		return es > s.es;
	}
};
int astar(puzzle pz) {
	priority_queue<state> pq;
	int sum = 0;
	for (int i = 0; i < num; i++) {
		if (pz.p[i] == num) continue;
		sum += md[i][pz.p[i] - 1];
	}
	pz.mdp = sum;
	pz.cost = 0;
	map<puzzle, bool> m;
	puzzle u, v;
	state initial;
	initial.pu = pz;
	initial.es = pz.mdp;
	pq.push(initial);
	while (!pq.empty()) {
		state st = pq.top(); pq.pop();
		u = st.pu;
		if (!u.mdp) return u.cost;
		m[u] = true;
		int sx = u.sp / nd;
		int sy = u.sp % nd;
		for (int r = 0; r < nd; r++) {
			int tx = sx + ud[r];
			int ty = sy + lr[r];
			if (tx >= nd || tx < 0 || ty >= nd || ty < 0) continue;
			v = u;
			//v.mdp = p.mdp - md[tx * nd + ty][tmp.p[tx * nd + ty] - 1] + md[sx*nd + sy][tmp.p[tx * nd + ty] - 1];
			v.mdp -= md[tx * nd + ty][v.p[tx * nd + ty] - 1];
			v.mdp += md[sx*nd + sy][v.p[tx * nd + ty] - 1];
			swap(v.p[sx * nd + sy], v.p[tx * nd + ty]);
			v.sp = tx * nd + ty;
			if (!m[v]) {
				v.cost++;
				state news;
				news.pu = v;
				news.es = v.cost + v.mdp;
				pq.push(news);
			}
		}
	}
	return -1;
}

int main() {
	puzzle in;
	for (int i = 0; i < num; i++)
		for (int j = 0; j < num; j++)
			md[i][j] = abs(i / nd - j / nd) + abs(i%nd - j%nd);
	for (int i = 0; i < num; i++) {
		cin >> in.p[i];
		if (!in.p[i]) { in.sp = i;  in.p[i] = num; }
	}
	cout << astar(in) << endl;
	return 0;
}

Measured memory_bytes: 255852
#include <stdio.h>

int main(){
    int a;
    int b;
    int c;
    char line [20];

    fgets(line,sizeof(line),stdin);
    sscanf(line,"%d %d %d",&a,&b,&c);

    if((a==5&&b==5&&c==7)||(a==5&&b==7&&c==5)||(a==7&&b==5&&c==5)){
        printf("YES\n");
    }else{
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

count = 0
for i in range(n):
    minj = i
    for j in range(i, n):
        if a[j] < a[minj]:
            minj = j
    if minj != i:
        count += 1
        tmp = a[i]
        a[i] = a[minj]
        a[minj] = tmp

print(" ".join(map(str, a)))
print(count)



Measured memory_bytes: 5596
import java.util.Scanner;

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

    // xが最大値、各桁の和がa以上b以下のものの総和を求める
    int x = scanner.nextInt(), a = scanner.nextInt(), b = scanner.nextInt();

    int ammount = 0;
    for(int i = 1; i <= x;i++){
      String s = String.valueOf(i);
      char[] c_array = s.toCharArray();
      int sum = 0;
      for(int j = 0; j < c_array.length;j++){
        sum += Integer.parseInt(String.valueOf(c_array[j]));
      }
      if(a <= sum && sum <= b ){
        ammount += i;
      }
    }
    System.out.println(ammount);
  }
}

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

int main(){
  string S,T;
  cin >> S >> T;
  int A=S.size(),B=T.size(),mincount=1e9;
  for(int i=0;i<A-B+1;i++){
    int count=0;
    string U=S.substr(i,B);
    for(int j=0;j<B;j++){
      if(T.at(j)!=U.at(j)){
        count++;
      }
    }
    mincount=min(mincount,count);
  }
  cout << mincount << endl;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    string a,b,c; cin >> a >> b >> c;
    YN(a.back()==b[0] && b.back()==c[0]);

    return 0;
}

Measured memory_bytes: 256
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
q,l,r = 0,0,0
for _ in range(n):
  b = int(input())
  for i in range(3):
    if b in a[i]:
      a[i][a[i].index(b)]=0
                
for i in range(3):
  l += a[i][i]
  t,y = 0,0
  for j in range(3):
    y += a[j][i]
    t += a[i][j]
    if i+j == 2:
      r += a[i][j]
  if not t or not y:
    q=1

print('Yes' if q or not l or not r else 'No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int a,b,c;
    cin >> a >> b >> c;
    cout << a*b/2 << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string C1,C2;
    cin >> C1;
    cin >> C2;
    if (C1.at(0) == C2.at(2) && C1.at(1) == C2.at(1) && C1.at(2) == C2.at(0)) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,K;
    int d,x;
    int count = 0;
    
    cin >> N >> K;
    vector<int> sunuke(N);
    for(int i=0;i<K;i++){
    	cin >> d;
    	for(int j=0;j<d;j++){
    		cin >> x;
    		sunuke.at(x-1) = 1;
    	}
    }
    
    for(int i=0;i<N;i++){
    	if(sunuke.at(i)==0)
    		count++;
    }
    
 	cout << count;
}

Measured memory_bytes: 3508
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int a[3];
    int five=0,seven=0;
    rep(i,0,2){
        cin>>a[i];
        if(a[i]==5) five++;
        if(a[i]==7) seven++;
    }
    if(five==2&&seven==1) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

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

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using int128 = __int128;
using cint = cpp_int;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)

// Stream
#define input(a) scanf("%lld", &(a))
#define output(a) printf("%lld\n", (a))
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }

signed main() {
    ll N, X;
    cin >> N;
    vector<ll> A, B;
    rep(i, N) cin >> X, A.push_back(X), B.push_back(X);
    sort(all(B));
    rep(i, N) {
        if (A[i] < B[N / 2]) {
            cout << B[N / 2] << endl;
        } else {
            cout << B[N / 2 - 1] << endl;
        }
    }
}

// for compilation: g++ -O3 -o _ _.cpp -std=c++17


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


//vector<vector<int>> z(n,vector<int>(2));
//n番目から数えてm個の文字列をXに置換したい場合はreplace(n,m,X) teWttest
//s1.substr(3,3);
//n番目以降の文字列をm個取り出す、上だとtte

int main(){
  int n,m;
  cin>>n>>m;
  priority_queue<ll>q;
  rep(i,n){
    ll temp;
    cin>>temp;
    q.push(temp);
  }
rep(i,m){
  ll now=q.top();
  q.pop();
  now/=2;
  q.push(now);
}
ll ans=0;
while (!q.empty()){
  ans+=q.top();
  q.pop();
}
cout<<ans;
  }


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n;
    cin >> n;
    int a[100];
    rep(i, n){
        cin >> a[i];
    }
    sort(a, a+n);
    reverse(a, a+n);

    int alice=0, bob=0;
    for(int i=0; i<n; i++){
        if(i%2 == 0){
            alice += a[i];
        }
        else{
            bob += a[i];
        }
    }
    cout << alice - bob;

    return 0;
}

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

int main(){
	ll a, b;
	scanf("%lld%lld", &a, &b);
	if (a == b) { printf("1\n"); exit(0); }
	int i = 59;
	while (a >> i == b >> i)a &= ~(1ll << i), b &= ~(1ll << i), --i;
	int j = i - 1;
	while (j >= 0 && !(b >> j & 1))--j;
	ll an = (1ll << i) - a;
	b |= (1ll << j + 1) - 1;
	an += min(1ll << i, b - a + 1);
	printf("%lld\n", an);
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX_V 100005
#define MAX_E 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef priority_queue<P> PQ;

int main(void) {
    ll K;
    cin >> K;
    ll a[100001];
    ll i, j;
    for(i=0; i<K; i++) {
        cin >> a[i];
    }
    ll L=2, R=2;
    for(i=K-1; i>=0; i--) {
        L=(L+a[i]-1)/a[i]*a[i];
        if(R<L) {
            prin(-1);
            return 0;
        }
        R=(R/a[i]+1)*a[i]-1;
    }
    
    cout << L << " " << R << endl;
}


Measured memory_bytes: 1152
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main () {
    int n;
    long long int data[100001];
    long long int sum[100001];
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%lld", data + i);
    }
    
    sort (data, data + n);
    int i;
    long long int total = 0;
    for (i = 0; i < n; i++) {
        total += data[i];
        sum[i] = total;
    }
    
    for (i = n - 1; i > 0; i--) {
        if (data[i] > 2 * sum[i - 1])
            break;
    }
    printf("%d", n - i);
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define MAX_N 200000 + 1
using namespace std;

int N, number[MAX_N], ans[MAX_N];

bool check(){
	for(int i = 1; i <= N; i++){
		int cnt = 0;
		for(int j = i; j <= N; j += i)
			cnt += ans[j];
		cnt %= 2;
		if(cnt ^ number[i]) return false;
	}
	return true;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	while(cin >> N){
		for(int i = 1; i <= N; i++)
			cin >> number[i];
		
		for(int i = N; i > 0; i--){
			int cnt = 0;
			for(int j = i; j <= N; j += i)
				cnt += ans[j];
			cnt %= 2;
			ans[i] = cnt ^ number[i];
		}
		
		if(check()){
			int sum = 0;
			for(int i = 1; i <= N; i++)
				if(ans[i]) sum++;
			cout << sum << endl;
			if(sum){
				for(int i = 1; i <= N; i++)
					if(ans[i]) cout << i << " ";
				cout << endl;
			}
		}
		else
			cout << -1 << endl;
		
		memset(number, 0, sizeof(number));
		memset(ans, 0, sizeof(ans));
	}
	
	return 0;
}

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

long modPow(long n, long m, long p = 1000000007)
{
    if (m == 0)
    {
        return 1;
    }
    long halfPow = modPow(n, m / 2, p);
    if (m % 2 == 0)
    {
        return (halfPow * halfPow) % p;
    }
    else
    {
        long v = (halfPow * halfPow) % p;
        return (v * n) % p;
    }
}
void prlongVector(vector<long> l)
{
    for (long i = 0; i < l.size(); i++)
    {
        if (i != 0)
        {
            cout << " ";
        }
        cout << l.at(i);
    }
    cout << endl;
}

int main()
{
    long n, k;
    // scanf("%d", &x);
    cin >> n >> k;
    long p = 1'000'000'000 + 7;
    long ans = 0;
    // cout << modPow(100001, 2) << endl;
    vector<long> numComb(k + 1, 0);
    for (long i = k; i > 0; i--)
    {
        // cout << k / i << n << endl;
        numComb.at(i) = modPow(k / i, n);
        // if (i == k / 2)
        // {
        //     cout << numComb.at(i) << endl;
        // }

        for (long j = 2 * i; j <= k; j += i)
        {
            numComb.at(i) -= numComb.at(j);
            while (numComb.at(i) < 0)
            {
                numComb.at(i) += p;
            }
            // if (i == k / 10)
            // {
            //     cout << j << " " << numComb.at(j) << " " << numComb.at(i) << endl;
            // }
        }
        // if (i == k / 2)
        // {
        //     cout << numComb.at(i) << " " << i << " " << numComb.at(i) * i << endl;
        // }
        ans += (numComb.at(i) * i) % p;
        ans = ans % p;
        // if (i == k / 2)
        // {

        //     cout << numComb.at(i) << " " << ans << endl;
        // }
    }
    // prlongVector(numComb);
    // prlongf("%d\n", x * x * x);
    cout << ans << endl;
}

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

set<int> memo[200005];

int main(int argc, char const *argv[])
{
	int h,w,n;
	cin>>h>>w>>n;
	int x,y;
	for (int i = 0; i < n; ++i)
	{
		cin>>x>>y;--x;--y;
		memo[x].insert(y);
	}
	int ok=0;
	for (int i = 0; i < h; ++i)
	{
		for (auto v:memo[i])
		{
			if (v<ok)
			{
				cout<<i<<endl;
				return 0;
			}
			else if (v==ok)
			{
				--ok;
				break;
			}
			else
			{
				break;
			}
		}
		++ok;
	}
	cout<<h<<endl;
	return 0;
}


Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
int isprime[100001],prime[100001];
int sum[100001]={0};
void Euler_sieve(int n)
{
	memset(isprime,0,sizeof(isprime));
	isprime[0]=isprime[1]=1;
	prime[0]=0;
	int i,j,total=0;
	for(i=2;i<=n;i++)
	{
		if(!isprime[i])
		{
			prime[++prime[0]]=i;
			if(!isprime[(i+1)/2])
			{
				total++;
			}
		}
		sum[i]=total;
		for(j=1;j<=prime[0]&&i*prime[j]<=n;j++)
		{
			isprime[i*prime[j]]=1;
			if(i%prime[j]==0)
				break;
		}
	}
}
int main()
{
	int n,i,a,b;
	scanf("%d",&n);
	Euler_sieve(100001);
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&a,&b);
		printf("%d\n",sum[b]-sum[a-1]);
	}
	return 0;
}

Measured memory_bytes: 1408
#include <vector>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int H, W, x, popcount[1024];
int main() {
	for (int i = 0; i < 1024; i++) {
		for (int j = 0; j < 10; j++) {
			if (i & (1 << j)) popcount[i]++;
		}
	}
	while (scanf("%d%d", &H, &W), H) {
		vector<int> bit(W);
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				scanf("%d", &x);
				bit[j] |= x << i;
			}
		}
		vector<int> cnt(1 << H);
		for (int i = 0; i < W; i++) cnt[bit[i]]++;
		int ret = 0;
		for (int i = 0; i < 1 << H; i++) {
			vector<int> f(1 << H);
			for (int j = 0; j < 1 << H; j++) {
				f[j] = popcount[i ^ j];
				f[j] = max(f[j], H - f[j]);
			}
			int res = 0;
			for (int j = 0; j < 1 << H; j++) res += cnt[j] * f[j];
			ret = max(ret, res);
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using lond = long double;
lond pi(void) {
 return atan(1.0) * 4.0;
}
#define PI 3.14159265358979323846264338327950L

int main(){
	int a,b,h,m;
	cin >> a >> b >> h >> m;
	double th = double(h *60 + m)/720 * 2 * PI;
	double tm = double(m)/60 * 2 * PI;
	//座標
	double xh = a * cos(th),yh = a*sin(th);
	double xm = b * cos(tm),ym = b*sin(tm);
	double dx = xh-xm,dy = yh-ym;
	double ans = sqrt(dx*dx + dy*dy);
	printf("%.10f\n",ans);
	return 0;
}

Measured memory_bytes: 3976
#include <iostream>

int main()
{
  int a = 0 ;
  int b = 0 ;

  std::cin >> a >> b ;

  if ( a < b )
    std::cout << "a < b" << std::endl ;
  else if ( a > b )
    std::cout << "a > b" << std::endl ;
  else
    std::cout << "a == b" << std::endl ;

  return 0 ;
}

Measured memory_bytes: 3076
#include<stdio.h>
 int main(){
 int a[100][100],b[100][100],i,j,k,n,m,l,x;
 long long int c[100][100]={0};
 scanf("%d %d %d",&n,&m,&l);

 for(i=0;i<n;i++){
 for(j=0;j<m;j++){
 scanf("%d",&x);
 a[i][j]=x;
 }
 }


 for(j=0;j<m;j++){
 for(k=0;k<l;k++){
 scanf("%d",&x);
 b[j][k]=x;
 }
 }

 for(i=0;i<n;i++){
 for(k=0;k<l;k++){
 for(j=0;j<m;j++){
 c[i][k]+=a[i][j]*b[j][k];
 }
 }
 }

 for(i=0;i<n;i++){
 for(k=0;k<l;k++){
 printf("%lld",c[i][k]);

if(k!=l-1)
{
	printf(" ");
}
 }
 printf("\n");
 }

 return 0;
 }

Measured memory_bytes: 768
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

struct Edge {
	int s, e, l;
};

vector<Edge> edge;

int binary_pow(int x, int n) {
	if (n == 0)return 1;
	else if (n == 1) return x;
	else if (n % 2 == 0) {
		int tmp = binary_pow(x, n / 2);
		return tmp * tmp;
	}
	else {
		int tmp = binary_pow(x, n / 2);
		return tmp * tmp *x;
	}
}

int main() {
	int L;

	cin >> L;

	int N;
	for (N = 1; binary_pow(2, N) <= L; N++);

	for (int i = 1; i < N; i++) {
		edge.push_back({ i,i + 1,binary_pow(2,i - 1) });
		edge.push_back({ i,i + 1,0 });
	}

	//まだ表現されていない値:len
	int len = binary_pow(2, N - 1), index = N - 1;


	while (len < L && index > 0) {
		if (len + binary_pow(2, index-1) - 1 <= L -1) {
			edge.push_back({ index, N,len });
			len += binary_pow(2, index-1);
		}
		index--;
	}

	cout << N << " " << edge.size() << endl;

	for (int i = 0; i < edge.size(); i++) {
		cout << edge[i].s << " " << edge[i].e << " " << edge[i].l << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        for (int i=a;i<=b;i++) {
            if (i%k==0) {
                System.out.println("OK");
                return;
            }
        }
        System.out.println("NG");
    }
}


Measured memory_bytes: 35684
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;

int main()
{
   ll a, b, c, d;
   cin >> a >> b >> c >> d;
   cout << max(a * c, max(a * d, max(b * c, b * d))) << endl;
   return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
int main(){
    int n,x,y;
    cin>>n>>x>>y;
    vector<int> cnt(n-1);
    for(int i =1;i<n;i++){
        for(int j=i+1;j<=n;j++){
            int d=min(j-i,abs(x-i)+abs(y-j)+1);
            //cout <<d <<endl;
            cnt[d-1]++;
        }

    }
    rep(i,n-1){
        int ans=cnt[i];
        cout <<ans<<endl;
    }
}

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

import heapq
import bisect

n,m = map(int,input().split())

ab = [[int(i) for i in input().split()] for j in range(n)]

ab.sort()

a_li = [-1] * n
b_li = [-1] * n

for i in range(n):
    a_li[i] = ab[i][0]
    b_li[i] = ab[i][1]

kouho = []
bfr_idx = 0
ans = 0

for i in range(m):
    day = i + 1
    idx = bisect.bisect_right(a_li,day)
    for j in range(idx-bfr_idx):
        heapq.heappush(kouho,-b_li[bfr_idx+j])
    bfr_idx = idx
    if len(kouho) != 0:
        ans += -heapq.heappop(kouho)

print(ans)

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int, int> pii;
const int mod = (int)1e9 + 7;


int main()
{

	//cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	int n=sz(s);
	if(n==3 && s[0]==s[2]){ puts("Second"); return 0;}
	if(n==3 && s[0]!=s[2]){ puts("First"); return 0;}
	
	if(s[0]!=s[n-1]){
		if(n%2) puts("First"); else puts("Second");
	}else{
		if(n%2) puts("Second"); else puts("First");
	}
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(void){
	int n, h = 0, m = 0, c = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		int old = h;
		scanf("%d", &h);
		if(old >= h)c++;
		else c = 0;
		if(c > m) m = c;
	}
	printf("%d\n", m);
	return 0;
}

Measured memory_bytes: 1708
#!/usr/bin/env python3
import copy
n, *masu = [i.split() for i in open(0)]
h, w, k = map(int, n)
c = 0
masu = [list(*i) for i in masu]
for i in range(2**h):
    hi = []
    for j in range(h):
        if i>>j &1:
            hi.append(j)
    for p in range(2**w):
        wi = []
        for q in range(w):
            if p>>q &1:
                wi.append(q)
        d = copy.deepcopy(masu)
        for r in hi:
            d[r] = ["."] * w

        for r in wi:
            for o in range(h):
                d[o][r] = "."
        if k == sum(s == "#" for s in sum(d, [])):
            c += 1
print(c)


Measured memory_bytes: 72108
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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;}

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

  ll n, a, b;
  cin >> n >> a >> b;
  if(a > b) cout << 0 << endl;
  else if(n == 1 && a == b) cout << 1 << endl;
  else if(n < 2) cout << 0 << endl;
  else{    
    ll maxv = a+b+(n-2)*b;
    ll minv = a+b+a*(n-2);
    cout << maxv-minv+1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, M;
    cin >> N >> M;
    vector<ll> x(N), y(N), z(N);
    rep(i, 0, N) cin >> x[i] >> y[i] >> z[i];
    ll ans = 0;
    rep(i, 0, 2) rep(j, 0, 2) rep(k, 0, 2)
    {
        vector<ll> a(N);
        rep(l, 0, N)
        {
            auto Sign = [](int i) { return i == 0 ? 1 : -1; };
            a[l] = Sign(i) * x[l] + Sign(j) * y[l] + Sign(k) * z[l];
        }
        sort(a.rbegin(), a.rend());
        ll sum = 0;
        rep(l, 0, M) sum += a[l];
        chmax(ans, sum);
    }
    cout << ans << endl;
}


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

int main(){
    int n, m, mm;
    cin >> n >> m;

    vector<vector<int>> sc(m,vector<int>(2));
    rep(i,m) cin >> sc[i][0] >> sc[i][1];
    if (m==1) {
        sc.push_back(sc[0]);
        mm = 2;
    } else {
        mm = m;
    }
    vector<int> a(n,0);
    sort(sc.begin(),sc.end());
    rep(i,mm-1){
        if (n!=1 && sc[i][0] == 1 && sc[i][1] == 0){
            cout << -1 << endl;
            return 0;
        } 
        if (sc[i][0]==sc[i+1][0]){
            if (sc[i][1]!=sc[i+1][1]){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    rep(i, m) a[sc[i][0] - 1] = sc[i][1];

    if (n != 1 && a[0] == 0) a[0] = 1;
    
    rep(i,n) cout << a[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	string S;
	cin >> N >> S;

	
	int ans[4][100010];
	ans[0][0] = 1;
	ans[0][1] = 1;

	ans[1][0] = 1;
	ans[1][1] = 0;
	
	ans[2][0] = 0;
	ans[2][1] = 1;
	
	ans[3][0] = 0;
	ans[3][1] = 0;


	REP(k, 4) {
		bool F = false,FF=false;
		FOR(i,1, N) {
			if (i == N - 1) {
				if (S[i] == 'o' && ans[k][i] == 1 && ans[k][i - 1] == ans[k][0]) F = true;
				if (S[i] == 'x' && ans[k][i] == 0 && ans[k][i - 1] == ans[k][0]) F = true;
				if (S[i] == 'o' && ans[k][i] == 0 && ans[k][i - 1] != ans[k][0]) F = true;
				if (S[i] == 'x' && ans[k][i] == 1 && ans[k][i - 1] != ans[k][0]) F = true;

				if (S[0] == 'o' && ans[k][i] == ans[k][1] && ans[k][0] == 1)FF = true;
				if (S[0] == 'o' && ans[k][i] != ans[k][1] && ans[k][0] == 0)FF = true;
				if (S[0] == 'x' && ans[k][i] != ans[k][1] && ans[k][0] == 1)FF = true;
				if (S[0] == 'x' && ans[k][i] == ans[k][1] && ans[k][0] == 0)FF = true;
			}
			if (F && FF) {
				//cout << k << endl;
				REP(j, N) {
					if (ans[k][j] == 1)cout << "S";
					else cout << "W";
				}
				cout << endl;
				return 0;
			}
			
			if (S[i] == 'x' && ans[k][i] == 1) {
				if (ans[k][i - 1] == 1) ans[k][i + 1] = 0;
				else ans[k][i + 1] = 1;
			}
			else if (S[i] == 'o' && ans[k][i] == 0) {
				if (ans[k][i - 1] == 1) ans[k][i + 1] = 0;
				else ans[k][i + 1] = 1;
			}
			else
				ans[k][i + 1] = ans[k][i - 1];
		}
	}

	cout << -1 << endl;
	return 0;
}



Measured memory_bytes: 3664
def is_prime(x: int) -> bool:
    """自然数nが素数であるかを判定する
    計算量: O(sqrt(N))
    """
    if x == 2:
        return True
    if x == 1 or x % 2 == 0:
        return False
    for k in range(3, int(x ** 0.5) + 1, 2):
        if x % k == 0:
            return False
    return True


n = int(input())
a = [int(input()) for i in range(n)]

ans = 0
for num in a:
    if is_prime(num):
        ans += 1
print(ans)


Measured memory_bytes: 6008
#include <numeric>
#include <iostream>
#include <array>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <queue>
#include <iomanip>

using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(ll i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
using vi = vector<int>;
using vs = vector<string>;
using vc = vector<char>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vb = vector<bool>;
using vvb = vector<vb>;
const ll MOD = 1e9 + 7;
set<char> alphabet = { 'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z' };

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




int main() {
    int N;
    cin >> N;
    vi prime;
    repp(i, 55555) {
        if (IsPrime(i)&&i%5==1)prime.push_back(i);
    }
    rep(i, N)cout << prime[i] << " ";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	 	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[m];
		int[] d = new int[m];
		int s = 100000000, t= 10000000 ,u=0;
		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}		
		for(int i = 0; i < m; i++){
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		
		for(int i = 0;i < n; i++){
			for(int j = 0; j < m; j++){
				t = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
				if(t < s){
					s = t;
					u = j;
				}
			}
			System.out.println(u+ 1);
			s = 1000000000;
			u = 0;
		}
		sc.close();	
	}
 
}


Measured memory_bytes: 21844
N = gets.chomp.to_i

def check(x)
  x = x.to_s
  x.include?('3') && x.include?('5') && x.include?('7')
end

def dfs(x)
  ans = 0
  if x <= N
    ans += 1 if check(x)
    ans += dfs(x*10 + 3)
    ans += dfs(x*10 + 5)
    ans += dfs(x*10 + 7)
  end
  ans
end

puts dfs(0)

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    string s,t;
    cin >> s >> t;
    ll ns = s.size(), nt = t.size();
    vector<vector<ll>> dp(ns+1,vector<ll>(nt+1,0));
    for(i = 1;i <= ns;++i){
        for(j = 1;j <= nt;++j){
            if(s.at(i-1) == t.at(j-1)){
                dp.at(i).at(j) = dp.at(i-1).at(j-1) + 1;
            }else{
                dp.at(i).at(j) = max(dp.at(i-1).at(j), dp.at(i).at(j-1));
            }
        }
    }
    vector<char> ans(dp.at(ns).at(nt));
    i = ns;
    j = nt;
    ll now = dp.at(ns).at(nt) - 1;
    if(now == -1){
        cout << endl;
        return 0;
    }
    while(i != 0 && j != 0){
        if(i == 0){
            --j;
        }else if(j == 0){
            --i;
        }else if(s.at(i-1) == t.at(j-1)){
            ans.at(now) = s.at(i-1);
            --now;
            --i;
            --j;
        }else{
            if(dp.at(i).at(j) == dp.at(i-1).at(j)) --i;
            else --j;
        }
    }
    for(i = 0;i < ans.size()-1;++i){
        cout << ans.at(i);
    }
    cout << ans.at(i) << endl;
    return 0;
} 


Measured memory_bytes: 70784
import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val as = readLine().split(" ").map(_.toInt)

  val m = scala.collection.mutable.Map[Int, Int]().withDefaultValue(0)
  
  for (i <- 2 to n) {
    m(as(i - 2)) += 1
  }

  for (i <- 1 to n) {
    println(m(i))
  }
}


Measured memory_bytes: 88112
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)

using namespace std;

vector<int> vec;

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int main(void) {
	long long a;
	long long b;

	vector<long long> vec;

	long long ans;


	cin >> a >> b;


	ans = a;

	long long temp;

	for (int i = 0; i < b; i++) {
		cin >> temp;

		ans -= temp;
	}

	if (ans < 0) { cout << -1; }
	else
	{
		cout << ans;
	}




}




Measured memory_bytes: 3624
x = input()
stack = []
for s in x:
    if s == "S":
        stack.append(s)
    elif s == "T" and len(stack) == 0 or stack[-1] == "T":
        stack.append(s)
    elif s == "T" and stack[-1] == "S":
        stack.pop()
print(len(stack))



Measured memory_bytes: 5092
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
string base(int n)
{
    string s;
    while(n){
        if(n%-2!=0){;
            s='1'+s;
            n-=1;
        }
        else
            s='0'+s;
        n/=-2;
    }
    return s;
}
int main()
{
    int n=0;
    cin >>n;
    if(n==0)
        cout << 0 <<endl;
    else
    cout << base(n) << endl;
    return 0;
}


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

int main(){
  char a,b;
  std::cin >> a>>b;
  if(a=='H'){
    if(b=='H'){
      std::cout <<'H' << std::endl;
    }else{
      std::cout <<'D' << std::endl;      
    }
  }else{
    if(b=='H'){
      std::cout <<'D' << std::endl;
    }else{
      std::cout <<'H' << std::endl;      
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N;
    cin>>N;
    vvi T(N);
    vi C(N);
    REP(i, 0, N-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        T[a].push_back(b);
        T[b].push_back(a);
    }
    REP(i, 0, N) cin >> C[i];
    sort(C.begin(), C.end());
    int leaf = 0, count = 0;

    vi ans(N, 0);
    stack<int> stk;
    vi Map(N, 0);

    while(T[leaf].size() != 1) leaf++;
    stk.push(leaf); Map[leaf] = 1;
    while(!stk.empty()){
        bool isLeaf = true;
        auto cur = stk.top();
        for(int next: T[cur]){
            if(Map[next] == 0){
                stk.push(next);
                Map[next] = 1;
                isLeaf = false;
            }
        }
        if(isLeaf){
            ans[cur] = C[count];
            count++;
            stk.pop();
        }
    }
    cout << accumulate(C.begin(), C.end()-1, 0) << endl;
    REP(i, 0, N) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <string>
#include <algorithm>
#include <iostream>

using namespace std;

int kaijou(int n){
  if(n==0||n==1) return 1;
  return n*kaijou(n-1);
}


int main() {
  int N,m,na,nb,cnt=0;
  string s="",a="",b="",c;

  cin >> N;
  for(int i=0;i<N;i++){
    cin>>c;
    a+=c;
  }
  for(int i=0;i<N;i++){
    cin>>c;
    b+=c;
  }
  for(int i=0;i<N;i++){
    s+=to_string(i+1);
  }
  m=kaijou(N);
  int *A=new int[m];
  do{
    cnt++;
    if(s==a)na=cnt;
    if(s==b)nb=cnt;
    }while(next_permutation(s.begin(),s.end()));
  cout<<abs(na-nb)<<endl;
}


Measured memory_bytes: 256