akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using ll = long long;

using namespace std;

typedef struct edge {ll to, cost;}edge;
typedef pair<ll, ll> P;

ll V, N, Q, K;
vector<vector<edge> > G;
vector<ll> d;
const long long INF = 1000000000000000;

int main()
{
    cin >> N;

    G.resize(N + 1);
    d.resize(N + 1);

    for(ll i = 0;i < N - 1;i++)
    {
        ll a, b, c;

        cin >> a >> b >> c;

        edge e;
        e.to = a;
        e.cost = c; 
        G[b].push_back(e);
        e.to = b;
        G[a].push_back(e);
    }

    cin >> Q >> K;

    priority_queue<P, vector<P>, greater<P> > pq;

    pq.push(make_pair(0, K));

    fill(d.begin(), d.end(), INF);

    d[K] = 0;

    while(!pq.empty())
    {
        P p = pq.top();
        pq.pop();

        ll c = p.first;
        ll from = p.second;

        if(d[from] < c)
        {
            continue;
        }
        for(ll i = 0;i < G[from].size();i++)
        {
            edge e = G[from][i];
            if(d[e.to] > d[from] + e.cost)
            {
                d[e.to] = d[from] + e.cost;
                pq.push(make_pair(d[e.to], e.to));
            }
        }
    }
    for(ll i = 0;i < Q;i++)
    {
        ll x, y;
        cin >> x >> y;
        cout << d[x] + d[y] << endl;
    }

    return 0;
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	int n;
	cin >> n;
	vector<int> a(3*n);
	rep(i,3*n) cin >>a[i];
	SORT(a);
	ll ans = 0 ;
	rSORT(a);
	int in = 1;
	rep(i,n){
		ans += a[in];
		in += 2 ;
	}
	cout <<ans <<endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
using ll = long long;
#define pi 3.1415926

int x[3];

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    x[0] = a;
    x[1] = b;
    x[2] = c;
    sort(x, x+3);
    cout << x[2]*10 + x[1] + x[0];
}
	


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



n = int(input())
b_L = []

for _ in range(n):
    b_L.append(int(input()))

for num in b_L:
    for i in range(0,3):
        if a_1[i] == num:
            a_1[i] = True
        if a_2[i] == num:
            a_2[i] = True
        if a_3[i] == num:
            a_3[i] = True



# 横判定
if a_1.count(True)==3 or a_2.count(True)==3 or a_3.count(True)==3:
    print("Yes")
    exit()

# 縦判定
for i in range(0,3):
    if a_1[i] == True and a_2[i] == True and a_3[i] == True:
        print("Yes")
        exit()

# 斜め判定
if a_1[0] == True and a_2[1] == True and a_3[2] == True:
    print("Yes")
    exit()
if a_1[2] == True and a_2[1] == True and a_3[0] == True:
    print("Yes")
    exit()

print("No")



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

inline int toDigit(char c) { return c - '0'; }

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

	long long a;
  	string bs;
  	int b = 0;

  	cin >> a >> bs;
  		
  	int p = 1;
  	for(int i = bs.length() - 1; i >= 0; i--) {
  		if(bs[i] == '.') { continue; }
  		b += p * toDigit(bs[i]);
  		p *= 10;
  	}

  	long long res = a * b / 100;
  	cout << res << "\n";
 
	return 0;
}

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

#define rep(i, x, n) for(int i=(x);i<(n);i++)
#define reps(i, x, n) for(int i=(x);i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){ return (y != 0 ? gcd(y, x % y) : x); }
//最小公倍数
lol lcm(lol x, lol y){ return ((x * y) / gcd(max(x, y), min(x, y))); }

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n, ans = 0;
  cin >> n;
  for(int i = 1;i < n;i ++){
    for(int j = 1;j < n;j ++){
      if(i * j < n){
	ans ++;
      } else {
	break;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
    int n; cin >> n;
    int r,g,b; r=g=b=-1;
    mint ans=1;

    rep(i,n){
        int a; cin >> a;
        mint counter=0;
        if(a==(r+1)) counter+=1; 
        if(a==(g+1)) counter+=1;
        if(a==(b+1)) counter+=1;
        ans*=counter;
        if(a==(r+1)) r++;
        else if(a==(g+1)) g++;
        else b++;
    }
	
	cout << ans.x << endl;

    return 0;
}


// 出力は.xで！！！！

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

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

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

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = 1LL << 61;


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll K;
    cin >> N >> K;
    vector<ll> w(N);
    vector<ll> d(N);
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> d[i];
    }

    ll inf = 0;
    ll sup = INF<ll>;
    auto check = [=](const ll mid) {
        ll n = 0;
        for (int i = 0; i < N; i++) {
            n += (mid < w[i]) ? 0LL : (ll)((mid - w[i]) / d[i] + 1);
        }
        return n >= K;
    };
    while (inf < sup - 1) {
        const ll mid = (inf + sup) / 2;
        if (check(mid)) {
            sup = mid;
        } else {
            inf = mid;
        }
    }
    if (check(sup - 1)) {
        cout << sup - 1 << endl;
    } else {
        cout << sup << endl;
    }
    return 0;
}


