akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int n; cin>>n;
    vector<vector<int>> G(n);
    vector<pair<int,int>> vp;
    for(int i=1;i<n;i++){ //辺はn-1個ある
        int a,b;
        cin>>a>>b;
        a--; b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        vp.emplace_back(a,b);
    }

    //グラフ作成終わり

    int k=0;
    map<pair<int,int>,int> I;
    vector<int> cs(n,0);

    vector<int> used(n,0);
    queue<int> que;
    used[0]=1;
    que.emplace(0);
    while(!que.empty()){
        int v=que.front(); que.pop();
        if(k<(int)G[v].size()) k=G[v].size();
        int color=1;
        for(int u:G[v]){
            if(used[u])continue;
            if(color==cs[v]) color++;
            cs[u]=color;
            I[make_pair(u,v)]=color;
            I[make_pair(v,u)]=color;
            color++;
            used[u]=1;
            que.emplace(u);
        }
    }

    cout<<k<<endl;
    for(auto p:vp) cout<<I[p]<<endl;
    return 0;
}

Measured memory_bytes: 20084
S = input()
K = int(input())

X = 0
for s in S:
    if s == "1":
        X += 1
    else:
        break

if K == 1:
    print(S[0])

elif K <= X:
    print(1)

else:
    for s in S:
        if s != "1":
            print(s)
            break
    else:
        print(1)


Measured memory_bytes: 2940
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる 
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

bool check(int a, int b) {
	return a > b;

}

int main() {
	llint n, m;
	cin >> n >> m;
	vpllint a(m);
	rep(i, m){
		cin >> a[i].first >> a[i].second;
		a[i].first--;
		a[i].second--;
	}
	vllint ans(m);
	ans[m - 1] = n*(n - 1) / 2;
	UnionFind Uni(n);
	for (int i = m - 2; 0 <= i; i--){//足し算と引き算を間違えました
		if (Uni.root(a[i + 1].first) != Uni.root(a[i + 1].second)){
			ans[i] = (llint)ans[i + 1] - Uni.size(a[i + 1].first)*Uni.size(a[i + 1].second);
			Uni.connect(a[i + 1].first, a[i + 1].second);
		}
		else{
			ans[i] = ans[i + 1];
			//ここの部分が抜けてました、ごめんなさい、勉強不足でした
		}
	}
	rep(i, m){
		cout << ans[i] << endl;
	}
	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s,t; cin>>s>>t;
	string ans,judge;
	for(int i=0;i<s.size();++i){
		ans+='z';
	}
	judge=ans;
	for(int i=0;i+t.size()<=s.size();++i){
		bool yes=true;
		for(int j=0,k=i;j<t.size();++j,++k){
			if(t.at(j)!=s.at(k)&&s.at(k)!='?'){
				yes=false;
			}
		}
		if(yes){
			string key=s.substr(0,i)+t;
			if(key.size()<s.size())key+=s.substr(key.size());
			replace(key.begin(),key.end(),'?','a');
			ans=min(ans,key);
		}
	}
	cout<<(ans!=judge?ans:"UNRESTORABLE"s)<<"\n"s;
}

Measured memory_bytes: 256
L = int(input()) - 1

N = []
n = 0

for i in range(20):
  if 2 ** i - 1 > L:
    break
  n = i

c = 2 ** n - 1
d = 2 ** (n - 1)
m = 2 * n
n += 1

for i in range(n-1, 0, -1):
  A = [(i, i+1, 0), (i, i+1, d)]
  if L - (d - 1) > c:
    L -= d
    m += 1
    A.append((i, n, L+1))
  N.append(A)
  d //= 2
  
print(n, m)
for a in N:
  for b in a:
    print(*b)

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

public class Main {

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				int[] a = new int[21];
				a[0] = sc.nextInt();
				int L = sc.nextInt();
				if(a[0] + L == 0) break;
				for(int i=1; i<=20; i++) {
					String s = a[i-1] + "";
					while(s.length() < L) {
						s += "0";
					}
					char[] c = s.toCharArray();
					Arrays.sort(c);
					int min = 0;
					int max = 0;
					for(int j=0; j<L; j++) {
						min = min * 10 + (c[j] - '0');
					}
					for(int j=L-1; j>=0; j--) {
						max = max * 10 + (c[j] - '0');
					}
					a[i] = max - min;
					boolean f = false;
					for(int j=i-1; j>=0; j--) {
						if(a[i] == a[j]) {
							f = true;
							System.out.println(j + " " + a[i] + " " + (i-j));
							break;
						}
					}
					if(f) break;
				}
			}
		}
	}
}


Measured memory_bytes: 27072
r,c = map(int, input().split())
M = [list(map(int, input().split())) for i in range(r)]

