akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[][] points = new int[n+1][3];
		for(int i=1;i<=n;i++){
		    points[i][0] =scn.nextInt();
		    points[i][1] =scn.nextInt();
		    points[i][2] =scn.nextInt();
		}
		// System.out.println(maxHappiness(1,points,-1));
		int[][] memo = new int[n+1][3];
		System.out.println(maxHappiness_memoized(1,points,-1,memo));

	}


    public static int maxHappiness_memoized(int day, int[][] points , int activityOnPrevDay,int[][] memo) {
    		if(day==points.length)return 0;
      		if(activityOnPrevDay!=-1 && memo[day][activityOnPrevDay]!=0)return memo[day][activityOnPrevDay];
    		int ans = Integer.MIN_VALUE;
    		for (int i = 0; i < 3; i++) {
    			if (i != activityOnPrevDay) {
    				int ca = points[day][i] + maxHappiness_memoized(day + 1, points, i,memo);
    				ans = Math.max(ans, ca);
    			}
    		}
    		if(activityOnPrevDay!=-1)
    		    memo[day][activityOnPrevDay]=ans;
    		return ans;
    }
}


Measured memory_bytes: 70108
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t { as swift
#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;

using XY = pair<int, int>;

vector<vector<int>> nodes;
vector<bool> visited;

void mark(int t, int c, int id, vector<int> &map) {
    if (c == t || visited[c]) return;
    visited[c] = true;
    map[c] = id;
    forin(i, 0, nodes[c].size()) {
        mark(t, nodes[c][i], id, map);
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<XY> e(m);
    nodes.resize(n + 1);
    forin(i, 0, m) {
        cin >> e[i].first >> e[i].second;
        nodes[e[i].first].push_back(e[i].second);
    }
    vector<vector<int>> fMap(n + 1, vector<int>(n + 1, 0)), dMap(n + 1, vector<int>(n + 1, 0));
    forin(i, 1, n + 1) {
        visited.assign(n + 1, false);
        int id = 1;
        forin(j, 0, nodes[i].size()) {
            mark(i, nodes[i][j], id++, fMap[i]);
        }
        visited.assign(n + 1, false);
        id = (int)nodes[i].size();
        for (auto j = nodes[i].size(); j > 0; --j) {
            mark(i, nodes[i][j - 1], id--, dMap[i]);
        }
    }
    forin(i, 0, m) {
        auto edge = e[i];
        if ((fMap[edge.first][edge.second] != dMap[edge.first][edge.second]) == (fMap[edge.second][edge.first] > 0)) {
            cout << "same" << endl;
        } else {
            cout << "diff" << endl;
        }
    }
}


Measured memory_bytes: 13572
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    int a, b;
    std::cin >> a >> b;

    if (a >= 10 || b >= 10) {
        std::cout << -1 << std::endl;
    } else {
        std::cout << a * b << std::endl;
    }
}


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

#define pb push_back
#define fi first
#define se second
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pii pair<int,int>
#define N 100001

int n;
int a[100010];
int b[100010];
int sum[200010];

set <int> s;
vector <int> num;
ll qaq;

int lowbit(int x) {
	return x&(-x);
}

void add(int x,int y) {
	while (x<=N*2) {
		sum[x]+=y;
		x+=lowbit(x);
	}
}

int query(int x) {
	int tmp=0;
	while (x) {
		tmp+=sum[x];
		x-=lowbit(x);
	}
	return tmp;
}

bool check(int cur) {
	memset(b,sizeof(b),0);
	for (int i=0;i<=2*N;i++) sum[i]=0;
	for (int i=0;i<n;i++) {
		if (a[i]<=cur) b[i]=1;
		else b[i]=-1;
	}
	int tmp=0;
	ll cnt=0ll;
	for (int i=0;i<n;i++) {
		tmp+=b[i];
		add(tmp+N,1);
		if (tmp>0) cnt+=1ll;
		cnt+=(ll)query(tmp+N-1);
//		cout<<b[i]<<" "<<tmp<<" "<<query(tmp+N-1)<<endl;
	}
	//cnt:小于等于cur的中位数数量
//	cout<<cur<<" "<<cnt<<" "<<qaq<<endl;
	return cnt>=qaq;
}

int main(){
	scanf("%d",&n);
	qaq=(((ll)n*(ll)(n+1))/2)/2+1;
	for (int i=0;i<n;i++) scanf("%d",&a[i]),b[i]=a[i];
	sort(b,b+n);
	for (int i=0;i<n;i++) {
		if (i==0||b[i]!=b[i-1]) num.pb(b[i]);
	}
	int m=num.size();
	int l=0,r=m-1;
//	cout<<m<<endl;
	while (l<r) {
		int mid=(l+r)/2;
		if (check(num[mid])) r=mid;
		else l=mid+1;
	}
	cout<<num[l]<<endl;
	return 0;
}
/*
10
1 5 2 3 2 5 3 2 6 3
*/

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

long long int NOD[10000100] = {};


long long int nod(long long int N)
{
   // long long int NOD [N + 1] = {0};

    for(long long int i = 1; i <= N; i++)
    {
        for(long long int j = i; j <= N; j += i)
        {
            NOD[j] += 1;
        }
    }

    return  NOD[N];
}

int main()
{
    long long int n, i=1, sum = 0, c;
    cin >> n;

    c = nod(n);

    while(i<=n)
    {


        //cout << c << endl;

        sum = sum + (i*NOD[i]);
        i++;
    }


    cout << sum;

}


Measured memory_bytes: 81628
#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>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

int x; 
ll solve(){
   ll ans=0;
   

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

    cin>>x;
    int ans=0;
    if(x>=400&&x<=599)ans=8;
    else if(x>=600&&x<=799)ans=7;
    else if(x>=800&&x<=999)ans=6;
    else if(x>=1000&&x<=1199)ans=5;
    else if(x>=1200&&x<=1399)ans=4;
    else if(x>=1400&&x<=1599)ans=3;
    else if(x>=1600&&x<=1799)ans=2;
    else if(x>=1800&&x<=1999)ans=1;
    cout<<ans<<endl;
    //cout<<solve()<<endl;
    return 0;
}

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

int main(){
  int N, K;

  cin >> N >> K;

  map<int, vector<int>> mp;
  for (size_t i = 0; i < N; i++) {
    int t, d;
    cin >> t >> d;
    mp[t].push_back(d);
  }

  //maxesとothersに値を入れる
  vector<int> maxes, others;
  for(auto& p : mp){
    auto nums = p.second;
    sort(nums.rbegin(), nums.rend());
    maxes.push_back(nums[0]);
    for(int i=1; i<nums.size(); i++) others.push_back(nums[i]);
  }

  sort(maxes.rbegin(), maxes.rend());
  sort(others.rbegin(), others.rend());

  //maxesとothersの累積和
  vector<int64_t> maxes_s(N+1, 0), others_s(N+1, 0);
  for(int i = 0; i < maxes.size(); i++){
    maxes_s[i+1] = maxes_s[i] + maxes[i];
  }
  for(int i = 0; i < others.size(); i++){
    others_s[i+1] = others_s[i] + others[i];
  }

  int kmax = min(K, (int) mp.size());
  int64_t ans = 0;
  for(int64_t k = 1; k <= kmax; k++){
    int64_t result = maxes_s[k] + others_s[K-k] + k * k;
    ans = max(ans, result);
  }

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


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

void solve(long long N, long long K, std::vector<long long> x)
{
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        long long dis_A = x[i];
        long long dis_B = K - x[i];
        if (dis_A < dis_B)
            sum += dis_A * 2;
        else
            sum += dis_B * 2;
    }
    cout << sum << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> x(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &x[i]);
    }
    solve(N, K, std::move(x));
    return 0;
}