Measured memory_bytes: 3456
l,r=map(int,input().split())
mod=2019
a=l//mod
b=r//mod
if a<b:
  print(0)
else:
  c=l%mod
  d=r%mod
  p=8101919
  for i in range(c,d):
    for j in range(i+1,d+1):
      p=min(p,(i*j)%mod)
  print(p)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(int i=a; i<b; i++)
#define loopb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli power(lli x, lli y){
    lli res = 1;
    x = x ;
    while (y > 0) {
        if (y & 1)
            res = (res*x) ;
        y = y>>1;
        x = (x*x);
    }
    return res;
}
lli solve(){
	lli n, k;
	cin>>n>>k;
	vll a(n);
	loop(i, 0, n)	cin>>a[i];
	vll f(n);
	loop(i, 0, n)	cin>>f[i];
	sort(a.begin(), a.end());
	sort(f.begin(), f.end(), greater<int>());
	lli lo = 0;
	lli hi = a[0] * f[0];
	loop(i, 1, n)	hi = max(hi, a[i] * f[i]);
	while(lo < hi){
		lli mid = lo + (hi - lo)/2;
		lli count = 0;
		loop(i, 0, n){
			lli temp = mid / f[i];
			if(temp < a[i])
				count += a[i] - temp;
 		}
 		if(count > k)
 			lo = mid+1;
 		else	
 			hi = mid;
	}
	cout<<lo<<"\n";
	return 0;
}
int main(){
	fastio;
	lli t;
//	cin>>t;
	t = 1;
	while(t>0){
		t--;
		solve();
	}
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define PI 3.14159265359
#define rep(i,a) for(int i=0;i<a;i++)

//int型を受け取ってその桁数を返す
int check_digits(int n, int m) {
	int digits = 0;
	while (n != 0) {
		n /= m;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum = 0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


//入力された文字列が回文か判断してboolを返す
bool is_kaibun(string s) {
	string s_r(s.rbegin(), s.rend());
	return (s == s_r);
}


void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }


//提出言語もしっかり確認して…
//問題文を落ち着いて読む！
//型に注意！！
//出力例もちゃんと全部見る！！！！！
int main() {
	int n, k, m;
	cin >> n >> k >> m;
	vi memo(n,0);
	int temp;
	rep(i, m) {
		cin >> temp;
		memo[temp-1]++;
	}

	rep(i, n) {
		if (k - (m - memo[i]) > 0)yes();
		else no();
	}

	system("pause");
	return 0;
}


Measured memory_bytes: 1272
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include "iomanip"
#include <cstdio>
#include <cstring>
#include <set>
#include <vector>
#include <fstream>
#include <algorithm>
#include <queue>
#include <cassert>
#include <stack>


using namespace std;


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


    int n;
    cin >> n;
    cout << (double)((n + 1) / 2) / n;
    return 0;
}



Measured memory_bytes: 256
from collections import defaultdict
import bisect

def main():
    q = int(input())
    d = defaultdict(int)

    inserted_flag = False
    sorted_keys = None

    for _ in range(q):
        para = input().split()

        if para[0] == "0":
            d[para[1]] = int(para[2])
            inserted_flag = True

        elif para[0] == "1":
            if para[1] in d.keys():
                print(d[para[1]])
            else:
                print("0")

        elif para[0] == "2":
            if para[1] in d.keys():
                del d[para[1]]
                inserted_flag = True
            
        elif para[0] == "3":
            if sorted_keys is None:
                sorted_keys = sorted(d.keys())

            if inserted_flag:
                sorted_keys = sorted(d.keys())
                inserted_flag = False

            l = bisect.bisect_left(sorted_keys, para[1])
            r = bisect.bisect_right(sorted_keys, para[2])

            for i in range(l, r):
                print("{} {}".format(sorted_keys[i], d[sorted_keys[i]]))

main()



Measured memory_bytes: 38212
using System;

namespace ABC111_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine();
            var a = string.Empty;
            foreach (var item in n)
            {
                if (item == '1') a += '9';
                else a += 1;
            }
            Console.WriteLine(a);
        }
    }
}


