akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

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

    int m_min=1e9;
    REP(i,N){
        int m; cin>>m;
        X-=m;
        m_min=min(m_min,m);
    }
    cout<<N+(X/m_min)<<endl;

}


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

// #define TEST

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int N, is_here[500][500], res[500][500];

void ready(void){
    cin >> N;
    for (int i = 0; i < N; ++i){
        for (int j = 0; j < N; ++j){
            is_here[i][j] = 1;
            res[i][j] = min(min(i, N - 1 - i), min(j, N - 1 - j));
        }
    }
}

#ifdef TEST
void show(void){
    cout << "-----res-----" << endl;
    for (int i = 0; i < N; ++i){
        for (int j = 0; j < N; ++j){
            if (res[i][j] < 10) cout << res[i][j] << "  ";
            else if (res[i][j] < 100) cout << res[i][j] << " ";
            else cout << res[i][j];
            cout << " ";
        }
        cout << endl;
    }
}
#endif

void dfs(int x, int y){
    for (int dx = -1; dx <= 1; ++dx){
        for (int dy = -1; dy <= 1; ++dy){
            if (x + dx < 0 || x + dx >= N || y + dy < 0 || y + dy >= N)
                continue;
            if (dx != 0 && dy != 0) continue;
            if (res[x][y] + is_here[x][y] < res[x + dx][y + dy]){
                res[x + dx][y + dy] = res[x][y] + is_here[x][y];
                dfs(x + dx, y + dy);
            }
        }
    }
}

int move(int p){
    --p;
    int x = p / N, y = p % N;
    int v = res[x][y];
    is_here[x][y] = 0;
    dfs(x, y);
    return v;
}

