akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
int n,y,a,b,c;
int main(){
	cin>>n>>y;
	bool f=0;
	
	for(int i=0;i<=2000;i++){
		for(int j=0;j<=2000;j++){
				if(i+j>n)continue;
				int sum=i*10000+j*5000+(n-i-j)*1000;
				//cout<<i<<j<<(n-i-j)<<" "<<sum<<endl;
				if((i*10000+j*5000+(n-i-j)*1000)==y){
					cout<<i<<" "<<j<<" "<<n-i-j<<endl;
					f=1;
					return 0;
				}
		}
	}
	if(!f)cout<<-1<<" "<<-1<<" "<<-1<<endl;

	return 0;
}

Measured memory_bytes: 256
import bisect

n = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
ans = 0
L = [0] * n
for i in range(n):
    a = bisect.bisect_left(A, B[i])
    L[i] = a
cum = [0] * (n + 1)
for i in range(n):
    cum[i+1] = cum[i] + L[i]
for i in range(n):
    b = bisect.bisect_left(B, C[i])
    ans += cum[b]
print(ans)


Measured memory_bytes: 23848
#include <iostream>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define MOD 1000000007
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

class SumSegTree {
private:

	int _sum(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)return 0;    // 交差しない
		if (a <= l && r <= b)return dat[k];   // a,l,r,bの順で完全に含まれる
		else {
			int s1 = _sum(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子
			int s2 = _sum(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子
			return s1 + s2;
		}
	}
public:
	int n, height;
	vector<int> dat;

	// 初期化（_nは最大要素数）
	SumSegTree(int _n) {
		n = 1;
		height = 1;
		while (n < _n) {
			n *= 2;
			height++;
		}
		dat = vector<int>(2 * n - 1, 0);
	}

	// 場所i(0-indexed)にxを足す
	void add(int i, int x) {
		i += n - 1; // i番目の葉ノードへ
		dat[i] += x;
		while (i > 0) { // 下から上がっていく
			i = (i - 1) / 2;
			dat[i] += x;
		}
	}

	// 区間[a,b)の総和。ノードk=[l,r)に着目している。
	int sum(int a, int b) {
		return _sum(a, b, 0, 0, n);
	}
};

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

	ll n;
	cin >> n;
	Array a(n, 0);
	REP(i, n) cin >> a[i];

	Array b(n, 0);

	ll j = 0;
	for (ll i = n - 1; i >= 0; i -= 2) {
		b[j] = a[i];
		j++;
	}
	for (ll i = n % 2; i < n; i += 2) {
		b[j] = a[i];
		j++;
	}

	for (auto i : b) {
		cout << i << " ";
	}

	return 0;
}

Measured memory_bytes: 5376
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

spread table a = do
  p <- VUM.read table a
  VUM.write table a (p + 1)

initial table (a : as) = do
  when (a /= 0) $ spread table (a -1)
  spread table a
  spread table (a + 1)
  when (as /= []) $ initial table as

seek table n l k = do
  p <- VUM.read table n
  let k' = if p > k then p else k
  if n == l
    then return k'
    else seek table (n + 1) l k'

main = do
  n <- getInt
  as <- getIntList
  let l = maximum as + 2
  table <- VUM.replicate l 0 :: IO (VUM.IOVector Int)
  initial table as
  table' <- VU.freeze table
  print $ VU.maximum table'


Measured memory_bytes: 12536
#include <iostream>
#include <queue>
#include <tuple>

using namespace std;

int main(){
    int H, W;
    cin >> H >> W;

    char s[H][W];
    int nb = 0;
    for(int i=0; i<H; i++){
        string S;
        cin >> S;
        for(int j=0; j<W; j++){
            s[i][j] = S[j];
            if(s[i][j] == '#') nb++;
        }
    }

    queue<tuple<int, int, int>> q;
    q.push(make_tuple(0, 0, 0));
    int dis = -1;
    while(!q.empty()){
        int x = get<1>(q.front());
        int y = get<0>(q.front());
        int d = get<2>(q.front());
        q.pop();
        if(x==W-1 && y==H-1){
            dis = d;
        }

        int dx[] = {-1, 1, 0, 0};
        int dy[] = {0, 0, -1, 1};
        for(int i=0; i<4; i++){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx<0 || nx>=W) continue;
            if(ny<0 || ny>=H) continue;
            if(s[ny][nx] == '#') continue;
            s[ny][nx] = '#';
            q.push(make_tuple(ny, nx, d+1));
        }
    }

    if(dis != -1){
        dis = H*W - (dis+1+nb);
    }
    cout << dis << endl;

    return 0;
}

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

