akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;

int main() {
  int N, A;
  cin >> N;
  vector<int> vec;
  vec.reserve(N);
  for (int i = 0;i < N;i ++) {
    vec[i] = 0;
  }
  for (int i = 1;i < N;i ++) {
    cin >> A;
    vec[A-1] ++;
  }
  for (auto i = 0;i < N;i ++) {
    cout << vec[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 4052
#include<iostream>
#include<set>
#include<vector>
#include<stack>
using namespace std;
#define int long long int
#define mod 1000000007
int fact(int n)
{
	if(n==0)
	   return 1;
	else
	   return (n*fact(n-1))%mod;
}
int32_t main()
{
     int n,m;
     cin>>n>>m;
     int val=abs(n-m);
     if(val>1)
     {
		 cout<<0<<endl;
	 }
	 else if(val==1)
	 {
		 int p=fact(n);
		 int q=fact(m);
		 int answer=p*q;
		 answer%=mod;
		 cout<<answer<<endl;
	 }
	 else
	 {
		int p=fact(n);
		int q=fact(n);
		int answer=(2*p*q)%mod;
		cout<<answer<<endl; 
	 }
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int X = sc.nextInt();
		if(500 * K >= X){
			System.out.println("Yes")			;
		}else{
			System.out.println("No")			;			
		}
	}
}


Measured memory_bytes: 21844
ary = gets.chomp.split.map(&:to_i)  # スペースで区切られた複数の整数
ary.sort!

if (ary[0] == ary[1] ||  ary[1] == ary[2]) && ary.uniq.count != 1 then
  puts "Yes"
else
  puts "No"
end

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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Paste snippets here!!

//

void solve(long long L) {
  double l = L;
  cout << (l/3.0)*(l/3.0)*(l/3.0) << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long L;
  std::cin >> L;
  solve(L);
  return 0;
}


Measured memory_bytes: 3672
n,x = map(int,input().split())

A = [1]
P = [1]
for i in range(n):
	A.append(A[i]*2+3)
	P.append(P[i]*2+1)
# print(A,P)

def func(n,x):
	if x == 1:
		return 0 if n != 0 else 1
	elif x <= 1+A[n-1]:
		return func(n-1,x-1)
	elif x == 2+A[n-1]:
		return P[n-1]+1
	elif x <= 2+2*A[n-1]:
		return P[n-1]+1+func(n-1,x-2-A[n-1])
	else:
		return 2*P[n-1]+1

print(func(n,x))

Measured memory_bytes: 3064
//17D8101030E Mouri Kentaro 2019/10/17
#include <iostream>
#include <vector>

int main(){
    int n;
    std::cin>>n;
    std::vector<int> S(n);
    for(int i=0;i<n;i++){
        std::cin>>S[i];
    }
    int q;
    std::cin>>q;
    std::vector<int> T(q);
    for(int i=0;i<q;i++){
        std::cin>>T[i];
    }

    int ans=0;
    int mid;
    for(int i=0;i<q;i++){
        int start=0;
        int end=n;
        while(end>start){
            mid=(end+start)/2;
            if(T[i]==S[mid]){
                ans++;
                break;
            }else if(T[i]<S[mid]){
                end=mid;
            }else{
                start=mid+1;
            }
        }
        
    }
    std::cout<<ans<<'\n';
}





Measured memory_bytes: 3352
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
using namespace std;

ll n,m,ar[N],sum,t;



int main()
{
	fast;
	cin>>n;
	cout<<n/2 - --n%2;

}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int>pii;
typedef vector<int>vi;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define fi first
#define se second
#define de(x) cout<<#x<<"="<<x<<"\n"
#define dd(x) cout<<#x<<"="<<x<<" "
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lowbit(a) ((a)&-(a))
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
const int N=2e6+5;
int main()
{
	string s;
	cin>>s;
	if(s[2] == s[3] && s[4] == s[5]){
		cout<<"Yes\n";
	}
	else cout<<"No\n";
	return 0;
}



Measured memory_bytes: 256
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from fractions import gcd
import math
def resolve():
    N=pin()
    X=sorted(lispin())
    d=[0]*(10**5+1)
    for x in X:
        d[x]+=1
    ans=0
    for i in range(10**5+1):
        a,b,c=0,0,0
        try:
            a=d[i]
            b=d[i+1]
            c=d[i+2]
        except IndexError:pass
        ans=max(ans,a+b+c)
    print(ans)
        
#%%submit!      
resolve()


Measured memory_bytes: 79296
#include <bits/stdc++.h>
using namespace std;
int main(){
 string s,t;
  cin >> s >> t;
  int point=0;
  int sn=s.size(),tn=t.size();
  int count=0,cou1;
  int ans;
  
  for(int i=point;i<sn-tn+1;i++){
    cou1=0;
    for(int j=0;j<tn;j++){
      if(s.at(j+point)==t.at(j)){
        cou1++;
      }
    }
    count=max(count,cou1);
    point++;
  }
  

 
  cout << tn-count << endl;
  return 0;
  
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
 
int main() {
ll n,k;
cin>>n>>k;
ll ca=10000000000;
ll counter=0;
ll a[n+1]={};
ll cb=10000000000;
for(ll i=0;i<n;i++){
cin>>ca;
a[ca]++;}
sort(a,a+n+1);
for(ll i=0;i<n;i++){
if(a[i]!=0){
ca=i;
break;}}
for(ll i=ca;i<n+1-k;i++){
counter+=a[i];}
cout<<counter<<endl;}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,sum;
  string s;
  map<int,int> date={};
  vector<pair<int,int> > v;
  vector<pair<int,int> > va;
  vector<pair<int,int> > val;
  cin>>n>>s;
  for(int i=0;i<n;i++){
	date[s[i]-'0'*100]++;
    if(date[s[i]-'0'*100]==1){
      v.push_back(make_pair((s[i]-'0')*100,i));
    }      
  }
  
  date.clear();
  for(int i=0;i<v.size();i++){
    for(int j=v[i].se+1;j<n;j++){
      date[v[i].fi+(s[j]-'0')*10]++;
      if(date[v[i].fi+(s[j]-'0')*10]==1){
        va.push_back(make_pair(v[i].fi+(s[j]-'0')*10,j));
      }
    }    
  }
  
  date.clear();
  for(int i=0;i<va.size();i++){
    for(int j=va[i].se+1;j<n;j++){
      date[va[i].fi+(s[j]-'0')]++;
      if(date[va[i].fi+(s[j]-'0')]==1){
        val.push_back(make_pair(va[i].fi+(s[j]-'0'),j));
      }
    }
  }
  
  cout<<val.size()<<"\n";
}

Measured memory_bytes: 384
n, a, b = map(int, input().split())

def modpow(a, n, mod):
    res = 1
    while n > 0:
        if (n&1):
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res

MOD = 10**9 + 7
res = modpow(2, n, MOD) - 1 

def combi(n, k):
    p, q = 1, 1
    for i in range(1, k + 1):
        p = p * (n - i + 1) % MOD
        q = q * i % MOD
    return p * modpow(q, MOD - 2, MOD)

res -= combi(n, a) + combi(n, b)
print(res%MOD)

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

using namespace std;

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

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

const long long INF = 1LL << 60;

int main(void){
  int N, tmp6, tmp9;
  cin >> N;
  vector<long long> DP(200010, INF);
  DP[0] = 0;
  DP[1] = 1;
  for(int i = 0; i < N; i++){
    chmin(DP[i+1], DP[i]+1);
    for(tmp6 = 6; i + tmp6 <= N; tmp6*=6){
      chmin(DP[i+tmp6],DP[i]+1);
    }
    for(tmp9 = 9; i + tmp9 <= N; tmp9*=9){
      chmin(DP[i+tmp9],DP[i]+1);
    }
  }
  
  cout << DP[N] << endl;
    
  return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;
/*int main()
{
	int n; cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
//	for(int i=0;i<n;i++) cout<<a[i];
	int sum=0;
	for(int i=n-1;i>1;i--)
	{
		for(int j=i-1;j>0;j--)
		{
			if(a[i]==a[j]) continue;
			for(int k=j-1;k>=0;k--)
			{
				if(a[k]!=a[i] and a[k]!=a[j] and a[i] < (a[k] + a[j])) 
				{
					sum++;
				}
				
				if(a[k]!=a[i] and a[k]!=a[j] and a[i] >= (a[k] + a[j])) 
				{
					break;
				}
				
			}
		}
	}
	
	cout<<sum;
}

int main()
{
	int n,d,ans=0;
	cin>>n>>d;
	while(n--)
	{
		int a,b; cin>>a>>b;
		long long int fl=a*a + b*b;
		float sum=sqrt(fl);
		if(sum<=d) ans++;
		
	}
	cout<<ans;
}*/
int main()
{
	int n; cin>>n;
	int a=0,w=0,t=0,r=0; 
	for(int i=0;i<n;i++)
	{
		string s; cin>>s;
		if(s=="AC") a++;
		else if(s=="WA") w++;
		else if(s=="TLE") t++;
		else r++;
	}
	
	cout<<"AC x "<<a<<"\nWA x "<<w<<"\nTLE x "<<t<<"\nRE x "<<r;
}


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

int main(){
	string s;
	cin >> s;
	int f=0;
	if(s.size()%2==1){
		f=1;
	}
	for(int i=0;i<s.size();i++){
		if(i%2==0){
			if(s.at(i)!='h'){
				f=1;
			}
		}else if(i%2!=0){
			if(s.at(i)!='i'){
				f=1;
			}
		}
	}
	if(f==0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n,d,count=0,x,y;
  cin>>n>>d;
  while(n--){
    cin>>x>>y;
  if(d*d>=x*x+y*y)count++;
  }
  cout<<count;
return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>

#include <cstdlib>

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

  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    int d1, d2;
    std::cin >> d1 >> d2;

    if (d1 == d2) {
      ++cnt;

      if (cnt == 3) {
        std::cout << "Yes\n";
        return 0;
      }
    } else {
      cnt = 0;
    }
  }

  std::cout << "No\n";
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  
  int s, t, u, v;
  int r = 0;
  
  cin >> A >> B;
  
  for (int i = A; i <= B; i++) {
    s = i / 10000;
    t = i % 10;
    u = i / 1000 % 10;
    v = i % 100 / 10;
    
    if (s == t && u == v)
      r++;
  }
  
  cout << r << endl;
}

Measured memory_bytes: 256
H, W, A, B = map(int, input().split())
grid = [[0]*W for i in range(H)]

for i in range(H - B):
    grid[i][W - A:] = [1] * A

for i in range(H - B, H):
    grid[i][:W - A] = [1] * (W - A)
for i in range(H):
    print("".join(map(str, grid[i])))


Measured memory_bytes: 11892
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans, cnt;

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

	ll sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	char r = 'R', l = 'L', u = 'U', d = 'D';

	// 行き
	rep(i, tx - sx) {
		cout << r;
	}
	rep(i, ty - sy) {
		cout << u;
	}

	// 帰り
	rep(i, tx - sx) {
		cout << l;
	}
	rep(i, ty - sy) {
		cout << d;
	}
	
	// 行き
	cout << d;
	rep(i, tx - sx + 1) {
		cout << r;
	}
	rep(i, ty - sy + 1) {
		cout << u;
	}
	cout << l;

	// 帰り
	cout << u;
	rep(i, tx - sx + 1) {
		cout << l;
	}
	rep(i, ty - sy + 1) {
		cout << d;
	}
	cout << r;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include <queue>
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1; i<n;i++)
#define ALL(a) a.begin(),a.end()
using namespace std;
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 }, h, w,n,r,l;
int main() {
	int n,a,b; cin >> n; vector<pair<int, int>> v(n);
	rep(i, n) {
		cin >> a >> b;
		v[i] = { b,a };
	}sort(ALL(v));
	int now = 0,ans = 0;
	vector<int> an;
	rep(i, n) {
		if (v[i].second > now) {
			now = v[i].first;
			ans++;
			an.push_back(v[i].second);
		}
	}cout << ans << endl;
}


Measured memory_bytes: 4228
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

struct Int {
	ll x;
	Int(ll x) : x(x) {}
	Int operator +(Int y) {
		return Int(this->x + y.x);
	}
	Int operator -(Int y) {
		return Int(this->x - y.x);
	}
	Int operator *(Int y) {
		return Int(this->x * y.x);
	}
	Int operator /(Int y) {
		if (y.x == 0) return Int(1);
		return Int(this->x / y.x);
	}
	Int operator %(Int y) {
		if (y.x == 0) return Int(1);
		return Int(this->x % y.x);
	}
	Int operator ^(Int y) {
		return Int(this->x ^ y.x);
	}
	bool operator ==(Int y) {
		return this->x == y.x;
	}
	bool operator !=(Int y) {
		return !(*this == y);
	}
	bool operator <(Int y) {
		return this->x < y.x;
	}
};

Int f(Int x) {
	return (((Int(1) * (Int(1) * Int(3))) / ((x - (Int(1) * (Int(1) - (Int(1) * Int(3))))) % Int(4))) * ((((Int(1) - (Int(1) * Int(3))) - ((Int(1) - (Int(1) * Int(2))) * Int(2))) == (Int(1) - (Int(1) * Int(3))) ? (x - (Int(1) * Int(2))) : (((Int(5) == ((Int(1) + Int(1)) < x ? (x - Int(2)) : Int(1)) ? (Int(2) * (Int(2) / Int(4))) : (x == ((Int(1) + Int(1)) < x ? (x - Int(2)) : Int(1)) ? x : ((x % (Int(4) ^ (Int(5) ^ x))) ^ ((x % (Int(4) ^ (Int(5) ^ ((((x % (Int(4) ^ (Int(5) ^ x))) ^ ((x % (Int(4) ^ (Int(5) ^ x))) % ((x - (Int(1) - Int(2))) ^ (Int(5) ^ x)))) % (Int(4) ^ (Int(5) ^ x))) * (Int(2) / (Int(3) / Int(4))))))) % ((x - (Int(1) - Int(2))) ^ (Int(5) ^ x)))))) / (Int(3) / (Int(3) % Int(5)))) * ((Int(1) - (Int(1) * Int(3))) / (Int(3) / Int(4))))) / ((Int(1) * (Int(1) * Int(3))) / ((x - (Int(1) * (Int(1) - (Int(1) * Int(3))))) % Int(4)))));
}

ll XOR(ll x) {
	if (x != 2) return f(Int(x)).x;
	else return 3;
}

int main() {
	ll a, b; cin >> a >> b;
	if (a == 0) cout << XOR(b) << endl;
	else {
		cout << (XOR(a - 1) ^ XOR(b)) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	init, _ := strconv.Atoi(read())
	ans := determine(N, init, 1)
	fmt.Printf("%s\n", ans)
}

func determine(N, cur, idx int) string {
	if N == idx {
		return "Yes"
	}
	idx++
	next, _ := strconv.Atoi(read())
	if next == cur {
		return determine(N, next, idx)
	}
	if next > cur {
		return determine(N, next-1, idx)
	}
	return "No"
}


Measured memory_bytes: 16640
#include <iostream>
#include<map>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示

using namespace std;
#define fin(ans) cout << (ans) << '\n'
int main()
{
    int N;cin >> N;
    cout << fixed << setprecision(15) << (float)(N - N / 2) /  N << endl;
    return 0;
}

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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010, M = 2 * N;

int n, m;
int a[N];
PII add[N];

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i ++ ) scanf("%d", a + i);
	
	for (int i = 0; i < m; i ++ )
	{
		int b, c;
		scanf("%d%d", &b, &c);
		add[i] = {c, b};
	}
	
	sort(a, a + n);
	sort(add, add + m);
	reverse(add, add + m);
	
	LL res = 0;
	for (int i = 0, j = 0; i < n; i ++ )
	{
		if (j < m && add[j].F > a[i])
		{
			a[i] = add[j].F;
			if ( -- add[j].S == 0) j ++ ;
		}
		res += a[i];
	}
	
	printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include<string.h>
int binarysearch(int a[],int key,int n)
{  int left=0,right=n,mid;
   while(left<right)
   {  mid=(left+right)/2;
      if(a[mid]==key)  return mid;
      else if(key<a[mid])  right=mid;
      else left=mid+1;
   }
   return 0;
}
int main()
{  int a[1000000],b[1000000];
   int i,n,t,k,m;
   m=0;
   scanf("%d",&n);
   for(i=0;i<n;i++)
     scanf("%d",&a[i]);
   scanf("%d",&t);
   for(i=0;i<t;i++)
   {  scanf("%d",&b[i]);
      if(binarysearch(a,b[i],n))  m++;
   }
   printf("%d\n",m);
   return 0;
}


Measured memory_bytes: 2308
n = int(input())
csf = [list(map(int, input().split())) for _ in range(n - 1)]

for i, (c, s, f) in enumerate(csf):
    t = s + c
    for j in range(i + 1, n - 1):
        C, S, F = csf[j][0], csf[j][1], csf[j][2]
        t = max(t, S)
        t = -(-t // F) * F + C
    print(t)
print(0)

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define IREP(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define IMAX INT_MAX
#define IMIN INT_MIN
#define LMAX LLONG_MAX
#define LMIN LLONG_MIN
template<typename T> inline void chmin(T &a, T b){ if(a > b) a = b; }
template<typename T> inline void chmax(T &a, T b){ if(a < b) a = b; }
template<typename T> inline void xch(T &a, T &b){ T w = a; a = b; b = w; }


int main() {
    int n;
    cin >> n;
    int A[n + 1], B[n], a[n + 1], b[n];
    REP(i, n + 1) cin >> A[i];
    REP(i, n) cin >> B[i];
    ll cntl = 0;
    a[0] = A[0];
    REP(i, n){
        a[i + 1] = A[i + 1];
        b[i] = B[i];
    }
    REP(i, n){
        cntl += min(a[i], b[i]);
        b[i] -= min(a[i], b[i]);
        cntl += min(a[i + 1], b[i]);
        a[i + 1] -= min(a[i + 1], b[i]);
    }
    a[0] = A[0];
    REP(i, n){
        a[i + 1] = A[i + 1];
        b[i] = B[i];
    }
    ll cntr = 0;
    IREP(i, n){
        cntr += min(a[i + 1], b[i]);
        b[i] -= min(a[i + 1], b[i]);
        cntr += min(a[i], b[i]);
        a[i] -= min(a[i], b[i]);
    }
    //cout << cntl << " " << cntr << endl;
    cout << max(cntl, cntr) << endl;
    return 0;
}








Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

/*
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define md(l, r) l + (r - l) / 2
#define ll long long
#define btw(a, l, r) a.begin() + l, a.begin() + r + 1
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int(x.size()))
#define sqr(x) (x) * (x)
#define endl '\n'

#define getfiles ifstream cin("input.txt"); ofstream cout("output.txt");
#define clr(x, y) memset((x), (y), sizeof (x))
#define ld long double

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<vector<pair<int, int> > > vvpii;
typedef vector<vector<pair<ll, ll> > > vvpll;
typedef pair<int, pair<int, int> > piii;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef vector<vector<ll> > vvll;
typedef vector<pair<ll, pair<ll, ll> > > vplll;
typedef pair<ll, ll> pll;

const ld eps = -1e9;
const long long N = 200001, P = 1e9 + 7, P1 = 1e9 + 13, iINF = 1e9, INF = 2e18, K = 73, K1 = 79;

ll dstF(ll x, ll y, ll xx, ll yy) {
    return (sqr(x - xx) + sqr(y - yy));
}

ld dstSqrtF(ll x, ll y, ll xx, ll yy) {
    return (sqrt(sqr(x - xx) + sqr(y - yy)));
}

ll _bp(ll val, ll st, ll p) {
    if (st == 0) {
        return 1;
    }
    ll temp = _bp(val, st / 2, p);
    temp = sqr(temp);
    temp %= p;
    if (st % 2 == 1) {
        temp *= val;
        temp %= p;
    }
    return temp;
}

ll _bp(ll val, ll st) {
    if (st == 0) {
        return 1;
    }
    ll temp = _bp(val, st / 2);
    temp = sqr(temp);
    if (st % 2 == 1) {
        temp *= val;
    }
    return temp;
}

ll nok(ll a, ll b) {
    return (a / __gcd(a, b) * b);
}

/*
ll fact[N];

void buildFacts(ll n, ll p) {
    fact[0] = 1;
    for (ll i = 1; i <= n; i++) {
        fact[i] = (fact[i - 1] * i) % p;
    }
}

ll C(ll n, ll k, ll p = -1) {
    if (p == -1) {
        ll x = fact[n];
        ll y = (fact[k] * fact[n - k]);
        return (x / y);
    } else {
        ll x = fact[n];
        ll y = (fact[k] * fact[n - k]) % p;
        x = (x * _bp(y, p - 2, p)) % p;
        return x;
    }
}
*/

void solve() {
    int x;
    cin >> x;
    cout << 1 - x;
}

signed main() {
    //freopen("checklist.in", "r", stdin);
    //freopen("checklist.out", "w", stdout);
    //fast_io;
    int q;
    q = 1;
    //cin >> q;
    while (q != 0) {
        solve();
        --q;
    }
}

/*
*/


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    string S; cin >> S;
    vi c(2);
    REP(i, S.length())
    {
        if(S[i] == '0') c[0]++;
        else c[1]++;
    }
    cout << 2*min(c[0], c[1]) << endl;
} 
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 512
import itertools
import math
 
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
 
avg = 0
permutations = list(itertools.permutations(range(N)))
for l in permutations:
  tmp = 0
  for i in range(len(l)-1):
    tmp += math.sqrt((xy[l[i+1]][0] - xy[l[i]][0])**2 + (xy[l[i+1]][1] - xy[l[i]][1])**2)
  avg += tmp

avg /= len(permutations)
print(avg)

Measured memory_bytes: 13936
n = int(input())
a = list(map(int, input().split()))

s = sum(a)
x = 0
ans = abs(2 * a[0] - s)
snuke = a[0]

for i in range(1, n-1):
    snuke += a[i]
    if abs(2 * snuke - s) < ans:
        ans = abs(2 * snuke - s)

print(ans)


Measured memory_bytes: 30484
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ABC121C - Energy Drink Collector
  int N, M;
  cin >> N >> M;
  vector<vector<int> > AB(N, vector<int>(2));
  REP(i, N){
    cin >> AB.at(i).at(0) >> AB.at(i).at(1);
  }
  sort(AB.begin(), AB.end());
  ll ans = 0, cnt = 0, tmp;
  while(M > 0){
    tmp = min(AB.at(cnt).at(1), M);
    ans += tmp * AB.at(cnt).at(0);
    M -= tmp;
    cnt++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5760
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] Ws = W.split(" ");
		int N = Integer.parseInt(Ws[0]);
		int D = Integer.parseInt(Ws[1]);

		double x = N/((2.0*D)+1);
		long ans = (long)x;
		if(x-ans > 0){
			ans++;
		}

		System.out.println(ans);

	}


}