Measured memory_bytes: 256
from itertools import groupby

def main():
    N=int(input())
    A=list(map(int,input().split()))
    A.sort()
    X=groupby(A)
    s=0
    for key,group in X:
        t=len(list(group))
        if int(key)>t:
            s+=t
        else:
            s+=t-int(key)
    print(s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14528
#include <stdio.h>

int main(void)
{
	int a,b,m,s;
	
	scanf("%d",&a);
	scanf("%d",&b);
	
	m=a*b;
	s=a*2+b*2;
	
	printf("%d %d\n",m,s);
	
	return 0;
}


Measured memory_bytes: 2120
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define print(x) cout << #x << " = " << x << endl;

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = acos(-1);
const long double eps = 1e-7;


const int MAX = 100001;

int n, m;
int l, r, d;
int numNode;		// 使用した条件の数え上げ
vector<pii> terms[MAX];	// 条件（first: エッジの先のインデックス、second：距離）
bool bHasLeft[MAX];		// 左に人がいるかどうか
bool bSearched[MAX];	// 探索をすでにしているかどうか
int dis[MAX];			// 距離を保存
bool bWrong;			// 矛盾が発生しているかどうか

// 深さ優先探索
void dfs(int p) {
	bSearched[p] = 1;
	numNode++;

	// インデックスpのノードにおける条件すべてをループ
	for (pii term : terms[p]) {
		if (!bSearched[term.first]) {	// エッジの先がまだ探索されていない場合
			dis[term.first] = dis[p] + term.second;	// 距離を保存
			dfs(term.first);	// 次のエッジを探索
		}
		else {	// エッジの先がすでに探索済みである場合
			if (dis[p] + term.second != dis[term.first]) {	// 既に探索した道のりと現在辿ってきた道のりが異なる場合
				bWrong = true;
				return;
			}
		}
	}
}

int main() {
	scanf("%d %d", &n, &m);

	for (int i = 0; i < m; i++) {
		scanf("%d %d %d", &l, &r, &d);

		terms[l].push_back(pii({ r, d }));
		bHasLeft[r] = true;
	}

	for (int i = 1; i <= n; i++) {
		// 左に人がいる時はスキップ
		if (bHasLeft[i]) continue;

		// 一番右になりえる要素から探索スタート
		dfs(i);
	}

	if (bWrong || numNode < n) printf("No\n");
	else printf("Yes\n");

	return 0;
}

Measured memory_bytes: 9472
import Control.Monad.State
import Data.Map as M
import Data.Maybe (fromJust)

main = returnSequence

returnSequence :: IO ()
returnSequence = do
    len <- getLine
    if len == "0" then return ()
                   else do
                       line <- getLine
                       let (list, num) = execState transformTillFPoint (Prelude.map read.words $ line, 0)
                       print num
                       putStrLn $ unwords.Prelude.map show $ list
                       returnSequence

transformTillFPoint :: State ([Int],Int) ()
transformTillFPoint = do
    (list, num) <- get
    let newlist = replace2App list
    if list == newlist then return ()
                                else do
                                    put (newlist, num+1)
                                    transformTillFPoint

replace2App :: Ord a => [a] -> [Int]
replace2App list = Prelude.map (\x -> fromJust.M.lookup x $ ixs) list
    where ixs = countAppearance list

countAppearance :: Ord a => [a] -> Map a Int
countAppearance [] = M.empty
countAppearance (x:xs) =
    let s = countAppearance xs in
        M.insertWithKey (\k x y -> x+y) x 1 s

Measured memory_bytes: 3984
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

n=input().rstrip()
if n[0]=="9" or n[1]=="9":
    print("Yes")
else:
    print("No")


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  string s,t; cin >> s >> t;
  int ans = 0;

  rep(i,s.size()){
    if(s[i] != t[i]) ans++;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string S;
    cin >> S;

    int len = (int)S.size();
    int d1 = S[0] - '0';
    int ans = d1;
    if (len != 1) {
        ans = 9 * (len - 1) + d1;
        bool flag = true;
        rep(i, len - 1) {
            if (S[len - i - 1] != '9') flag = false;
        }
        if (!flag) ans--;
    }

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using LL = long long;

const int maxN = 5e5 + 5;
const int mod = 998244353;

int n, m, ans;
int fac[maxN], inv[maxN];

inline void Mod(int& x)
{ x >= mod ? x -= mod : x < 0 ? x += mod : 0; }

int QPow(int bas, int ind)
{
    int res = 1;
    while (ind)
    {
        if (ind & 1)
            res = (LL)res * bas % mod;
        bas = (LL)bas * bas % mod;
        ind >>= 1;
    }
    return res;
}

void Init(int lim)
{
    fac[0] = inv[0] = 1;
    for (int i = 1; i <= lim; ++i)
        fac[i] = (LL)fac[i - 1] * i % mod;
    inv[lim] = QPow(fac[lim], mod - 2);
    for (int i = lim - 1; i; --i)
        inv[i] = (LL)inv[i + 1] * (i + 1) % mod;
}

inline int C(int n, int m)
{ return (LL)fac[n] * inv[m] % mod * inv[n - m] % mod; }

int main()
{
    cin >> n >> m;
    if (n > m)
        swap(n, m);
    Init(m);
    for (int i = 0; i <= n; ++i)
        if (i & 1)
            Mod(ans -= (LL)C(n, i) * C(m, i) % mod * fac[i] % mod * QPow(m + 1, n - i) % mod * QPow(n + 1, m - i) % mod);
        else
            Mod(ans += (LL)C(n, i) * C(m, i) % mod * fac[i] % mod * QPow(m + 1, n - i) % mod * QPow(n + 1, m - i) % mod);
    cout << ans << endl;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll A[200010];
    cin >> N;
    rep(i,0,N){
        cin >> A[i];
    }
    sort(A, A+N, greater<ll>());
    ll ans = 0;
    map<ll,ll> mp;
    rep(i,0,N){
        mp[A[i]]++;
    }
    rep(i,0,N){
        if(mp[A[i]] == 0) continue;
        ll nn = 1;
        while(nn <= A[i]){
            nn *= 2;
        }
        ll val = nn - A[i];
        mp[A[i]]--;
        if(mp[val] != 0){
            // print(A[i]);
            // print(val);
            mp[val]--;
            ans++;
        }
    }
    print(ans);



}


Measured memory_bytes: 26880
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

char A[10][10];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int H,W;
    cin>>H>>W;
    
    rep(i,H)rep(j,W) cin>>A[i][j];
    
    bool f=true;
    rep(i,H-1)rep(j,W-1){
        if(A[i+1][j]=='#'&&A[i][j+1]=='#'){
            f=false;
        }
    }
    
    cout1((f?"Possible":"Impossible"))
}

Measured memory_bytes: 256
import sys

A = list(map(int, sys.stdin.read().rstrip().split("\n")))
n = A[0]
del A[0]

#shellSort
cnt = 0

G = [i for i in [262913, 65921, 16577, 4193, 1073, 281, 77, 23, 8, 1] if i <= n]

m = len(G)

for i in range(m):
    g = G[i]
    # insertionSort
    for j in range(g, n):
        v = A[j]
        k = j - g
        while (k >= 0) and (A[k] > v):
            A[k + g] = A[k]
            k -= g
            cnt += 1
        A[k + g] = v

print(m)
print(*G)
print(cnt)
print("\n".join(map(str, A)))

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

#define int long long int

const int mod = 1e9+7;

#undef int
int main()
{
#define int long long int
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	string ans = "APPROVED";
	int n;
	cin>>n;
	while(n--)
	{
		int x;
		cin>>x;
		if(!(x & 1) && x % 3 && x % 5)
			ans = "DENIED";
	}
	cout<<ans;

	return 0;
}

Measured memory_bytes: 384
#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(){
    string s;
    cin >> s;
    vector <string> day;
    day.push_back("SUN");
    day.push_back("MON");
    day.push_back("TUE");
    day.push_back("WED");
    day.push_back("THU");
    day.push_back("FRI");
    day.push_back("SAT");

    int ans;
    rep(i,7){
        if (s==day[i]){
            ans=7-i;
        }
    }
    cout << ans << endl;
    

    return 0;
}

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