int main() {
  ll N,a[200002],q=1000000001;
  cin>>N;
    for (int i = 0; i < N; ++i) cin >> a[i];
    sort(a, a + N, greater<int>()); 
  ll s=a[0];
  ll x=(N-2)/2;
  if(N==2){
    cout<<a[0]<<endl;
  }
  else if(N%2==1){
	for(ll i=0;i<x;i++){
      s+=2*a[i+1];
    }
    s+=a[x+1];
  cout<<s<<endl;
  }
  else{
    	for(ll i=0;i<x;i++){
      s+=2*a[i+1];
    }
    cout<<s<<endl;
  }
}
    

Measured memory_bytes: 5196
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7;
const ll LINF=1e18;
using namespace std;
//#define int long long
#define int long double
//template
typedef pair<int,int> P;
std::vector<P> up,down,med;
int T;
void change(int x,int l,int h){
  int ka=(l/(x*(T-x)))*(T/2)*(T/2);
  int jo=(h/(x*(T-x)))*(T/2)*(T/2);
  if(ka>T/4)up.push_back(P(ka,jo));
  else if(jo<T/4)down.push_back(P(jo,ka));
  else med.push_back(P(ka,jo));
}
int speed(int h){
  int a=4*h/(T*T);
  int sain=a*T/sqrt(a*a*T*T+1);
  return sqrt(2*a)*(T/2)/sain;
}
//main
signed main(){
  int N;cin>>T>>N;
  for(int i=0;i<N;i++){
    int x,l,h;cin>>x>>l>>h;
    change(x,l,h);
  }
  int ma=LINF,mi=-1;
  sort(up.rbegin(),up.rend());
  sort(down.begin(),down.end());
  int ans=0;
  for(auto p:up){
    if(p.second>=ma)continue;
    ans+=speed(p.first);
    ma=p.first;
    //cout<<p.first<<" "<<p.second<<endl;
  }
  for(auto p:down){
    if(p.second<=mi)continue;
    ans+=speed(p.first);
    mi=p.first;
    //cout<<p.first<<" "<<p.second<<endl;
  }
  bool f=false;
  for(auto p:med)if(p.first>mi&&p.second<ma)f=true;
  if(f)ans+=speed(T/4);
  cout<<fixed<<setprecision(12)<<ans<<endl;
}



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

int main(){
    int m, f, r;
    while(cin>>m >>f >>r){
        if(m==-1 && f==-1 && r==-1)break;
        if(m==-1 || f==-1){
            cout<<'F'<<endl;
            continue;
        }
        if(m+f>=80){
            cout<<'A'<<endl;
        }else if(m+f>=65){
            cout<<'B'<<endl;
        }else if((m+f>=50)||(r>=50)){
            cout<<'C'<<endl;
        }else if(m+f>=30){
            cout<<'D'<<endl;
        }else{
            cout<<'F'<<endl;
        }
    }
    return 0;
}



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

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

  int a, b, c;
  cin >> a >> b >> c;
  int n=a;
  string ans="NO";
  rep(i, a*b){
    if(n%b==c){
      ans="YES";
      break;
    }
    n+=a;
  }

  cout << ans << endl;

  return 0;
}

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

const int INF = 1001001001;
const int mod = 1000000007;

ll pow(ll base, ll order) {
	ll ans = 1;
	rep(i,order - 1) ans *= base;
	return ans;
}

int gcd(int a, int b) {
	if (a < b) {
		int c = a;
		a = b;
		b = c;
	}
	if (b == 0) return a;
	return gcd (b, a % b);
}

ll sum(ll x) { // sum of subsequent numbers from 0 to x
	return x*(x + 1)/2;
}

int main() {
	ll x;
	cin >> x;
	ll source = 100, ans = 0;
	while(source < x) {
		source *= 1.01;
		ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3644
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
// 293206GT
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <stack>
#include <string>
#include<algorithm>
#include <random>
#include <bitset>
#include <chrono>

typedef long long ll;
#define int ll
using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) (x) * (x)
typedef pair<int, int> pii;
typedef long double ld;
typedef pair<ld, ld> pld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
#define rep(x, y, a) for (int x = (y); x < (int)(a); ++x)
#define asd(n) rep(i, 0, n)
#define jkl(n) rep(j, 0, n)
#define all(a) a.begin(), a.end()
#define chkmax(a, b) a = max(a, (b))
#define chkmin(a, b) a = min(a, (b))
#define prev asasdasd
#define next aasdasda
#define left asdasdasdasd
#define right asnabsdkasdl
#define rank asdasdknlasd
#define move asdasdas

namespace IO {

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a);

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a);

    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a) {
        for (pair<A, B> x: a)
            out << x.first << " " << x.second << '\n';
        return out;
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a) {
        for (A x: a) out << x << ' ';
        return out;
    }

    template<class A, class B>
    istream &operator>>(istream &in, pair<A, B> &a) {
        in >> a.first >> a.second;
        return in;
    }

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x: a) in >> x;
        return in;
    }
}
using namespace IO;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve() {
    int n;
    cin >> n;
    int ans = 0;
    rep(i, 1, n) ans += (n - 1) / i;
    put(ans);
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(30);
//    freopen("input.txt", "r", stdin);
    int q = 1;
//    cin >> q;

    while (q--) solve();
}


