akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <sstream>
#include <vector>
using namespace std;

int main()
{
        string s, tmp, str, commands;
        stringstream ss;
        vector<string> dice;

        getline(cin, s);

        ss << s;

        while(getline(ss, str, ' ')) {
                dice.push_back(str);
        }

        cin >> commands;

        for(int i = 0; i < commands.length(); i++) {
                switch(commands[i]) {
                        case 'N':
                                tmp = dice[0];
                                dice[0] = dice[1];
                                dice[1] = dice[5];
                                dice[5] = dice[4];
                                dice[4] = tmp;
                                break;
                        case 'E':
                                tmp = dice[0];
                                dice[0] = dice[3];
                                dice[3] = dice[5];
                                dice[5] = dice[2];
                                dice[2] = tmp;
                                break;
                        case 'W':
                                tmp = dice[0];
                                dice[0] = dice[2];
                                dice[2] = dice[5];
                                dice[5] = dice[3];
                                dice[3] = tmp;
                                break;
                        case 'S':
                                tmp = dice[0];
                                dice[0] = dice[4];
                                dice[4] = dice[5];
                                dice[5] = dice[1];
                                dice[1] = tmp;
                                break;
                        default :
                                break;
                }
        }

        cout << dice[0] << endl;

        return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1000000000000005;
const int maxn=1e6+5;
ll n,m,p;
int main()
{
    scanf("%lld",&n);
    if(n==1||n==2||n==0||n%2==1) printf("0\n");
    else
    {
        ll res=0;
        ll t=5;
        while(n/t)
        {
            res+=n/(t*2);
            t*=5;
        }
        ll cot=0;
        printf("%lld\n",res);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<array>
using namespace std;
int main()
{
	int N;
	int saidaichi = -1;
	int sum = 0;
	int L[100];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	sort(L, L+N);
	saidaichi = L[N-1];
	for (int i = 0; i < N-1; i++) {
		sum += L[i];
	}
	
	if (saidaichi < sum) {
		cout << "Yes" << endl;
	}
	else if(saidaichi>=sum){
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int main(void)
{
	long long n,m,s;
	s = 0;
	scanf("%lld %lld", &n, &m);
	if (n*2<=m)
	{
		s+=n;
		m-=n*2;
		s+=m/4;
	}
	else
	{
		s+=m/2;
	}
	printf("%lld\n",s);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main (String args[]) {
    Scanner sc= new Scanner(System.in);
    int H1 = sc.nextInt();
    int M1 = sc.nextInt();
    int H2 = sc.nextInt();
    int M2 = sc.nextInt();
    int K = sc.nextInt();
    
    int t = H2*60 + M2 - H1*60 - M1;
    System.out.println(t-K);
  }
}

Measured memory_bytes: 35720
n,k = map(int,input().split())
p = [0]*n
a = []
ans = 0
for i in range (k):
  a = []
  d = input()
  a = list(map(int,input().split()))
  for j in a:
    p[j-1] +=1
  
for i in p:
  if i == 0:
    ans +=1
print(ans)

Measured memory_bytes: 67876
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define ios; ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef double db;
mt19937 rnd(random_device{}());
const int mod = 1e9 + 7;
const int N = 2e5 + 5;
const int M = 1e3 + 5;
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
inline ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
int n, m, k;
ll a[N];

ll solve(){
    rep(i,1,n)
        if(a[i]==0) return 0;
    ll sum=a[1], tmp=1e18;
    rep(i,2,n){
        if(tmp/sum<a[i]) return -1;
        sum*=a[i];
    }
    return sum;
}

int main(){
    cin>>n;
    rep(i,1,n) cin>>a[i];
    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 4428
#include <stdio.h>
int binarySearch(int key, int numa, int a[]) {
	int left = 0;
	int right = numa;
	int mid;

	while (left < right) {
		mid = (left + right) / 2;
		if (a[mid] == key) {
			return 1;
		}
		if (key > a[mid]) {
			left = mid + 1;
		}
		else if (key < a[mid]) {
			right = mid;
		}
	}

	return 0;

}

int main(void)
{
	int num = 0, numa, numb, key, i, left, right;
	int a[100000];

	scanf("%d", &numa);

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

	scanf("%d", &numb);
	
	for (i = 0; i < numb; i++) {
		scanf("%d", &key);
		if (binarySearch(key, numa, a)) {
			num++;
		}
		
	}
	printf("%d\n", num);
	
	return 0;
}


Measured memory_bytes: 2108
n = input()
tmp_n = n.split(" ")

N = tmp_n[0]
M = tmp_n[1]
n_list = []

for i in range(int(M)):
    num = input()
    tmp_num = num.split()
    n_list.append(int(tmp_num[0]))
    n_list.append(int(tmp_num[1]))
    
for j in range(1,int(N)+1):
    count = 0
    for k in n_list:
        if k == j:
            count = count + 1        
    print(count)


Measured memory_bytes: 3064
s = input()

memo =[]

for i in range(len(s)):
    if i == 0:
        memo.append([0])
        continue

    if s[i-1]=="R" and s[i]=="L":
        memo[-1].append(i)

    if s[i-1]=="L" and s[i]=="R":
        memo[-1].append(i-1)
        memo.append([i])

    if i == len(s)-1:
        memo[-1].append(i)


last = [0]*len(s)

for l in memo:
    hidari = (l[1]-l[0] - (l[1]-l[0])//2) + ((l[2]-l[1]+1)//2)
    migi = ((l[1] - l[0]) // 2) + ((l[2] - l[1] + 1) - ((l[2] - l[1] + 1) // 2))

    last[l[1]-1] += hidari
    last[l[1]] += migi

ans = list(map(str, last))

print(" ".join(ans))

Measured memory_bytes: 21556
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

int main() {
	ll N, X;
	cin >> N >> X;
	if (X == 1 || X == 2 * N - 1) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	if (N == 2) {
		cout << 1 << endl;
		cout << 2 << endl;
		cout << 3 << endl;
		return 0;
	}
	vector<ll> four;
	if (X != 2 * N - 2) {
		four = {X+1, X-1, X, X+2};
	} else {
		four = {X-1, X+1, X, X-2};
	}
	set<ll> four_set(four.begin(), four.end());
	ll next = 1;
	vector<ll> ans;
	while (true) {
		if (ans.size() == 2 * N - 1) {
			break;
		}
		if (ans.size() == N - 3) {
			copy(four.begin(), four.end(), back_inserter(ans));
			continue;
		}
		if (four_set.find(next) != four_set.end()) {
			next++;
			continue;
		}
		ans.push_back(next);
		next++;
	}
	rep(i,0,2*N-1) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;

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

int main(){
    int N,K;
    cin >> N >> K;
    int r=(N-1)*(N-2)/2-K;
    if (r<0){
        cout << -1 << endl;
        return 0;
    }
    cout << N+r-1 << endl;
    rep2(i,2,N+1){
        cout << 1 << ' ' << i << endl;
    }
    int s=2;
    while(r>0){
        for (int i=s+1;i<=N&&r>0;i++){
            cout << s << ' ' << i << endl;
            r--;
        }
        s++;
    }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) c[i]=i+1;
    int ansaa, ansbb, ansa=0, ansb=0;
    do{
        ++ansa;
        int flag=0;
        rep(i,n){
            if(a[i]!=c[i]){
                ++flag;
                break;
            }
        }
        if(flag==0){
            ansaa=ansa;
        }
    } while(next_permutation(c.begin(),c.end()));
    do{
        ++ansb;
        int flag=0;
        rep(i,n){
            if(b[i]!=c[i]){
                ++flag;
                break;
            }
        }
        if(flag==0){
            ansbb=ansb;
            break;
        }
    } while(next_permutation(c.begin(),c.end()));
    cout << abs(ansaa-ansbb) << "\n";
    return 0;
}

Measured memory_bytes: 256
//suhan lee, saitama university;
#include <iostream>
using namespace std;
struct slaves{
  int a;
  int b;
};

void sort(slaves* slave,int m){
  slaves tmp;
  for(int i=0;i<m-1;i++)
    for(int j=0;j<m-1;j++)
      if(slave[j].a>slave[j+1].a){
	tmp=slave[j];
	slave[j]=slave[j+1];
	slave[j+1]=tmp;
      }
      else continue;
}
int search(int k,slaves* slave,int* ninzu,int m){
  int i=0;
  int max=0;
  //  if(slave[m].a>k) return 0;
  while(slave[i].a<=k+1){
    if(slave[i].b>max)
      max=slave[i].b;
    //  cout <<"max is :"<<max<<endl;
    i++; 
    if(i==m){ 
      break;
    }
   
  }
  *ninzu+=1;

  if(max<=k)
    *ninzu=0;
  return max;

}



int main(){
  
  slaves pro[100];
  int n,m,ninzu,tmp,tmp2;

  ninzu=0;
  cin >>n>>m; 
  for(int i=0;i<m;i++)
    cin >>pro[i].a>>pro[i].b;
  // for(int i=0;i<m;i++)
    //    cout <<pro[i].a<<"  "<<pro[i].b<<endl;
  sort(pro,m);
  // for(int i=0;i<m;i++)
    // cout <<pro[i].a<<"  "<<pro[i].b<<endl;
    // cout <<endl<<endl;
  tmp=search(0,pro,&ninzu,m);

  while(1){
    //     cout <<"tmp is :"<<tmp<<endl;
    if(tmp==0||ninzu==0){
      cout <<"Impossible"<<endl;
      return 0;
    }
    else if(tmp==n)
      {
	cout <<(ninzu)<<endl;
	return 0;
      }
    else{
      tmp=search(tmp,pro,&ninzu,m);
      tmp2=tmp;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
S = input()
n = len(S)
ans = 0
for i in range(2**(n-1)):
    B = bin(i)[2:].zfill(n)
    t = 0
    for j in range(n):
        if B[j]=='0':
            t = t*10+int(S[j])
        else:
            ans += t
            t = int(S[j])
    ans += t
print(ans)

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

string s;
void solve()
{
    string ret;
    for(auto c : s) {
        if(c == ',') cout << " ";
        else cout << c;
    }
    cout << flush;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
    cin >> s;

    solve();

	return 0;
}

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

int n;
int t[202], dp[202][202];

int solve(int a, int b){
  if(a + 1 == b) return dp[a][b] = abs(t[a] - t[b]);
  if(a == b) return 0;
  if(dp[a][b] != -1) return dp[a][b];

  int &res = dp[a][b];

  for(int i = a; i < b; i++){
    res = max(res, solve(a, i) + solve(i + 1, b) + abs(t[a] - t[i + 1]));
  }

  return res;
}

int main(){
  int T;
  cin >> T;

  while(T--){
    cin >> n;
    for(int i = 0; i < n; i++){
      cin >> t[i];
      t[i + n] = t[i];
    }

    memset(dp, -1, sizeof(dp));

    int ans = 0;

    for(int i = 0; i < n; i++){
      ans = max(ans, solve(i, i + n - 1));
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1332
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  ll n,ans=0;
  cin>>n;
  vector<ll> a(n);
  for(auto&& e: a) 
  {
    cin>>e;
  }
  map<ll,ll> minus,plus;
  for (ll i = 0; i < n; ++i)
  {
    minus[i-a[i]]++;
    plus[i+a[i]]++;
  }
  for(const auto& e: plus) 
  {
    ans+=minus[e.first]*e.second;
  }
  cout<<ans;
}

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

int N, M;
map<int, int> D;

int main() {
    scanf("%d", &N);
    for(int i = 0; i < N; i++) {
        int d; scanf("%d", &d);
        D[d]++;
    }
    scanf("%d", &M);
    bool ok = true;
    for(int i = 0; i < M; i++) {
        int t; scanf("%d", &t);
        if(!D[t]) {
            ok = false;
        }
        else D[t]--;
    }
    if(ok) printf("YES");
    else printf("NO");
}


Measured memory_bytes: 9600
n, a, b, c, d = map(int, input().split())
s = '_' + input()

if s[c] == '#' or s[d] == '#':
    print('No')
    exit()

# '##'を検知
if '##' in s[a:c+1] or '##' in s[b:d+1]:
    print('No')
    exit()

if c > d:
    # 3 マス以上の連続する'.'が必要
    num_dot = s[b-1:d+2].count("...")
    if num_dot == 0:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 41840
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <iomanip>
using namespace std;
long long mod=1e9+7;
struct all{
	vector<long long> kai,gya,nck;
	all(long long n){
		kai.resize(n+1);
		gya.resize(n+1);
		nck.resize(n+1);
	}
	long long pow(long long x,long long n){
		long long ret=1;
		if(n>0){
			ret=pow(x,n/2);
			if(n%2==0){
				(ret=(ret*ret))%=mod;
			}else{
				(ret=((ret*ret)%mod)*x)%=mod;
			}
		}
		return ret;
	}
	long long inv(long long n){
		return pow(n,mod-2);
	}
	vector<long long> cul(long long n){
		kai[n]=n;
		for(int i=n-1;i>0;i--){
			(kai[i]=kai[i+1]*i)%=mod;
		}
		gya[1]=inv(1);
		for(int i=2;i<=n;i++){
			(gya[i]=gya[i-1]*inv(i))%=mod;
		}
		for(int i=1;i<=n;i++){
			(nck[i]=kai[n+1-i]*gya[i])%=mod;
		}
		nck[0]=1;
		nck[n]=1;
		return nck;
	}
};
int main(){
	int n,k;
	cin>>n>>k;
	all nii(n-k+1);
	all mii(k-1);
	vector<long long> a=nii.cul(n-k+1);
	vector<long long> b=mii.cul(k-1);
	for(int i=1;i<=k;i++){
		if(n-k+1<i){
			cout<<0<<endl;
		}else{
			cout<<a[i]*b[i-1]%mod<<endl;
		}
	}
	return 0;
}


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

int main(){
  int a,b;
  cin>>a>>b;
  
  if(a<=5){
    cout<<0<<endl;
  }else if(a<=12){
    cout<<b/2<<endl;
  }else{
    cout<<b<<endl;
  }
}


Measured memory_bytes: 256
# include<stdio.h>
int main(void)
{
 int a,b,x;
 scanf("%d %d %d",&a,&b,&x);
 
 if(a>x)
  printf("NO");
 else{
  if(x>(a+b))
   printf("NO");
  else
   printf("YES");
 }

 return 0;
}

Measured memory_bytes: 128
from collections import defaultdict
N = int(input())
raw_numbers = list(map(int, input().split()))
numbers = defaultdict(int)

for num in raw_numbers:
    numbers[num] += 1
    
total = sum(raw_numbers)
    
Q = int(input())

for _ in range(Q):
    a, b = list(map(int, input().split()))
    taken = numbers[a]
    total -= a * numbers[a]
    numbers[b] += numbers[a]
    total += b * taken
    numbers[a] = 0
    print(total)

Measured memory_bytes: 90992
n, m = map(int, input().split())
A = []
B = []
for i in range(n):
    x, y = map(int, input().split())
    A.append(x)
    B.append(y)

ans = 0
for price, amount in sorted(zip(A, B)):
    ans += price * min(m, amount)
    m -= amount
    if m <= 0:
        break
print(ans)

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

/*
最大値の最小化(今回の場合, 最長の最短化)は二分探索が使える典型問題.
全ての丸太を, 丸太の長さを表す数直線上のある点X以下の長さにするために必要な切る回数が
K以下であるかどうかを判定する問題.
今回は最大値を最小化するので, 数直線上において大きい側がok, 小さい側がngとなる.
(長さ0の丸太は切ることができない)
二分探索である長さXを取って, 全ての丸太について, それぞれ長さX以下にするためには
何回切る必要があるかを調べる((A[i]-1)/x). その合計がK以下かどうか判定.
基本的に, Xが大きい方が切る回数は減るので, 合計がK以上ならXを大きくするべき(left(ng)=X)だし,
Kかそれ以下ならもっと攻められるから小さくするべき(right(ok)=X)
そうやって探索範囲を半分にしていって, 最終的にleftとrightの差が1以下になったら終了.
最小の最大値を求めるので, rightの値を取る.
*/

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  
  // めぐる式二分探索法
  // ngは解が存在しない値, okは解が存在する値を設定すれば良いので, 今回の場合はそれぞれ0, 1e9でも良い
  int ng = 0, ok = 1e9;
  while (abs(ok - ng) > 1) {  // どちらが大きいか明白であればabsは要らない
    int mid = (ok + ng) / 2;    
  
    // ラムダ式. [&]で既出の変数を関数内で使うことができる. }後の()は関数呼び出しの意
    auto check = [&] {
      ll count = 0;
      // 全ての丸太について, それぞれを長さmid以下にするために必要な切断回数を求め足し合わせる
      rep(i, N) count += abs(A.at(i) - 1) / mid;  // absにしないとRuntime Error起きる
      return count <= K;  // return true or false
    }() ? ok = mid : ng = mid;
    
    /*
    上の処理は以下と同義
    auto check = [&] {処理};
    if (check(mid)) ok = mid;
    else ng = mid;
    */
  }
  
  // 最小の最大値ok(right)
  cout << ok << endl;
}


Measured memory_bytes: 4052
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

vector<P> vp;
int n, a, b, c;

int main(){
	while (cin >> n&&n){
		REP(i, n){
			cin >> a >> b >> c;
			vp.push_back(P(b + c, a));
		}
		sort(ALL(vp), greater<P>());
		cout << vp[0].second << " " << vp[0].first << endl;
		vp.clear();
	}
}

Measured memory_bytes: 1532
#!/usr/bin/env python
#-*- coding: utf-8 -*-

from collections import defaultdict
from math import factorial as f
from fractions import gcd as g

s = raw_input ()
t = raw_input ()
w = s

def solve (s, t):
    if len (t) > len (s): return -1
    N = len (s)
    s += "*" * 50
    ret = -1
    for i in range (N):
        ok = True
        for j in range (len (t)):
            if s [i + j] == "?": continue
            if s [i + j] == t [j]: continue
            ok = False
            break
        if ok:
            ret = max (ret, i)
    return ret

x = solve (s, t)
if x != -1:
    w = w [:x] + t + w [x + len (t):]
    w = w.replace ("?", "a")
    print w
else:
    print "UNRESTORABLE"




Measured memory_bytes: 4392
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
#define dump(a) cout << (a) << endl;
typedef long long ll;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> x(n), y(n);
    vector<ll> xa, ya;
    for( int i = 0; i < n; i++ ) {
        cin >> x[i] >> y[i];
        xa.push_back(x[i]);
        ya.push_back(y[i]);
    }
    sort( xa.begin(), xa.end() );
    sort( ya.begin(), ya.end() );
    ll res = (xa.back()-xa.front()) * (ya.back()-ya.front());
    for( int xi = 0; xi < n-1; xi++ ) {
        for( int xj = xi+1; xj < n; xj++ ) {
            for( int yi = 0; yi < n-1; yi++ ) {
                for( int yj = yi+1; yj < n; yj++ ) {
                    int cnt = 0;
                    for( int i = 0; i < n; i++ ) {
                        if( xa[xi] <= x[i] && x[i] <= xa[xj] && ya[yi] <= y[i] && y[i] <= ya[yj] ) cnt++;
                    }
                    if( cnt >= k ) res = min( res, (xa[xj]-xa[xi]) * (ya[yj]-ya[yi]) );
                }
            }
        }
    }
    dump( res );
    return 0;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
int N;
int ans = 0;
vector<ll> v{3, 5, 7};
/* function */
bool isOK(ll x) {
    vector<int> cnt(10);
    ll tmp = x;
    while (tmp > 0) {
        cnt[tmp % 10]++;
        tmp /= 10;
    }
    for (int vi : v) { if (cnt[vi] == 0) return false; }
    return true;
}
void dfs(ll n, ll x) {
    ll m;
    for (int i = 0; i < 3; i++) {
        m = n + v[i] * pow(10, x);
        if (m <= N) {
            if (isOK(m)) ans++;
            dfs(m, x + 1);
        }
    }
}
/* main */
int main(){
    cin >> N;
    dfs(0, 0);
    cout << ans << '\n';
}


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


int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  for(int i = 0; i < N; i++){
    cin >> V.at(i);
  }
  int count = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      for(int k = 0; k < N; k++){
        if(V.at(i)==V.at(j) || V.at(j)== V.at(k) || V.at(k)==V.at(i)){
          continue;
        }
        else{
          if(V.at(i) < V.at(j)+V.at(k) && V.at(j) < V.at(k)+V.at(i) && V.at(k) < V.at(i)+V.at(j)){
            count++;
          }
        }
      }
    }
  }
  cout << count/6 << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
#include <set>
#include <map>
#include <unordered_map>
#include <cassert>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    fast_io();

    int h,w; std::cin >> h >> w;
    std::string s(w+2,'#');
    std::vector<std::string> stage(h+2,s);

    for(int i=1; i<h+1; i++){
        for(int j=1; j<w+1; j++){
            char a; std::cin >> a;
            stage[i][j] = a;
        }
    }

    for(int i=0; i<stage.size(); i++){
        std::cout << stage[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 3600
n,k = map(int,input().split())
x = list(map(int,input().split()))

x.append(0)
x.sort()

#print(x)

min = 10**10

zeroIdx = x.index(0)

for i in range(zeroIdx-k,zeroIdx+1):
    if i < 0 : 
        continue
    elif len(x) <= i + k :
        break

    plsIdx = i + k 
    misIdx = i

    #print(misIdx,plsIdx,x[misIdx],x[plsIdx])

    if abs(x[plsIdx]) > abs(x[misIdx]) :
        tmp = abs(x[plsIdx]) + (abs(x[misIdx])<<1)
    else:
        tmp = (abs(x[plsIdx])<<1) + abs(x[misIdx])

    if tmp < min :
        min = tmp

print(min)

Measured memory_bytes: 14844
def rec(cds, hd)
  if cds.size > 0
    if cds.count(cds[0]+1) > 0 and cds.count(cds[0]+2) > 0
      cds_t = Marshal.load(Marshal.dump(cds))
      cds_t.delete_at(cds_t.index(cds[0]+2))
      cds_t.delete_at(cds_t.index(cds[0]+1))
      cds_t.shift
      return true if rec(cds_t, hd)
    end
    if cds[0] == cds[1] and hd
      cds_h = Marshal.load(Marshal.dump(cds))
      2.times{cds_h.shift}
      return true if rec(cds_h,false)
    end
    if cds[0] == cds[1] and cds[0] == cds[2]
      cds_s = Marshal.load(Marshal.dump(cds))
      3.times{cds_s.shift}
      return true if rec(cds_s, hd)
    end
  elsif cds.size == 0
    return true 
  end
end

while gets
  te = $_.chomp.split('').map(&:to_i).sort
  ans = []
  1.upto(9) do |i|
    men = (Marshal.load(Marshal.dump(te)) << i).sort
    unless men.count(i) > 4 then
      ans << i if rec(men,true)
    end
  end
  puts ans.empty? ? 0 : ans.join(" ")
end

Measured memory_bytes: 8976
#include<cstdio>
#include<iostream>
using namespace std;
int ga[55][55],m,n,s;
int b[5][3]={{0,0,0},{0,1,0},{0,-1,0},{0,0,1},{0,0,-1}};
bool vis[55][55];
struct node{
	int x,y,step;
}q[2507];
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	int i,j;
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
		{
			char c;
			cin>>c;
			if(c=='.')
				ga[i][j]=0;
			else 
			{
				ga[i][j]=1;	
				s++;
			}
				
		}
/*	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			cout<<ga[i][j];
		}
		cout<<endl;
	}*/
		
			
	int t=1,w=1;
	q[t].x=1;
	q[t].y=1;
	q[t].step=1;
	vis[1][1]=1;
	while(t<=w)
	{
		node cur=q[t];t++;
		int x=cur.x,y=cur.y,step=cur.step;
		for(i=1;i<=4;i++)
		{
			int tx=x+b[i][1],ty=y+b[i][2];
			//cout<<tx<<" "<<ty<<" "<<ga[tx][ty]<<" "<<vis[tx][ty]<<endl;
			if(ga[tx][ty]==0&&tx>0&&tx<=n&&ty>0&&ty<=m&&(!vis[tx][ty]))
			{
				if(tx==n&&ty==m)
				{
					cout<<n*m-s-step-1<<endl;
					return 0;
				}
				w++;
				q[w].x=tx;
				q[w].y=ty;
				q[w].step=step+1;
				vis[tx][ty]=1;

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

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

int main() {
  int N,M,i,j,k,s,c=0;
  cin >> N >> M;
  vector<vector<int>> sw(M, vector<int>(0));
  vector<int> p(M);
  
  for(i=0; i<M; i++) {
    cin >> k;
    for(j=0; j<k; j++) {
      cin >> s;
      sw.at(i).push_back(s);
    }
  }
  
  for(i=0; i<M; i++)
    cin >> p.at(i);
  
  for(i=0; i<pow(2,N); i++) {
    stringstream ss;
    ss << bitset<10>(i);
    string b = ss.str();
    for(j=0; j<M; j++) {
      int sm=0;
      for(k=0; k<sw.at(j).size(); k++)
        sm += b.at(10-sw.at(j).at(k)) - '0';
      if(sm%2 != p.at(j))
        break;
    }
    if(j==M)
      c++;
  }
  
  cout << c << endl;
}

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

count = 0
for i in range(n):
    if a[i] < b[i]:
        count += (b[i] - a[i]) // 2
    else:
        count += b[i] - a[i]

print("Yes" if count >= 0 else "No")

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

int main() {
    int k, n; cin >> k >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int ans = a[n - 1] - a[0];
    rep(i, n - 1) {
        int t = (k - a[i + 1]) + a[i];
        ans = min(ans, t);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
N = int(input())
X_bin = input()
#N = 10**5
#X_bin = '1' * N

X_int = int(X_bin, 2)  # bin => int


def calc_bin_cnt(next_int):
    if next_int == 0:
        return 0
    next_bin = bin(next_int)[2:]
    # popcount
    cnt = 0
    for i in next_bin:
        if i == '1':
            cnt += 1
    return cnt


def calc_ans(next_int, cnt=None):
    if next_cnt == 0:
        return 0
    if next_int == 0:
        return 1
    if cnt is None:
        cnt = calc_bin_cnt(next_int)
    next_int = next_int % cnt
    if next_int > 0:
        ans = calc_ans(next_int) + 1
    else:
        ans = 1
    return ans


X_cnt = calc_bin_cnt(X_int)
f_p = X_int % (X_cnt+1)
if X_cnt-1 == 0:
    f_m = 0
else:
    f_m = X_int % (X_cnt-1)
for i in range(N):
    if X_bin[i] == '1':
        next_cnt = X_cnt - 1
        if next_cnt == 0:
            next_int = 0
        else:
            next_int = f_m - pow(2, (N-i-1), next_cnt)  # マイナスでも正しく求まる？
    else:
        next_cnt = X_cnt + 1
        next_int = f_p + pow(2, (N-i-1), next_cnt)
    print(calc_ans(next_int, next_cnt))
    #calc_ans(next_cnt, next_cnt)


Measured memory_bytes: 9532
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

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

  string S;
  cin >> S;

  vector<int> W(N + 1, 0);
  vector<int> E(N + 1, 0);
  int cntW = 0;
  int cntE = 0;
  for (int i = 0; i < N; ++i) {
    if (S.at(i) == 'W') cntW++;
    if (S.at(i) == 'E') cntE++;
    W.at(i + 1) = cntW;
    E.at(i + 1) = cntE;
  }

  long long ans = 1001001001;
  for (int i = 0; i < N; ++i) {
    long long num = 0;
    num += W.at(i);
    num += E.at(N) - E.at(i + 1);
    ans = min(ans, num);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3076
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        String T = scanner.next();
        int ans = 0;
        for(int i = 0; i < S.length(); i++) {
            if(T.charAt(i) == S.charAt(i)) ans++;
        }


        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
#include<cstdio>
#include<map>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=101101;
map <int,int> st;
int n;
int main(){
	int can=1,x;
	scanf("%d",&n);
	for (int i=1; i<=n; i++){
		scanf("%d",&x);
		if (st[x]==1)	can=0;
		st[x]++;
	}
	if (can)	printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define ssort(a) sort(a.begin(), a.end())
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  string s1, s2;
  cin >>s1 >> s2;
  ll ans=1;
  int prestate=0;
  rep(i, n){
    if(s1[i]==s2[i]){
      if(prestate==0){
        ans*=3;
      } else if(prestate==1){
        ans*=2;
      }
      ans%=mod;
      prestate=1;
    } else {
      i++;
      if(prestate==0){
        ans*=6;
      } else if(prestate==1){
        ans*=2;
      } else if(prestate==2){
        ans*=3;
      }
      ans%=mod;
      prestate=2;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
using ll = long long;

int main() {
    ll n,ans=0;
    cin >> n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++){
         cin >> a[i];
         ans+=a[i];
    }
    if(ans%10==0){
        sort(a.begin(),a.end());
        for(ll i=0;i<n;i++){
            if(a[i]%10!=0){
                ans-=a[i];
                break;
            }
        }
        if(ans%10==0)   cout << 0 << endl;
        else    cout << ans << endl;
    }
    else{
        cout << ans << endl;
    }
	return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b,c;cin>>a>>b>>c;
  cout<<c<<" "<<a<<" "<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define reps(i, n , m) for(ll i = n; i <= m; i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
const int mod = 1000000007; 
long long inv[200000],fact[200000],ifact[200000];
long long comb(ll n, ll k){
	if(n<k)return 0;
	else if (n<0||k<0) return 0;
	else return fact[n] * ifact[k] % mod * ifact[n-k] % mod;
}
 
 
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	/*inv[1] = fact[0] = fact[1] = ifact[0] = ifact[1] = 1; for (int i=2;i<200000;i++){ inv[i] = (mod - mod / i) * inv[mod % i] % mod; fact[i] = fact[i-1] * i % mod;ifact[i] = ifact[i-1] * inv[i] % mod;
	}*/ //nCr
	ll N;
	cin>>N;
	vector<ll> A(N);
	ll sum=0;
	rep(i,N){
		cin>>A[i];
	    sum+=A[i];
	}
	vector<int> ans(N);
	ans[0]=sum;
	ans[1]=sum;
	rep(i,N/2)ans[0]-=A[i*2+1]*2;
	rep(i,N/2)ans[1]-=A[i*2+2]*2;
	rep(i,N-2){
		ans[i+2]=A[i+1]*2-ans[i+1];
	}
	rep(i,N)cout<<ans[i]<<endl;
}

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

int main(){
    string s; cin >> s;
    long long answer=0;
    for (long long bit=0; bit<(1<<s.size()-1); bit++){
        long long temp_sum=0;
        for (int i=0; i<s.size(); i++){
            temp_sum*=10;//すでに入っている値を10倍する
            if ((bit & (1<<i)) || i==s.size()-1){//そのbitが立っている or 末尾（その後ろに+があるとみなす）
                temp_sum+=s.at(i)-'0';
                answer+=temp_sum;
                temp_sum=0;
            } else {//立っていなかったら
                temp_sum+=s.at(i)-'0';
            }
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
constexpr int IINF = INT_MAX;

template <typename Monoid>
struct SegmentTree{
private:
    using F = function<Monoid(Monoid, Monoid)>;
    int N;
    vector<Monoid> node;
    F f;
    Monoid e;  // identity element

public:
    SegmentTree(){}
    SegmentTree(F f, Monoid e):f(f), e(e){}
    void init(int sz){
        N = 1;
        while(N < sz) N <<= 1;
        node.assign(2*N-1, e);
    }
    void build(vector<Monoid>& v){
        int sz = int(v.size());
        init(sz);
        for(int i=0; i<sz; i++){
            node[i+N-1] = v[i];
        }
        for(int i=N-2; i>=0; i--){
            node[i] = f(node[i*2+1], node[i*2+2]);
        }
    }
    void update(int k, Monoid x){
        k += N-1;
        node[k] = x;
        while(k > 0){
            k = (k-1)/2;
            node[k] = f(node[2*k+1], node[2*k+2]);
        }
    }
    // [a,b)
    Monoid query(int a, int b){return query(a, b, 0, 0, N);}
    Monoid query(int a, int b, int k, int l, int r){
        if(b <= l || r <= a) return e;
        if(a <= l && r <= b) return node[k];
        Monoid vl, vr;
        vl = query(a, b, 2*k+1, l, (l+r)/2);
        vr = query(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }
};


struct edge
{
    int from, to, d;
};


int n, q, root = 0;
vector<vector<edge> > g;
vector<int> depth, vs, id, idr;

auto funcmin = [=](P a, P b){return min(a,b);};
SegmentTree<P> rmq(funcmin,{IINF, -1});
auto funcsum = [=](int a, int b){return a+b;};
SegmentTree<int> rsq(funcsum, 0);

void dfs(int v, int p, int d, int &k){
    id[v] = k;
    vs[k] = v;
    depth[k] = d;
    k++;
    for(auto e : g[v]){
        if(e.to == p) continue;
        dfs(e.to, v, d+1, k);
        vs[k] = v;
        depth[k] = d;
        k++;
    }
    idr[v] = k;
}

void init(){
    int k=0;
    depth.resize(n*2-1);
    vs.resize(n*2-1);
    id.resize(n);
    idr.resize(n);
    dfs(root,-1,0,k);
    vector<P> tmp;
    for(int i=0;i<k;i++){
        tmp.push_back({depth[i], vs[i]});
    }
    rmq.build(tmp);
    rsq.init(k);
}

int LCA(int u, int v){
    return rmq.query(min(id[u], id[v]), max(id[u], id[v])+1).second;
}

void update(int v, int w){
    rsq.update(id[v]-1, rsq.query(id[v]-1,id[v])+w);
    rsq.update(idr[v]-1, rsq.query(idr[v]-1,idr[v])-w);
}

int getDist(int u, int v){
    int w = LCA(u, v);
    return rsq.query(0, id[u]) + rsq.query(0, id[v]) - rsq.query(0,id[w])*2;
}

int main() {
    cin >> n;
    g.resize(n);
    for(int i=0;i<n;i++){
        int m;
        cin >> m;
        for(int j=0;j<m;j++){
            int v;
            cin >> v;
            g[i].push_back({i,v,0});
        }
    }
    init();
    cin >> q;
    for(int i=0;i<q;i++){
        int c;
        cin >> c;
        if(c){
            int u;
            cin >> u;
            cout << getDist(root, u) << endl;
        }
        else{
            int v, w;
            cin >> v >> w;
            update(v, w);
        }
    }
    return 0;
}



Measured memory_bytes: 31800
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long n,a[5];
	cin>>n;
	for(int i=0;i<5;i++)cin>>a[i];
	sort(a,a+5);
	cout<<(4+n/a[0]+(n%a[0]>0))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

lint gcd(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

lint lcm(lint a, lint b) {
	//aとbの最小公倍数を返す
	return a / gcd(a, b) * b;
}

/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	int N;
	string S;
	int K;
	cin >> N >> S >> K;
	rep(i, N) {
		if (S[i] == S[K - 1]) {
			cout << S[i];
		}
		else {
			cout << '*';
		}
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
double EPS=1e-10;
double EQ(double a,double b){
    return abs(a-b)<EPS;
}
void fast_stream(){
  std::ios_base::sync_with_stdio(0);
}
template<class T>
string IntToString(T num){
  string res;stringstream ss;ss<<num;
  return ss.str();
}
ll StringToInt(string &str){
  ll res;
  for(int i=0;i<(int)str.size();i++)
    res=(res*10+str[i]-'0');
  return res;
}

char ch1[]={'w','a','k','s','t','n','h','m','y','r'};
char ch2[]={'a','i','u','e','o'};
int tmp[1001];
int main(){
  tmp['T']=0;
  tmp['L']=1;
  tmp['U']=2;
  tmp['R']=3;
  tmp['D']=4;
  string s;
  cin>>s;
  for(int i=0;i<(int)s.size();i+=2){
    int pos=s[i]-'0';
    int ang=tmp[(int)s[i+1]];
    if(pos==0){
      if(ang==0)cout<<"wa";
      else if(ang==2)cout<<"nn";
      else cout<<"wo";
    }
    else{
      if(pos!=1)cout<<ch1[pos];
      cout<<ch2[ang];
    }
  }
  cout<<endl;
  
  return 0;
}

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

int main() {
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    string T;
    for (int i = 0; i < Q; ++i) {
      int t;
      cin >> t;
      if (t == 1) swap(S, T);
      else {
        int f;
        char c;
        cin >> f >> c;
        if (f == 1) T += c;
        else S += c;
      }
    }
    reverse(T.begin(), T.end());
    T += S;
    cout << T << endl;
    return 0;
}

Measured memory_bytes: 1128
n=int(input())
a=[int(i) for i in input().split()]

if n%2==0:
    li1=a[::2]
    li2=a[::-2]
    ans=li2+li1
    print(*ans)
else:
    li1=a[1::2]
    li2=a[::-2]
    ans=li2+li1
    print(*ans)

Measured memory_bytes: 26180
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 2200000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

bool p_[nmax_def];

void p_ini (){

	rep(i, nmax_def) {
		p_[i] = 1;
	}
	p_[0] = 0;
	p_[1] = 0;
	ll i = 2;
	while (1) {
		ll j = i * 2;
		while (1) {
			p_[j] = 0;
			j += i;
			if (j > 1050000)
				break;
		}
		i++;
		if (i > 1050000)
			break;
	}
}

ll gcd(ll a, ll b)
{
	ll x;
	while (1)
	{
		x = a % b;
		if (x == 0)
			return b;
		else
		{
			a = b;
			b = x;
		}
	}
}

int main() {
	p_ini();
	ll A, B;
	cin >> A >> B;
	ll AB = gcd(A, B);
	ll ans = 1;
	rep(i, 1040000) {
		if (!p_[i])
			continue;
		if (AB % i == 0) {
			while (1) {
				if (AB % i != 0)
					break;
				AB /= i;
			}
			ans++;
		}
	}
	if (AB > 1)
		ans++;
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 2432
#include <algorithm>
#include <cstdio>

const int N = 200000;
const int MOD = 1e9 + 7;

void update(int& x, int a)
{
    x += a;
    if (x >= MOD) {
        x -= MOD;
    }
}

int inv(int a)
{
    return a == 1 ? 1 : 1LL * (MOD - MOD / a) * inv(MOD % a) % MOD;
}

int n, a[N], id[N];

bool by_a(int i, int j)
{
    return a[i] < a[j];
}

struct DS
{
    void multiply(int a)
    {
        if (a) {
            sum = 1LL * sum * a % MOD;
            multiple = 1LL * multiple * a % MOD;
            inv_multiple = 1LL * inv_multiple * inv(a) % MOD;
        } else {
            now ++;
            sum = 0;
            multiple = inv_multiple = 1;
        }
    }

    void add(int k, int v)
    {
        update(sum, v);
        v = 1LL * v * inv_multiple % MOD;
        for (; k < n; k += ~k & k + 1) {
            update(at(k), v);
        }
    }

    int ask(int k)
    {
        int result = 0;
        for (; ~k; k -= ~k & k + 1) {
            update(result, at(k));
        }
        return 1LL * multiple * result % MOD;
    }

    int& at(int i)
    {
        if (ts[i] != now) {
            ts[i] = now;
            mem[i] = 0;
        }
        return mem[i];
    }

    int sum = 0, multiple = 1, inv_multiple = 1, now, ts[N], mem[N];
} ds;

int main()
{
#ifdef LOCAL_JUDGE
    freopen("E.in", "r", stdin);
#endif
    scanf("%d", &n);
    for (int i = 0; i < n; ++ i) {
        scanf("%d", a + i);
        id[i] = i;
    }
    std::sort(id, id + n, by_a);
    // for i < j
    // if id[i] < id[j], count # of perms where p[i] > p[j]
    // if id[i] > id[j], count # of perms where p[i] < p[j] = (# of perms) - (# of perms where p[i] > p[j])
    int suffix = 1;
    int result = 0;
    for (int i = n - 1; i >= 0; -- i) {
        int aa = a[id[i]];
        result = 1LL * result * (aa + MOD - i) % MOD;
        int tmp = ds.ask(id[i]);
        tmp = (1LL * ds.sum + MOD - tmp + MOD - tmp) % MOD;
        update(result, 1LL * tmp * (aa + MOD - i) % MOD * (aa + MOD - i - 1) % MOD);
        ds.multiply((aa + MOD - i - 1) % MOD);
        ds.add(id[i], suffix);
        suffix = 1LL * suffix * (aa + MOD - i) % MOD;
    }
    ds.now ++;
    int inversion = 0;
    for (int i = n - 1; i >= 0; -- i) {
        update(inversion, ds.ask(id[i]));
        ds.add(id[i], 1);
    }
    update(result, 2LL * inversion * suffix % MOD);
    printf("%d\n", static_cast<int>(1LL * result * inv(2) % MOD));
}


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

int bubbleSort(int A[],int N){
	int sw=0,i,j,temp;
	bool flag=1;
	for(i=0;flag;i++){
		flag=0;
		for(j=N-1;j>=i+1;j--){
			if(A[j]<A[j-1]){
				temp=A[j];
				A[j]=A[j-1];
				A[j-1]=temp;
				sw++;
				flag=1;
			}
		}
	}
	return sw;
}

int main(){
	int A[100],N,sw,i;

	cin >> N;
		for(i=0;i<N;i++)
			cin >> A[i];
	
	sw = bubbleSort(A,N);
	
	for(i=0;i<N;i++){
		if(i)
			cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;
	
	return 0;
}

Measured memory_bytes: 3084
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
B,C = [0 for i in range(Q)],[0 for i in range(Q)]
for i in range(Q):
    B[i],C[i] = map(int,input().split())

n = [0 for i in range(100001)]
S = 0
for i in range(N):
    n[A[i]] = n[A[i]] + 1
    S = S + A[i]

for i in range(Q):
    S = S + (C[i]-B[i])*n[B[i]]
    n[C[i]] = n[C[i]] + n[B[i]]
    n[B[i]] = 0
    print(S)

Measured memory_bytes: 22716
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> grh(n);
  vector<int> tls(n, 0);
  for (int i = 0; i < n + m - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    grh[a].push_back(b);
    tls[b]++;
  }
  stack<int> stk;
  vector<int> sorted;
  for (int i = 0; i < n; i++) {
    if (!tls[i]) {
      stk.push(i);
    }
  }
  while (!stk.empty()) {
    int crr = stk.top();
    stk.pop();
    sorted.push_back(crr);
    for (int nxt : grh[crr]) {
      tls[nxt]--;
      if (!tls[nxt]) {
        stk.push(nxt);
      }
    }
  }
  vector<int> prt(n);
  for (int i = 0; i < n; i++) {
    prt[i] = i;
  }
  for (int i = 0; i < n; i++) {
    int s = sorted[i];
    for (int t : grh[s]) {
      prt[t] = s;
    }
  }
  for (int i = 0; i < n; i++) {
    if (prt[i] == i) {
      prt[i] = 0;
    } else {
      prt[i] += 1;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << prt[i] << '\n';
  }
  return 0;
}

Measured memory_bytes: 7672