int main(void) {
    ll A;
    string B;
    cin >> A >> B;

    ll i,d,dd;

    i = B[0] - '0';
    d = B[2] - '0';
    dd = B[3] - '0';

    ll ans;
    ans = (A*(i*100+d*10+dd))/100;
/*
    if(A==0 || (i==0 && d==0 && dd==0))
      cout << 0 << endl;
    else{
  */

      cout <<ans << endl;
    

    return 0;
}


Measured memory_bytes: 3632
from sys import stdin
from collections import Counter

def main():

    input = stdin.readline

    N = int(input())

    A = [0] * N

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

    all_case = 0

    num_all = Counter(A) 

    for k in num_all.values():
        all_case += (k * (k-1)) // 2

    for i in A:
        ans = all_case - (num_all[i] - 1)
        print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 27456
#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL S;
int main(){
	scanf("%lld", &S);
	LL t = ceil(sqrt(S));
	LL x = 0, y = 0, d = t * t - S;
	for(LL i = 1; i * i <= d; ++ i)
		if(d % i == 0)
			x = i, y = d / i;
	printf("0 0 %lld %lld %lld %lld", x, t, t, y);
	return 0;
}

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

long long N;
string S;
long long rnum[500000];
long long lnum[500000];

int main(){
	cin >> N >> S;
	for(long long i = 1; i < S.length(); i++){
		if(S[i-1] == 'E'){
			rnum[i] = rnum[i-1] + 1;
		}else{
			rnum[i] = rnum[i-1];
		}
	}
	for(long long i = S.size() - 2; i >= 0; i--){
		if(S[i+1] == 'W'){
			lnum[i] = lnum[i+1] + 1;
		}else{
			lnum[i] = lnum[i+1];
		}
	}


	long long ans = INT_MAX;
	for(long long i = 0; i < S.length(); i++){
		ans = min(ans, (long long)S.size() - rnum[i] - lnum[i] - 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 6916
import java.lang.Math.*

fun main(args: Array<String>) {
    val (n,k) = readLine()!!.split(" ").map{it.toInt()}
    val x = readLine()!!.split(" ").map{ it.toLong() }
	
	var ans=Long.MAX_VALUE
	for(r in k-1..n-1){
		val l=r-k+1
		val lr=x[r]-x[l]
		ans=min(ans,lr+abs(x[l]))
		ans=min(ans,lr+abs(x[r]))
	}
	println(ans)
}

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

int main(){

  int n;
  while(cin>>n){

    if(n==0){
      break;
    }
  string f[n];
  for(int i=0;i<n;i++){
    cin>>f[i];
  }

  int t=0;

  for(int i=1;i<n;i++){

    if(f[i]=="lu"&&f[i-1]=="ru"){
	t++;
    }else if(f[i]=="ru"&&f[i-1]=="lu"){
      t++;
    }else if(f[i]=="ld"&&f[i-1]=="rd"){
      t++;
    }else if(f[i]=="rd"&&f[i-1]=="ld"){
      t++;
    }

  }
  

  cout<<t<<endl;

  }

  return 0;



}

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


int min_tri(int x, int y, int z);
int my_abs(int x);

int main(){
    int N, X, Y;
    int pair_, ans_tmp1, ans_tmp2, ans_tmp3;
    std::cin >> N >> X >> Y;
    vector<int>  ans(N-1,0);

    for(int k = 1; k <= N-1; k++){
        for(int j = k + 1; j <= N; j++){
            ans_tmp1 = j - k;
            ans_tmp2 = my_abs(X-k) + 1 + my_abs(Y - j);
            ans_tmp3 = my_abs(Y-k) + 1 + my_abs(X - j);

            pair_ = min_tri(ans_tmp1, ans_tmp2, ans_tmp3);
            //std::cout << pair_ << "\n";
            ans[pair_ - 1]++;
        }

    }

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


}

int min_tri(int x, int y, int z){
    int ans;
    if(x < y){
        if(x < z){
            ans = x;
        }else{
            ans = z;           
        }
    }else{
        if(y < z){
            ans = y;
        }else{
            ans = z;
        }
    }
    return ans;
}

int my_abs(int x){
    if(x < 0){
        return -x;        
    }else{
        return x;
    }
    
}

Measured memory_bytes: 3636
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int64_t A[100000];

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> N;
    for (size_t i = 0; i < N; i++)
    {
        in >> A[i];
    }

    std::sort(A, A + N);

    int32_t count = 0;

    for (size_t i = 0; i < N; i++)
        for (size_t j = i+1; j < N; j++)
            if (A[i] != A[j])for (size_t k = j+1; k < N; k++)
    {
        if(A[i]!=A[k] && A[j]!=A[k])
        if (A[i] + A[j] > A[k]) {
            ++count;
        }
    }
    out << count << endl;

    return 0;
}
#endif


Measured memory_bytes: 3192
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <tuple>
#include <sstream>
#include <iomanip>
#include <map>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

bool less_by_second(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool greater_by_second(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first > b.first;
    }
}

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    map<int, int> mp2j, mp2jp1;
    for (int i = 1; i <= n; ++i)
    {
        int a;
        cin >> a;
        if (i % 2) mp2jp1[a] += 1;
        else mp2j[a] += 1;
    }
    
    
    vector<pair<int, int>> a_odd;
    a_odd.reserve((mp2jp1.size()));
    for (auto a : mp2jp1)
    {
        a_odd.emplace_back(a);
    }
    vector<pair<int, int>> a_even;
    a_even.reserve((mp2j.size()));
    for (auto a : mp2j)
    {
        a_even.emplace_back(a);
    }
    
    sort(a_odd.begin(), a_odd.end(), greater_by_second);
    sort(a_even.begin(), a_even.end(), greater_by_second);
    
    int max_2jp1 = a_odd[0].first;
    int num_other_2jp1 = n/2 - a_odd[0].second;
    int max_2j = a_even[0].first;
    int num_other_2j = n/2 - a_even[0].second;
    
    if (max_2jp1 == max_2j) //要素数最大の要素が同じ
    {
        cout << min(n-a_odd[0].second-a_even[1].second, n-a_odd[1].second-a_even[0].second) << endl;
    }
    else
    {
        cout << num_other_2j + num_other_2jp1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 5760
h, n = (int(x) for x in input().split())
dp = [[0 for i in range(n+1)] for j in range(h+1)]
for i in range(h):
    t=input()
    t=list(t)
    for j in range(n):
        if t[j] == '#':
            dp[i][j] = '#'

for i in range(h):
    for j in range(n):
        if dp[i][j] == '#':
            if dp[i-1][j-1] != '#':
                dp[i-1][j-1]+=1
            if dp[i][j-1] != '#':
                dp[i][j-1]+=1
            if dp[i+1][j-1] != '#':
                dp[i+1][j-1]+=1
            if dp[i-1][j] != '#':
                dp[i-1][j]+=1
            if dp[i-1][j+1] != '#':
                dp[i-1][j+1]+=1
            if dp[i+1][j] != '#':
                dp[i+1][j]+=1
            if dp[i][j+1] != '#':
                dp[i][j+1]+=1
            if dp[i+1][j+1] != '#':
                dp[i+1][j+1]+=1

for i in range(h):
    print(''.join(map(str,dp[i][:n])))

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && a == c){
        cout << 1;
    }else if(a == b || a == c || b == c){
        cout << 2;
    }else{
        cout << 3;
    }
}

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

int main() {
  double n;
  cin>>n;
  vector<double> p(n);
  rep(i,n) cin>>p[i];
  double sum=0;
  rep(i,n){
    sum+=1/p[i];
  }
  cout<<fixed<<setprecision(6);
  cout<<1/sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int N;

string S[20];

void solve(){
    for(int i=0;i<N;i++) cin>>S[i];
    if(N==1){
        cout<<S[0].front()<<endl;
        return;
    }

    vector<int> v[21];
    char opt[21];
    char val[21];
    int lev[21]={};
    for(int i=0;i<N;i++){
        for(int j=0;j<S[i].size();j++){
            if(S[i][j]=='.') lev[i]++;
            else val[i]=S[i][j];
        }
    }

    int now=0;
    for(int i=0;i<N;i++){
        if(now==lev[i]){
            if(val[i]=='+'||val[i]=='*'){
                now++;
                opt[now]=val[i];
            }else v[now].push_back(val[i]-'0');
        }else{
            int num;
            if(opt[now]=='+') num=0;
            else num=1;
            for(int j=0;j<v[now].size();j++){
                if(opt[now]=='+') num+=v[now][j];
                else num*=v[now][j];
            }
            v[now].clear();
            v[now-1].push_back(num);
            now--;
            i--;
        }
    }

    while(now>0){
        int num;
        if(opt[now]=='+') num=0;
        else num=1;
        for(int j=0;j<v[now].size();j++){
            if(opt[now]=='+') num+=v[now][j];
            else num*=v[now][j];
        }
        v[now].clear();
        v[now-1].push_back(num);
        now--;
    }
    cout<<v[0][0]<<endl;
}

int main(){
  while(1){
      cin>>N;
      if(N==0) break;
      solve();
  }

  return 0;
}



Measured memory_bytes: 3188
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

typedef pair<int, int> P;

vector<P> v, sv;
map<int, int> mp;

int main(){
    int n, m;
    cin >> n >> m;
    v.assign((size_t)m, P(0, 0));
    sv.assign((size_t)m, P(0, 0));
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        sv[i] = v[i] = P(x, y);
    }
    sort(sv.begin(), sv.end());

    int x;
    for (int i = 0; i < m; ++i) {
        if (i == 0 || sv[i].first != sv[i - 1].first) x = 1;
        else x++;
        mp[sv[i].second] = x;
    }

    for (int i = 0; i < m; ++i) {
        printf("%06d%06d\n", v[i].first, mp[v[i].second]);
    }

}

Measured memory_bytes: 7808
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int A,B,C,D;

int main(){
    cin>>A>>B>>C>>D;
    out(min(A,B)+min(C,D));
}


Measured memory_bytes: 256
def judge(m = -1, f = -1, r = -1):
    result = ""
    if m == -1 or f == -1:
        result = 'F'
    elif m + f >= 80:
        result = 'A'
    elif m + f >= 65:
        result = 'B'
    elif m + f >= 50:
        result = 'C'
    elif m + f >= 30:
        if r >= 50:
            result = 'C'
        else:
            result = 'D'
    else:
        result ='F'
    return result

while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    print(judge(m, f, r))


Measured memory_bytes: 5600
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

  vector<int> a(N);
  rep(i, N) { cin >> a[i]; }

  rep(i, K) {
    vector<int> tmp(N + 1, 0);
    rep(i, N) {
      tmp[max(0L, i - a[i])]++;
      tmp[min((int64_t)N, i + a[i] + 1)]--;
    }
    rep(i, N) { tmp[i + 1] += tmp[i]; }
    bool c = true;
    rep(i, N) { c = c && (a[i] == tmp[i]); }
    copy(tmp.begin(), tmp.end() - 1, a.begin());
    if (c) {
      break;
    }
  }
  rep(i, N) { cout << a[i] << " "; }
  cout << endl;
  return 0;
}