Measured memory_bytes: 11092
/*
author: Apoorv Singh
*/

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

using namespace std;
using namespace __gnu_pbds;

typedef vector <int> vi;
typedef vector <long long> vl;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define ll long long
#define pb push_back   
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " " << (x) << endl;
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second

ll modulo = 1e9 + 7;

template <class X>

void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    int arr[n];
    FOR(i,0,n)
        cin >> arr[i];
    int M = 1e5 + 10;
    int x[M] = {0}, y[M] = {0};
    for (int i = 0; i < n; i += 2)
        ++x[arr[i]];
    priority_queue<pii> pq1, pq2;
    FOR(i,0,M)
    {
        if (x[i] > 0)
            pq1.push({x[i],i});
    }
    for (int i = 1; i < n; i += 2)
        ++y[arr[i]];
    FOR(i,0,M)
    {
        if (y[i] > 0)
            pq2.push({y[i],i});
    }
    int ans = 0;
    if (pq1.top().S != pq2.top().S)
        ans = n - (pq1.top().F + pq2.top().F);
    else
    {
        int a,b;
        a = pq1.top().F;
        pq1.pop();
        b = pq2.top().F;
        pq2.pop();
        if (pq1.empty() and pq2.empty())
            ans = n/2;
        else if (pq1.empty())
            ans = n/2-pq2.top().F;
        else if (pq2.empty())
            ans = n/2-pq1.top().F;
        else
        {
            int x1 = n-(a + pq2.top().F);
            int x2 = n-(b + pq1.top().F);
            ans = min(x1,x2); 
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2552
#include <bits/stdc++.h>
typedef long long ll;
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define dbg2(x,y) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl
#define dbg3(x,y,z) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<", "<<#z<<" = "<<z<<endl
#define dbg4(x,y,z,q) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<", "<<#z<<" = "<<z<<", "<<#q<<" = "<<q<<endl
#define dbg_array(x,sz) for (int i = 0; i < sz; ++i) cout << x[i] << " \n"[i==sz-1]
using namespace std;

const ll N = 1000 + 9, M = 400 - 9, Max_ans = 1LL * (1e16);
int a[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
#ifdef ECLIPSE
	freopen("input.in", "rt", stdin);
	//freopen("output.out", "wt", stdout);
#endif
	int n, k, ans = 0;
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < k; ++i)
		ans += a[i];
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      cout << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) {
    cin >> A[i];
  }

  ll Pmin = 2;
  ll ans = A[0] - 1;

  repp(i, 1, N - 1) {
    if (A[i] < Pmin)
      continue;

    if (A[i] == Pmin) {
      Pmin++;
      continue;
    }

    ans += (A[i] - 1) / Pmin;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys


def solve(X: int):
    gohyaku = X//500
    X %= 500
    go = X // 5

    print(gohyaku*1000+go*5)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import sys
sys.setrecursionlimit(1000000)
memo = {0:1}

def fact(x):
  if x in memo:
    return memo[x]
  memo[x] = x * fact(x - 1)
  return memo[x]

def comb(x, y):
  return fact(x) // fact(x - y) // fact(y)

n, k = map(int, input().split())
print(comb(n + k - 1, k - 1) % 1000000007)


Measured memory_bytes: 9680
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

string S, T;
string A = "";

int main() {
	
	cin >> S >> T;
	A = S;
	A += S;
	int flag = 0;
	for(int i = 0; i < S.size(); i++) {
		// cout << A.substr(i, S.size()) << " ";
		string B = A.substr(i, S.size());
		if(B == T)
		{
			// cout << "YES";
			flag = 1;
			break;
		}
	}
	if(!flag) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}

	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include<stdio.h>

void trace(int A[], int N){
  int i;
  for(i =0; i < N; i++){
    if(i > 0) printf(" ");
    printf("%d",A[i]);

  }

  printf("\n");
}

void insertionSort(int A[], int N){
  int j,i,v;
  for(i = 1; i < N; i++){
    v =A[i];
    j = i-1;

    while(j >= 0 && A[j] > v){
      A[j +1] = A[j];
      j--;

  }
    A[j +1] = v;
    trace(A, N);
  }
}

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

  scanf("%d",&N);
  for(i = 0;i < N; i++) scanf("%d",&A[i]);

  trace(A, N);
  insertionSort(A, N);
  
  return 0;
}



Measured memory_bytes: 2128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcorder_BeginnerContest_118
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int menCnt = line[0];
            int itemCnt = line[1];
            int[] cntArr = new int[itemCnt + 1];

            for (int i = 0; i < menCnt; i++)
            {
                int[] tmpLine = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                for (int j = 0; j < tmpLine[0]; j++)
                {
                    cntArr[tmpLine[j + 1]]++;
                }
            }

            int ret = 0;
            for (int i = 1; i <= itemCnt; i++)
            {
                if (menCnt == cntArr[i]) ret++;
            }

            Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <valarray>
#include <vector>

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

using namespace std;

void solution()
{
    rep(i,5){
        int x;
        cin >> x;
        if(x == 0){
            cout << (i+1) << '\n';
            break;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solution();
    return 0;
}


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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int i = 0;
    for(; i<k; i++) {
        if (a < b) break;
        b *= 2;
    }
    for(; i<k; i++) {
        if (b < c) break;
        c *= 2;
    }
    if ((a < b) && (b < c)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    for(int i=0; i<N; i++){
        int K[100], P[100];
        cin >> K[i] >> P[i];
            if(K[i]%P[i]!=0)
                cout << K[i]%P[i] << endl;
            else
                cout << P[i] << endl;
}
} 


Measured memory_bytes: 3100
from collections import Counter
from _collections import defaultdict
n = int(input())
ans = defaultdict(int)
for i in range(n):
    s = input()
    ans[s] += 1
print('AC x ' + str(ans['AC']))
print('WA x ' + str(ans['WA']))
print('TLE x ' + str(ans['TLE']))
print('RE x ' + str(ans['RE']))


Measured memory_bytes: 9300
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
    //Seiranchan!
    int D;
    cin >> D;

    if(D==25){
        cout << "Christmas" <<endl;
    }else if(D==24){
        cout << "Christmas Eve"<<endl;
    }else if(D==23){
        cout << "Christmas Eve Eve"<<endl;
    }else{
        cout << "Christmas Eve Eve Eve" <<endl;
    }
}

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

struct node{
  int key;
  struct node *right;
  struct node *left;
  struct node *parent;
};

struct node *root;
struct node *NIL;

struct node *find(struct node *, int);
void insert(int);
void inorder(struct node *);
void preorder(struct node *);

int main(){

  int i,n,x;

  struct node *t;
  char *com;
  char *cominsert = "insert";
  char *comprint = "print";

  com = (char*)malloc(7*sizeof(char));  

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%s", com);
    if(com[0] == 'f'){
      scanf("%d", &x);
      t = find(root, x);
      if(t != NIL){
	printf("yes\n");
      }
      else{
	printf("no\n");
      }
    }
    else if(strncmp(com,cominsert,6)==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strncmp(com,comprint,5)==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

struct node *find(struct node *u, int k){
  while (u != NIL && k != u->key){
    if(k < u->key){
      u = u->left;
    }
    else {
      u = u->right;
    }
  }
  return u;
}

void insert(int k){

  struct node *y = NIL;
  struct node *x = root;
  struct node *z;

  z = (struct node *)malloc(sizeof(struct node));

  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x-> key){
      x = x->left;
    }
    else {
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL) {
    root = z;
  }
  else{
    if(z->key < y->key) {
      y->left = z;
    }
    else {
      y -> right = z;
    }
  }
}

void inorder(struct node *u){
  if(u == NIL){
    return;
  }
  inorder(u->left);
  printf(" %d", u->key);
 
  inorder(u->right);
}

void preorder(struct node *u){
  if(u == NIL) {
    return;
  }
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}



Measured memory_bytes: 20448
#include<stdio.h>
int c[1500][1500];
int sublong(const char *s){
 int len = 0;
 while (*s++){
   len++;
 }
 return len;
}

int lcs(char a[], char b[], int la, int lb){
 int i, j, common = 0;

 for(i=0; i<=la; i++){
   c[i][0]=0;
 }
 for(j=0; j<=lb; j++){
   c[0][j]=0;
 }

 for(i=0; i<=la-1; i++){
   for(j=0; j<=lb-1; j++){
     if (a[i] == b[j]) {
       c[i+1][j+1] = c[i][j] + 1;
     } else {
       if (c[i][j+1] >= c[i+1][j]) {
         c[i+1][j+1] = c[i][j+1];
       } else {
         c[i+1][j+1] = c[i+1][j];
       }
     }
     if (common <= c[i+1][j+1]) {
       common = c[i+1][j+1];
     }
   }
 }

 return common;
}

int main(){
 int mlong,klong;
 int  num, i,Max[152];
 char mother[1500], kids[1500];

 scanf("%d", &num);
 for(i=1;i<=num;i++){
   scanf("%s",mother);
   scanf("%s",kids);
   mlong = sublong(mother);
   klong = sublong(kids);
   Max[i] = lcs(mother,kids,mlong,klong);
 }
 
 for(i=1;i<=num;i++){
   printf("%d\n",Max[i]);
 }

 return 0;
}

Measured memory_bytes: 7592
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if((a+b)%2==0)
    cout << (a+b)/2 << endl;
  else
    cout << (a+b)/2+1 << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
a = int(input())


if n < 500:
    if n <= a:
        print('Yes')
    else:
        print('No')
else:    
    amari = n%500
    if amari <= a:
        print('Yes')
    else:
        print('No')

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

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

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


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

  vector<int64_t> a(21);

  a[0] = 1;
  for(int64_t i=0; i<n; i++){
    a[i+1] = a[i] * (i+1);
  }

  cout << a[n] << endl;

}
  
  


Measured memory_bytes: 3076
a=input()
ans=0
if a=='SUN':
    a=7
elif a=='MON':
    a=6
elif a=='TUE':
    a=5
elif a=='WED':
    a=4
elif a=='THU':
    a=3
elif a=='FRI':
    a=2
else:
    a=1

print(a)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int vis[111111],pos;
struct rg
{
	int l,r,id;
}a[111111],b[111111];
bool cmp1(rg x,rg y)
{
	if (x.l>y.l) return 1;
	if (x.l<y.l) return 0;
	return x.r>y.r;
}
bool cmp2(rg x,rg y)
{
	if (x.r<y.r) return 1;
	if (x.r>y.r) return 0;
	return x.l<y.l;
}
int chg(int x,int y,int &p)
{
	int s;
	if (p>=x&&p<=y)
	{
		return 0;
	}
	if (p>y)
	{
		s=p-y;
		p=y;
		return s;
	}
	if (p<x)
	{
		s=x-p;
		p=x;
		return s;
	}
}
int main()
{
	long long ans1=0,ans2=0;
	int n,i,j,l,r;
	ios_base::sync_with_stdio(0);
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>l>>r;
		a[i]=b[i]=(rg){l,r,i};
	}
	pos=0;
	memset(vis,0,sizeof(vis));
	sort(a+1,a+n+1,cmp1);sort(b+1,b+n+1,cmp2);
	i=1;j=1;
	while (i<=n&&j<=n)
	{
		while (i<=n&&vis[a[i].id]) i++;
		if (i>n) break;
		ans1+=chg(a[i].l,a[i].r,pos);
		vis[a[i].id]=1;
		while (j<=n&&vis[b[j].id]) j++;
		if (j>n) break;
		ans1+=chg(b[j].l,b[j].r,pos);
		vis[b[j].id]=1;
	}
	while (i<=n)
	{
		while (i<=n&&vis[a[i].id]) i++;
		if (i>n) break;
		ans1+=chg(a[i].l,a[i].r,pos);
		vis[a[i].id]=1;
	}
	while (j<=n)
	{
		while (j<=n&&vis[b[j].id]) j++;
		if (j>n) break;
		ans1+=chg(b[j].l,b[j].r,pos);
		vis[b[j].id]=1;
	}
	ans1+=abs(pos);
	pos=0;
	memset(vis,0,sizeof(vis));
	sort(a+1,a+n+1,cmp2);sort(b+1,b+n+1,cmp1);
	i=1;j=1;
	while (i<=n&&j<=n)
	{
		while (i<=n&&vis[a[i].id]) i++;
		if (i>n) break;
		ans2+=chg(a[i].l,a[i].r,pos);
		vis[a[i].id]=1;
		while (j<=n&&vis[b[j].id]) j++;
		if (j>n) break;
		ans2+=chg(b[j].l,b[j].r,pos);
		vis[b[j].id]=1;
	}
	while (i<=n)
	{
		while (i<=n&&vis[a[i].id]) i++;
		if (i>n) break;
		ans2+=chg(a[i].l,a[i].r,pos);
		vis[a[i].id]=1;
	}
	while (j<=n)
	{
		while (j<=n&&vis[b[j].id]) j++;
		if (j>n) break;
		ans2+=chg(b[j].l,b[j].r,pos);
		vis[b[j].id]=1;
	}
	ans2+=abs(pos);
	cout<<max(ans1,ans2)<<endl;
	return 0;
}

Measured memory_bytes: 3200
module global_variables
end module global_variables
program main
  use global_variables
  implicit none
  integer i,res
  character(3) s
  read *, s
  res = 0
  do i=1,3
    if (s(i:i) .eq. '1') then
      res = res + 1
    endif
  enddo
  print '(i0)', res
end program main


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Peaks | diff Peaks.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Peaks.cpp && ./a.out

/*
 
 5/3/2020
 
 5:05-
 
 */

const int MAX_N=1e6+1;
int H[MAX_N];
int N,M;
VI G[MAX_N];


void solve() {
  int res=0;
  REP(u,N) {
    int cnt=0;
    FORR(v,G[u]) cnt+=H[v]>=H[u];
    res+=cnt==0;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>M;
  REP(i,N) cin>>H[i];
  REP(i,M) {
    int u,v; cin>>u>>v;
    --u,--v;
    G[u].push_back(v),G[v].push_back(u);
  }
  solve();
  
  return 0;
}


Measured memory_bytes: 30252
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    ll X,Y;
    cin >> X >> Y;
    int count = 0;
    ll cal = X;
    while(cal <= Y){
        count++;
        cal *= 2;
    }
    cout << count << endl;
    return 0;
}


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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 29
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

int n,t;
vector<ll> a;
ll ma = -1;
ll mi = -1;
ll sa1 = -1,sa2 = -1;

int main(){
  cin >> n >>t;
  int x;
  cin >> x;
  mi = x;
  FOR(i,1,n){
    ll x;
    cin >> x;
    a.push_back(x-mi);
    if(mi > x) mi = x;
  }
  sort(a.begin(),a.end(),greater<ll>());
  int cnt = 1;
  FOR(i,1,n){
    if(a[0] == a[i]){
      cnt++;
      continue;
    }
    break;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1528
#include<stdio.h>
int main()
{
	int n,sum=0;scanf("%d",&n);
	int a[50];
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			sum+=a[i]*a[j];
		}
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    char[] s = sc.next().toCharArray();
    boolean ans = true;
    for(int i = 0;i < 3;i++){
      if(s[i] == s[i+1])  ans = false;
    }
    if(ans){
      System.out.println("Good");
    }else{
      System.out.println("Bad");
    }
  }
}


Measured memory_bytes: 23764
n = int(input())
l = [[0]*3 for _ in range(n)]

for i in range(n):
    x, y = input().split()
    l[i][0] = x
    l[i][1] = int(y)*-1
    l[i][2] = i + 1

l.sort()

for i in range(n):
    print(l[i][2])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main()
{
    int N;
    cin >> N;
    double v[N+10];
    rep(i,N) cin >> v[i];

    sort(v, v+N);

    double ans = v[0];
    rep(i,N-1)
    {
        ans = (ans + v[i+1]) / 2.0;
    }
    cout << setprecision(10) << fixed << ans << endl;
}

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

#define File freopen("in.txt","r",stdin);
#define ll long long

const int mINF = 0x80000000;
const int INF = 0x3f3f3f3f;
const int maxn= 100000+10;

int a[maxn];

int main()
{
    int n,x;
    cin>>n>>x;
    for(int i=0; i<n; i++)  scanf("%d",a+i);

    ll de=0,ans=0,sum=0;
    for(int i=1; i<n; i++){
        sum = a[i-1]+a[i];
        if(sum > x){
            de = sum - x;
            if(de > a[i]){
                a[i] = 0;
                ans += de;
            }else{
                a[i] = a[i] - de;
                ans += de;
            }
        }else{
            ans += 0;
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ1_9_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string _str = Console.ReadLine();

            int _n = int.Parse(Console.ReadLine());
            string[] _order;

            for (int i = 0; i < _n; i++)
            {
                _order = Console.ReadLine().Split(' ');


                if (_order[0] == "replace")
                {
                    if (_order[1] == "0")
                    {
                        _str = _order[3]
                            + _str.Substring(int.Parse(_order[2]) + 1);
                    }
                    else if (_order[2] == _str.Length.ToString())
                    {
                        _str = _str.Substring(0, int.Parse(_order[1]))
                            + _order[3];
                    }
                    else
                    {
                        _str = _str.Substring(0, int.Parse(_order[1]))
                            + _order[3]
                            + _str.Substring(int.Parse(_order[2]) + 1);
                    }
                }
                else if (_order[0] == "reverse")
                {
                    char[] str;
                    string strFinaly;
                    if (_order[1] == "0")
                    {
                        str = _str.Substring(int.Parse(_order[1]), int.Parse(_order[2]) + 1).ToArray();
                        Array.Reverse(str);
                        strFinaly = new string(str);
                        _str = strFinaly
                            + _str.Substring(int.Parse(_order[2]) + 1);
                    }
                    else if (_order[2] == _str.Length.ToString())
                    {
                        str = _str.Substring(int.Parse(_order[1]) + 1).ToArray();
                        Array.Reverse(str);
                        strFinaly = new string(str);
                        _str = _str.Substring(0, int.Parse(_order[1]))
                            + strFinaly;

                    }
                    else
                    {
                        str = _str.Substring(int.Parse(_order[1]), int.Parse(_order[2]) - int.Parse(_order[1]) + 1).ToArray();
                        Array.Reverse(str);
                        strFinaly = new string(str);
                        _str = _str.Substring(0, int.Parse(_order[1]))
                            + strFinaly
                            + _str.Substring(int.Parse(_order[2]) + 1);
                    }
                }
                else if (_order[0] == "print")
                {
                    Console.WriteLine(_str.Substring(int.Parse(_order[1]), int.Parse(_order[2]) - int.Parse(_order[1]) + 1));
                }
            }
        }
    }
}



Measured memory_bytes: 18248
from heapq import heapify, heappop, heappush
from collections import deque
N,M=map(int,input().split())
A=[0]*N #ラグ
B=[0]*N #報酬
C=[0]*N
for i in range(N):
    A[i],B[i]= map(int,input().split())
    C[i]=[A[i],B[i]]
C.sort()
D=deque(C)
reward=0
#print(D)

h=[]
heapify(h)

for i in range(M-1,-1,-1):   
    while D:
        e = D.popleft()
        if e[0]==M-i:
            heappush(h,-1*e[1])
        else:
            D.appendleft(e)
            break
    #print(h)
    if h:
        reward += (-1)*heappop(h)
        
print(reward)


Measured memory_bytes: 26896
#![allow(unused)]

use std::cmp;
use std::io::{self, BufRead};
use std::iter;
use std::collections::*;

macro_rules! destruct_ {
  ($e: expr, ()) => (
    //assert!($e.next().is_none())
  );
  ($e: expr, ($arg: ident, $( $args: ident )*)) => (
    $arg = $e.next().unwrap();
    destruct_!($e, ($($args)*))
  );
  ($e: expr, ($arg: ident $( $args: ident )*)) => (
    $arg = $e.next().unwrap();
    destruct_!($e, ($($args)*))
  );
}

macro_rules! split {
  ($e: expr, ($($name: ident)*)) => {
    let mut iter = $e.into_iter();
    destruct_!(iter, ($($name)*));
  }
}

macro_rules! gets {
  ($id: ident) => (
    let stdin = io::stdin();
    $id = Vec::new();
    for line in stdin.lock().lines() {
      $id.push(
        line
          .unwrap()
          .split_whitespace()
          .map(|a| a.parse().unwrap())
          .collect()
      );
    }
  )
}

macro_rules! get {
  ($id: ident) => (
    let stdin = io::stdin();
    $id = Vec::new();
    for line in stdin.lock().lines() {
      $id.push(
        line
          .unwrap()
          .parse().unwrap()
      );
    }
  )
}

macro_rules! p {
  ($a: expr) => (
    println!("{}", $a);
  )
}

macro_rules! pp {
  ($a: expr) => (
    println!("{:?}", $a);
  )
}

fn main() {
  let mut argss: Vec<Vec<i32>>;
  let mut ns;
  let mut n;
  let mut ls;
  gets!(argss);
  split!(argss, (ns ls));
  split!(ns, (n));

  //let mut s = String::new();
  //let mut b = if n % 2 == 0 { false } else { true };
  //for i in 0 .. (n as usize) {
  //  if 0 == i {
  //    s = ls[i].to_string();
  //  } else {
  //    if b {
  //      s.push_str(&format!(" {}", ls[i]));
  //    } else {
  //      s.insert(0, ' ');
  //      for c in ls[i].to_string().chars().rev() {
  //        s.insert(0, c);
  //      }
  //    }
  //    b = !b;
  //  }

  //}
  //p!(s);
  //

  let mut q = VecDeque::new();

  let mut b = if n % 2 == 0 { false } else { true };
  for i in 0 .. (n as usize) {
    if 0 == i {
      q.push_front(ls[i]);
    } else {
      if b {
        q.push_back(ls[i]);
      } else {
        q.push_front(ls[i]);
      }
      b = !b;
    }
  }


  for i in 0 .. (n as usize) {
    if i == ((n - 1) as usize) {
      println!("{}", q[i]);
    } else {
      print!("{} ", q[i]);
    }
  }
}


Measured memory_bytes: 9332
def Hr(h, x, y, cx, cy):
    return h+abs(x-cx)+abs(y-cy)
def H(h, x, y, cx, cy):
    return max(h-abs(x-cx)-abs(y-cy),0)


N = int(input())
x = [list(map(int, input().split())) for i in range(N)]
for cx in range(0, 101):
    for cy in range(0, 101):
        judge = True
        m = [l for l in range(N) if x[l][2]!=0][0]
        H0 = Hr(x[m][2], x[m][0], x[m][1], cx, cy)
        for n in range(len(x)):
            Hn = H(H0, x[n][0], x[n][1], cx, cy)
            if(x[n][2] == Hn):
                judge = judge and True
            else:
                judge = judge and False
        if(judge):
            print(cx, cy, H0)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N;
    string S;
    cin>>N>>S;
    ll count=0;
    rep(f, 10) rep(s, 10) rep(t, 10){
        ll index=0;
        rep(i, N){
            if(index==0 && S[i]=='0'+f) index++;
            else if(index==1 && S[i]=='0'+s) index++;
            else if(index==2 && S[i]=='0'+t) index++;
        }
        if(index==3) count++/*,cout<<f<<sp<<s<<sp<<t<<endl*/;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
def solve():
    R,C,K = map(int, input().split())
    #value = [[0 for _ in range(C)] for _ in range(R)]
    dp = [[[0 for _ in range(C+1)] for _ in range (R+1)] for _ in range(5)]
    for _ in range(K):
        r,c,v = map(int, input().split())
        dp[4][r][c] = v

    #print(value)
    #print(dp)

    for r in range(1, R+1):
        for c in range(1, C+1):
            v = dp[4][r][c]
            prow = max(dp[0][r-1][c], dp[1][r-1][c], dp[2][r-1][c], dp[3][r-1][c])
            if v == 0: # no item
                dp[0][r][c] = max(prow, dp[0][r][c-1])
                dp[1][r][c] = dp[1][r][c-1]
                dp[2][r][c] = dp[2][r][c-1]
                dp[3][r][c] = dp[3][r][c-1]
            else:
                dp[0][r][c] = max(prow, dp[0][r][c-1])
                dp[1][r][c] = max(dp[1][r][c-1], dp[0][r][c-1] + v, prow + v)
                dp[2][r][c] = max(dp[2][r][c-1], dp[1][r][c-1] + v)
                dp[3][r][c] = max(dp[3][r][c-1], dp[2][r][c-1] + v)

    #print(dp)
    print(max(dp[0][R][C], dp[1][R][C], dp[2][R][C], dp[3][R][C]))

solve()

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{

  int a, b;
  cin >> a >> b;
  

      int ans = b * 2 + 1;
  if (a % ans == 0)
    pr(a / ans);
  else
    pr(a / ans + 1);

  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  // 
  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string w;cin>>w;
  int alp[26]={};
  bool flag=false;
  REP(i,(int)w.size()){
    alp[(int)(w[i]-'a')]++;
  }
  REP(i,26){
    if(alp[i]%2!=0)flag=true;
  }
  if(!flag){
    P("Yes");
  }else{
    P("No");
  }
  return 0;
}


Measured memory_bytes: 256