Measured memory_bytes: 3196
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int N, H, W;
  cin >> N;
  cin >> H;
  cin >> W;

  int ans = (N - H + 1) * (N - W + 1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	if(a[1]==a[2]&&a[0]==a[2])
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;	
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


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

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

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=10000;
const ll INF=1000000010;
const int MAX=100001;
int dx[8]={0,1,0,-1,1,-1,1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
template< class T >
struct BinaryIndexedTree
{
  vector< T > data;

  BinaryIndexedTree(int sz)
  {
    data.assign(++sz, 0);
  }

  T sum(int k)
  {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x)
  {
    for(++k; k < (int)data.size(); k += k & -k) data[k] += x;
  }
};
int main(){
	int n,m;cin>>n>>m;
	vector<pair<int,P> > v;
	for(int i=0;i<n;i++){
		int l,r;cin>>l>>r;
		v.push_back(make_pair(r-l+1,P(l,r)));
	}
	sort(v.begin(),v.end());
	BinaryIndexedTree<int> bit(m+1);
	int idx=0;
	for(int i=1;i<=m;i++){
		while(v[idx].first<i&&idx<n){
			bit.add(v[idx].second.first,1);
			bit.add(v[idx].second.second+1,-1);
			idx++;
		}
		int ans=n-idx;
		for(int j=i;j<=m;j+=i){
			ans+=bit.sum(j);
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 8560
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main(){
    int n,max_num = -1000001,min_num = 1000001,tmp;
    long long int sum = 0;
    scanf("%d",&n);
    for(int i = 0; i < n; i++){
        scanf("%d",&tmp);
        sum += tmp;
        max_num = max(max_num,tmp);
        min_num = min(min_num,tmp);
    }
    printf("%d %d %lld\n",min_num,max_num,sum);
}




Measured memory_bytes: 2760
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
using pii = pair<int, int>;
using vi = vector<int>;
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
//manip
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power(T a, T b)
{return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
#define LB(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0


template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!

int main() {
    //cast caution
    //look constraints always
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll ans = 0;
    ans = b - b / c - b / d + b / lcm(c, d);
   // cout << b / c << " " << b / d << " " << b / lcm(c, d) << endl;
    //cout << "ans " << ans << endl;
    a--;
    ans -= a - a / c - a / d + a / lcm(c, d);
    //cout << a / c << " " << a / d << " " << a / lcm(c, d) << endl;
    cout << ans << endl;
}
//cast caution



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

using namespace std;
typedef long long ll;

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


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}

int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  int two = 0;
  int one = 0;
  int zero = 0;
  REP(i, N) {
    int a = nextInt();
    if (a % 4 == 0) two++;
    else if (a % 2 == 0) one++;
    else zero++;
  }
  bool ans = false;
  if (one >= 1) one = 1;
  if (two + 1 >= zero + one) ans = true;
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define Int long long
using namespace std;

const int MAXN=500005;
const long MOD=(long)(1e9+7);
vector<int> adj[MAXN];
vector<pair<int,int>> G[MAXN];

Int N,M,K;
Int B,C,H,W;
Int X,Y,Z;
vector<Int> A;

Int ceilS(Int x,Int y){
    return (x+y-1)/y;
}
using D=long double;

Int perform(Int x){
    return (x*(x+1))/2LL;
}

int main()
{
    cin>>X>>Y;
    cout<<max(0LL,X-Y)<<"\n";
}

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

int main(){
	string s,out;
	cin >> s;
	for(size_t i = 0; i < s.length(); ++i){

		if(i % 2==0){
			out.push_back(s[i]);
		}
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 512
N = int(input())
B = input()

B_1 = B.count("1")
mod_p1 = int(B,2) % (B_1+1)
if B_1 != 1:
    mod_m1 = int(B,2) % (B_1-1)

def calc_small(n, iter):
    iter += 1
    mod = n % bin(n).count("1")

    if mod == 0:
        return iter
    else:
        return calc_small(mod, iter)

for i in range(N):
    if B_1 == 1 and int(B[i]) == 1:
        print(0)
        continue
    mod = (mod_m1 - pow(2,N-i-1,B_1-1)) % (B_1-1) if int(B[i]) == 1 else (mod_p1 + pow(2,N-i-1,B_1+1)) % (B_1+1)
    iter = 1
    if mod == 0:
        print(iter)
    else:
        print(calc_small(mod, iter))

Measured memory_bytes: 78468
//Name: Taro's Obsession
//Level: 3
//Category: グラフ,Graph,DAG,トポロジカルソート
//Note: 

/**
 * 証言に矛盾がないことから、証言からできるグラフは必ずDAGとなる。
 * したがって、トポロジカルソートしたものは部屋に入った順番として有効なものになる。
 *
 * オーダーは O(N + M)。
 */
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void topological_inner(const vector<vector<int>> &g, int v, vector<int> &res, vector<bool> &visited) {
    visited[v] = true;
    for(int to : g[v]) {
        if(!visited[to]) {
            topological_inner(g, to, res, visited);
        }
    }
    res.push_back(v);
}

vector<int> topological_sort(const vector<vector<int>> &g) {
    const int N = g.size();
    vector<int> res;
    vector<bool> visited(N, false);
    for(int i = 0; i < N; ++i) {
        if(!visited[i]) {
            topological_inner(g, i, res, visited);
        }
    }
    reverse(begin(res), end(res));
    return res;
}

bool solve() {
    int M, N;
    if(!(cin >> M >> N)) return false;
    vector<vector<int>> g(M);
    for(int i = 0; i < N; ++i) {
        int x, y;
        cin >> x >> y;
        --x; --y;
        g[x].push_back(y);
    }
    auto ord = topological_sort(g);
    for (auto i : ord) {
        cout << i+1 << endl;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1216
#include <climits>
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
using namespace std;
int main(int, char**)
{
	long N, M;
	cin >> N;
	vector<long> a(N), box(N), sums(N, 0);
	for (long i = 0; i < N; ++i)
	{
		cin >> a[i];
	}
	M = 0;
	for (long i = N - 1; i >= 0; --i)
	{
		for (long j = i + (i + 1); j < N; j += (i + 1))
		{
			sums[i] += box[j];
		}
		box[i] = (sums[i] % 2 == a[i]) ? 0 : 1;
		sums[i] += box[i];
		if (sums[i] % 2 != a[i])
		{
			cout << -1 << endl;
			return 0;
		}
		if (box[i] == 1)	++M;
	}
	cout << M << endl;
	for (long i = 0; i < N; ++i)
	{
		if (box[i] == 1)
		{
			--M;
			cout << i + 1;
			if (M != 0)
			{
				cout << " ";
			}
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 5632
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


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

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 4e5 + 5;

int N;
pair<LL, LL> A[MAXN];

void input()
{
    read(N);
    for (int i = 0; i < N * 2; ++i) {
        read(A[i].x);
        A[i].y = i;
    }
}

void solve()
{
    static LL val[MAXN];

    for (int i = 0; i < N * 2; i += 2) {
        if (A[i].x > A[i+1].x)
            std::swap(A[i].x, A[i+1].x);
        val[i] = A[i].x;
        val[i+1] = A[i+1].x;
    }

    LL x0 = +oo, x1 = -oo, y0 = +oo, y1 = -oo;
    for (int i = 0; i < N * 2; i += 2) {
        chkmin(x0, A[i].x); chkmax(x1, A[i].x);
        chkmin(y0, A[i+1].x); chkmax(y1, A[i+1].x);
    }
    LL ans = (x1 - x0) * (y1 - y0);

    if (N > 1) {
        std::sort(A, A + N * 2);
        LL curmax = x1;
        for (int i = 0; i < N * 2; ++i) {
            chkmin(ans, (A[N*2-1].x - A[0].x) * (curmax - A[i].x));
            if (A[i].y & 1) break;
            chkmax(curmax, val[A[i].y^1]);
        }
    }

    printf("%lld\n", ans);
}

int main()
{
#ifdef __DEBUG
    freopen("E.in", "r", stdin);
    freopen("E.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}

// 会桃花之芳园，序天伦之乐事。
//     -- 李白《春夜宴桃李园序 / 春夜宴从弟桃花园序》


Measured memory_bytes: 9600
import Control.Monad

main = do
    [n,m] <- map read . words <$> getLine
    a <- replicateM n (map read . words <$> getLine) :: IO [[Int]]
    let b = join $ map (\x -> tail x) a
    print $ sum [ isAns b i n | i<-[1..30]]

    
isAns :: [Int] -> Int -> Int -> Int
isAns b i n = let num = filter (==i) b in if length num == n then 1 else 0 


Measured memory_bytes: 1148
from collections import defaultdict
if __name__ == '__main__':
    mod = 10**9 +7
    N = int(input())
    S = str(input())
    
    letter = defaultdict(int)
    for i in range(N):
        letter[S[i]] += 1
    count = 1
    for c in letter:
        count *= (letter[c]+1)
        count %= mod
    print(count-1)

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

int main() {
    vector<vector<int>> vec(3, vector<int>(3));
    int n;
    rep(i,3) rep(j,3) cin >> vec.at(i).at(j);
    cin >> n;
    rep(i,n) {
        int b;
        cin >> b;
        rep(j,3) rep(k,3) {
            if(vec.at(j).at(k) == b) vec.at(j).at(k) = 0;
        }
    }
    bool ans = false;
    rep(i,3) {
        if(vec.at(i).at(0) == 0 && vec.at(i).at(1) == 0 && vec.at(i).at(2) == 0) {
            ans = true;            
        }
    }
    rep(j,3) {
        if(vec.at(0).at(j) == 0&&vec.at(1).at(j)==0&&vec.at(2).at(j)==0) {
            ans = true;
        }
    }
    if(vec.at(0).at(0)==0 && vec.at(1).at(1)==0 && vec.at(2).at(2) == 0) {
        ans = true;
    }
    if(vec.at(0).at(2)==0 && vec.at(1).at(1) == 0 && vec.at(2).at(0) == 0) {
        ans = true;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a, b, c, k, ans = 0;
    scanf("%d %d %d %d", &a, &b, &c, &k);

    if (a < k)
        ans += a;
    else
        ans += k;

    k -= a;
    k -= b;

    if (k > 0)
    {
        if (c < k)
            ans -= c;
        else
            ans -= k;
    }

    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 1684
#include<bits/stdc++.h>
#define LL long long
using namespace std;
 
const int N = 5000+9;
const int M = 200+9;
 
int n,m,que[M][N],cnt[M],mat[M][N],bst[M];
LL delta[N],x[N],vout,cur,dis,len;
 
inline int read() {
    char c=getchar(); int f=1,ret=0;
    while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
    while (c<='9'&&c>='0') {ret=ret*10+c-'0';c=getchar();}
    return ret * f;
}
 
int main() {
    n = read(); m = read();
    for (int i=1;i<n;i++) 
        x[i] = read();
    for (int j=1;j<=n;j++) {
        for (int i=1;i<=m;i++) {
            mat[i][j] = read();
        }
    }
    for (int r=1;r<=n;r++) {
        cur = 0; len = (dis += x[r-1]);
        for (int i=1;i<=m;i++) {
            while (cnt[i] && mat[i][que[i][cnt[i]]] <= mat[i][r]) {
                if (cnt[i] > 1) 
                    delta[que[i][cnt[i]-1]] += mat[i][que[i][cnt[i]-1]] - mat[i][que[i][cnt[i]]];
                cnt[i]--;
            }
            que[i][++cnt[i]] = r;
            if (cnt[i] > 1) delta[que[i][cnt[i]-1]] += mat[i][r] - mat[i][que[i][cnt[i]-1]];
            bst[i] = max(bst[i], mat[i][r]);
            cur += bst[i];
        }
        for (int l=1;l<=r;l++) {
            vout = max(vout, cur - len);
            cur += delta[l];
            len -= x[l];
        }
    }
    printf("%lld\n",vout);
    return 0;
}

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

using namespace std;

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

    string s;
    cin >> s;
    int nump = 0, numg = 0, score = 0;

    for (char c: s) {
        if (numg <= nump) {
            numg++;

            if (c == 'p') {
                score--;
            }
        } else {
            nump++;

            if (c == 'g') {
                score++;
            }
        }
    }
    cout << score << '\n';

    return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int a, b;
  cin >> a >> b;
  cout << max(max(a + b, a - b), a * b);
}
#endif


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

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] str_a = br.readLine().split(" ");
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(str_a[i]);
        }
        
        long sum = 0;
        long count = 0;
        
        for (int i = 0; i < n; i++) {
            sum += a[i];
            if (i % 2 == 1) {
                if (sum >= 0) {
                    count += sum + 1;
                    sum = -1;
                }
            }
            else {
                if (sum <= 0) {
                    count += 1 - sum;
                    sum = 1;
                }
            }
        }
        
        long count2 = 0;
        sum = 0;
        for (int i = 0; i < n; i++) {
            sum += a[i];
            if (i % 2 == 0) {
                if (sum >= 0) {
                    count2 += sum + 1;
                    sum = -1;
                }
            }
            else {
                if (sum <= 0) {
                    count2 += 1 - sum;
                    sum = 1;
                }
            }
        }
        System.out.println(count>=count2?count2:count);
    }
}


Measured memory_bytes: 37900
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

    int X, Y;
	cin >> X >> Y;
	if(X*2<= Y && Y <= X*4 && Y % 2 == 0){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

Measured memory_bytes: 3644
from collections import Counter

def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n = ii()
s = input()
d = Counter(s)

ans = 1
mod = 1000_000_007

for _,v in d.items():
    ans *= v+1
    ans %= mod

print(ans-1)


Measured memory_bytes: 9528
sd, t = input(), input()
# for i in range(len(t)-len(sd)+1)において,
# :sd[i]==t[i] or sd=='?' ならばそのsdの箇所を実際にtで書き換え、かつ残りの?をaに書き換えたものを結果として残す。結果は昇順なので比較しながら一つだけ残す
# :それ以外ならばとくになにもしない
# 結果が空白ならばUNRESTORABLEとする
# オーダーがよくわからんけど余裕だろう
ans = ''
for i in  range(len(sd) - len(t)+1):
    target = sd[i:i+len(t)]
    count = 0
    for j in range(len(t)):
        if t[j]==target[j] or target[j]=='?':
            count+=1
        else:
            break
    if count==len(t):
        # 候補として追加。残りの?をaに変える
        tmp = sd[:i]+t+sd[len(t)+i:]
        if ans=='':
            ans = ''.join(['a' if i=='?' else i for i in tmp])
        else:
            ans = min(ans, ''.join(['a' if i=='?' else i for i in tmp]))
print('UNRESTORABLE' if ans=='' else ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int m,k;
int main()
{
    /*for(int i=2;i<=17;i++)
    {
        int ans=0;
        for(int j=0;j<1<<i;j++)
            ans^=j;
        cout<<ans<<endl;
    }*/
    scanf("%d%d",&m,&k);
    if(m==0&&k==0)
        printf("0 0\n");
    else if(m==1&&k==0)
        printf("0 0 1 1\n");
    else if(m==0&&k!=0||m==1&&k!=0)
        printf("-1\n");
    else if(k>=1<<m) printf("-1\n");
    else
    {
        printf("%d ",k);
        for(int i=0;i<1<<m;i++)
        {
            if(i==k) continue;
            printf("%d ",i);
        }
        printf("%d ",k);
        for(int i=(1<<m)-1;i>=0;i--)
        {
            if(i==k) continue;
            printf("%d ",i);
        }
    }
}


Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

ll n;
ll a[100002];
ll d[100002];

int main() {
	cin >> n;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	ll t = n*(n + 1)/2LL;
	if (sum%t != 0) {
		cout << "NO" << endl;
		return 0;
	}
	t = sum / t;
	for (int i = 0; i < n; i++) {
		d[i] = a[(i + 1)%n] - a[i];
		d[i] -= t;
		if (d[i] > 0) {
			cout << "NO" << endl;
			return 0;
		}
		d[i] = abs(d[i]);
	}
	ll cnt = 0;
	for (int i = 0; i < n; i++) {
		if (d[i] % n != 0) {
			cout << "NO" << endl;
			return 0;
		}
		cnt += d[i] / n;
	}
	if (cnt == t) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

 
 
int main() {
   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
     
    char ch;
    cin>>ch;
    if(ch>=65 && ch<=90)
      cout<<"A";
      
    else
     cout<<"a";
	return 0;
	
} 

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define endl '\n'

int32_t  main()
{
    IOS;    
    double a,b,n;
    cin>>a>>b>>n;
    cout<<floor(a*min((b-1),n)/b);
    return 0;
    
}

Measured memory_bytes: 3792
from collections import Counter
n=int(input())
a=Counter(list(map(int,input().split())))
b=[]
for i in a:
    b.append([i,a[i]])
b.sort()
x=b[-1][0]
if b[0][0]!=(x+1)//2:
    print("Impossible")
    exit()
if not(x%2==0 and b[0][1]==1 or x%2==1 and b[0][1]==2):
    print("Impossible")
    exit()
if x>n-1:
    print("Impossible")
    exit()
n=len(b)
cnt=2
k=b[0][0]  
# print(b)
for i in range(1,n):
    if b[i][1]<2 or b[i][1]<cnt or b[i][0]!=k+1:
        # print(i,b[i][1]<2,b[i][1]<cnt,b[i][0]!=k+1)
        print("Impossible")
        exit()
    b[i][1]=cnt
    k+=1
print("Possible")

Measured memory_bytes: 3316
fn d() {
    input!{
        n: usize,
        mut k: u64,
        a: [usize; n]
    }
    let mut ans: usize = 0;
    let mut table: Vec<u64> = vec![0; n];

    if k > n as u64 {
        let mut i: u64 = 0;
        loop {
            ans = a[ans] - 1_usize;
            i += 1;

            if table[ans] != 0 {
                k = (k - i) % (i - table[ans]);
                break;
            }
            else {
                table[ans] = i;
            }
        }
    }

    for i in 0..k {
        ans = a[ans] - 1_usize;
    }
    println!("{}", ans + 1);
}

use proconio::input;
use proconio::marker::Chars;

fn main() {
    d();
}


Measured memory_bytes: 6444
// https://atcoder.jp/contests/abc099/tasks/abc099_a

#include <iostream>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int n;
  string r;

  cin >> n;

  r = n < 1000 ? "ABC" : "ABD";

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

bool func(pair<ll,ll> A, pair<ll,ll> B){
    return (A.first-A.second) > (B.first-B.second);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N ;
    vector<pair<ll,ll> > AB;
    vector<ll> A, B;
    cin >> N ;
    
    rep(i, N){ll inp; cin >> inp; A.pb(inp);}
    rep(i, N){ll inp; cin >> inp; B.pb(inp);}
    rep(i, N) AB.pb(mp(A[i],B[i]));
    
    sort(all(AB), func);
    
    ll idx = -1;
    ll rest = 0;
    ll ans = 0;
    

    rep(i, AB.size()){
        ll A = AB[i].first;
        ll B = AB[i].second;
        if(A < B){
            while(rest < (B-A)){
                idx ++;
                rest += (AB[idx].first - AB[idx].second);
                if(AB[idx].first <= AB[idx].second) break;
            }
            
            if(rest < (B-A)){
                ans = -1;
                break;
            }
            rest -= (B-A);
            ans ++;
        }
        
    }
    
    if(ans == -1) cout << ans << endl;
    else cout << ans+idx+1 << endl;
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 3956
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		
		int n=cin.nextInt(),A[]=new int[n];
		for(int i=0;i<n;i++)A[i]=cin.nextInt();
		
		for(int i=1;i<n;i++) {
			for(int j=0;j<n-1;j++)System.out.print(A[j]+" ");
			System.out.println(A[n-1]);
			
			int v=A[i];
			int j=i-1;
			while(j>=0 && A[j]>v) {
				A[j+1]=A[j];
				j--;
			}
			A[j+1]=v;
		}
		for(int j=0;j<n-1;j++)System.out.print(A[j]+" ");
		System.out.println(A[n-1]);

	}

}


Measured memory_bytes: 33636
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
t = [a, b, c, d, e]
times = []
amari_not_zero = []
for i in range(len(t)):
    amari = t[i] % 10
    if amari == 0:
        times.append([t[i], amari])
    else :
        amari_not_zero.append([t[i], amari])
anz = sorted(amari_not_zero, key=lambda x: x[1], reverse=True)
for i in range(len(anz)):
    times.append(anz[i])

finish_time = 0
buf = 0
for i in range(len(times)):
    if i == len(times) - 1:
        finish_time += times[i][0]
    else :
        for j in range(14):
            buf2 = buf - times[i][0]
            if (not buf2 < 0) and buf2 <= 10:
                finish_time += buf
                break
            buf += 10
    buf = 0
print(finish_time)


Measured memory_bytes: 3064
n = int(input())
words = []

for i in range(n):
    w = input()
    if i==0:
        words.append(w)
        continue
    else:
        # print(words, w, i)
        if words[i-1][-1] == w[0] and w not in words:
            words.append(w)
        else:
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

  int main (void){
    int a,b,c;
    
    scanf("%d %d %d",&a,&b,&c);
    
   if(1>a || a>100){
   exit(0);
   }else if(1>b || b>100){
   exit(0);
   }else if(1>c || c>100){
   exit(0);
   }
   
   if(a == b && a == c){
   printf("1");
   return 0;
   }else if(a == b && b != c){
   printf("2");
   return 0;
   }else if(a !=b && b == c){
   printf("2");
   return 0;
   }else if(a == c && c != b){
   printf("2");
   return 0;
   }else if(a != b && b != c && a != c){
   printf("3");
   return 0;
   }
  }

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

int aa[3][3] = { 0 };

int main()
{
    int a[3][3],b[10];

    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
            cin >> a[i][j];

    int N;
    cin >> N;

    for (int i = 0; i < N; i++)
        cin >> b[i];

    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
            for (int k = 0; k < N; k++)
                if (a[i][j] == b[k])
                    aa[i][j] = 1;

    string s = "No";
    for (int i = 0; i < 3; i++) {
        if (aa[i][0] and aa[i][1] and aa[i][2] and 1)
            s = "Yes";
        if (aa[0][i] and aa[1][i] and aa[2][i] and 1)
            s = "Yes";
    }
    if (aa[0][0] and aa[1][1] and aa[2][2] and 1)
        s = "Yes";
    if (aa[0][2] and aa[1][1] and aa[2][0] and 1)
        s = "Yes";

    cout << s;
}

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main(void)
{
    int A, B;
    cin >> A  >> B;
    if ((A + B) > (A - B)){
        if ((A+B) > (A*B))
        {
            cout << A+B << endl;
        }
        else
        {
            cout << A*B << endl;
        }
        
    }
    else if ((A-B) > (A*B))
    {
        cout << A - B <<endl;
    }
    else
    {
        cout << A*B << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   int D;
   cin>>D;
    if(D==22){
        cout<<"Christmas Eve Eve Eve"<<endl;
    }else if(D==23){
        cout<<"Christmas Eve Eve"<<endl;
    }
    else if(D==24){
        cout<<"Christmas Eve"<<endl;
    }
    else{
        cout<<"Christmas"<<endl;
    }
   
}

Measured memory_bytes: 3448
#include <iostream>
#include <math.h>
using namespace std;
int main(){
    int a, b, c, d, e, f;
    int min1, min2, sum;
    cin >> a >> b >> c >> d >> e >> f;
    min1=a;
    if(min1>=b){min1=b;}
    if(min1>=c){min1=c;}
    if(min1>=d){min1=d;}
    
    min2=e;
    if(e>=f){min2=f;}
    
    sum=a+b+c+d+e+f-min1-min2;
    
    
    cout << sum << endl;
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 1160
a,b=map(int,input().split())
list=[]
List=[]
for i in range(a):
  list.append(b+i)
for j in range(a):
  List.append(abs(b+j))
LIST=sum(list)
List=min(List)
if int(LIST)<0:
  print(int(LIST)+int(List))
else:
  print(int(LIST)-int(List))


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
    int x,y,i,a=0,s=0;
    cin>>x>>y;

    for(i=0;i<=x;i++)
    {
        s=x-i;

        a=i*2+s*4;

        if(a==y)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;

}


Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int main(){
  int n, a, b; cin >> n >> a >> b;
  int ans = 0;
  for(int i = 1; i <= n; ++i){
	int po = 0, yo = i;
    while(yo){
      po += yo % 10;
      yo /= 10;
    }
    if(a <= po && po <= b) ans += i;
  }
  cout << ans << endl;
  return 0;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N; cin >> N;
    bool prime[100010];
    rep(i, 100010) prime[i] = true;
    for(int i = 2; i < 1000; i++){
        for(int j = (i << 1); j < 100010; j+=i){
            prime[j] = false;
        }
    }
    prime[0] = false; prime[1] = false;
    for(int ans = N;; ans++){
        if(prime[ans]){
            cout << ans << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int Nibusearch(int A[],int n,int key){
  int i=0,left=0,right=n,mid;
  while(left < right){
    mid = (left + right) / 2;
    if( A[mid] == key){
      //  printf("mid=%d\n",mid);
      return mid;
    }
    else if( key < A[mid]){
      right = mid;
    }
    else
      left = mid + 1;
  }
  return -1;
}




  


	      //  while(A[i]!=key){
	      //  mid=(left+right)/2;
	      //  if(key==A[mid]){
	      //    left=mid;
	      //    printf("%d\n",mid);
	      //    return mid;
	      //  }
	      //  else if(key<A[mid]){
	      // right=mid;
//  }
	      // else if(key>A[mid]){
	      //    left=mid;
	      //  }
	      //  i++;
	      // }
	      // return 0;
	      //}
int main()
{
  int i,n,A[100000+1],q,key,total=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(Nibusearch(A,n,key)!=-1){
      total++;
    }
  }
   printf("%d\n",total);
  return 0;
}

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

#define REP(i,n) for(int i = 0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long, long> pl;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c;
    cin >> a >> b >> c;
    ll ans = 0;
    if(c<b){
        ans = b+c;
    }else{
        ans = 2ll*b;
        if(c-b>a){
            ans += a+1;
        }else{
            ans +=c-b;
        }

    }
    cout << ans << endl;

    
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int a,b;
  int x,y;
  int c[4]={4,6,9,11};
  x=y=0;
  cin>>a>>b;
  if(a==b){cout<<"Yes"<<endl;return 0;}
  if(a==2 || b==2) {cout<<"No"<<endl; return 0;}
  for(int i=0;i<4;i++){
    if(a==c[i]) x=1;
    if(b==c[i]) y=1;
  }
  if(x==y) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}







Measured memory_bytes: 256
def merge_sort(arr):
    if len(arr) <= 1:
        return arr

    mid = len(arr) // 2
    # ここで分割を行う
    left = arr[:mid]
    right = arr[mid:]

    # 再帰的に分割を行う
    left = merge_sort(left)
    right = merge_sort(right)

    # returnが返ってきたら、結合を行い、結合したものを次に渡す
    return merge(left, right)


def merge(left, right):
    merged = []
    l_i, r_i = 0, 0

    # ソート済み配列をマージするため、それぞれ左から見ていくだけで良い
    while l_i < len(left) and r_i < len(right):
        # ここで=をつけることで安定性を保っている
        if left[l_i] <= right[r_i]:
            merged.append(left[l_i])
            l_i += 1
        else:
            merged.append(right[r_i])
            r_i += 1

    # 上のwhile文のどちらかがFalseになった場合終了するため、あまりをextendする
    if l_i < len(left):
        merged.extend(left[l_i:])
    if r_i < len(right):
        merged.extend(right[r_i:])
    return merged

if __name__ == "__main__":
    n = int(input())
    d = list(map(int, input().split()))
    d = merge_sort(d)
    l = len(d)
    a = d[l//2-1]
    b = d[l//2]
    print(b-a)


Measured memory_bytes: 87824