Measured memory_bytes: 4820
#include <iostream>
using namespace std;
int px,py; 
int w,h,f[100][100];
 
bool cheak(){
  if(f[px][py] == 0){
    cout << "LOOP" << endl;
    return true;
  }
  return false;
}
 
int main(){
 
  char ma[100][100];
  while(  cin >> h >> w,w + h ){
    for(int i = 0 ; i < h ; i++){
      for(int j = 0 ; j < w ; j++){
    cin >> ma[j][i];
    f[j][i] = 1;
      }
    }
 
    px = 0,py = 0; 
    while(1){
      if(ma[px][py] == '>' ){
    px++;
    if(cheak())break;
      } else if(ma[px][py] == 'v' ){
    py++;
    if(cheak())break;
      }else if(ma[px][py] == '<' ){
    px--;
    if(cheak())break;
      }else if(ma[px][py] == '^' ){
    py--;
    if(cheak())break;
      } else {
    cout << px << " " << py << endl;
    break;
      }
      f[px][py] = 0;
    }
  }
}

Measured memory_bytes: 1208
mod = 10**9+7
N, K = map(int, input().split())
if K % 2:
    print(0)
else:
    dp = [[[0]*(2*N**2+2*N) for _ in range(N+1)] for _ in range(N+1)]
    dp[0][0][0] = 1
    for i in range(N):
        for k in range(i+2):
            for S in range(-N**2+1, N**2):
                d = dp[i][k][S]
                if not d:
                    continue
                dp[i+1][k][S] = (dp[i+1][k][S]+(2*k+1)*d)%mod
                dp[i+1][k+1][S-2*(i+1)] = (dp[i+1][k+1][S-2*(i+1)]+d)%mod
                dp[i+1][k-1][S+2*(i+1)] = (dp[i+1][k-1][S+2*(i+1)]+k*k*d)%mod
    print(dp[N][0][K])