Measured memory_bytes: 21076
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';

ll gcd(ll a,ll b) {
    while(1) {
        if(a < b) swap(a, b);
        if(!b) break;
        a %= b;
    }
    return a;
}
int main() {
    ll n,ans=0;
    cin>>n;
    vl a(n),l(n+1),r(n+1);

    rep(i,n)cin>>a[i];

    rep(i,n){
        l[i+1]=gcd(l[i],a[i]);
        r[n-i-1]=gcd(r[n-i],a[n-i-1]);
    }
    rep(i,n)ans=max(ans,gcd(l[i],r[i+1]));
    cout<<ans<<endl;
}

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

int main()
{
	int a, b, W;
	cin >> W >> a >> b;
	int ans = 0;
	if(a + W < b) ans = b - (a + W);
	else if(b + W < a) ans = a - (b + W);
	else ans = 0;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  lines.shift();
  const arr = lines.shift().split(' ').map(Number);
  buildMaxHeap(arr);
  console.log(arr.reduce((s, e) => s += ` ${e}`, ''));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest;
    left = 2 * i + 1;
    right = 2 * i + 2;
    largest = left < n && arr[left] > arr[i] ? left : i;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
    //   arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      [arr[i], arr[largest]] = [arr[largest], arr[i]];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
}