ans = [[0 for i in range(c+1)] for j in range(r+1)]
for i in range(r):
    for j in range(c):
        ans[i][j] = M[i][j]
        
for j in range(c):
    ans[r][j] = sum([ans[i][j] for i in range(r)])
    
for i in range(r+1):
    ans[i][c] = sum([ans[i][j] for j in range(c)])
    
for i in range(r+1):
    print(*ans[i])


Measured memory_bytes: 6268
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        String[] num = new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
        List<String> list = new ArrayList<>(Arrays.asList(num));
        for (int i = 0; i < 100000; i++) {
            String s = list.get(i);
            long last = Integer.parseInt(String.valueOf(s.charAt(s.length() - 1)));
            if (last != 0) {
                list.add(s + (last - 1));
            }
            list.add(s + last);
            if (last != 9) {
                list.add(s + (last + 1));
            }
        }
        String result = list.get(n - 1);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 56148
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    vector<int> a(3);
    rep(i, 3) cin >> a[i];
    sort(a.begin(), a.end());

    int max_num = a[2];
    int sum = a[0] + a[1] + a[2];

    int ans;

    rep(ri, 2) {
        if ( ri == 1 ) ++max_num;
        if ( ((max_num*3)&1) == (sum&1) ) {
            ans = ( max_num * 3 - sum ) / 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
input_a = input()
if input_a[0] != 'A':
    print("WA")
elif input_a.count('C')==0:
    print("WA")
elif input_a.count('C')>1:
    print("WA")
elif input_a.index('C') <=1:
    print("WA")
elif input_a.index('C') ==len(input_a)-1:
    print('WA')
elif input_a.count('C') ==1:
    if input_a.replace('A','a').replace('C','c').islower():
        print('AC')
    else:
        print('WA')


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc123_b
{
  class Program
  {
    static void Main(string[] args)
    {
      var a = CIn.ReadIntArray(5).OrderBy(e => e % 10 == 0 ? 0 : 10 - e % 10).ToArray();
      var ans = 0;

      for (var i = 0; i < 5; i++)
      {
        ans += i != 4 ? (int)Math.Ceiling((double)a[i] / 10) * 10 : a[i];
      }

      Console.WriteLine(ans);
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

Measured memory_bytes: 13396
n, m = map(int, input().split())

l_n = [i for i in range(1, n+1)]
l_m = [i for i in range(1, m+1)]


print(len([k * j for i, k in enumerate(l_n) for j in l_n[i + 1:]]) 
    + len([k * j for i, k in enumerate(l_m) for j in l_m[i + 1:]]))

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    for (int i=0;i<n;++i){
        int a;
        int b;
        int c;
        cin >> a >> b >> c;
        if (a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a){
            cout << "YES" << endl;
            }
        else {
            cout << "NO" << endl;
            }
    }
    return 0;
}


Measured memory_bytes: 3072
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var ab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var a = ab[0];
        var b = ab[1];
        Console.WriteLine(b % a == 0 ? a + b : b - a);
    }
}


Measured memory_bytes: 13268
N = int(input())
K = int(input())
X = list(map(int, input().split()))
result = 0
def A(x):
    disA = 0
    disA = 2 * x
    return disA
def B(k, x):
    disB = 0
    disB = 2 * (k -x)
    return disB

for i in X:
    if A(i) <= B(K, i):
        result += A(i)
    else:
        result += B(K, i)
print(result)

Measured memory_bytes: 3064
A,B = gets.split.map &:to_i

p case
when A == B; 0
when B >= A && A >= 0; B - A
when A <= B && B <= 0; B - A
when A == 0; B.abs + (B < 0 ? 1 : 0)
when B == 0; A.abs + (0 < A ? 1 : 0)
when A*B < 0; (B.abs - A.abs).abs + 1
when B <= A && A < 0; (B-A).abs + 2
when A >= B && B > 0; (B-A).abs + 2
end


Measured memory_bytes: 1788
#include <stdio.h>
 
int main(){
    int countTable[256] = {0};
    char ch;
 
    while((ch = getchar()) != EOF){
                countTable[ch]++;
    }
    for(int i = 97; i <=122;i++)printf("%c : %d\n",i,countTable[i]+countTable[i-32]);
}



Measured memory_bytes: 2720
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
const int MOD = 1000000007;
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string s;
  int player[15];
  int b;

  cin >> n;
  while(n != 0){
    cin >> s;
    b = 0;
    memset(player, 0, sizeof(player));
    for(int i = 0;i < s.size();i++){
      if(s[i] == 'M'){
	player[i % n] ++;
      }else if(s[i] == 'S'){
	b += (player[i % n] + 1);
	player[i % n] = 0;
      }else{
	player[i % n] += (b + 1);
	b = 0;
      }
    }

    sort(player, player + n);
    for(int i = 0;i < n;i++){
      cout << player[i] << ' ';
    }
    cout << b << endl;
    cin >> n;
  }
  return 0;
}




Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cout << #a << " = " << a << endl

const ll inf = 1e15;
const ll mod = 1e9+7;

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

int N;
int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101};
ull s;
map<ull, ll> num;