Measured memory_bytes: 143580
S = input()
T = input()
S2 = S.replace('?','a')
ans = []

for i in range(len(S)-len(T)+1):
    S_sub = S[i:i+len(T)]
    
    check = True
    
    for s,t in zip(S_sub,T):
        if s != t and s == '?':
            continue
        elif s == t:
            continue
        elif s != t and s != '?':
            check = False
            break
        
    if check == True:
        tmp = S2[:i] + T + S2[i+len(T):]
        ans.append(tmp)
        
if len(ans) != 0:
    answer = sorted(ans)[0]
else:
    answer = 'UNRESTORABLE'
    
print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int n;
    long sum = 0;
    cin >> n;
    map<int,int> d;
    rep(i,n){
        int a;
        cin >> a;
        d[a]++;
        sum += a;
    } 
    int q;
    cin >> q;
    rep(i,q){
        int b,c;
        cin >> b >> c;
        sum += (c-b)*d[b];
        d[c] += d[b];
        d[b] = 0;
        cout << sum << endl;
    }
}

Measured memory_bytes: 7976
A = int(input())
B = int(input())
C = int(input())
X = int(input())

total = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            Ans = 500*i + 100*j + 50*k
            if Ans == X:
                total +=1
print(total)


Measured memory_bytes: 9164
# 整数の入力
a = input()
a = int(a)