int main(void){
    ready();
    ll res = 0;
#ifdef TEST
    show();
#endif
    for (int i = 0; i < N * N; ++i){
        int p; cin >> p;
        res += move(p);
#ifdef TEST
        show();
#endif
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 24420
var
  a, b, h, m, angle: double;
  distance: double;

begin
  read(a);
  read(b);
  read(h);
  read(m);

  angle := Abs((30 * h) - (5.5 * m));

  distance := Sqrt((sqr(a) + sqr(b)) - (2 * (a) * (b) * Cos(angle * pi / 180)));

  writeln(distance);

end.

Measured memory_bytes: 1376
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int k;
	string s;
	cin>>k>>s;
	
	if(s.size()>k){
		REP(i,k) cout<<s[i];
		cout<<"...";
		cout<<endl;
	}else{
		cout<<s<<endl;
	}
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

struct group {
    ll c0, c1;
    int i;
    bool operator<(const group &r) const { return c0 * r.c1 < c1 * r.c0; }
};

int c[200009];
bool used[200009];

int find(int x) { return c[x] != x ? c[x] = find(c[x]) : x; }

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

    int n;
    cin >> n;
    vector<int> p(n);
    vector<group> g;
    priority_queue<group> que;
    FOR(i, 1, n) {
        cin >> p[i];
        p[i]--;
    }
    rep(i, n) {
        int v;
        cin >> v;
        if(v == 0)
            g.push_back(group{1, 0, i});
        else
            g.push_back(group{0, 1, i});
        if(i) que.push(g.back());
        c[i] = i;
    }

    ll ans = 0;
    while(!que.empty()) {
        group u = que.top();
        que.pop();

        int x = u.i;
        if(used[x]) continue;
        used[x] = 1;

        int y = find(p[x]);
        ans += g[y].c1 * g[x].c0;
        g[y].c0 += g[x].c0;
        g[y].c1 += g[x].c1;
        if(y) que.push(g[y]);
        c[x] = y;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 14664
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

LL a[200005];

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

    sort(a, a + n);
    if (n == 1) {
        printf("0\n");
        return 0;
    } else if (n == 2) {
        printf("%lld\n", a[1]);
        return 0;
    }

    LL ans = a[n - 1];
    for (int i = n - 2, j = 2; i >= 0; i--) {
        ans += a[i];
        j++;
        if (j == n) { break; }
        ans += a[i];
        j++;
        if (j == n) { break; }
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 5312
S = input()[::-1]
# maerd
# remaerd
# esera
# resera
L = ["dream"[::-1],
"dreamer"[::-1],
"erase"[::-1],
"eraser"[::-1]]

i = 0
N = len(S)
while i < N:
  d = 0
  for l in L:
    if S.startswith(l, i):
      d = len(l)
      break
  if d > 0:
    i += d
    continue
  print("NO")
  break
else:
  print("YES")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <fstream>
#include <string>
using namespace std;
#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 ll long long

int main() {
    //入力
    int n,x,t;
    cin >> n >> x >> t;
    //処理
    int ans = 0;
    if (n % x == 0) {
        ans = n / x * t;
    }
    else {
        ans = (n / x + 1) * t;
    }

    //出力
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#D問題
import math
N = int(input())

prime = []
for i in range(2,N+1):
    n = math.ceil(math.log2(i))
    flag = 0
    for j in range(2,n+1):
        if i%j == 0:
            flag = 1
            break
    if flag == 0:
        if i != 49:
            prime.append(i)

count = 0
plen = len(prime)
#(74)
for i in range(plen):
    p = prime[i]
    pc = 0
    while p <= N:
        pc+=(N//p)
        p*=prime[i]
    if pc >= 74:
        count+=1
        #print(prime[i])
#(2,24)
for i in range(plen):
    for j in range(plen):
        if i == j:
            continue
        p1 = prime[i]
        p2 = prime[j]
        pc1 = 0
        while p1 <= N:
            pc1+=(N//p1)
            p1*=prime[i]
        pc2 = 0
        while p2 <= N:
            pc2+=(N//p2)
            p2*=prime[j]
        if pc1 >= 2 and pc2 >= 24:
            count+=1
            #print(prime[i],prime[j])
#(4,14)
for i in range(plen):
    for j in range(plen):
        if i == j:
            continue
        p1 = prime[i]
        p2 = prime[j]
        pc1 = 0
        while p1 <= N:
            pc1+=(N//p1)
            p1*=prime[i]
        pc2 = 0
        while p2 <= N:
            pc2+=(N//p2)
            p2*=prime[j]
        if pc1 >= 4 and pc2 >= 14:
            count+=1
            #print(prime[i],prime[j])
#(2,4,4)
for i in range(plen):
    for j in range(plen):
        if i == j:
            continue
        for k in range(plen):
            if i == k or j == k or j < k:
                continue
            p1 = prime[i]
            p2 = prime[j]
            p3 = prime[k]
            pc1 = 0
            while p1 <= N:
                pc1+=(N//p1)
                p1*=prime[i]
            pc2 = 0
            while p2 <= N:
                pc2+=(N//p2)
                p2*=prime[j]
            pc3 = 0
            while p3 <= N:
                pc3+=(N//p3)
                p3*=prime[k]
            if pc1 >= 2 and pc2 >= 4 and pc3 >= 4:
                count+=1
                #print(prime[i],prime[j],prime[k])

print(count)
#print(prime)

Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
const int INF=1000000000;

int main(){
    int n,k;
    std::cin >> n >> k;
    std::vector<int> h(n);
    rep(i,n){
        std::cin >> h[i];
    }
    std::vector<int>dp(n,INF);
    dp[0]=0;
    
    rep(i,n){
        for(int j=i+1;j<=k+i;j++){
            if(j>n){
                break;
            }
            dp[j]=std::min(dp[j],dp[i]+abs(h[i]-h[j]));
        }
    }
    std::cout << dp[n-1] << std::endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

#define ll long long
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define vstr vector<string>

using namespace std;

int main()
{

	ll n;
	cin >> n;
	ll ans;
	if (n < 600)
	{
		ans = 8;
	}
	else if (n < 800)
	{
		ans = 7;
	}
	else if (n < 1000)
	{
		ans = 6;
	}
	else if (n < 1200)
	{
		ans = 5;
	}
	else if (n < 1400)
	{
		ans = 4;
	}
	else if (n < 1600)
	{
		ans = 3;
	}
	else if (n < 1800)
	{
		ans = 2;
	}
	else ans = 1;
	cout << ans << endl;
}

Measured memory_bytes: 3196
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back
#define REP(i,a,b) for(int i=a; i<=b; i++)
#define MOD 1000000007

void solve(int test_case) {//209
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k&1) {
		ll ac = b+c;
		ll bc = a+c;
		ll cc = a+b;
		a=ac,b=bc,c=cc;
	}
	cout<<a-b;
}//b+c 2a+b+c 2a+3b+3c 6a+5b+5c 10a+11b+11c
 //c+a a+2b+c 3a+2b+3c 5a+6b+5c 11a+10b+11c
 //a+b a+b+2c 3a+3b+2c 5a+5b+6c 11a+11b+10c
 //5 9  19
 //4 10 18
 //5 9  19

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	//prefill();
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3572
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
#define watch(x) cout << (#x)<<" = "<<x<<endl
const int N = 1e6 + 9;

ii tree[N * 4];
priority_queue<int> arr[N];
ii merge(ii a, ii b) {
	return (a.first > b.first ? a : b);
}
inline int mid(int& s, int& e) {
	return (s + e) / 2;
}
void insert(int segIdx, int s, int e, int x, int y) {
	if (x < s || x > e)
		return;
	if (s == e) {
		arr[s].push(y);
		tree[segIdx] = { arr[s].top() - x, x };
		return;
	}
	int l = segIdx << 1, r = l | 1;
	insert(l, s, mid(s, e), x, y);
	insert(r, mid(s, e) + 1,e, x, y);
	tree[segIdx] = max(tree[l], tree[r]);
}
ii query(int segIdx, int s, int e, int x) {
	if (x < s)
		return { INT_MIN, -1 };
	if (x >= e)
		return tree[segIdx];
	int l = segIdx << 1, r = l | 1;
	return merge(query(l, s, mid(s, e), x), query(r, mid(s, e) + 1, e, x));
}
void del(int segIdx, int s, int e, int x) {
	if (x < s || x > e)
		return;
	if (s == e) {
		arr[s].pop();
		if (sz(arr[s]))
			tree[segIdx].first = arr[s].top() - x;
		else
			tree[segIdx].first = INT_MIN;
		return;
	}
	int l = segIdx << 1, r = l | 1;
	del(l, s, mid(s, e), x);
	del(r, mid(s, e) + 1, e, x);
	tree[segIdx] = merge(tree[l], tree[r]);
}
int main() {
	file();
	fast();
	for (int i = 0; i < N * 4; i++)
		tree[i].first = INT_MIN;
	int n; cin >> n;
	vii v1;
	int sopen = 0, sclose = 0;
	for (int i = 0; i < n; i++) {
		string str; cin >> str;
		int open = 0, close = 0;
		for (auto& ch : str) {
			if (ch == '(')
				open++;
			else {
				if (!open)
					close++;
				else
					open--;
			}
		}
		if (!close) sopen += open;
		else if (!open) sclose += close;
		else
			v1.push_back({ close, open }), insert(1, 0, (int)1e6, close, open);
	}
	sort(allr(v1));
	for (auto& it : v1) {
		ii gt = query(1, 0, (int)1e6, sopen);
		//cout << gt.first << ' ' << gt.second << endl;
		if (gt.first == INT_MIN)
			RT("No\n");
		del(1, 0, (int)1e6, gt.second);
		sopen += gt.first;
	}
	if (sopen != sclose)
		RT("No\n");
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 69140
c = [[int(i) for i in input().split()] for i in range(3)] 

for a1 in range(101):
    b1 = c[0][0] - a1
    b2 = c[0][1] - a1
    b3 = c[0][2] - a1
    a2_1 = c[1][0] - b1
    a2_2 = c[1][1] - b2
    a2_3 = c[1][2] - b3
    a3_1 = c[2][0] - b1
    a3_2 = c[2][1] - b2
    a3_3 = c[2][2] - b3
    if (a2_1 == a2_2 == a2_3) and (a3_1 == a3_2 == a3_3):
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 3064
N, X = map(int, input().split())
 
a, p = [1], [1]
for i in range(N):
  a.append(a[i] * 2 + 3)
  p.append(p[i] * 2 + 1)

def f(N, X): # X <= 0 や X > a_N を許容し解説本文から簡略化
  if N == 0:
    return 0 if X <= 0 else 1
  elif X <= 1 + a[N-1]:
    return f(N-1, X-1)
  elif X == 2 + a[N-1]:
    return p[N-1] + 1
  elif X == 3 + 2 * a[N-1]:
    return 2 * p[N-1] + 1
  else:
    return p[N-1] + 1 + f(N-1, X-2-a[N-1])
print(f(N, X))

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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(n * a, b) << endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

char a[4], b[4], c[4];

int main() {
  scanf("%s", a);
  scanf("%s", b);
  scanf("%s", c);
  printf("%c%c%c\n", a[0], b[1], c[2]);
  return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        n: usize,
        x: usize,
        m: usize
    }
    let mut res = x;
    let mut pattern = vec![x];
    let mut before = x;
    let mut firstpat = 0usize;
    let mut stopped = false;
    for _ in 0..n - 1 {
        let next = before * before;
        let next = next % m;
        if pattern.contains(&next) {
            firstpat = next;
            stopped = true;
            break;
        }
        res += next;
        pattern.push(next);
        before = next;
    }
    //println!("{:?}", pattern);
    if stopped {
        let firstindex = pattern.iter().position(|&i| i == firstpat).unwrap();
        //println!("{:?}", pattern);
        //ループ部分だけ取り出す
        let pattern: Vec<usize> = pattern.into_iter().skip(firstindex).collect();
        //println!("{:?}", pattern);
        let len = pattern.len();
        let sum: usize = pattern.iter().sum();
        let n = n - firstindex; //最初の個数を取り除く
        res -= sum;
        res += (n / len) * sum;
        let s: usize = pattern.iter().take(n % len).sum();
        //println!("0..{} : {}", n % len, s);
        res += s;
    }
    println!("{}", res);
}


Measured memory_bytes: 2684
#include <iostream>
#include <vector>
#include <cstring>
#include <cstdio>
using namespace std;

#define DO(n) for ( int ____n = n; ____n-->0; )
#define REP(i, n) for (int i=0;i<n;++i)
#define FOR(i, a, b) for (int i=a;i<b;++i)
#define DWN(i, b, a) for (int i=b-1;i>=a;--i)
#define REP_1(i, n) for (int i=1;i<=n;++i)
#define FOR_1(i, a, b) for (int i=a;i<=b;++i)
#define DWN_1(i, b, a) for (int i=b;i>=a;--i)
#define ECH(it, A) for (__typeof(A.begin()) it = A.begin(); it != A.end(); ++it)
#define RST(A) memset(A, 0, sizeof(A))
#define FLC(A, x) memset(A, x, sizeof(A))
#define PB push_back

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

typedef double DB;
typedef vector<int> VI;
const int INF = 0x3f3f3f3f;

const int N = int(1e2) + 9, M = 20;
char str[N][M+1]; int slen[N]; VI adj[N], radj[N];

int vis[N][N][M+M+1]; int dp[N][N][M+M+1];
int n, m;


int f(int i0, int i1, int j){

    int &z = dp[i0][i1][j+M], &v = vis[i0][i1][j+M];

    if (v == 3) return z;

    if (v == 1){
        v = 2;
        return -INF;
    }

    v = 1; z = j ? -INF : 0;

    if (j > 0){
        ECH(it, radj[i0]){
            int i00 = *it; bool ok = true;

            int up = min(j, slen[i00]); REP(k, up){
                if (str[i00][slen[i00]-1-k] != str[i1][slen[i1]-j+k]){
                    ok = false;
                    break;
                }
            }

            if (!ok) continue;
            checkMax(z, f(i00, i1, j-slen[i00]) + slen[i00]);
        }
    }
    else{

        j = -j;

        ECH(it, adj[i1]){
            int i11 = *it; bool ok = true;

            int up = min(j, slen[i11]); REP(k, up){
                if (str[i0][j-1-k] != str[i11][k]){
                    ok = false;
                    break;
                }
            }

            if (!ok) continue;
            checkMax(z, f(i0, i11, slen[i11]-j) + slen[i11]);
        }
    }

    if (z >= 0 && v == 2) z = INF;
    v = 3;


    //if (z >= 0)
    //cout << ")" << i0 << " " << i1 << " " << j << " " << v << " "<< z << endl;
    //cout << i0 << " " <<i1 << " " << j << ": " << z << " "<<v << endl;
    return z;
}

bool isPalindrome(int i0, int l, int r){
    int len = r-l;
    REP(i, len/2) if (str[i0][l+i] != str[i0][r-1-i]) return false;
    return true;
}

int main(){

#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif

    while (~scanf("%d%d", &n, &m)){

        REP(i, n){
            scanf("%s", str[i]); adj[i].clear(), radj[i].clear();
            slen[i] = strlen(str[i]);
        }

        DO(m){
            int a, b; scanf("%d%d", &a, &b); --a, --b;
            adj[a].PB(b); radj[b].PB(a);
        }

        FLC(dp, -1); RST(vis); int z = 0; REP(i, n) REP(j, slen[i]+1){
            if (isPalindrome(i, 0, slen[i]-j) && f(i, i, j) >= 0) checkMax(z, f(i, i, j) + slen[i]);
            if (isPalindrome(i, j, slen[i]) && f(i, i, -j) >= 0) checkMax(z, f(i, i, -j) + slen[i]);
        }

        if (z >= INF) z = -1;
        printf("%d\n", z);
    }
}

Measured memory_bytes: 5524
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main(void){
  char S[4];
  int i;
  scanf("%s",S);
  for(i=0;i<3;i++){
    if(S[i]=='7'){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}

Measured memory_bytes: 2084
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

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

	deque<char> s;
	string ts;
	cin >> ts;
	for (auto x : ts) {
		s.push_back(x);
	}
	int rv = 0;
	int q;
	cin >> q;
	while (q--) {
		int tp;
		cin >> tp;
		if (tp == 1) {
			rv ^= 1;
		} else {
			int f;
			char c;
			cin >> f >> c;
			f--;
			if (!(f ^ rv)) s.push_front(c);
			else s.push_back(c);
		}
	}
	string rs;
	for (auto x : s) rs.push_back(x);
	if (rv) reverse(rs.begin(), rs.end());
	cout << rs << endl;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  int x = 0;
  vector<int> a(N);
  rep(i, 0, N) {
    cin >> a[i];
    if (a[i] % 2 == 0)
      x++;
  }
  if (x == N) {
    cout << "second" << endl;
  } else {
    cout << "first" << endl;
  }

  return 0;
}


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

using namespace std;

int main(int argc, char const *argv[]) {
	string str;
	bool flag = false;
	std::cin >> str;
	for (size_t i = 1; i < str.size(); i++) {
		for (size_t j = 0; j < str.size(); j++) {
			if (i == j) {
				continue;
			}
			if (str[i] == str[j]) {
				flag = true;
				std::cout << "no" << '\n';
				break;
			}
		}
		if (flag) {
			break;
		}
	}
	if (!flag) {
		std::cout << "yes" << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define N 10000

int main(void){
	long long int a[N],sum=0;
	int min,max,n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	min=a[0];
	max=a[0];
	for(int i=0;i<n;i++){
		sum+=a[i];
		if(min>a[i])min=a[i];
		if(max<a[i])max=a[i];
	}
	cout<<min<<" "<<max<<" "<<sum<<endl;
}


Measured memory_bytes: 3160
import java.io.*;
import java.util.Scanner;

class Main
{
	public static void main (String[] args) throws IOException
	{
  		Scanner in = new Scanner(System.in);
		String A = in.next();
		String B = in.next();
		String C = in.next();
		int a = Integer.parseInt(A);
		int b = Integer.parseInt(B);
		int c = Integer.parseInt(C);

		int count = 0;

		for(int i = a; i < b + 1; i++){
	      	if(c % i == 0){
	        	count++;
	      	}
    	}
    	
    	System.out.println(count);
	}
}

Measured memory_bytes: 17312
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,l;
    cin>>n;
    std::deque<int> deq;
    for (int i=0;i<n;i++) {
        cin>>l;
        deq.emplace_back(l);
    }
    sort(deq.begin(),deq.end(),greater<int>());
    int sum=0;
    for (int j=1;j<n;j++) {
        sum+=deq[j];
    }
    if (sum>deq[0]) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;
int main() {
	int n;
	cin>>n;

	vector<string>vstr(n);
	for(auto& e:vstr)cin>>e;
    
    vector<int>a(26);
    for(int j=0;j<vstr[0].size();++j){
        ++a[vstr[0][j]-'a'];
    }
    for(int i=1;i<n;++i){
        vector<int>a_(26,0);
        for(int j=0;j<vstr[i].size();++j){
            ++a_[vstr[i][j]-'a'];
        }
        for(int j=0;j<a.size();++j){
            if(a_[j]!=0&&a[j]!=0)a[j]=min(a_[j],a[j]);
            else a[j]=0;
        }
    }
    
    string ans="";
    for(int i=0;i<a.size();++i)
        for(int j=0;j<a[i];++j)
            ans+='a'+i;
    
    cout<<ans<<endl;

	return 0;
}


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

int main(){
  int N,M,K;cin >> N >> M >> K;
  vector<int> A(N);
  vector<int> B(M);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  for(int i=0;i<M;i++){
    cin >> B[i];
  }
  vector<int> C(K);
  int x,y,c;
  for(int i=0;i<K;i++){
    cin >> x >> y >> c;
    C[i] = A[x-1] + B[y-1] - c;
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  cout << min(C[0],A[0]+B[0]) << endl;
}

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

int n,last,x,a[1001],ans;

int main()
{
	
	cin>>n;
	for (int i=1;i<=n;++i) cin>>a[i];
	for (int i=1;i<=n;++i){
		if (a[i]!=a[i-1]) ans+=last/2,last=1;
		else last++;
	}
//	cout<<ans<<" "<<last<<endl;
	ans+=last/2;
	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>
#include <map>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  int x,y;
  x=abs(tx-sx);
  y=abs(ty-sy);
  vector<int> v;
  REP(i,y)v.push_back(1);
  REP(i,x)v.push_back(2);
  REP(i,y)v.push_back(3);
  REP(i,x)v.push_back(4);
  v.push_back(4);
  v.push_back(1);
  REP(i,y)v.push_back(1);
  REP(i,x)v.push_back(2);
  v.push_back(2);
  v.push_back(3);
  v.push_back(2);
  v.push_back(3);
  REP(i,y)v.push_back(3);
  REP(i,x)v.push_back(4);
  v.push_back(4);
  v.push_back(1);
  map<int,char> m;
  if(ty>sy){
    m[1]='U';
    m[3]='D';
  }else{
    m[3]='U';
    m[1]='D';
  }
  if(tx>sx){
    m[2]='R';
    m[4]='L';
  }else{
    m[2]='R';
    m[4]='L';
  }
  for(auto i:v){
    cout<<m[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int D = 10;

ll d, g;
ll p[D], c[D];
ll ans = 100000;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> d >> g;
    for (int i = 0; i < d; ++i) {
        cin >> p[i] >> c[i];
    }

    vector<int> perm(d);
    for (int i = 0; i < d; ++i) perm[i] = i;
    do {
        ll score = 0, taken = 0;
        for (auto diff : perm) {
            ll tot = min(p[diff], (g - score) / (100 * (diff + 1)));
            taken += tot;
            // cout << diff << ' ' << score << ' ' << tot << '\n';
            score += tot * 100 * (diff + 1);
            if (tot == p[diff]) score += c[diff];
            score = min(score, g);
        }
        ans = min(ans, taken);
        // cout << taken << '\n';
    } while (next_permutation(perm.begin(), perm.end()));

    cout << ans;
}


Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<string>
#include<utility>
#include<iomanip>
#include<bitset>
#include<math.h>
using namespace std;

 
int main(){
 
	int n;
	cin >> n;
	vector<int> v(n);
	int max1 = -1;
	int max2 = -1;
	vector<int> b(n);
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		v[i] = a;
	}
	
	b = v;

	sort(b.begin(),b.end());
	max1 = b[n-1];
	max2 = b[n-2];

	for (int i = 0; i < n; i++)
	{
		if(v[i] == max1){
			cout << max2 << endl;
		}else{
			cout << max1 << endl;
		}
	}
	
}

Measured memory_bytes: 3200
val P = 1000000007L

data class Edge(val from: Int, val to: Int)

class FiniteField(val x: Long) {
    constructor(xi: Int): this(xi.toLong())
    operator fun plus(o: Long) = FiniteField((x + o) % P)
    operator fun plus(o: FiniteField) = this + o.x
    operator fun minus(o: Long) = FiniteField((x + P - o) % P)
    operator fun minus(o: FiniteField) = this - o.x
    operator fun times(o: Long) = FiniteField((x * o) % P)
    operator fun times(o: FiniteField) = this * o.x
    operator fun times(o: Int) = this * o.toLong()
    override fun toString() = x.toString()
}

fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val graph = Array(n, { mutableListOf<Edge>() })
    repeat(n - 1) {
        val (aRaw, bRaw) = readLine()!!.split(" ").map { it.toInt() }
        val a = aRaw - 1
        val b = bRaw - 1
        graph[a].add(Edge(a, b))
        graph[b].add(Edge(b, a))
    }

    fun solve(v: Int, parent: Int, depth: Int): FiniteField {
        if (graph[v].size == 0) return FiniteField(1)
        val numChildren = graph[v].size - if (depth > 0) 1 else 0
        val numColors = k - 1 - if (depth > 0) 1 else 0
        if (numColors < numChildren) return FiniteField(0)
        var ans = FiniteField(1)
        for (i in 0 until numChildren) {
            ans *= numColors - i
        }
        for (e in graph[v]) {
            if (e.to == parent) continue
            ans *= solve(e.to, v, depth + 1)
        }
        return ans
    }
    println(solve(0, -1, 0) * k)
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  string s;cin>>s;
  cout<<s.substr(0,4)<<' '<<s.substr(4,8)<<endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int N,M,X;
  cin>>N>>M>>X;
  int A[M];
  for(int i=0;i<M;i++){
    cin>>A[i];
  }
  
  int big=0;
  for(int i=0;i<M;i++){
    if(A[i]>X){
      big++;
    }
  }
  cout<<((M-big>big)? big:(M-big));
}
  

Measured memory_bytes: 256
n=int(input())
v=list(map(int,input().split()))
ans=0.0
temp=0
for _ in range(n):
    for i in range(n-1):
        if v[i]>v[i+1]:
            temp=v[i]
            v[i]=v[i+1]
            v[i+1]=temp

for i in range(n-1):
    v[i+1]=(v[i]+v[i+1])/2

print(v[n-1])

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		int t = 0;
		long n = N;
		while(n>0){
			t += n%10;
			n = n/10;
		}
		if (N%t == 0) System.out.println("Yes");
		else System.out.println("No");
	}
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int x = std::max(ri(), ri());
	int n = ri();
	std::cout << (n - 1) / x + 1 << std::endl;
	return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define esort(s) sort((s).begin(),(s).end())

typedef long long ll;
typedef pair<int,int> ipair;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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

    int a,b,c;
    cin >> a>>b>>c;
    if(a+b+c>=22) cout << "bust\n";
    else cout << "win\n";

    return 0;
}

Measured memory_bytes: 256
import bisect

N=int(input())
hito=[]
for i in range(N):
    h,p=map(int,input().split())
    hito.append((h+p,h,p))

hito.sort()
data=[0]
for i in range(0,N):
    gomi,h,p=hito[i]
    for j in range(len(data)-1,-1,-1):
        if j==len(data)-1:
            if h>=data[-1]:
                data.append(data[-1]+p)
            if h>=data[j-1] and j!=0:
                data[j]=min(data[j],data[j-1]+p)
        else:
            if h>=data[j-1] and j!=0:
                data[j]=min(data[j],data[j-1]+p)
    

print(len(data)-1)



Measured memory_bytes: 75060
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    ll a,v,b,w,t,d,s;
    cin >> a >> v >> b >> w >> t;
    if(w>=v){
        cout << "NO" << endl;
    } else {
        d=abs(a-b);
        s=abs(v-w);
        if(d<=s*t) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3576
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define INF 1000000000
#define ll long long

bool flag[1100001];
int main()
{
	int N, M, K;
	cin >> N >> M >> K;

	REP(i, 0, N + 1) {
		flag[M*i] = true;
	}
	REP(i, 0, M + 1) {
		flag[N*i] = true;
	}
	REP(i, 1, N + 1) {
		REP(j, 1, M + 1) {
			flag[M*i + N*j - 2 * (i * j)] = true;
		}
	}

	if (flag[K]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> v(n);
	for(int i=0;i<n;i++){
		cin >> v[i];
	}
	
	int Mx=0,Mn=v[0],cnt=0;
	for(int i=0;i<n;i++){
		Mx = max(Mx,v[i]-Mn);
		Mn = min(Mn,v[i]);
	}
	
	Mn=v[0];
	for(int i=0;i<n;i++){
		if(v[i]-Mn==Mx) cnt++;
		Mn = min(Mn,v[i]);
	}
	
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//imos
int main(){
    ll n;
    cin >> n;

    ll p[n+1] = {};
    REP(i,n)
    {
        cin >> p[i];
        --p[i];
    }

    ll res = 0;

    REP(i,n)
    {
        if(i == p[i])
        {
            if(i+1 == p[i+1])
            {
                ++res;
                ++i;//skip
            }
            else
            {
                ++res;
            }
        }
    }

    cout << res << endl;

    return 0;    
}



Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
 
int main(){
	int A, B, C;
	cin >> A >> B >> C;
 
	if((A==5&&B==5&&C==7)||(A==5&&B==7&&C==5)||(A==7&&B==5&&C==5)) cout << "YES" << endl;
    else cout << "NO" << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
    #include<string>
    using namespace std;
    int main(){
      int N, A, B;
      cin >> N >> A >> B;
      string kaz;
      int sum=0;
      int sum2=0;
      for(int i=1; i<N+1; i++){
        kaz = to_string(i);
        sum = 0;
        for(int j=0; j<kaz.size(); j++){
          sum += kaz.at(j) - '0';
        }
        if(A <= sum && sum <= B){
          sum2 += i;
        }
      }
      cout << sum2 << endl;
    }

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

vector<ll> pw2(51,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}

//a,b x
int main(){
	rep1(i,50) pw2[i]=2*pw2[i-1];
	string sin; cin>>sin;
	string s="AKIHABARA";
	vector<string> S(16,"");
	rep(i,16){
		ll tmp=i;
		vector<ll> f(9,2);
		f[0]=tmp/pw2[3];
		tmp%=pw2[3];
		f[4]=tmp/pw2[2];
		tmp%=pw2[2];
		f[6]=tmp/pw2[1];
		tmp%=pw2[1];
		f[8]=tmp/pw2[0];
		rep(j,9){
			if(f[j]==0) continue;
			else S[i]+=s[j];
		}
	}
	//rep(i,16) cout<<S[i]<<endl;
	rep(i,16){
		if(sin==S[i]){
			cout<<"YES";
			return 0;
		}
	}
	cout<<"NO";
}

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

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

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

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


void solve()
{
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2 - x1, dy = y2 - y1;
    int x3, y3, x4, y4;
    x3 = x2 - dy; y3 = y2 + dx; 
    x4 = x1 - dy; y4 = y1 + dx;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

int main(){
	int H, W, N;
	cin >> H >> W >> N;
	vector<int> a(N+1, 0);
	for (int i = 1; i <= N; i++){
		cin >> a[i];
	}

	vector<vector<int>> res(H, vector<int>(W, 0));
	int h = 0, w = 0;
	for (int color = 1; color <= N; color++){
		for (int i = 0; i < a[color]; i++){
			if (h%2 == 0){
				res[h][w] = color;
				w++;
				if (w == W){
					h++;
					w = W-1;
				}
			} else {
				res[h][w] = color;
				w--;
				if (w == -1){
					h++;
					w = 0;
				}
			}
		}
	}

	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++){
			cout << res[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}


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

using namespace std;

#define ll long long
#define ld long double

ll n , m , t;
ll ans1 , ans2 , ans3 , ans4;

int main(){
	cin >> t;
	while(t--){
		string s;
		cin >> s;
		if(s == "AC"){
			ans1++;
		}
		else if(s == "WA"){
			ans2++;
		}
		else if(s == "TLE"){
			ans3++;
		}
		else{
			ans4++;
		}
	}
	cout << "AC x " << ans1 << endl;
	cout << "WA x " << ans2 << endl;
	cout << "TLE x " << ans3 << endl;
	cout << "RE x " << ans4 << endl;
}


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

class Main{
	public static void main(String args[]){
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			int t = Integer.parseInt(br.readLine());

			for(int i = 0; i < t; i++){
				int n = Integer.parseInt(br.readLine());
				String str = br.readLine();
				System.out.println(solve(n, str));
			}
		}catch(Exception e){
			System.err.println(e);
		}
	}

	public static int solve(int n, String str){
		String str1 = str.substring(0, 2 * n);
		String str2 = str.substring(2 * n, 4 * n);
		//System.out.println(str1 + "\n" + str2);

		// 各通路を通る必要があるかどうか見る
		boolean routes[][] = new boolean[2][n+1];
		if(str1.charAt(0) == 'Y') routes[0][0] = true;
		for(int i = 1; i < n; i++){
			if(str1.charAt(2*i - 1) == 'Y' || str1.charAt(2*i) == 'Y') routes[0][i] = true;
		}
		if(str1.charAt(2*n-1) == 'Y') routes[0][n] = true;

		if(str2.charAt(0) == 'Y') routes[1][0] = true;
		for(int i = 1; i < n; i++){
			if(str2.charAt(2*i - 1) == 'Y' || str2.charAt(2*i) == 'Y') routes[1][i] = true;
		}
		if(str2.charAt(2*n-1) == 'Y') routes[1][n] = true;

		// 前から見ていく
		int which_first = -1;
		for(int i = 0; i < routes[0].length; i++){
			if(routes[0][i]){
				which_first = 0;
				break;
			}else if(routes[1][i]){
				which_first = 1;
				break;
			}
		}
		// 入れる棚が無いとき
		if(which_first == -1) return n+1;

		int which_last = -1;
		for(int i = routes[0].length - 1; i >= 0; i--){
			if(routes[0][i]){
				which_last = 0;
				break;
			}else if(routes[1][i]){
				which_last = 1;
				break;
			}
		}

		int result = n;
		for(int i = 0; i < routes[0].length; i++){
			if(routes[0][i]) result++;
			if(routes[1][i]) result++;
		}
		// System.out.println(which_first + " " + which_last);
		result += which_first;
		result += which_last;

		//printBoolean(routes);
		return result;
	}

	public static void printBoolean(boolean routes[][]){
		for(int i = 0; i < routes[0].length; i++){
			if(routes[0][i]){
				System.out.print("T");
			}else{
				System.out.print("F");
			}
		}
		System.out.print("\n");
		for(int i = 0; i < routes[0].length; i++){
			if(routes[1][i]){
				System.out.print("T");
			}else{
				System.out.print("F");
			}
		}
	}
}

Measured memory_bytes: 25572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, q, num, ans = 0;
ll S[100100];
int main() {
    cin >> n;
    for (ll i = 0; i < n; i++) cin >> S[i];
    cin >> q;
    for (ll i = 0; i < q; i++) {
        cin >> num;
        int index = lower_bound(S, S + n, num)-S;
        if(S[index] == num) ans++; 
    }

    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 3988
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():
    S = input()
    A = [int(c) for c in S]

    temp1=[0]*len(S)
    for i in range(0,len(S),2):
        temp1[i]=1

    temp2=[0]*len(S)
    for i in range(1,len(S),2):
        temp2[i]=1

    cnt1=0
    cnt2=0
    for i in range(len(S)):
        if A[i]!=temp1[i]:
            cnt1+=1
        if A[i]!=temp2[i]:
            cnt2+=1

    print(min(cnt1,cnt2))





resolve()

Measured memory_bytes: 5620
function Main(input){
	input=input.split(" ");
	let a=parseInt(input[0],10);
	let b=parseInt(input[1],10);
	let c=parseInt(input[2],10);
	if (a > b) {
		[a, b] = [b,a];
		if (b > c) {
			[b,c ] = [c,b];
			if (a > b) {
				[a,b] = [b,a];
			}
		} else if (a > c) {
			[a,c] = [c,a];
		}
	} else if (a > c) {
		[a,c] = [c,a];
		[b,c] = [c,b];
	} else if (b > c) {
		[b,c] = [c,b];
	}
	console.log("%d %d %d", a, b, c)		
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15128
def getval():
    s = int(input())
    return s


def main(s):
    #Combination calculation using mod m
    mod = 10**9+7
    lim = 10**5
    fact = [1,1]
    inv = [1,1]
    finv = [1,1]
    for i in range(2,lim+1):
        fact.append((fact[i-1] * i) % mod)
        inv.append(mod - inv[mod%i] * (mod // i) % mod)
        finv.append(finv[i-1] * inv[i] % mod)
    def mod_comb(n,k):
        if n<k:
            return 0
        if n<0 or k<0:
            return 0
        return fact[n] * (finv[k] * finv[n-k] % mod) % mod

    ans = 0
    for i in range(1,700):
        if 3*i>s:
            break
        n = s - 3*i
        temp = mod_comb(n+i-1,n)
        ans += temp 
        ans %= mod 

    print(ans)
        
    

if __name__=="__main__":
    s = getval()
    main(s)

Measured memory_bytes: 86544
#include <stdio.h>

int main(void) {
	
	int h,m,n;
	scanf("%d%d%d",&h,&m,&n);
	
	if(h<m && m<n)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	
	
	// your code goes here
	return 0;
}



Measured memory_bytes: 2124
#include "bits/stdc++.h"
using namespace std;
int main() {
    long long n; cin >> n;
    string s;
    while (n) {
        if (n % 2)s = '1' + s;
        else s = '0' + s;
        n = ceil((double)n / (double)-2);
    }
    if (s == "")s = "0";
    cout << s << endl;
}

Measured memory_bytes: 256
#include"iostream"
#include"algorithm"
using namespace std;

int main()
{
	int n, x, m[110];
	cin >> n >> x;
	int sum = 0;
	int mini = 200000;
	for (int i = 0; i < n; i++)
	{
		cin >> m[i];
		sum += m[i];
		mini = min({ mini,m[i] });
	}
	cout << (x - sum) / mini + n << endl;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

/*
functionの中を書いて使う
宣言の時に単位元を書く
*/
template<typename T>
class segtree{
	int n;vector<T> dat;T ZERO;
public:
	segtree(int n_,T zero):ZERO(zero){
	  n = 1;
	  while(n < n_)n*=2;
	  dat.resize(2*n);
	  for(int i = 0;i < 2*n;i++)dat[i] = ZERO;
	}
	void update(int k, int a){
	  k += n - 1;dat[k] = a;
	  while(k > 0){
		k = (k-1)/2;
		dat[k] = function(dat[k*2+1],dat[k*2+2]);
	  }
	}
	
	T function(T a,T b){
		return min(a,b);
	}

	// 外からの呼び出しはquery(a,b,0,0,n) [l,r)に対応していることを示す。
	T query(int a,int b,int k,int l,int r){
	  if( r <= a || b <= l) return ZERO;
	  //[a,b)が[l,r)を完全に含んでいればこの節点の値
	  if(a <= l && r <= b)  return dat[k];
	  else{
		T vl = query(a,b,k*2+1,l,(l+r)/2);
		T vr = query(a,b,k*2+2,(l+r)/2,r);
		return function(vl,vr);
	  }
	}
	
	T que(int a,int b){return query(a,b,0,0,n);}
};

int main(){
	int n,q;cin >> n >> q;
	segtree<ll> st(n,(1LL<<31)-1);
	
	REP(i,q){
		int a,b,c;cin >> a >> b >> c;
		if(a == 0){
			st.update(b,c);
		}
		else{
			cout << st.que(b,c+1) << endl;
		}
	}
	
	return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define PB emplace_back

using namespace std;

const int N = 1e6+100;

long long int dp[N], a[N], mod=998244353;

long long int wop(long long int x, long long int y) {
    long long int ret=1;
    for(;y>=1;y/=2) {
        if(y&1)ret*=x;
        x*=x;
    }
    return ret;
}

bool PA(string s) {
    for(int i = 0 ; i < s.size() ; i++ ) {
        if(s[i]!=s[s.size()-i-1])return 0;
    }
    return 1;
}

int main () {
    ios::sync_with_stdio(0);
    long long int n, s, ans=0;
    cin >> n >> s;
    for(int i = 0 ; i < n ; i++ ) {
        cin >> a[i];
        if(i==0) {
            dp[0]=dp[a[i]]=1;
        }
        else {
            for(int j = s ; j >= a[i] ; j-- ) {
                dp[j]+=dp[j-a[i]];
                dp[j]%=mod;
            }
            dp[0]++;
            dp[a[i]]++;
            dp[0]%=mod;
            dp[a[i]]%=mod;
        }
        ans+=dp[s];
        ans%=mod;
    }
    cout << ans;
}


Measured memory_bytes: 2304
#include<stdio.h>
#include<string.h>
char a[60],b[60],c[60];
int main(void)
{
    int z=1;
    gets(a);
    gets(b);
    strcpy(c,a);
    int i,j;
    int m=strlen(a),n=strlen(b);
    for(j=m-1; j>=0; j--)
    {
        z=1;
        int g=n-1;
        for(i=j,g=n-1; g>=0; i--,g--)
        {
            if(c[i]==b[g]||c[i]=='?')
            {
                c[i]=b[g];
            }
            else
            {
                z=0;
                break;
            }
        }
        if(z==0)
        {
            strcpy(c,a);
        }
        else
        {
            break;
        }
    }
    if(z==1)
    {
        for(i=0; i<m; i++)
        {
            if(c[i]=='?')
                c[i]='a';
        }
        puts(c);
    }
    else
        printf("UNRESTORABLE");
}



Measured memory_bytes: 128