Measured memory_bytes: 115044
N,X,Y=map(int,input().split())

ans=[0]*N
for i in range(1,N):
    for j in range(i+1,N+1):
        num=min(j-i,abs(j-Y)+abs(i-X)+1)
        ans[num]+=1

for k in range(1,N):
    print(ans[k])

Measured memory_bytes: 47452
o = list(input())
e = list(input())
x=[]
if len(e)==len(o):
	for i in range(len(e)):
		x.append(o[i])
		x.append(e[i])
if len(e)+1==len(o):
	for i in range(len(e)):
		x.append(o[i])
		x.append(e[i])
	x.append(o[len(o)-1])


print(''.join(x))




Measured memory_bytes: 3060
#include <stdio.h>

int main(){
int a,b;
char ma;
while(1){
scanf("%d %c %d",&a,&ma,&b);
if(ma=='+')
printf("%d\n",a+b);
else if(ma=='-')
printf("%d\n",a-b);
else if(ma=='/')
printf("%d\n",a/b);
else if(ma=='*')
printf("%d\n",a*b);
else
break;
}
return 0;
}


Measured memory_bytes: 2748
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

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

    int shortcut = Y - X;
    --X;
    --Y;

    map<int, int> shortest2kosuu = map<int, int>();
    for (int i = 0; i < N - 1; ++i) {
        for (int j = i + 1; j < N; ++j) {
            int straight = j - i;
            int shortest = straight;
            bool simpleShortCut = (i <= X) && (Y <= j);
            if (simpleShortCut) {
                shortest -= shortcut;
                shortest += 1;
            }
            else {
                // i <= X <= j <= Y
                bool complexShortCut = (i <= X) && (j < Y);
                if (complexShortCut) {
                    int tryToShortCut = (X - i) + 1 + (Y - j);
                    if (tryToShortCut < shortest) {
                        shortest = tryToShortCut;
                    }
                }
                else {
                    bool moreComplexShortCut = (X < i) && (Y <= j);
                    if (moreComplexShortCut) {
                        int tryToShortCut = (i - X) + 1 + (j - Y);
                        if (tryToShortCut < shortest) {
                            shortest = tryToShortCut;
                        }
                    }
                    else {
                        bool moremoreComplexShortCut = (X < i) && (j < Y);
                        if (moremoreComplexShortCut) {
                            int tryToShortCut = (i - X) + 1 + (Y - j);
                            if (tryToShortCut < shortest) {
                                shortest = tryToShortCut;
                            }
                        }
                    }

                }
            }

            if (shortest2kosuu.count(shortest) == 0) {
                shortest2kosuu.insert(make_pair(shortest, 1));
            }
            else {
                shortest2kosuu[shortest] += 1;
            }
        }
    }

    vector<int> ans(N - 1, 0);
    for (int i = 0; i < N - 1; ++i) {
        if (shortest2kosuu.count(i + 1) > 0) {
            ans[i] = shortest2kosuu[i + 1];
        }
        else {
            ans[i] = 0;
        }
    }
    for (int i = 0; i < N - 1; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}


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