b = input()
b = int(b)

c = input()
c = int(c)

x = input()
x = int(x)

ans = 0

for i in range(0,a+1):
    for j in range(0,b+1):
        for k in range(0,c+1):
            if x == i*500 + j*100 + k*50:
                ans = ans + 1

print(ans)


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)

// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif


template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

#endif



void solve(){
    int A, B;
    cin >> A >> B;
    
    for(int i=1; i<=2000; i++){
        if((int)(i*0.08) == A && (int)(i*0.1)==B){ cout << i << endl; return;}
    }
    cout << -1 << endl;
}

signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


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

int main(){
  int n;
  cin >> n;
  int p[n];
  int count=0;
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  for(int i=0;i<n-2;i++){
    if(p[i]<p[i+1] && p[i+1]<p[i+2]){
        count++;
    }
    if(p[i]>p[i+1] && p[i+1]>p[i+2]){
        count++;
    }
  }
  cout << count << endl;
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n,m;cin>>n>>m;
  vector<int> p(m, 0);
  vector<int> y(m, 0);
  vector<vector<int>> yd(100001);
  for (int i=0; i<m; i++) {
    cin >> p[i] >> y[i];
    yd[p[i]].push_back(y[i]);
  }
  for (int i=0; i<=n; i++) {
    sort(yd[i+1].begin(),yd[i+1].end());
  }
  for (int i=0; i<m; i++) {
    int pos = int(lower_bound(yd[p[i]].begin(),yd[p[i]].end(),y[i])-yd[p[i]].begin())+1;
    printf("%06d%06d\n", p[i], pos);
  }
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 7808
#pragma GCC optimize (2)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

inline int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}

