akhauriyash/Code-Regression huggingface dataset:
/*g++ main.cpp -o main.out*/
/*./main.out*/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int n,m,sum,a[1005],f;

int main()
{
    cin>>n>>m;
    rep(i,n)cin>>a[i],sum+=a[i];
    sort(a,a+n);
    red(i,n-1,n-m)
    {
        if(1.0*a[i]<1.0*sum/(4.0*m))
        {
            //cout<<a[i]<<' '<<sum/(4*m)<<endl;
            f=1;
            break;
        }
    }
    if(f)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


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

int main() {
    string s, t;
    cin >> s >> t;
    int sol = t.size();
    for(int i = 0; i <= s.size() - t.size(); i++) {
        int nr = 0;
        for(int j = 0; j < t.size(); j++) {
            if(t[j] != s[i + j]) {
                nr++;
            }
        }
        sol = min(sol, nr);
    }
    cout << sol;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cmath>
#define ll long long

using namespace std;

int main(){
  int N,cnt = 0;
  cin >> N;
  ll L[N];
  
  for(int i=0;i < N;i++){
    cin >> L[i];
  }

  for(int i=0;i < N;i++){
    for(int j=i+1;j < N;j++){
      if(L[i] == L[j]) continue;
      for(int k=j+1;k < N;k++){
        if(L[i] == L[k] || L[j] == L[k]) continue;
        if(L[i]+L[j]>L[k] && L[j]+L[k]>L[i] && L[k]+L[i]>L[j]) cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3632
import java.util.*;

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

        int n = sc.nextInt();
        int m = sc.nextInt();
        int q = sc.nextInt();

        int[][] plane = new int[n + 1][n + 1];

        for (int i = 0; i < m; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();

            plane[r][l]++;
        }

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                plane[i][j] = plane[i][j - 1] + plane[i][j];
            }
        }

        for (int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            int ans = 0;
            int cnt = 0;
            for (int j = l; j <= r; j++) {
                ans += plane[j][r] - plane[j][l - 1];
            }

            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 158036
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;



void main() {
    int M;
    scan(M);
    auto d = new long[](M);
    auto c = new long[](M);

    long cs;
    long ds;
    foreach (i ; 0 .. M) {
        scan(d[i], c[i]);
        cs += c[i];
        ds += d[i] * c[i];
    }

    auto ans = cs - 1 + (max(0, ds - 9) + 8) / 9;
    writeln(ans);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}

Measured memory_bytes: 5116
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int a[n][m], index[n] = {}, count[m] = {};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
            a[i][j]--;
        }
        count[a[i][0]]++;
    }
    vector<bool> alive(m, true);
    int current = distance(count, max_element(count, count + m)), result = count[current];
    for (int i = 1; i < m; i++) {
        alive[current] = false;
        for (int j = 0; j < n; j++) {
            count[a[j][index[j]]]--;
            while (!alive[a[j][index[j]]]) {
                index[j]++;
            }
            count[a[j][index[j]]]++;
        }
        int max = 0;
        for (int j = 0; j < m; j++) {
            if (alive[j] && count[j] > max) {
                max = count[j];
                current = j;
            }
        }
        result = min(result, count[current]);
    }
    cout << result;
    return 0;
}


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

bool comp(const int &a,const int&b){
  return abs(a) < abs(b);
}

int main(){
  int n,l;
  cin >> n >> l;
  vector<int> apple(n);
  for(int i=0;i<n;i++){
    apple.at(i) = l+i;
  }
  sort(apple.begin(),apple.end(),comp);
  int count = 0;
  for(int k=1;k<n;k++){
    count += apple.at(k);
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f[200005];
int vl[200005];
int n,q,c;
vector<int> v[200005];
vector<int> s[200005];
int main()
{
	cin >> n >> q; 
	f[1] = 1;
	for (int i = 0;i < n - 1;i++)
	{
		int x,y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	for (int i = 0;i < q;i++)
    {
    	int p,x;
    	cin >> p >> x;
		vl[p] += x;
    }
	queue<int> que;
	que.push(1);
    while (que.size())
    {
        int x = que.front();
        que.pop();
        for (int i = 0;i < v[x].size();i++)
        {
        	if (f[v[x][i]] == 0)
        	{
        		f[v[x][i]] = x;
        		que.push(v[x][i]);
        		vl[v[x][i]] += vl[x]; 
        	}
        }
    }
    for (int i = 1;i <= n;i++)
    {
    	cout << vl[i] << " \n"[i == n]; 
    }
	return 0;
}


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

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

  int digits = floor(log10(N) + 1);
  int ret = 0;
  for( int i = 0; i < digits-1; i+=2){
    ret += 9*pow(10, i);
  }
  if( digits % 2 != 0 ){
    ret += N - floor(pow(10, digits-1)) + 1;
  }

  cout << ret << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> arr[3];
vector<int> dp[3];
int fill(int n,int j)
{
	if(n==1)
	{
		return arr[j][1];
	}
	if(dp[j][n] != -1)
	{
		return dp[j][n];
	}
	int ans = INT_MIN;
	for(int i=0;i<3;i++)
	{
		if(i==j)
			continue;
		ans = max(ans,fill(n-1,i)+arr[j][n]);
	}
	return dp[j][n] = ans;
}
int main()
{
	int n;
	cin >> n;
	for(int i=0;i<3;i++)
	{
		arr[i].resize(n+1);
		dp[i].assign(n+1,-1);
	}
	for(int i=1 ; i<=n ;i++)
	{
		for(int j=0;j<3;j++)
			cin >> arr[j][i];
	}
	cout << max({fill(n,0),fill(n,1),fill(n,2)});
}

Measured memory_bytes: 10368
#include <iostream>

using namespace std;

int main(void)
{
	int H, W;

	while(true)
	{
		cin >> H >> W;

		if( (H==0) && (W==0) )
		{
			break;
		}

		for(int i = 0; i < H; i++)
		{
			if( (i % 2) == 0 )
			{
				for(int j = 0; j < W; j++)
				{
					if( (j % 2) == 0)
					{
						cout << "#";
					}
					else
					{
						cout << ".";
					}
				}
				cout << endl;
			}
			else
			{
				for(int j = 0; j < W; j++)
				{
					if( (j % 2) == 0 )
					{
						cout << ".";
					}
					else
					{
						cout << "#";
					}
				}
				cout << endl;
			}
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// use std::io::{stdout, Write, BufWriter};
use std::cmp::{max};

fn main() {
    input! {
        a: i32,
        b: i32,
        c: i32,
        x: i32,
    }
    let mut ans = 0;
    for k in 0..(a+1) {
        for l in 0..(b+1) {
            for m in 0..(c+1) {
                if 500*k + 100*l + 50*m == x { ans += 1 }
            }
        }
    }
    println!("{}", ans);
}


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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> x >> y;
	if (x + y >= 10) {
		cout << "error";
	}
	else {
		cout << x + y;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ans=0;
string s;

int main()
{
	cin>>s;int n=s.size();
	int a=0;
	for(int i=0;i+1<n;i++)
	{
		if(s[i]=='A')
		a++;
		else
		if(s[i]=='B'&&s[i+1]=='C')
		{
			i++;
			ans+=a;
		}
		else
		a=0;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
  int n;
  std::cin >> n;
  std::vector<int> a(n),b(100005,0);
  rep(i,n)std::cin >> a[i];
  rep(i,n)b[a[i]+1]++;
  int ma=0,mal=0;
  for (int i = 1; i < 100005; i++) {
    /* code */
    int c;
    c=b[i-1]+b[i]+b[i+1];
    if(ma<c){ma=c;mal=i+1;}
  }
  std::cout <<ma  << std::endl;
  
  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a , b;
  cin >> a >> b;
  
  if (a%2 == 1 && b%2 == 1) {
    cout << " Odd " << endl;
  }
  else {
    cout << " Even " << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n,k,cntr=0;
  scanf("%d %d",&n,&k);
  for(int i=0;i<n;i++)
  {
    int temp;
    scanf("%d",&temp);
    if(temp>=k)
      cntr++;
  }
  printf("%d",cntr);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int mod=1000000007;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> d(n+1,-1);
  d[0]=1;
  d[1]=1;
  for(int i=0;i<m;i++){
    cin >> a[i];
    d[a[i]]=0;
  }
  for(int i=2;i<=n;i++){
    if(d[i]!=0){
      d[i]=(d[i-1]+d[i-2])%mod;
    }
  }
  cout << d[n] << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
	public static final int limit = 9;
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while(true){
			int n=s.nextInt();
			int m=s.nextInt();
			if(n==0&&m==0)break;
			System.out.println(s(n,m,0));
		}

	}
	public static int s(int n,int m,int x){
		if(n==1){
			return x<=m&&m<=limit?1:0;
		}
		int a=0;
		for(int i=x;i<=limit;i++){
			a+=s(n-1,m-i,i+1);
		}
		return a;
	}
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol n; cin >> n;
    vector<string> s(n);
    vector<string> ssave(n);
    vector<lol> snum(n, 0);
    lol presize{0};

    REP(i, n)
    {
        string str; cin >> str;
        //s.insert(str);
        ssave[i] = str;
    }
    sort(ALL(ssave));
    lol j{0};
    s[0] = ssave[0];
    FOR(i, 1, n-1)
    {
        if(ssave[i] == ssave[i-1])
        {
            snum[j]++;
        }
        else
        {
            j++;
            s[j] = ssave[i];
        }
        
    }
    lol maxnum{-1*INF};
    REP(i, j+1)
    {
        maxnum = max(maxnum, snum[i]);
    }
    REP(i, j+1)
    {
        //cout << "*" << endl;
        if(snum[i] == maxnum)
        {
            cout << s[i] << endl;
        }
    }

    /*for(set<string>::iterator itr = s.begin(); itr != s.end(); itr++)
    {
        cout << *itr << '\n';
    }
    cout << SIZE(s) << endl;*/
    return 0;
}

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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;

int main(void){

  ll a,b;
  cin >> a;
  
  b = a + a*a + a*a*a;
  cout << b;

  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> X(N);
    map<int, int> m;
    for (int i = 0; i < N; i++) {
        cin >> X.at(i);
        m[X[i]]++;
    }
    vector<vector<int>> num(M);
    for (auto p : m) {
        num[p.first % M].push_back(p.second);
    }
    /*
    for (int i = 0; i < M; i++) {
        cout << i << ": ";
        for (auto v : num[i]) {
            cout << v << " ";
        }
        cout << endl;
    }
*/
    ll ans = 0;
    ans += accumulate(ALL(num[0]), 0LL) / 2;
    for (int i = 1; i < (M + 1) / 2; i++) {
        int A = 0;
        int a = 0;
        int B = 0;
        int b = 0;
        for (auto v : num[i]) {
            A += v;
            a += v / 2 * 2;
        }
        for (auto v : num[M - i]) {
            B += v;
            b += v / 2 * 2;
        }
        if (B < A) {
            swap(A, B);
            swap(a, b);
        }
        if (B - A <= b) {
            ans += (A + B) / 2;
        } else {
            ans += b / 2;
            ans += A;
        }
        //      cout << A << " " << B << " " << ans << endl;
    }
    if (M % 2 == 0) {
        ans += accumulate(ALL(num[M / 2]), 0LL) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 10752
#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;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 2003;
int n, b[N], w[N];
int cb[N][N], cw[N][N], dp[N][N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	for (int i = 1; i <= 2 * n; i++) {
		char c;
		int x;
		cin >> c >> x;
		if (c == 'B') {
			b[x] = i;
		}	else {
			w[x] = i;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= i; j++) {
			if (b[j] > b[i + 1]) {
				cb[i][0]++;
			}
		}
		for (int j = 1; j <= n; j++) {
			cb[i][j] = cb[i][j - 1] + (w[j] > b[i + 1]);
		}
	}
	for (int j = 0; j < n; j++) {
		for (int i = 1; i <= j; i++) {
			if (w[i] > w[j + 1]) {
				cw[0][j]++;
			}
		}
		for (int i = 1; i <= n; i++) {
			cw[i][j] = cw[i - 1][j] + (b[i] > w[j + 1]);
		}
	}
	memset(& dp, 0x3f, sizeof(dp));
	dp[0][0] = 0;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			if (i > 0) {
				dp[i][j] = min(dp[i][j], dp[i - 1][j] + cb[i - 1][j]);
			}
			if (j > 0) {
				dp[i][j] = min(dp[i][j], dp[i][j - 1] + cw[i][j - 1]);
			}
		}
	}
	cout << dp[n][n];
}


Measured memory_bytes: 47232
#include <stdio.h>
#include <algorithm>

using namespace std;

struct TRAMP{
	char mark;
	int number;
};

int main(){
	int n,min;
	char buf[3];
	scanf("%d",&n);

	TRAMP selectArray[n],bubbleArray[n];

	for(int i = 0; i < n; i++){
		scanf("%s",buf);
		selectArray[i].mark = buf[0];
		selectArray[i].number = buf[1] - '0';
		bubbleArray[i] = selectArray[i];
	}

	for(int i = n-1; i >= 0; i--){
		for(int j = 0; j < i; j++){
			if(bubbleArray[j].number > bubbleArray[j+1].number) swap(bubbleArray[j], bubbleArray[j+1]);
		}
	}

	for(int i = 0; i < n-1; i++){
		min = i;
		for(int j = i+1; j < n; j++){
			if(selectArray[j].number < selectArray[min].number){
				min = j;
			}
		}
		if(i != min){
			swap(selectArray[i],selectArray[min]);
		}
	}

	for(int i = 0; i < n-1; i++) printf("%c%d ",bubbleArray[i].mark,bubbleArray[i].number);
	printf("%c%d\n",bubbleArray[n-1].mark,bubbleArray[n-1].number);
	printf("Stable\n");
	for(int i = 0; i < n-1; i++) printf("%c%d ",selectArray[i].mark,selectArray[i].number);
	printf("%c%d\n",selectArray[n-1].mark,selectArray[n-1].number);

	int p;
	for(p=0; p < n; p++){
		if(selectArray[p].number != bubbleArray[p].number || selectArray[p].mark != bubbleArray[p].mark)
			break;
	}
	if(p == n){
		printf("Stable\n");
	}else{
		printf("Not stable\n");
	}

	return 0;
}



Measured memory_bytes: 2700
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    char b; cin >> b;
    
    char ans=0;
    switch(b){
    case 'A': { ans='T'; } break;
    case 'T': { ans='A'; } break;
    case 'C': { ans='G'; } break;
    case 'G': { ans='C'; } break;
    default:  {} break;
    };
    
    cout << ans << endl;
    
    return 0;
}

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

using namespace std;
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
char a[33][33];
int u[33][33];

int get (int x, int y) {
	for (int i = 0; i < n; i ++)
		for (int j = 0; j < m; j ++)
			u[i][j] = 0;

	queue < pair < int, int > > q;
	q.push(mp(x, y));
	u[x][y] = 1;

	while(q.size()) {
		auto it = q.front();
		q.pop();

		for (int di = 0; di < 4; di ++) {
			int nx = it.F + dx[di], ny = it.S + dy[di];
			if (nx < 0 || ny < 0 || nx >= n || ny >= m || a[nx][ny] != '.') continue;

			if (!u[nx][ny]) {
				u[nx][ny] = u[it.F][it.S] + 1;
				q.push(mp(nx, ny));
			}
		}
	}
	int res = 1;
	for (int i = 0; i < n; i ++)
		for (int j = 0; j < m; j ++)
			res = max(res, u[i][j]);

   	return res - 1;
}

int main () {
	SpeedForce;
	cin >> n >> m;
	for (int i = 0; i < n; i ++) {
		for (int j = 0; j < m; j ++) {
			cin >> a[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i ++) {
		for (int j = 0; j < m; j ++) if (a[i][j] != '#') {
			ans = max(ans, get(i, j));
		}
	}
	//assert(ans == 0);
	cout << ans << '\n';
   	return Accepted;
}

// B...a

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
#define A(x) ((x)<0?-(x):(x))
ll s[8][1001];
int main( void )
{
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  for (int i=0; i<N; i++) {
    ll x, y, z;
    cin >> x >> y >> z;
    s[0][i] =  x + y + z;
    s[1][i] =  x + y - z;
    s[2][i] =  x - y + z;
    s[3][i] =  x - y - z;
    s[4][i] = -x + y + z;
    s[5][i] = -x + y - z;
    s[6][i] = -x - y + z;
    s[7][i] = -x - y - z;
  }
  ll ret = (-1LL) << 50;
  for (int i=0; i<8; i++) {
    sort( s[i], s[i]+N );
    ll r = 0;
    for (int j=0; j<M; j++) {
      r += s[i][N-1-j];
    }
    ret = max(ret, r);
  }
  cout << ret << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1000000000;

int main()
{
	int n,m;
	cin >> n>>m;
	if(n==1&&m==0)
	{
		cout<<0<<endl;
		return 0;
	}
	int roop = 10;
	rep(i,n-1)
	{
		roop*=10;
	}
	
	vector<int> s(m),c(m);
	rep(i,m)
	{
		int x,y;
		cin >> x >> y;
		x--;
		s[i] = x;
		c[i] = y;
	}
	
	for(int i = roop/10;i<roop;i++)
	{
		
		string S = to_string(i);
		bool isans = true;
		//cout<<S<<endl;
		rep(i,m)
		{
			if(S[s[i]]!=c[i]+'0')
			{
				isans = false;
			}
		}
		if(isans)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	if(n==1)
	{
		for(int i=0;i<10;i++)
		{
			string S = to_string(i);
		bool isans = true;
		//cout<<S<<endl;
		rep(i,m)
		{
			if(S[s[i]]!=c[i]+'0')
			{
				isans = false;
			}
		}
		if(isans)
		{
			cout<<i<<endl;
			return 0;
		}
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
//ITP1_5_A
#include<iostream>
using namespace std;

int main()
{
	int h,w,i,j;
	
	while(1){
	cin>>h>>w;
	
	if(h==0&&w==0)
		break;
	
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cout<<"#";
			if(j==w-1)
			cout<<endl;
			}
		if(i==h-1)
		cout<<endl;
		}
	}
	return 0;
}

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

int quick_sort(int a[],int start,int end,int data_size)
{
    int pivot,temp=0,i,j;
    pivot=end;
    temp=a[start];
    a[start]=a[pivot];
    a[pivot]=temp;
    i=start+1;
    j=end;
    do{
        while(a[i]<=a[start] && i<end)   i++;
        while(a[j]>=a[start] && j>start) j--;
        if(i<j){
            temp=a[i];
            a[i]=a[j];
            a[j]=temp;
        }
    }while(i<j);
    temp=a[start];
    a[start]=a[j];
    a[j]=temp;
    if(start<j) quick_sort(a,start,j-1,data_size);
    if(i<end) quick_sort(a,i,end,data_size);
}

int main()
{
    int n,k,i,out = 0;
    scanf("%d %d",&n,&k);
    int p[n];
    for(i=0;i<n;i++) scanf("%d",&p[i]);
    quick_sort(p,0,n-1,n);
    for(i=0;i<k;i++) out = out+p[i];
    printf("%d\n",out);
    return 0;
}


Measured memory_bytes: 1676
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author hakamada
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        YProcon_1 solver = new YProcon_1();
        solver.solve(1, in, out);
        out.close();
    }

    static class YProcon_1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int K = in.nextInt();
            int cont = 0;

            for (int i = 1; i <= N; i += 2) {
                cont++;
            }

            if (cont < K) {
                out.println("NO");
            } else {
                out.println("YES");
            }
        }

    }
}



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

using namespace std;

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

#define F first
#define S second

const int MAXN = 1e5 + 10;

int n, k, a[MAXN], b[MAXN];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	ll ans = 0;
	for (int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
		if ((a[i]&k) == a[i])
			ans += b[i];
	}
	for (int i = 0; i < 30; i++)
		if (k>>i&1){
			ll temp = 0;
			int z = k>>i;
			for (int j = 0; j < n; j++)
				if (!(a[j]>>i&1))
					if ((a[j]>>i&z) == (a[j]>>i))
						temp += b[j];
			ans = max(ans, temp);
		}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<queue>
#include<map>
using namespace std;
int seg_tree[2][1<<18],seg_N;
const int seg_init_num=1<<30;
typedef pair<int,pair<int,int> > PP;
typedef long long int LL;
int t[200005];
int place[200005];
int s[200005];
priority_queue<PP,vector<PP>,greater<PP> > q1;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
PP make_PP(int a,int b,int c){
	return make_pair(a,make_pair(b,c));
}

void seg_init(int n){
	int i;
	for(i=0;(1<<i)<n;i++);
	seg_N=(1<<i)-1;
}

int seg_comp(int a,int b){//min
	return a<b?a:b;
}

void seg_set(int a,int n,int mode,bool first=true){
	if(first){
		n+=seg_N;
		seg_tree[mode][n]=a;
		seg_set(a,(n-1)/2,mode,false);
	}else{
		int b=seg_comp(seg_tree[mode][n],a);
		seg_tree[mode][n]=b;
		if(n>0 && a==b)seg_set(a,(n-1)/2,mode,false);
	}
}

int seg_search(int a,int b,int mode,int n=0,int r=0,int l=seg_N){
	if(l<a || b<r)return seg_init_num;
	if(a<=r && l<=b)return seg_tree[mode][n];
	return seg_comp(seg_search(a,b,mode,n*2+1,r,(r+l)/2),seg_search(a,b,mode,n*2+2,(r+l)/2+1,l));
}

void q1_set(int a,int b){
	
	int c=seg_search(a/2,a/2+(b-a)/2,a%2);
	q1.push(make_PP(c,a,b));
}

int main(){
	int n;
	int i,j,k;
	int a,b,c;
	PP pa;
	cin>>n;
	seg_init(n/2);
	for(i=0;i<2;i++){for(j=0;j<(1<<18);j++){
		seg_tree[i][j]=seg_init_num;
	}}
	for(i=0;i<n;i++){
		cin>>t[i];
		place[t[i]]=i;
		seg_set(t[i],i/2,i%2);
	}
	a=seg_search(0,n/2-1,0);
	q1.push(make_PP(a,0,n-1));
	for(i=0;i<n/2;i++){
		pa=q1.top(),q1.pop();
		s[i*2]=pa.first;
		a=place[pa.first];
		b=seg_search(a/2+a%2,pa.second.second/2,1-(a%2));
		s[i*2+1]=b;
		b=place[b];
		if(pa.second.first<a)q1_set(pa.second.first,a-1);
		if(a+1<b)q1_set(a+1,b-1);
		if(b<pa.second.second)q1_set(b+1,pa.second.second);
	}
	array_show(s,n);
	return 0;
}



Measured memory_bytes: 6520
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        if (k <= a) {
            System.out.println(k);
            return;
        }
        if (k <= a + b) {
            System.out.println(a);
        } else {
            int gap = k - (a + b);
            System.out.println(a - gap);
        }
    }
}

Measured memory_bytes: 35748
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
// #define mod 1000000007LL
#define fi first
#define se second
const ll p = 1000000007;
const ll mod = 1000000007;
map<ll,ll> st;
void primeFactors(ll n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        st[2]++;  
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            st[i]++;  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        st[n]++;  
}  
int main()
{
    ll n;
    cin>>n;
    ll ans = 0;
    primeFactors(n);
    map<ll,ll>::iterator itr;
    for(itr=st.begin();itr!=st.end();itr++)
    {
        int t = sqrt(1+8*(itr->second));
        ans = ans + (t-1)/2;
    }
    cout<<ans;
}   


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<vector<int>> v(10);
    rep(i,n){
        v[s[i]-'0'].push_back(i);
    }
    rep(i,10){
        v[i].push_back(1e9);
    }
    int ans = 0;
    rep(i,10){
        rep(j,10){
            rep(k,10){
                int id = -1;
                id = *upper_bound(v[i].begin(),v[i].end(),id);
                if(id==1e9){
                    continue;
                }
                id = *upper_bound(v[j].begin(), v[j].end(), id);
                if (id == 1e9)
                {
                    continue;
                }
                id = *upper_bound(v[k].begin(), v[k].end(), id);
                if (id == 1e9)
                {
                    continue;
                }
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define ss second
//#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  A.begin(), A.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))


#define forr(i,n) for(i=0; i<n; i++)
#define whilee(i,t) while(i!=t)
#define pb(x) push_back(x);

//sort(A.begin(),A.end());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//accumulate(A.begin(), A.end(), 0);
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());


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

    //vector <int> A;
    //deque <int> A;
    //queue <int> A;
    //stack <int> A;
    //set <int> A;
    //map <int,int> A;
    //pair <int,int> A ;
    //vector <pair <int,int>> A ;
    //string S, T;
    int i, j, k, a, b, c, l, m, n, p, q, r, s, t, x, y, z, cnt=0;
    string S, T;
    cin>>S;
    T=S;
    reverse(T.begin(),T.end());
    if(S==T)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<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(){
    int n;
    cin>>n;
    int ans=n*800;
    ans-=(n/15)*200;
    cout<<ans<<endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int h, w;
string s[100];

int main() {
	cin >> h >> w;
	rep(i,h) cin >> s[i];
	
	rep(i,w+2) cout << '#';
	cout << ln;
	rep(i,h) cout << '#' << s[i] << "#" << ln;
	rep(i,w+2) cout << '#';
	cout << ln;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int N;
	cin >> N;
	string S[10000];
	//int flagA[10000];
	//int flagB[10000];
	int cntA = 0;
	int cntB = 0;
	int cntAB = 0;
	int cnt = 0;
	for (int i = 0; i < N; ++i)
	{
		//flagA[i] = flag[i] = 0;
		cin >> S[i];
		for (int j = 0; j < S[i].length() - 1; ++j)
		{
			if ((S[i].substr(j,1) == "A")&&(S[i].substr(j+1,1) == "B"))
			{
				cnt++;
			}
		}

		if ((S[i].substr(0,1) == "B")&&(S[i].substr(S[i].length()-1,1) == "A"))
		{
			cntAB++;
		}
		else if (S[i].substr(0,1) == "B")
		{
			cntB++;
		}
		else if (S[i].substr(S[i].length()-1,1) == "A")
		{
			cntA++;
		}

	}
	int ans;
	if (cntAB == 0)
	{
		ans = cnt + min(cntA,cntB);
	}
	else if ((cntAB != 0)&&(cntA + cntB == 0))
	{
		ans = cnt + cntAB - 1; 
	}
	else if ((cntAB != 0)&&(cntA + cntB != 0))
	{
		ans = cnt + min(cntA,cntB) + cntAB;
	}

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using std::cout;
using ll =long long;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  ll num;
  cin>> num;
  vector<int> p(11);
  for(int i =0; i<11 ;i++){
    p[i] = num % 10;
    num = num/10;
  }
  int ans = 643;
  for(int i =0; i<9 ;i++){
    ans = min(abs(p[i] +10*p[i+1] +100*p[i+2] ,753) ,ans );
  }
  
  cout <<ans<<endl;


}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, n, b;
  a = 0;
  in(n);
  rep(i, n){
    in(b);
    while(b % 2 == 0){
      b = b / 2;
      a++;
    }
  }
  out(a);
  memi;
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}
void solve();
int main(){ cin.tie(0); ios::sync_with_stdio(false); solve(); return 0;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

vector<int> topological_sort(const vector<vector<int>>& graph){
  // if graph is not DAG, return {}
  // else topological sorted vertices
  int N = graph.size();
  stack<int> st;
  vector<int> h(N), res;
  for(int i = 0; i < N; i++)
    for(auto& v: graph[i]) h[v]++;
  for(int i = 0; i < N; i++)
    if(h[i] == 0) st.push(i);
  while(st.size()) {
    int u = st.top(); st.pop();
    res.push_back(u);
    for(auto& v: graph[u]){
      h[v]--;
      if(h[v] == 0) st.push(v);
    }
  }
  if(res.size() != N) res.clear();
  return res;
}

void GRL_4_B(){
  int N,M; cin >> N >> M;
  vvi g(N);
  rep(i,M){
    int s,t; cin >> s >> t;
    g[s].pb(t);
  }
  auto ts = topological_sort(g);
  rep(i,N) cout << ts[i] << endl;
}

void solve(){
  GRL_4_B();
}



Measured memory_bytes: 3740
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define REP(i, n) for(long i = 0; i < n; i++)
#define FOR(i, a,b) for(long i = a; i < b; i++)

using namespace std;

int main(void) {
  cout.precision(12);

  long N;
  cin >> N;
  vector<long> a(3*N);
  REP(i, 3*N) cin >> a[i];

  priority_queue<long, vector<long>, greater<long>  > before_queue;
  priority_queue<long> after_queue;

  long before_sum = 0;
  long after_sum = 0;

  vector<long> before_result(3*N, 0);
  vector<long> after_result(3*N, 0);
  
  REP(i,N){
  	before_sum += a[i];
  	before_queue.push(a[i]);
  	
  	after_sum += a[i+2*N];
  	after_queue.push(a[i+2*N]);
  }
  
  before_result[N-1] = before_sum;
  after_result[2*N] = after_sum;
  FOR(i,N,2*N){
  	before_sum += a[i];
  	before_queue.push(a[i]);
  	before_sum -= before_queue.top();
  	before_queue.pop();
  	before_result[i] = before_sum;
  	
  }
  
  for(int i = 2*N-1; i>= N ;i--){
  	after_sum += a[i];
  	after_queue.push(a[i]);
  	after_sum -= after_queue.top();
  	after_queue.pop();
  	after_result[i] = after_sum;
  }
  
  bool not_calculated = true;
  long result;
 
  for (long i = N-1; i < 2*N; i++) {
    long tmp_result = before_result[i] - after_result[i+1];
    if (not_calculated or result < tmp_result) result = tmp_result;
    not_calculated = false;
  }
  
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 9076
import Data.List

factors n = [x | x <- [1..n], n `mod` x == 0]

factorization 1 = []
factorization x = v : factorization (x `div` v)
  where
      v = (factors x) !! 1

count [] xs rs = rs
count (n:ns) xs rs = count ns xs $ ((length (filter (\x -> x == n) xs)) + 1) : rs

main = do
  line <- getLine
  let n = (read :: String -> Int) line
      xs = concat $ fmap factorization [2..n] in
    putStrLn . show $ foldr (\x y -> (x * y) `mod` 1000000007) 1 $ count (nub xs) xs []


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

int calc(int H,int W,int a) {
    if(H%2==0 || W%2==0) {
        vector<int> t;
        t.push_back(a);
        t.push_back((H*W)/2);
        t.push_back((H*W)/2);
        sort(ALL(t));
        return t[2]-t[0];
    }
    int ret=INF;
    {
        vector<int> t;
        t.push_back(a);
        t.push_back(H/2*W);
        t.push_back((H-(H/2))*W);
        sort(ALL(t));
        chmin(ret,t[2]-t[0]);
    }
    {
        vector<int> t;
        t.push_back(a);
        t.push_back(H*(W/2));
        t.push_back(H*(W-(W/2)));
        sort(ALL(t));
        chmin(ret,t[2]-t[0]);
    }
    return ret;
}
signed main() {
    int H,W;
    cin>>H>>W;
    int ans=INF;
    for(int i=1;i<H;i++) {
        int a=i*W;
        int b=(H-i)*W;
        if(a<b) {
            chmin(ans,calc(H-i,W,a));
        }
        else {
            chmin(ans,calc(i,W,b));
        }
    }
    for(int i=1;i<W;i++) {
        int a=i*H;
        int b=(W-i)*H;
        if(a<b) {
            chmin(ans,calc(H,W-i,a));
        }
        else {
            chmin(ans,calc(H,i,b));
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
out=[(0,0,2,1),(1,0,2,1),(2,0,2,1),(3,0,2,1),(0,0,2,1),(0,1,2,1),(0,2,2,1),(0,3,2,1),(0,0,1,2),(1,0,1,2),(2,0,1,2),(3,0,1,2),(0,2,0,1),(1,2,0,1),(2,2,0,1),(3,2,0,1),(0,2,0,1),(0,2,1,1),(0,2,2,1),(0,2,3,1)]
dp=[[[[0]*4 for i in range(4)]for j in range(4)] for k in range(n-2)]
dp[0]=[[[1]*4 for i in range(4)] for j in range(4)]
dp[0][0][2][1]=0
dp[0][0][1][2]=0
dp[0][2][0][1]=0
for i in range(n-3):
    for j in range(4):
        for k in range(4):
            for l in range(4):
                for m in range(4):
                    if (j,k,l,m) in out:
                        continue
                    else:
                        dp[i+1][k][l][m]+=dp[i][j][k][l]%mod
#print(dp)
ans=0
for i in range(4):
    for j in range(4):
        ans+=sum(dp[-1][i][j])%mod
print(ans%mod)

Measured memory_bytes: 74524
#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()
typedef long long lint;
 
int main() {
  int a,b;
  cin >> a >>b;
  
  if(a>b){
    rep(i,a)cout << b;
    cout << endl;
    return 0;
  }
  else{
    rep(i,b)cout << a;
    cout << endl;
    return 0;
  }
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
int n;
scanf ("%d", &n);
char str[n];
scanf ("%s", str);

int ctr = 0;
int maks = 0;

for (int i = 0; i < n; i++){
	if (str[i] == 'I'){
		ctr+=1;
	}
	else if (str[i] == 'D'){
		ctr -= 1;
	}
	if (maks < ctr){
		maks = ctr;
	}
}
printf ("%d", maks);
	return 0;
}

Measured memory_bytes: 2088