int main() {
  int n;cin >> n;
  vector<int> a(n);
  rep(i,n)cin >> a[i];
  ll count = 0;
  rep(i,n){
    if(a[a[i]-1]==i+1)count++;
  }
  cout << count/2 << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 998244353;

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

  ll x;
  cin >> x;

  ll cur = 100;

  int ret = 0;
  while(cur < x){
    ret++;
    cur += cur/100;
  }
  cout << ret << endl;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <string.h>

int shelf_max;
int result[10001][3];
char map[40004];
char map2[10001];

/*prev now status*/
const int costs[3][3][4]={
	{
		{0,1,3,3},
		{1,1,2,2},
		{2,2,2,2}
	},{
		{1,1,2,2},
		{0,1,1,2},
		{1,2,1,2}
	},{
		{2,2,2,2},
		{1,2,1,2},
		{0,3,1,3}
	}
};

int main(void) {
	int case_num;
	int i,j,k;
	int now_min;
	scanf("%d",&case_num);
	for(i=0;i<case_num;i++) {
		scanf("%d",&shelf_max);
		scanf("%s",map);
		memset(result,0,sizeof(result));
		memset(map2,0,sizeof(map2));
		if(map[0]=='Y')map2[0]|=1;
		if(map[shelf_max*2]=='Y')map2[0]|=2;
		for(j=1;j<shelf_max;j++) {
			if(map[j*2-1]=='Y' || map[j*2]=='Y')map2[j]|=1;
			if(map[shelf_max*2+j*2-1]=='Y' ||
				map[shelf_max*2+j*2]=='Y')map2[j]|=2;
		}
		if(map[shelf_max*2-1]=='Y')map2[shelf_max]|=1;
		if(map[shelf_max*4-1]=='Y')map2[shelf_max]|=2;
		result[0][0]=costs[0][0][map2[0]];
		result[0][1]=costs[0][1][map2[0]];
		result[0][2]=costs[0][2][map2[0]];
		for(j=1;j<=shelf_max;j++) {
			for(k=0;k<3;k++) {
				now_min=0x7fffffff;
				if(now_min>result[j-1][0]+costs[0][k][map2[j]])
					now_min=result[j-1][0]+costs[0][k][map2[j]];
				if(now_min>result[j-1][1]+costs[1][k][map2[j]])
					now_min=result[j-1][1]+costs[1][k][map2[j]];
				if(now_min>result[j-1][2]+costs[2][k][map2[j]])
					now_min=result[j-1][2]+costs[2][k][map2[j]];
				result[j][k]=now_min+1;
			}
		}
		now_min=result[shelf_max][0];
		if(now_min>result[shelf_max][1]+1)
			now_min=result[shelf_max][1]+1;
		if(now_min>result[shelf_max][2]+2)
			now_min=result[shelf_max][2]+2;
		printf("%d\n",now_min);
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main()
{
	int a[5],b[5],x,i,y;
	for(i=0;i<5;i++)
		scanf("%d",&a[i]);
	for(i=0;i<5;i++)
	{
		b[i]=a[i]%10;
	}
	for(x=0,i=1;i<4;i++)
	{
		if(b[x]==0)
			x++;
		if(b[i]!=0&&b[x]>b[i])
			x=i;
	}
	//printf("%d\n",x);
	for(i=0,y=0;i<5;i++)
	{
		if(i==x)
			y=y+a[i];
		else
		{
			if(a[i]>10&&b[i]!=0)
			{a[i]=a[i]/10;y=y+a[i]*10+10;/*printf("*%d\n",y);*/}
			else
				if(a[i]<=10)
				{y=y+10;/*printf("**%d\n",y);*/}
				else
					if(a[i]>10&&b[i]==0)
						y=y+a[i];
		}
	}
	printf("%d\n",y);
	return 0;
}

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

int main() {
  char b;
  cin >> b;
  if(b == 'A') cout << 'T' << endl;
  else if(b == 'T') cout << 'A' << endl;
  else if(b == 'C') cout << 'G' << endl;
  else cout << 'C' << endl;
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,dp[1002][1002];
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
char s[1002][1002];
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>h>>w;
    rep(i,h)rep(j,w)cin>>s[i][j];
    dp[0][0]=1;
    rep(i,h){
        rep(j,w){
            if(i==0&&j==0)continue;
            if(s[i][j]=='#')dp[i][j]=0;
            else{
                if(i==0)(dp[i][j]=dp[i][j-1])%=MOD;
                else if(j==0)(dp[i][j]=dp[i-1][j])%=MOD;
                else (dp[i][j]=dp[i-1][j]+dp[i][j-1])%=MOD;
            }
        }
    }
    Cout(dp[h-1][w-1]);
    return 0;
}


Measured memory_bytes: 9088
class UnionFind:
 
    def __init__(self, size):
        # 負の値はルート (集合の代表) で集合の個数
        # 正の値は次の要素を表す
        self.size = size
        self.table = [-1 for _ in range(size)]
 
    def find(self, x):
        # 集合の代表を求める
        children = []
        while self.table[x] >= 0:
            children.append(x)
            x = self.table[x]
        for c in children:
            self.table[c] = x
        return x
 
    def union(self, x, y):
        # 併合
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] >= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
        return self.table[s1]
 
n,k,l= map(int, input().split())
road = UnionFind(n+1)
train = UnionFind(n+1)
for i in range(k):
    p,q = map(int, input().split())
    road.union(p, q)
for i in range(l):
    p,q = map(int, input().split())
    train.union(p,q)
import collections
d = collections.defaultdict(int)
for i in range(1,n+1):
    r = road.find(i)
    t = train.find(i)
    d[(r,t)] += 1
res = [d[(road.find(i), train.find(i))] for i in range(1,n+1)]

print(*res, sep=' ')

Measured memory_bytes: 112420
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> Type igcd(Type x,Type y){return (y==0)?x:igcd(y,x%y);}
template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

//参加者解答参考.
int main(){
	int w,h;
	cin>>w>>h;
	
	vector<pii > vp(w+h);//pii(cost,jud)
	REP(i,w){
		int p;
		cin>>p;
		vp[i]=pii(p,0);
	}
	REP(i,h){
		int q;
		cin>>q;
		vp[i+w]=pii(q,1);
	}
	sort(ALL(vp));
	
	llong ans=0;
	int nw=w+1,nh=h+1;
	REP(i,w+h){
		if(vp[i].second==0){
			ans+=(llong)vp[i].first*nh;
			nw--;
		}else{
			ans+=(llong)vp[i].first*nw;
			nh--;
		}
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

const ll MOD = 998244353;
const int MAX_N = 100100;
int D[MAX_N];
ll num[MAX_N]; //num[i] := 頂点1との距離がiの頂点が何個あるか
int N;

int main()
{
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) scanf("%d", &D[i]);

    if(D[0] != 0) { printf("0\n"); return 0;}

    for(int i = 0; i < N; ++i) ++num[D[i]];

    ll res = 1LL;

    for(int i = 1; i < N; ++i) res = res*num[D[i]-1]%MOD;

    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int y0[] = {1868, 1912, 1926, 1989};
    int m0[] = {9, 7, 12, 1};
    int d0[] = {8, 30, 25, 8};
    char s0[][10] = {"pre-meiji", "meiji", "taisho", "showa", "heisei"};

    for(;;){
        int y, m, d;
        if(!(cin >> y >> m >> d))
            return 0;

        for(int i=0; i<5; ++i){
            if(i == 4 || y < y0[i] || y == y0[i] && m < m0[i] || y == y0[i] && m == m0[i] && d < d0[i]){
                cout << s0[i];
                if(i != 0)
                    cout << ' ' << (y-y0[i-1]+1) << ' ' << m << ' ' << d;
                cout << endl;
                break;
            }
        }
    }
}

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

typedef long long ll;

const int MAXN = 105, MAXV = 100005;
const ll inf = 0x3f3f3f3f3f3f3f3f;

ll dp[MAXV];
ll weight[MAXN];
ll value[MAXN];
int object_count, max_weight;

void solve() {
    for (int v = 1; v < MAXV; ++v) dp[v] = inf;
    for (int i = 1; i <= object_count; ++i) {
        for (int v = MAXV - 1; v >= value[i]; --v) {
            dp[v] = min(dp[v], dp[v - value[i]] + weight[i]);
        }
    }
}

int main() {
    scanf("%d%d", &object_count, &max_weight);
    for (int i = 1; i <= object_count; ++i) {
        scanf("%lld%lld", weight + i, value + i);
    }
    solve();
    for (int v = MAXV - 1; ~v; --v) {
        if (dp[v] && dp[v] <= max_weight) {
            printf("%d\n", v);
            return 0;
        }
    }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int w, h, x, y;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> w >> h >> x >> y;
	cout << setprecision(12) << (double)w*h/2 << " " << (2*x == w && 2*y == h ? 1 : 0) << "\n";
}

Measured memory_bytes: 256
import sys
def input() : return sys.stdin.readline().strip()

def main():
    N = int(input())
    S = input()
    r = S.count("R")
    g = S.count("G")
    b = N-r-g

    all_num = r*g*b
    sub = 0
    for i in range(N):
        for j in range(i+1, N):
            if S[i] == S[j]: continue
            k = j + (j - i)
            if k >= N or S[k] == S[i] or S[k] == S[j]: continue
            sub += 1
    print(all_num - sub)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9220
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<int, int> P;

mat G(1e+5, vec(0));
vec color(1e+5, 0);
bool ifd2 = true, only_one = false;
void dfs(int v, int c){
    color[v] = c;
    if(G[v].empty()){
        only_one = true;
        return;
    }
    for(int to : G[v]){
        if(color[to] == 0){
            dfs(to, -c);
        }else if(color[to] == c){
            ifd2 = false;
        }
    }
}

int main() {
    cin>>N>>M;
    rep(i,M){
        cin>>A>>B;
        --A;
        --B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    ll d2{0}, nd2{0}, one{0};
    rep(i,N){
        if(color[i] == 0){
            ifd2 = true;
            only_one = false;
            dfs(i, 1);
            only_one ? ++one : ifd2 ? ++d2 : ++nd2;
        }
    }
    cout<<one * (N * 2 - one) + (d2 + nd2) * (d2 + nd2) + d2 * d2<<endl;
}

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



int main() 
{
  string S; cin>>S;
  ll n=0;
  rep(i,S.size())
  {
    if(i==0)
    {
      continue;
    }
    if(S.at(i)!=S.at(i-1))
    {
      n++;
    }
  }  
  cout<<n<<endl;
  return 0;
}


Measured memory_bytes: 1020
n = int(input())
d = []
cnt = 1
for i in range(n):
    d.append(int(input()))
d.sort(reverse=True)
_ = d[0]
for j in range(n-1):
    if _ > d[j+1]:
        cnt += 1
        _ = d[j+1]
print(cnt)


Measured memory_bytes: 9076
a,b,k = map(int,input().split())
A = []
B = []

for i in range(1,a+1):
    if a % i ==0:
        A.append(i)
        
for i in range(1,b+1):
    if b  % i ==0:
        B.append(i)
        
A = set(A)
B = set(B)

OK = A & B
OK = sorted(OK)

print(OK[-k])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int N;
vi a;
bool use[100];

int main(){
    cin >> N;
    a.resize(N);
    rep(i,N) cin >> a[i];

    map<int,int> mp;
    for(int i=0;i<N;i++){
        mp[a[i]]++;
    }

    rep(i,N){
        if(a[i] == 2){
            use[i] = true;
        }
    }

    if(mp[-2] > 0){
        int k = mp[-2];
        if(k%2==1){
            if(mp[-1] > 0){
                rep(i,N) if(a[i] == -1){
                    use[i] = true;
                    break;
                }
            }else{
                k--;
            }
        }
        int cnt = 0;
        rep(i,N) if(a[i] == -2 and cnt < k){
            cnt++;
            use[i] = true;
        }
    }

    int ansc = 0;
    rep(i,N) if(use[i]) ansc++;
    cout << ansc << endl;
    for(int i=0;i<N;i++) if(use[i]){
        cout << i + 1 << endl;
    }

}



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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T, typename U, typename V> inline
ostream& operator<<(ostream &o, tuple<T,U,V> &p)
{
    return o << "{" << get<0>(p) << "," << get<1>(p) << "," << get<2>(p) << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

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

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

int main(void)
{
    string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    string t;
    cin >> t;

    if(s.find(t) != string::npos) {
        cout << "A" << endl;
    } else {
        cout << "a" << endl;
    }
    return 0;
}

/*atcoder*/


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

int main() {
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	vector<int> p(A), q(B), r(C);
	for (int i = 0; i < A; ++i) cin >> p[i];
	for (int i = 0; i < B; ++i) cin >> q[i];
	for (int i = 0; i < C; ++i) cin >> r[i];

	sort(p.rbegin(), p.rend());
	sort(q.rbegin(), q.rend());
	sort(r.rbegin(), r.rend());

	priority_queue<int, vector<int>, greater<int>> Q;
	for (int i = 0; i < X; i++) Q.push(p[i]);
	for (int i = 0; i < Y; i++) Q.push(q[i]);
	
	long long ans = 0;
	for (int i = 0; i < C; i++) {
		if (r[i] > Q.top()) {
			ans += r[i];
			Q.pop();
		}
	}
	while (!Q.empty()) {
		ans += Q.top();
		Q.pop();
	}
	

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

Measured memory_bytes: 5428