int main()
{
	char s[100000];
	scanf("%s",s+1); int n=strlen(s+1); 
	char ch[10]={' ','k','e','y','e','n','c','e'};
	for (int i=1; i<=n; i++)
		for (int j=i-1; j<=n; j++)
		{
			bool flag=0;
			if (n-j+i-1!=7) continue;
			for (int k=1; k<i; k++) if (s[k]!=ch[k]) {flag=1; break;}
			for (int k=j+1; k<=n; k++) if (s[k]!=ch[k-j-1+i]) {flag=1; break;}
			if (!flag) {puts("YES"); return 0;}
		}
	puts("NO");
	return 0;
}


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

count = 0

for i in range(n-1):
    if a[i] > x:
        count += a[i] - x
        a[i] = x
        
        count += a[i+1]
        a[i+1] = 0
        
    elif a[i]+a[i+1] > x:
        count = count + a[i+1] + a[i] - x
        a[i+1] = x - a[i] 
    
print(count)

Measured memory_bytes: 14132
#include <cstdio>

typedef long long ll;
#define min(a, b) (((a) < (b)) ? (a) : (b))

int main()
{
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    printf("%d %d\n", min(a, b), (((a + b - n) > 0) ? (a + b - n) : (0)));
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
const int maxn = 10010;
int main()
{
    int n;
    scanf("%d", &n);
    int p[maxn];
    for(int i = 0; i < n; i++){
        scanf("%d", &p[i]);
    }
    long long sum = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            sum += p[i] * p[j];
        }
    }
    printf("%lld", sum);
    return 0;
}


Measured memory_bytes: 128
#include "iostream"
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
    int N;
    string S, T;
    cin >> N;
    cin >> S >> T;

    for (int i = 0; i < N; i++){
        cout << S.at(i) << T.at(i);
    }
    cout << endl;
    return 0;
}

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

using namespace std;

typedef long long int ll;

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

  int n, sum = 0;
  cin >> n;
  vector < int > a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
  }
  sort(a.begin(), a.end());

  if(a[0] >= 0){
    cout << sum - 2 * a[0] << '\n';
    for(int i = 1; i < n - 1; i++){
      cout << a[0] << " " << a[i] << '\n';
      a[0] -= a[i];
    }
    cout << a[n - 1] << " " << a[0] << '\n';
  }else if(a[n - 1] < 0){
    cout << 2 * a[n - 1] - sum << '\n';
    for(int i = 0; i < n - 1; i++){
      cout << a[n - 1] << " " << a[i] << '\n';
      a[n - 1] -= a[i];
    }
  }else{
    int j = 0;
    for(int i = 0; i < n; i++){
      if(a[i] >= 0){
        j = i;
        break;
      }
    }
    int ans = 0;
    for(int i = 0; i < n; i++) ans += abs(a[i]);
    cout << ans << '\n';
    for(int i = j; i < n - 1; i++){
      cout << a[0] << " " << a[i] << '\n';
      a[0] -= a[i];
    }
    for(int i = 0; i < j; i++){
      cout << a[n - 1] << " " << a[i] << '\n';
      a[n - 1] -= a[i];
    }
  }
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

const int inf = 1e9;