ull convert(string input) {
    ull ret = 1;
    for (char &c: input) {
        ret *= prime[c-'a'];
    }
    //cout << ret << endl;
    return ret;
}

int main() {
    cin >> N;
    string input;
    for (int i = 0; i < N; i++) {
        cin >> input;
        s = convert(input);
        num[s]++;
    }

    ll result = 0;
    for (auto n: num) {
        //cout << n.first << "=" << n.second << endl;
        result += n.second * (n.second - 1) / 2;
    }
    cout << result << endl;
}


Measured memory_bytes: 6528
module IntMap = Map.Make (struct
  type t = int
  let compare = compare
end)

let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a))
  |> Array.fold_left (fun m a ->
      IntMap.add a (1 + try IntMap.find a m with Not_found -> 0) m)
      IntMap.empty
  |> IntMap.bindings
  |> List.map (fun (a, x) -> if a <= x then x - a else x)
  |> List.fold_left ( + ) 0
  |> Printf.printf "%d\n"

Measured memory_bytes: 19200
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from math import gcd


A, B, N = read_ints()
x = min(B - 1, N)
print((A * x) // B)


Measured memory_bytes: 65564
// OURL: https://atcoder.jp/contests/abc079/tasks/abc079_c
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
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...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // string s;
  // cin >> s;
  auto num = make_v<int>(4);
  REP(i,4) {
    char c = getchar();
    num[i] = c - '0';
  }
  for (int i = 0; i <= 0b111; ++i) {
    int sum = num[0];
    REP(j,3) {
      if (i & (1<<j)) {
        sum += num[j+1];
      } else {
        sum -= num[j+1];
      }
    }
    if (sum == 7) {
      cout << num[0];
      REP(j,3) {
        cout << ((i & (1<<j)) ? "+" : "-");
        cout << num[j+1];
      }
      cout << "=7" << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
  ll N,M; cin >> N >> M;
  vector<P> a(M); //(cost, 開けられる宝箱の集合)
  REP(i,M){
    ll cost, num, box = 0; cin >> cost >> num;    
    REP(j, num){
      ll x; cin >> x;
      x--;
      box |= (1<<x);
    }
    a[i] = make_pair(cost,box);
  }
  ll K = 1<<N;
  const ll INF = 1e18;
  vector<ll> dp(K, INF);
  dp[0] = 0;
  REP(i,K){
    REP(j,M){
      ll t = i | a[j].second;
      chmin(dp[t],dp[i] + a[j].first);
    }
  }
  ll ans = dp[K-1];
  if(ans == INF) ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define max3(p,q,r)max(max(p,q),r)
#define min3(p,q,r)min(min(p,q),r)
#define chmin(p,q)(p=min(p,q))
#define INF 100000000000
using namespace std;
typedef long long ll;

ll x,y;
void half(ll h,ll w){
  if(h*w%2==0){
		x=y=h*w/2;
	}else{
    ll t;
    if(h<w){t=h;h=w;w=t;}
    x = (h/2+h%2)*w;
    y = h/2*w;
  }
}

int main(){
  ll h,w;
  cin >> h >> w;
  ll ans = INF;
  for(ll hh=h/3;hh<h/3+3;hh++){
    half(h-hh,w);
    chmin(ans, max3(hh*w,x,y) - min3(hh*w,x,y));
  }
  for(ll ww=w/3;ww<w/3+3;ww++){
    half(w-ww,h);
    chmin(ans, max3(ww*h,x,y) - min3(ww*h,x,y));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
#include<map>
using namespace std;

int main(){
    long long n;
    cin>>n;
    long long a[n];
    map<long long,long long>d;
    bool flag=true;
    for(int i=0;i<n;i++){
        cin>>a[i];
        d[a[i]]++;
        if(d[a[i]]>1)flag=false;
    }
    if(flag)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 17696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(ll i=0;i<N;++i)
const ll INF = 1LL<<60;

int F[105][10];
int P[105][11];

int main(){
    string S,T; cin >> S >> T;
    string ans;
    rep(i,S.size()){
        if(S[i] != '?'){
            ans.push_back(S[i]);
        }else ans.push_back('a');
    }
    ll L = -1;
    rep(i,S.size()){
        if(S.size() - i < T.size())break;
        if(S[i] == T[0] || S[i] == '?'){
            ll tmp = i;
            bool ok = true;
            for(int j=1;j<T.size();j++){
                if(S[i+j] != T[j] && S[i+j] != '?'){
                    ok = false;
                }
            }
            if(ok) L = tmp;
        }
    }
    if(L == -1){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    rep(i,T.size()){
        ans[L + i] = T[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ZERO(a) memset(a,0,sizeof(a))
#define FILL(a,b) memset(a,b,sizeof(a))
#define SORT(v) sort((v).begin(),(v).end())
#define RSORT(v) sort((v).rbegin(),(v).rend())
#define FOR(i,a,b)  for(int i=a, i##_len=(b); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
int N;
string S;
string T;

string solve() {
    string ret = "";
    for (int i = 0; i < N; i++) {
        ret.push_back(S[i]);
        ret.push_back(T[i]);
    }
    return ret;
}

int main(void) {
    cin >> N;
    cin >> S;
    cin >> T;

    cout << solve() << endl;
    return 0;
}

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

int main(void)
{
  char s[128];
  scanf("%s",s);
  int len=(int)strlen(s);
  int flag1=0,flag2=0;
  for(int i=0;i<len;i++){
    if(flag2==0&&s[i]=='C'){
      flag1=1;
    }
    if(flag1==1&&s[i]=='F'){
      flag2=1;
    }
  }
  if(flag1&&flag2){
    puts("Yes");
  }else{
    puts("No");
  }
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
using Graph = vector<vector<ll>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 1 << 29;
/****** define constant end ********/

/****** define variable start ******/
ll x, y, a, b, c;
vl p, q, r;
/******* define variable end *******/
ll solve()
{
    cin >> x >> y >> a >> b >> c;
    p.resize(a);
    q.resize(b);
    r.resize(c);
    // c回見る 後ろから変えていって、どこをとったか記録 要素が両方おおきくなったらおわり

    REP(i, a)
    {
        cin >> p[i];
    }
    REP(i, b)
    {
        cin >> q[i];
    }
    REP(i, c)
    {
        cin >> r[i];
    }
    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    sort(r.begin(), r.end(), greater<ll>());
    ll a_ite = a - x;
    ll b_ite = b - y;
    REP(i, c)
    {
        if (p[a_ite] > r[i] && q[b_ite] > r[i])
        {
            break;
        }
        if (a_ite == a)
        {
            if (q[b_ite] < r[i])
            {
                q[b_ite] = r[i];
                b_ite++;
            }
        }
        else if (b_ite == b)
        {
            if (p[a_ite] < r[i])
            {
                p[a_ite] = r[i];
                a_ite++;
            }
        }
        else
        {
            if (p[a_ite] < q[b_ite])
            {
                p[a_ite] = r[i];
                a_ite++;
            }
            else
            {
                q[b_ite] = r[i];
                b_ite++;
            }
        }
    }
    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    ll ans = 0;
    REP(i, x)
    {
        ans += p[i];
    }

    REP(j, y)
    {
        ans += q[j];
    }
    cout << ans << endl;
    return 0;
}
int main()
{
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */

    return (int)end_solve;
}


Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  int x = 1;
  for (int i = m; i > 0; i--) {
    x *= 2;
  }
  int y = 100 * (n - m) + 1900 * m;
  cout << x * y << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  long long A[100100]={0};
  for(int i = 0; i < N+1; i++)cin >> A[i];
  long long B[100100]={0};
  for(int i = 0; i < N; i++)cin >> B[i];
  
  long long count = 0;
  for(int i = 0; i < N ; i++){
  if(A[i] >=B[i]){
    count += B[i];
  }
  else{
    count+= A[i];
    B[i]-= A[i];
    A[i] = 0;
    if(A[i+1]>=B[i]){
      count+= B[i];
      A[i+1]-= B[i];
    }
    else{
      count+= A[i+1];
      A[i+1] = 0;
    }
    
  }
}
cout << count << endl;
}

Measured memory_bytes: 1920
a,b,m=map(int, input().split())  
ai=list(map(int, input().split()))
bi=list(map(int, input().split()))

#xyc=[]
xymin=min(ai)+min(bi)

for i in range(m):
#    xyc.append(list(map(int, input().split()))
    x,y,c=map(int, input().split())
    xy=ai[x-1]+bi[y-1]-c
    if xymin>xy:
        xymin=xy

print(xymin)


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

const int MAXN = 305;

char str[MAXN];
int n, k;
int dp[MAXN][MAXN][MAXN];

int dfs(int L, int R, int k)
{
	if (k < 0) return -1e8;
	if (L > R) return 0;
	if (L == R) return 1;
	if (dp[L][R][k] != -1) return dp[L][R][k];
	dp[L][R][k] = max(dfs(L+1, R, k), dfs(L, R-1, k));
	dp[L][R][k] = max(dp[L][R][k], dfs(L+1, R-1, k-(str[L] != str[R]))+2);
	return dp[L][R][k];
}

int main()
{
	memset(dp, -1, sizeof dp);
	scanf("%s", str+1), n = strlen(str+1);
	scanf("%d", &k);
	cout << dfs(1, n, k) << endl;
	return 0;
}


Measured memory_bytes: 111104
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
g = a[0]
for i in range(n):
    g = math.gcd(g, a[i])
if g != 1:
    print('not coprime')
    quit()
p = [0] * (10**6+1)
prime = []
cnt = 0
for i in range(2, 10**6 + 1):
    if p[i] == 0:
        prime.append(i)
        cnt += 1
        for j in range(i, 10**6 + 1, i):
            p[j] += 1

tmp = [0] * (10**6 + 1)
for i in range(n):
    tmp[a[i]] = 1
for i in prime:
    cnt = 0
    for j in range(i, 10**6+1, i):
        if tmp[j]:
            cnt += 1
    if cnt > 1:
        print('setwise coprime')
        quit()
print('pairwise coprime')


Measured memory_bytes: 190616
#include <set>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <math.h>
#include <map>
using namespace std;
int main() {
 
	int N, M;
	vector<string> S, T;
	cin >> N;
	for (int i = 0; i < N; i++) {
		string tmp;
		cin >> tmp;
		S.push_back(tmp);
	}
	cin >> M;
	for (int i = 0; i < M; i++) {
		string tmp;
		cin >> tmp;
		T.push_back(tmp);
	}
	int max_prize = 0;
	for (auto itr = S.begin(); itr != S.end(); itr++) {
		int blue_c = count(S.begin(), S.end(), *itr);
		int red_c = count(T.begin(), T.end(), *itr);
		int diff = blue_c - red_c;
		if (max_prize < diff) max_prize = diff;
	}
	cout << max_prize << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b);
#define chmin(a, b) (a)=min(a, b);
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll N, K;
ll a[MAX*2];

ll ok(ll m) {
  ll i;
  ll cnt=0;
  
  for(i=0; i<N; i++) {
    if(a[i]>0) {
      ll b=m/a[i];
      if(m<0&&m%a[i]) b--;
      cnt+=upper_bound(a, a+N, b)-a;
    }else if(a[i]<0) {
      ll b=m/a[i];
      if(m<0&&m%a[i]) b++;
      cnt+=N-(ll)(lower_bound(a, a+N, b)-a);
    }else {
      if(m>=0) cnt+=N;
    }
  }
  
  for(i=0; i<N; i++) if(a[i]*a[i]<=m) cnt--;
  cnt/=2;
  
  return cnt>=K;
}


int main(void) {
  ll i, j, k;
  
  cin >> N >> K;
  
  for(i=0; i<N; i++) cin >> a[i];
  sort(a, a+N);
  
  ll l=-INF-7, r=INF+7;
  while(l+1<r) {
    ll m=(l+r)/2;
    if(ok(m)) r=m;
    else l=m;
  }
  
  pt(r);
  
}





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

int A[100],n;

int bubbleSort(int A[], int n){
    int s=0;
    int flag;
    flag = 1;
    while(flag){
        flag = 0;
        for(int j=n-1; j>=1; j--){
            if(A[j]<A[j-1]){
                s++;
                swap(A[j],A[j-1]);
                flag = 1;
            }
        }
    }
    
    return s;
}

int main(){
    cin >> n;
    int ans;
    
    for(int i=0; i<n; i++) {
        cin >> A[i];
    }
    
    ans = bubbleSort(A,n);
    
    for(int i=0; i<n; i++){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
    cout << ans << endl;
    
    return 0;
}

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

int main(){
  int n,i=2;string s1,s2;cin>>n>>s1>>s2;
  long long ans=6;bool f=0;
  if(s1.at(0)==s2.at(0)){
    ans=3,f=1,i=1;
  }
  while(i<n){
    if(s1.at(i)==s2.at(i)){
      ans*=(f?2:1),f=1,i++;
    }else{
      ans*=(f?2:3),f=0,i+=2;
    }
    ans%=1000000007;
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
typedef pair<LL, tuple<int, int, int>> P;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int X, Y, Z, K; cin >> X >> Y >> Z >> K;
  vector<LL> A(X), B(Y), C(Z); cin >> A >> B >> C;
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  set<tuple<int, int, int >> g;

  priority_queue<P> que;
  que.push({A[X-1] + B[Y-1] + C[Z-1], {X-1, Y-1, Z-1}});
  g.insert({X-1, Y-1, Z-1});
  for (int i = 0; i < K; ++i) {
    auto p = que.top(); que.pop();
    cout << p.first << endl;
    auto [x, y, z] = p.second;
    if (x > 0 & !g.count({x-1, y, z})) {
      g.insert({x-1, y, z});
      que.push({A[x-1] + B[y] + C[z], {x-1, y, z}});
    }
    if (y > 0 & !g.count({x, y-1, z})) {
      g.insert({x, y-1, z});
      que.push({A[x] + B[y-1] + C[z], {x, y-1, z}});
    }
    if (z > 0 & !g.count({x, y, z-1})) {
      g.insert({x, y, z-1});
      que.push({A[x] + B[y] + C[z-1], {x, y, z-1}});
    }
  }
}


Measured memory_bytes: 4116
#include <algorithm>
#include <vector>
#include <bits/stdc++.h>

using namespace std;

bool can_make_triangles(int a, int b, int c)
{
    return (a < (b + c)) && (b < (a + c)) && (c < (a + b));
}

int main()
{
    int N;
    cin >> N;
    
    vector<int> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L.at(i);
    }
    
    sort(L.begin(), L.end());
    
    int ans = 0;
    
    for (int a = 0; a < N - 2; a++) {
        for (int b = a + 1; b < N - 1; b++) {
            int l_a = L.at(a);
            int l_b = L.at(b);
            
            int c_start = b+1;
            int l_c_start = L.at(c_start);
            while (!((l_b - l_a) < l_c_start)) {
                c_start += 1;
                l_c_start = L.at(c_start);
            }
            
            int c_end = N-1;
            int l_c_end = L.at(c_end);
            while (!(l_c_end < (l_a + l_b))) {
                c_end -= 1;
                l_c_end = L.at(c_end);
            }
            
            if (!can_make_triangles(l_a, l_b, l_c_start) && !can_make_triangles(l_a, l_b, l_c_end))
            { break; }
            
            ans += (c_end - c_start + 1);
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int K, T;
priority_queue<int> que;

int main() {
  INCANT;
  cin >> K >> T;
  int a;
  rep(i, T) {
    cin >> a;
    que.push(a);
  }
  
  while(que.size()>1) {
    int b =que.top(); que.pop();
    int c = que.top(); que.pop();
    if (b-1!=0) que.push(b-1);
    if (c-1!=0) que.push(c-1);
  }
  cout << que.top()-1 << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter


def split_RL_block(S):
    N = len(S)
    ret = []

    RL = "R"
    c = "R"
    for i in range(1, N):
        now = S[i]
        if RL == "R" and now == "R":
            c += "R"
        elif RL == "R" and now == "L":
            RL = "L"
            c += "L"
        elif RL == "L" and now == "R":
            ret.append(c)
            RL = "R"
            c = "R"
        else:
            c += "L"
    else:
        ret.append(c)
    return ret


def count_children_RL_border(RL):
    N = len(RL)
    ret = [0] * N
    
    cnt_RL = Counter(RL)
    idx_r = cnt_RL["R"] - 1
    idx_l = idx_r + 1

    r = 0
    l = 0
    for i in range(N):
        if abs(i - idx_r) % 2 == 0:
            r += 1
        else:
            l += 1
    ret[idx_r] = r
    ret[idx_l] = l

    return ret


def main():
    S = input()
    N = len(S)
    RL = split_RL_block(S)
    ans = []
    for rl in RL:
        tmp = count_children_RL_border(rl)
        ans += tmp
    
    print(*ans)


if __name__ == "__main__":
    main()

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

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


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
#include<queue>
#include<utility>
using namespace std;
using ll = long long;

const ll MOD=1e9+7;
const ll MAX=200010;
const ll MAX_P=200010;
ll fact[MAX_P];
void make_fact(){
  fact[0]=fact[1]=1;
  for(ll i=2;i<MAX_P;i++){
    fact[i]=(fact[i-1]*i)%MOD;
  }
}
ll Extgcd(ll a,ll b,ll &x,ll &y){
  ll d=a;
  if(b!=0){
    Extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }
  else{
    x=1;y=0;
  }
  return d;
}

ll mod_inv(ll a,ll p){//mod pでのaの逆元を求める
  ll x,y;
  Extgcd(a,p,x,y);
  return (x%p+p)%p;
}
//n!=a*p^e (a,p互いに素,p素数) とした時のeとa mod p を求める
ll mod_fact(ll n,ll p,ll& e){
  e=0;
  if(n==0) return 1;
  
  ll res=mod_fact(n/p,p,e);
  e+=n/p;

  if(n/p%2!=0) return res*(p-fact[n%p])%p;
  return res*fact[n%p]%p;
}

//nCk mod pを求める
ll mod_comb(ll n,ll k,ll p){
  if(n<0||k<0||n-k<0) return 0;
  ll e1,e2,e3;
  ll a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
  if(e1>e2+e3) return 0;
  return a1*mod_inv(a2*a3%p,p)%p;
}

int main(){
    make_fact();
    ll n,m,k;
    ll ans,temp=0;
    cin >> n >> m >> k;
    ll N = n*n;
    ll M = m*m;
    for(int i=0;i<=m-1;i++){
        temp+=i*(m-i)%MOD;
    }
    ans = temp%MOD*N%MOD;
    temp=0;
    for(int i=0;i<=n-1;i++){
        temp+=i*(n-i)%MOD;
    }
    ans += (temp%MOD*M%MOD);
    ans*=mod_comb(n*m-2,k-2,MOD);
    cout << ans%MOD;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int N = 3e5 + 7;
int32_t main(){
    IOS;
    int n,x,t;
    cin >> n >> x >>t;
    if(n%x==0) cout << (n/x)*t << endl;
    else cout << ((n/x)+1)*t << endl;
    return 0;
}



Measured memory_bytes: 3644
import sys

n = int(input())
coun = 0
def yaku(num):
    yakusuu_array = []
    for i in range(1,num+1):
        if num % i == 0:
            yakusuu_array.append(i)
    return len(yakusuu_array)

for i in range(1,n+1,2):
    p = yaku(i)
    if p == 8:
        coun += 1
print(coun)

Measured memory_bytes: 3316
import java.util.Scanner;

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

        int input = scanner.nextInt();

        switch (input % 10) {
            case 0:
                System.out.println("pon");
                break;
            case 1:
                System.out.println("pon");
                break;
            case 2:
                System.out.println("hon");
                break;
            case 3:
                System.out.println("bon");
                break;
            case 4:
                System.out.println("hon");
                break;
            case 5:
                System.out.println("hon");
                break;
            case 6:
                System.out.println("pon");
                break;
            case 7:
                System.out.println("hon");
                break;
            case 8:
                System.out.println("pon");
                break;
            case 9:
                System.out.println("hon");
                break;
        }
        scanner.close();
    }
}

Measured memory_bytes: 35744
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << 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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, cur = -1; cin >> n;
    vi h(n);
    rep(i, n){
        cin >> h[i];
        if(cur == -1 && h[i] > 0) cur = i;
    }
    ll ans = 0;
    if(cur == -1){
        cout << 0 << endl;
        return 0;
    }
    while(cur<n){
        if(h[cur] == 0){
            cur++;
            continue;
        }
        ans++;
        for(ll i=cur; i<n; i++){
            if(h[i] > 0) h[i]--;
            else break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.cpp
 * Author: baisganon
 *
 * Created on 2017/06/04, 19:09
 */

#include<iostream>

using namespace std;

int count=0;

void merge(int A[],int left,int mid,int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1+1],R[n2+1];
    for(int i=0;i<n1;i++){
        L[i]=A[left+i];
    }
    for(int i=0;i<n2;i++){
        R[i]=A[mid+i];
    }
    L[n1]=2000000000;
    R[n2]=2000000000;
    int i=0,j=0;
    for(int k=left;k<right;k++){
        if(L[i]<=R[j]){
            A[k]=L[i++];
        }else{
            A[k]=R[j++];
        }
        count++;
    }
    return;
}

void mergeSort(int A[],int left,int right){
    if(left+1>=right)return;
    int mid = (left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
}

int main(){
	int size;
	cin >> size;
	int S[size];
	for(int i=0;i<size;i++){
		cin >> S[i];
	}

	mergeSort(S,0,size);

	for(int i=0;i<size;i++){
		cout<<S[i]<<((i==size-1)?"":" ");
	}
	cout << endl << count << endl;
        int xxx;
        cin >> xxx;
	return 0; 
}

Measured memory_bytes: 6960
package main

import (
	"fmt"
	//"sort"
	//"strconv"
	//"strings"
	"bufio"
	"os"
	"strconv"
	//"math"
)

func main() {
	//struct sort not preparation today
	//input
	var n int
	fmt.Scan(&n)

	var x []int
	var h []int

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for i := 0; i < n; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		h = append(h, a)
		x = append(x, 0)
	}

	for i := 0; i < n; i++ {
		x[h[i]-1] = i + 1
	}
	for i := 0; i < n; i++ {
		fmt.Print(x[i])
		if i != n {
			fmt.Print(" ")
		}
	}
}


Measured memory_bytes: 8980
s = list(input())
N = s.count("N")
W = s.count("W")
S = s.count("S")
E = s.count("E")
ans = "Yes"

if N>=1 and S==0:
    ans = "No"
elif N==0 and S>=1:
    ans = "No"

if W>=1 and E==0:
    ans = "No"
elif W==0 and E>=1:
    ans = "No"

print(ans)


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

int N;
int x[10], y[10];

double dist(int i, int j){
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];

    return pow(dx*dx + dy*dy, 0.5);
}

void solve(){
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> x[i] >> y[i];
    }
    double sum = 0.0;
    vector<int> v(N);
    for(int i = 0; i < N; i++){
        v[i] = i + 1;
    }
    do{
        for(int i = 0; i < N - 1; i++){
                sum += dist(v[i], v[i + 1]);
         }
    }while(next_permutation(v.begin(), v.end()));
    int Factorial = 1;
    for(int i = 2; i <= N; i++){
        Factorial *= i;
    }
    cout << fixed << setprecision(10) << sum / Factorial << endl;
    return;
}

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

Measured memory_bytes: 4240
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    ll a;
    cin >> a;
    cout << n*n - a << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a + 1):
    for j in range(b + 1):
        y = x - i * 500 - j * 100
        if y % 50 == 0 and y // 50 <= c and y >= 0:
            cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<unordered_map>
typedef unsigned long long ull;
typedef signed long long sll;
using namespace std;

#define INF 0x7FFFFFFFFFFFFFFF
#define BIG_PRIME 1000000007

#define MAX 199999
ull fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % BIG_PRIME;
        inv[i] = BIG_PRIME - inv[BIG_PRIME%i] * (BIG_PRIME / i) % BIG_PRIME;
        finv[i] = finv[i - 1] * inv[i] % BIG_PRIME;
    }
}
// 二項係数計算
ull COM(ull n, ull k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % BIG_PRIME) % BIG_PRIME;
}
struct Point
{
  ull r;
  ull c;
  ull p;
  Point(){}
  Point(ull R,ull C,ull P)
  {
    r=R;
    c=C;
    p=P;
  }
  bool operator<(const Point &rhs) const{
    return (r==rhs.r)?c<rhs.c:r<rhs.r;
  }
};

vector<Point> points;

ull calc_dp(ull n)
{
  if(points[n].p==INF)
  {
    points[n].p=COM(points[n].r+points[n].c,points[n].r);
    for(ull i=0;i<n;++i)
    {
      if(points[i].c<=points[n].c)
      {
        ull r = points[n].r-points[i].r;
        ull c = points[n].c-points[i].c;
        points[n].p=(points[n].p+BIG_PRIME-((calc_dp(i)*COM(r+c,r))%BIG_PRIME))%BIG_PRIME;
      }
    }
  }
  return points[n].p;
}

int main()
{
  COMinit();
  ull i,r,c,H,W,N;
  cin >> H >> W >> N;

  for(i=0;i<N;++i)
  {
    cin >> r >> c;
    points.push_back(Point(r-1,c-1,INF));
  }
  points.push_back(Point(H-1,W-1,INF));
  sort(points.begin(),points.end());
  
  cout << calc_dp(N);
  
  return 0;
}


Measured memory_bytes: 5120
#include "bits/stdc++.h"
using namespace std;

#ifdef LOCAL
        #include "debug.h"
        #define input freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        #else
        #define debug(...) 4
        #define input ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#endif

using ll = long long;
const int N = 2e5 + 5;
const int mod = 998244353;

int main() {
    input;
    ll n;
    cin >> n;
    vector<int> v(n), v2(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
        cin >> v2[i];
    }
    sort(v.begin(), v.end());
    sort(v2.begin(), v2.end());
    if(n % 2) {
        int ans = v2[n / 2] - v[n / 2] + 1;
        cout << ans;
    }
    else {
        int ans = (v2[n / 2] + v2[(n / 2) - 1]  - v[n / 2] - v[(n / 2) - 1]) + 1;
        cout << ans;
    }


}


Measured memory_bytes: 4792
N = int(input())
S = list(input())
R = [0]*N
G = [0]*N
B = [0]*N
for i in range(N):
    if S[i]=="R":
        R[i] += 1
    elif S[i] == "G":
        G[i] += 1
    else:
        B[i] += 1

ans = sum(R)*sum(G)*sum(B)

for i in range(N):
    for j in range(i+1,min((N+i+3)//2,N)):
        k = 2*j-i
        if  k<N:
            if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
                ans -= 1
                
print(ans)

Measured memory_bytes: 9308
//winners never quit
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int flag=0,ans=0;
    while(n--)
    {
       int a,b;
       scanf("%d %d",&a,&b);
       if(a==b){
        flag++;
        if(flag==3){
            ans=1;
        }
       }
       else
        flag=0;

    }
    if(ans==1)
        printf("Yes\n");
    else
        printf("No\n");

        return 0;
}


Measured memory_bytes: 3756