int main() {
	int N;
	cin>>N;
	vector<int> a(N);
	rep(i,N) cin>>a[i];
	int ans=inf;
	for (int A = -100; A <= 100; ++A){
		int cost=0;
		rep(i,N){
			cost+=(a[i]-A)*(a[i]-A);
		}
		ans=min(ans,cost);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

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

	long MODULO = 1_000_000_000 + 7;

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] e = new int[n][3];
		for (int i = 0; i < n; ++i) {
			e[i][0] = sc.nextInt();// x
			e[i][1] = sc.nextInt();// v
			e[i][2] = -1;
		}
		Arrays.sort(e, new Comparator<int[]>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				return Integer.compare(o1[1], o2[1]);
			}
		});
		for (int i = 0; i < n; ++i) {
			e[i][2] = i;
		}

		Arrays.sort(e, new Comparator<int[]>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				return Integer.compare(o1[0], o2[0]);
			}
		});

		int[][] min = new int[n][2];
		int[][] max = new int[n][2];
		for (int i = 0; i < n; ++i) {
			min[i][0] = Integer.MAX_VALUE;
			max[i][0] = -Integer.MAX_VALUE;
			min[i][1] = -1;
			max[i][1] = -1;
		}
		for (int i = 0; i < n; ++i) {
			if (i == 0 || max[i - 1][0] < e[i][1]) {
				max[i][0] = e[i][1];
				max[i][1] = e[i][2];
			} else {
				max[i][0] = max[i - 1][0];
				max[i][1] = max[i - 1][1];
			}
		}
		for (int i = n - 1; i >= 0; --i) {
			if (i == n - 1 || min[i + 1][0] > e[i][1]) {
				min[i][0] = e[i][1];
				min[i][1] = e[i][2];
			} else {
				min[i][0] = min[i + 1][0];
				min[i][1] = min[i + 1][1];
			}
		}
		long[] f = new long[n];
		long s = 0;
		int t = 0;
		for (int i = 0; i < n; ++i) {
			while (min[i][1] - max[t][1] > 1) {
				s = (s - f[t] + MODULO) % MODULO;
				++t;
			}
			f[i] = s;
			if (min[i][1] == min[0][1]) {
				++f[i];
			}
			s += f[i];
			while (s >= MODULO) {
				s -= MODULO;
			}
			while (f[i] >= MODULO) {
				f[i] -= MODULO;
			}
		}
		long ans = 0;
		for (int i = 0; i < n; ++i) {
			if (max[n - 1][1] == max[i][1]) {
				ans += f[i];
			}
			while (ans >= MODULO) {
				ans -= MODULO;
			}
		}
		System.out.println(ans);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

Measured memory_bytes: 130984
a=sorted(list(map(int,input().split())))
cnt=0
while a[2]-a[0]>=2:
  a[0]+=2
  cnt+=1
while a[2]-a[1]>=2:
  a[1]+=2
  cnt+=1
a=sorted(a)
if a[0]<a[1]:
  cnt+=2
elif a[1]<a[2]:
  cnt+=1
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#if 0
#define DEBUG(x) do{cerr << #x << "=" << x << endl;}while(0);
#else
#define DEBUG
#endif


int main(){
	int n,d;
	cin >> n >> d;

	vector<vector<int>> X(n);
	for(int i=0; i<n;++i){
		X[i] = vector<int>(d);
		for(int j=0;j<d;++j){
			cin >> X[i][j];
		}
	}

	int count = 0;
	for(int i=0; i<n;++i){
		for(int j=i+1; j<n;++j){
			int sum = 0;
			for(int k=0;k<d;++k){
				int dist_k = X[i][k] - X[j][k];
				sum += dist_k * dist_k;
			}
			double dist = sqrt(sum);
			double diff = floor(dist) - dist;
			if( diff <= 1e-7 && -1e-7 <= diff ){
				DEBUG(i);
				DEBUG(j);
				count++;
			}
		}
	}

	cout << count << endl;

	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    const int INF = 100000000;
    queue<ll> que;
    ll cnt = 0;
    ll k;
    cin >> k;
    int i = 1;
    rep(i, 9){
        que.push(i+1);
    }
    while (que.size()){
        ll x = que.front();
        que.pop();
        cnt++;
        int t = x%10;
        if(t-1 >= 0) que.push(10*x +t-1);
        que.push(10*x + t);
        if (t+1 <= 9) que.push(10*x + t+1);
        if (cnt+que.size() >= k){
            int i = 0;
            while (cnt != k){
                x = que.front();
                que.pop();
                cnt++;
            }
            cout << x << endl;
            return 0;
        }

    }
}

Measured memory_bytes: 768
#include "bits/stdc++.h"

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	vector<int> v;
	vcin(v,3);
	ssort(v);
	if(v[0] + v[1] == v[2]){
		P("Yes");
	}else{
		P("No");
	}
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
from functools import reduce

n = int(input())
a = list(map(int,input().split()))
b = [0]*n
a_xor=reduce(lambda x,y : x^y,a)
for i in range(n):
  b[i]=a[i]^a_xor  
##  b[i] = reduce(lambda x,y : x^y,a[0:i+1]+a[i:])

print(" ".join(list(map(str,b))))

Measured memory_bytes: 42112
using System;
class Program{
  static void Main(string[] args){
    string[] tmp=Console.ReadLine().Split(' ');
    int a = int.Parse(tmp[0]);
    int b = int.Parse(tmp[1]);
    int p = b%a==0 ? a+b : b-a;
    Console.WriteLine(p);
  }
}

Measured memory_bytes: 11092
#include<fstream>
#include<string>
#include<iostream>
#include<sstream>
#include<iterator>
#include<cmath>

using namespace std;


int main(){
 int N;
 cin >> N;
 int a[N+1] = {0};
 int b[N] = {0};
 int i;
 long long int sum = 0;
 for(i=0;i<N+1;++i){
     cin >> a[i];
   }
  for(i=0;i<N;++i){
     cin >> b[i];
   }
  for(i=N-1;i>-1;--i){
    if(a[i+1]>=b[i]){
      sum += b[i];}
    else{
      sum += a[i+1];
      if(a[i]<=b[i]-a[i+1]){
        sum += a[i];
        a[i] = 0;}
      else{
        sum += (b[i] - a[i+1]);
        a[i] -= (b[i] - a[i+1]);}
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1024