akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

int parse(string s)
{
    int r;

    if (s[0] == '0') {
        r += s[1] - '0';
    } else {
        r += s[0..2].to!int;
    }
    r *= 60;

    if (s[3] == '0') {
        r += s[4] - '0';
    } else {
        r += s[3..5].to!int;
    }
    r *= 60;

    if (s[6] == '0') {
        r += s[7] - '0';
    } else {
        r += s[6..8].to!int;
    }

    return r;
}

void main()
{
    for (;;) {
        auto N = readln.chomp.to!int;
        if (N == 0) return;

        auto tt = new int[](60*60*24);
        foreach (_; 0..N) {
            auto t = readln.split;
            ++tt[parse(t[0])];
            --tt[parse(t[1])];
        }
        int max_t = tt[0];
        foreach (i; 1..tt.length) {
            tt[i] += tt[i-1];
            max_t = max(max_t, tt[i]);
        }
        writeln(max_t);
    }
}


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

const int N = 1e5+5;
vector<int> primes(N+1,1);
vector<int> pre(N+1);

void cal(){
	primes[0] = 0;
	primes[1] = 0;
	for(int i = 2; i <= N; i++){
		if(primes[i] && primes[(i+1)/2]) pre[i] = 1;
		else pre[i] = 0;
		if(primes[i]){
			for(int j = i*2;j<=N;j+=i){
				primes[j] = 0; 
			}
		}
	}
}


int main(){

	int q;
	cin>>q;

    cal();

   // for(int i = 1;i < 15;i++) cout<<primes[i]<<" ";

  //for(int i = 1;i < 55; i++) cout<<pre[i]<<" ";

    for(int i = 3; i <= N ;i++){
    	pre[i]+=pre[i-1];
    }  


    for(int i = 0; i < q; i++){
    	int l,r;
    	cin>>l>>r;
       cout<<pre[r] - pre[l-1]<<endl;
    }

}

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

#define N	200000
#define MD	998244353

int main() {
	static char cc[N + 1];
	static int dp[3][3][3][2], dq[3][3][3][2];
	int n, i, ka, kb, kc, ba, ca, a, eq, ans;

	scanf("%s", cc), n = strlen(cc);
	ka = kb = kc = 0;
	for (i = 0; i < n; i++)
		if (cc[i] == 'a')
			ka++;
		else if (cc[i] == 'b')
			kb++;
		else
			kc++;
	if (ka == n || kb == n || kc == n) {
		printf("1\n");
		return 0;
	}
	if (n == 2 && cc[0] != cc[1]) {
		printf("2\n");
		return 0;
	}
	if (n == 3 && cc[0] != cc[1] && cc[1] != cc[2] && cc[0] != cc[2]) {
		printf("3\n");
		return 0;
	}
	kb = (kb - ka) % 3, kc = (kc - ka) % 3;
	if (kb < 0)
		kb += 3;
	if (kc < 0)
		kc += 3;
	dp[2][2][0][0] = 1, dp[1][0][1][0] = 1, dp[0][1][2][0] = 1;
	for (i = 1; i < n; i++) {
		memset(dq, 0, sizeof dq);
		for (ba = 0; ba < 3; ba++)
			for (ca = 0; ca < 3; ca++)
				for (a = 0; a < 3; a++)
					for (eq = 0; eq < 2; eq++) {
						int x = dp[ba][ca][a][eq], a_;

						if (x == 0)
							continue;
						for (a_ = 0; a_ < 3; a_++) {
							int ba_ = ba, ca_ = ca, eq_ = eq || a == a_;

							if (a_ == 0)
								ba_ = (ba_ + 2) % 3, ca_ = (ca_ + 2) % 3;
							else if (a_ == 1)
								ba_ = (ba_ + 1) % 3;
							else
								ca_ = (ca_ + 1) % 3;
							dq[ba_][ca_][a_][eq_] = (dq[ba_][ca_][a_][eq_] + x) % MD;
						}
					}
		memcpy(dp, dq, sizeof dq);
	}
	ans = 1;
	for (i = 1; i < n; i++)
		if (cc[i] == cc[i - 1]) {
			ans = 0;
			break;
		}
	for (a = 0; a < 3; a++)
		ans = (ans + dp[kb][kc][a][1]) % MD;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1892
# -*- coding: utf-8 -*-
import sys
from heapq import *

q = []
while True:
    cmd = sys.stdin.readline().split()
    if cmd[0] == 'end':
        break
    elif cmd[0] == 'insert':
        heappush(q, -int(cmd[1]))
    else:
        print(-heappop(q))



Measured memory_bytes: 45576
/*
ID: hafiz.i1
TASK: milk2
LANG: C++
*/
#include<bits/stdc++.h>

#define ll long long
#define mod 1000000007

using namespace std;



int main()
{
//    freopen("milk2.in", "r", stdin);
//    freopen("milk2.out", "w", stdout);
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a=0,b,s=0;
    for(int i=1;i<=n;i++){
        cin>>b;
        s+=b;
        a=max(a,b);
    }
    cout<<s-(a/2)<<endl;
}


Measured memory_bytes: 3592
n,*l=map(int,open(0).read().split())
count=0
if n<3:
    print(count)
else:
    import itertools
    for i,j,k in list(itertools.combinations(range(len(l)),3)):
        t=sorted([l[i],l[j],l[k]])
        if len(set(t))==3:
            if t[2]<t[0]+t[1]:
                count+=1
    print(count)

Measured memory_bytes: 20632
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int H = 0;
    static int[] A = new int[2000005];

    public static void main(String[] args) {
        int k;
        while(true) {
            String cmd = sc.next();
            if (cmd.equals("insert")) {
                k = sc.nextInt();
                insert(k);
            } else if (cmd.equals("extract")) {
                System.out.println(extract());
            } else if (cmd.equals("end")) {
                return;
            }
        }
    }

    public static void insert(int k) {
        H++;
        A[H] = k;
        int i = H;
        while(i > 1 && A[i/2] < A[i]) {
            int tmp = A[i/2];
            A[i/2] = A[i];
            A[i] = tmp;

            i = i / 2;
        }
    }

    public static int extract() {
        if (H < 1) return -1;

        int ret = A[1];
        A[1] = A[H];
        H--;
        maxHeapify(1);

        return ret;
    }

    public static void maxHeapify(int i) {
        int l = i * 2;
        int r = i * 2 + 1;

        int largest;
        if (l <= H && A[l] > A[i]) {
            largest = l;
        } else {
            largest = i;
        }
        if (r <= H && A[r] > A[largest]) {
            largest = r;
        }

        if (largest != i) {
            int tmp = A[i];
            A[i] = A[largest];
            A[largest] = tmp;

            maxHeapify(largest);
        }
    }
}

Measured memory_bytes: 556836
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int num[5];
string S;
set<char> U;

signed main(){
	cin>>S;
	REP(i,S.size()){
		num[S[i]-'a']++;
		U.insert(S[i]);
	}
	if(S.size()==1){
		cout<<"YES"<<endl;
		return 0;
	}
	else if(S.size()==2){
		cout<<(S[0]!=S[1]?"YES":"NO")<<endl;
		return 0;
	}
	sort(num,num+3);
	if(num[2]-num[0]<=1){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);

  int n;
  cin >> n;
  
  int dp[n], ans = 0;
  memset(dp, 0, sizeof dp);
  
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j * i < n; ++j) {
      dp[i*j]++;
    }
  }
  
  for (int i = 1; i < n; ++i) ans += dp[i];
  cout << ans << '\n';
}


Measured memory_bytes: 11464
import sys

I = list(map(int, input().split()))
H_i = list(map(int,input().split()))
H_i = [i for i in H_i if 1 <= i and i <= 10**9]
N = I[0] # Monster数
K = I[1] # 必殺技回数

if not 0 <= K or not K <= 2*10**5 or not 1 <= N or not N <= 2*10**5:
    print("error")
    sys.exit()

H_i = sorted(H_i, reverse=True) # 降順ソート
H_i = H_i[K:]
ans = sum(H_i)
print(ans)

Measured memory_bytes: 26024
object Main extends App {
    val sc = new java.util.Scanner(System.in)

    val n = sc.nextInt
    val k = sc.nextInt
    val a = Array.fill(n)(sc.nextInt)
    for (i <- k until n) {
        println(if (a(i) > a(i-k)) "Yes" else "No")
    }

}

Measured memory_bytes: 60680
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stack>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <assert.h>
#include <unordered_map>

using namespace std;

const int maxN = 1e3;

#define FORU(i, l, r) for (int i = l; i <= r; ++i)
#define FORD(i, r, l) for (int i = r; i >= l; --i)
#define REPU(i, r) for (int i = 0; i < r; ++i)
#define F first
#define S second
#define PB push_back
#define LL long long
#define BIT(x, i) ((x >> i) & 1)
#define PINT pair < int, int >
#define MP make_pair

int n, d1, d2, marked[maxN][maxN], flag, color[maxN][maxN][2];
vector < PINT > lst[2][2], edge;
int dx[] = { 1, 1, -1, -1 },
    dy[] = { -1, 1, -1, 1 };

void dfs(int i, int j, int c, int col) {
    marked[i][j] = flag;
    color[i][j][c] = col;
    for (auto& p : edge)
        REPU(t, 4) {
            int ii = i + dx[t] * p.F;
            int jj = j + dy[t] * p.S;
            if (ii >= 0 && ii <= 2 * n && jj >= 0 && jj <= 2 * n)
                if (marked[ii][jj] != flag) dfs(ii, jj, c, 1 - col);
        }
}

void assign_color(int c, int d) {
    edge.clear();
    FORU(i, 0, min(2 * n - 1, (int) sqrt(d)))
        if (sqrt(d - i * i) == (int) sqrt(d - i * i))
            edge.PB({i, (int) sqrt(d - i * i)});
    ++flag;
    REPU(i, 2 * n)
        REPU(j, 2 * n)
            if (marked[i][j] != flag) dfs(i, j, c, 0);
}

int main() {
    cin >> n >> d1 >> d2;
    assign_color(0, d1);
    assign_color(1, d2);
    REPU(i, 2 * n)
        REPU(j, 2 * n)
            lst[color[i][j][0]][color[i][j][1]].PB({i, j});
    REPU(i, 2)
        REPU(j, 2)
            if (lst[i][j].size() >= n * n) {
                REPU(t, n * n) 
                    cout << lst[i][j][t].F << " " << lst[i][j][t].S << endl;
                return 0;
            }
}


Measured memory_bytes: 42328
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
aList = [int(x) for x in input().split()]

i = lcm_list(aList)-1
result = 0

for x in aList:
    result+=i%x
print(result)

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

int i;
string a, b;

bool fit(int x) {
  for(int i = 0; i < b.size(); ++i)
    if(a[i + x] != '?' && a[i + x] != b[i]) return 0;
  return 1;
}

int main() {
  ios_base::sync_with_stdio(0);

  cin >> a >> b;

  for(i = a.size() - b.size(); i >= 0; --i) {
    if(!fit(i)) continue;
    for(int j = 0; j < b.size(); ++j) if(a[i + j] == '?') a[i + j] = b[j];
    for(int j = 0; j < a.size(); ++j) if(a[j] == '?') a[j] = 'a';

    cout << a << '\n';
    return 0;
  }

  cout << "UNRESTORABLE\n";

  return 0;
}

Measured memory_bytes: 256
// Problem : A - Payment
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 100005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub uppper_bound
using namespace std;
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{
	int n;
	cin >> n;
	int x = n/1000;
	if(n%1000==0)
	{
		cout << 0 ;
		return;
	}
	x++;
	cout << x*1000-n;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3636
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int N,M,A,B,C,T;
V mul(const V &a, const V &b){
	V c(N*N);
	int i=0,j;
	for(;i<N;i++)for(j=0;j<N;j++)c[i*N+j]=(a[slice(i*N,N,1)]*b[slice(j,N,N)]).sum()%M;
	return c;
}
V exp(const V &a, const int n){
	if(n==1)return a;
	if(n%2==1)return mul(exp(a,n-1),a);
	V b=exp(a,n/2);
	return mul(b,b);
}
V z(){
	V x(N*N);
	int i;
	if(T){
		for(i=0;i<N;i++){
			if(i>0)x[i*N+i-1]=A;
			x[i*N+i]=B;
			if(i<N-1)x[i*N+i+1]=C;
		}
		return exp(x,T);
	}else{
		for(i=0;i<N;i++)x[i*N+i]=1;
		return x;
	}
}
main(){
	int i;
	V s;
	for(;scanf("%d%d%d%d%d%d",&N,&M,&A,&B,&C,&T),N;){
		s.resize(N);
		for(i=0;i<N;i++)scanf("%d",&s[i]);
		const V r=z();
		for(i=0;i<N;i++){
			printf(i<N-1?"%d ":"%d\n",(r[slice(i*N,N,1)]*s).sum()%M);
		}
	}
}

Measured memory_bytes: 1084
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		for (int i=0; i<n; i++) {
			System.out.println(sc.nextLine().replace("Hoshino", "Hoshina"));
		}
	}
}


Measured memory_bytes: 26404
#include <stdio.h>

int main(void) {
	int A, B;
	int rangeAmin;
	int rangeBmin;
	int maxMinAB;

	scanf("%d %d", &A, &B);

	if (A & 1) {
		rangeAmin = A * 100 / 8 + 1;
	}
	else {
		rangeAmin = A * 100 / 8;
	}

	rangeBmin = B * 10;

	if (rangeAmin >= rangeBmin) {
		maxMinAB = rangeAmin;
	}
	else {
		maxMinAB = rangeBmin;
	}

	if ((A == (maxMinAB * 8 / 100)) && (B == (maxMinAB * 10 / 100))) {
		printf("%d\n", maxMinAB);
	}
	else {
		printf("-1");
		printf("\n");
	}
	return 0;

}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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 ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll k; cin>>k;
  k--;
  if(k<=10){
    cout<<k+1<<endl;
    return 0;
  }
  queue<pll> q; 
  reps(i,9) q.emplace(i,i);
  ll cnt=9;
  
  vll nxt={-1,0,1};
  while(!q.empty()){
    auto p=q.front(); q.pop();
    ll v=p.first, c=p.second;
    rep(i,3){
      ll nc=c+nxt[i];
      if(nc<0||9<nc) continue;
      ll nv=v*10+nc;
      if(cnt==k){
        cout<<nv<<endl;
        return 0;
      }
      cnt++;
      q.emplace(nv,nc);
    }
  }
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
	int ans, f = 0, p = 0, d;
	while (f == 0) {
		p++;
		d = X - Y*p - Z*(p+1);
		if (d < 0) {
			ans = p - 1;
			goto l1;
		}
	}
l1:	cout << ans << endl;
	return 0;
}

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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;


void solve(){
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif
	multiset<char> s;

	string str;
	cin >> str;
	rep(i, str.size()){
		s.insert(str[i]);
	}
	bool flag = true;
	for (auto c : s){
		if (s.count(c) % 2 == 1){
			flag = false;
			break;
		}
	}
	cout << (flag ? "Yes" : "No") << endl;
}


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


	solve();
	//system("PAUSE");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    ll n, a, b; cin >> n >> a >> b;
    if (a + b <= n + 1 && n <= a * b) {
        VL x;
        ll m = n;
        while (ll(x.size()) < a && a - ll(x.size()) - 1 <= m - b) {
            x.push_back(b);
            m -= b;
        }
        if (ll(x.size()) < a) {
            x.push_back(m - (a - ll(x.size()) - 1));
            while (ll(x.size()) < a)x.push_back(1);
        }

        ll base = 0;
        VL ans;
        each(i, x) {
            erFOR(j, base + 1, min(base + i, n))ans.push_back(j);
            base += i;
        }
        FOR(i, 0, n)cout << ans[i] << ENDL(i, n);
    }
    else {
        cout << "-1\n";
        return 0;
    }
}

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

int main(int argc, char const *argv[])
{
    double r, are, cir;
    cin >> r;

    double pi = 3.141592653589;
    are = pi * r * r;
    cir = 2 * pi * r;

    printf("%.6f %.6f", are, cir);
    
    return 0;
}



Measured memory_bytes: 3204
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,a[100],ans=0,mini;
  cin >> n;
  for(int i=0; i<n; i++) {
      cin >> a[i];
  }
  for(int i=0; i<n; i++) {
      mini=i;
      for(int j=i; j<n; j++) {
          if(a[mini]>a[j]) {
              mini=j;
          }
      }
      if(mini!=i) {
          swap(a[i],a[mini]);
          ans++;
      }
  }
  for(int i=0; i<n-1; i++) {
      cout << a[i] << " ";
  }
  cout << a[n-1] << endl;
  cout << ans << endl;
}


Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<map>
#include<set>
#include<queue>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = (n-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long

int main(){
    int k; cin >> k;
    if(k % 2 == 0) cout << (k/2)*(k/2) << endl;
    else cout << (k/2+1)*(k/2) << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int A[100],N,sw;
int bubbleSort(int A[],int N)
{
	int sw=0;
	bool flag=1;
	for(int i=0;flag;i++)
	{
		flag=0;
		for(int j=N-1;j>=i+1;j--)
		{
			if(A[j]<A[j-1])
			{
				swap(A[j],A[j-1]);
				flag=1;
				sw++;
			}
		}
	}
	return sw;
}
int main()
{

	cin>>N;
	for(int i=0;i<N;i++)
	cin>>A[i];
	sw=bubbleSort(A,N);
	for(int i=0;i<N;i++)
	{
		if(i)cout<<" ";
		cout<<A[i];
	}
	cout<<endl;
	cout<<sw<<endl;
	return 0;
}

Measured memory_bytes: 3100
def base10toN(num, base):
    converted_string, modstring = "", ""
    currentnum = num
    if not num:
        return '0'
    while currentnum:
        mod = currentnum % base
        currentnum = currentnum // base
        converted_string = chr(48 + mod + 7*(mod > 10)) + converted_string
    return converted_string
h,w,k=map(int,input().split())
c=[]
for i in range(h):
  a=input()
  c.append(a)
ans=0
for i in range(2**h):
  iconvert=base10toN(i,2)
  ic=[]
  for _ in range(h-len(iconvert)):
    ic.append('0')
  for _ in range(len(iconvert)):
    ic.append(iconvert[_])
  for j in range(2**w):
    jconvert=base10toN(j,2)
    jc=[]
    for _ in range(w-len(jconvert)):
      jc.append('0')
    for _ in range(len(jconvert)):
      jc.append(jconvert[_])
    count=0
    for a in range(h):
      for b in range(w):
        if ic[a]=='0' and jc[b]=='0' and c[a][b]=='#':
          count+=1
    if count==k:
      ans+=1
print(ans)


Measured memory_bytes: 74300
import sys
a =[]
a.append(list(map(int,input().split())))
a.append(list(map(int,input().split())))
a.append(list(map(int,input().split())))
n = int(input())
b =[]
for i in range(n):
    b.append(int(input()))
#print(b)
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = 0
#print(a)

for i in range(3):
    if sum(a[i])==0:
        print('Yes')
        exit()
for i in range(3):
    if a[0][i]+a[1][i]+a[2][i]==0:
        print('Yes')
        exit()
if (a[0][0]+a[1][1]+a[2][2]==0)or(a[0][2]+a[1][1]+a[2][0]==0):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3192
/*         _    _____         _
           \`,""   ,'7"r-..__/ \
          ,'\ `, ,',','    _/   \
         /   \  7 / /     (   \ |
        J     \/ j  L______\  / |
        L   __JF"""/""\"\_,    /
        L,-"| O|  f O |  L_  _/
        F   \_ /  \__/   `-  j|
            .-'    `"""    ,' |          _..====.._
            \__/         r"_  A        ,' _..---.._`,
             `-.______,,-L// / \  ___,' ,'_..:::.. `,`,
                      j   / / / 7"    `-<""=:'  '':. \ \
                     /   <,' /  F  . i , \   `,    :T W I
                     |    \,'  /    >X<  |     \   :| | L
                     |     `._/    ' ! ` |      I  :| |  G
                      \           \     /       |  :H T  |
                     __>-.__   __,-\   |        |  S P   |
                    /     /|   | \  \  \_       | 'A R   |
                   /   __/ |   |  L  L   \      K./ /    L
                  /   |    |   4  I  I    |    E./ /   ,'
                 J    \    I    L F  I    |    // / _,'
        _________|     |   F    |J   F    |   //_/-'
        \   __   |    /   J     |/  J     |  /="
        \\  \_\  \__,' \  F     |   F     |
        \\\_____________\/      F__/      F
         \\| ¼ÆËã»ú±à³Ì |_____/  (______/
          \/´ÓÈëÃÅµ½ÈëÍÁ/
*/
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string> 
using namespace std;
int main(){
	string s;
	cin>>s;
	int len=s.length();
	if(s[0]==s[len-1]){
		if(len%2==1){
			cout<<"Second";
			return 0;
		}
		else{
			cout<<"First";
			return 0;
		}
	}
	else{
		if(len%2==1){
			cout<<"First";
			return 0;
		}
		else{
			cout<<"Second";
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 512
function Main(input) {
	input = input.trim();
  var list = input.split("\n")[1].split(" ").map((list)=>Number(list)).sort(function(a,b){return b - a;});
  var max = list.shift();
  if(list.length == 1){
     console.log(max + " " + list[0]);
  }else{
    var kijun = Math.floor(max / 2);
    var output = max;
    var last = max;
    for(var i = 0; i < list.length; i++){
      if(last > Math.abs(kijun - list[i])){
         output = list[i];
        last = Math.abs(kijun - list[i]);
      }
    }
    console.log(max + " " + output);
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 28744
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> arr(n);
  long long int min = LLONG_MAX;
  long long int cnt = 0;
  for(int i = 0; i < n; i++){
    cin >> arr[i];
    if(arr[i] <= min){
      min = arr[i];
      cnt++;
    }
  }
  cout << cnt << endl;
    
return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int N,ans;
  	cin>>N;
  	ans=N;
  	for(int i=0;i<=10;i++){
      	if(ans<=1000) {
        	cout<<1000-ans;
          	return 0;
        }
    	ans=ans-1000;
    }
  	cout<<1000-ans;
  	return 0;
}

Measured memory_bytes: 3592
//
//  main.cpp
//  ABC162E-teacher
#include <iostream>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back((int)i);
      f[i] = (int)i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = (int)i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
  int n, k;
  cin>>n>>k;
  mint my_ans;
    vector<mint>my_d(k+1);
  for (int i = 1; i <= k; ++i) {
    my_d[i] = mint(k/i).pow(n);
  }
    for(int x=k;x>=1;x--){
        int j=2;
        while(x*j<=k){
            my_d[x]-=my_d[x*j];
            j++;
            if(j==1)break;
        }
    }
    for (int i = 1; i <= k; ++i){
        my_ans += my_d[i]*i;
    }
    cout << my_ans << endl;
  return 0;
}


Measured memory_bytes: 3528
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<map>
#define ran(x) (x).begin(),(x).end()
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<string> s(n), t(m);
	for(int i = 0; i < n; ++i)
		cin >> s[i];
	for(int j = 0; j < m; ++j)
		cin >> t[j];
	int ans = 0;
	int k = 0;
	for(int f = 0; f < n - m + 1; ++f) {
		int l = 0;
		for(int h = 0; h < n - m + 1; ++h) {
			int cou = 0;
			for(int i = 0; i < m; ++i) {
				for(int j = 0; j < m; ++j) {
					if(t[i][j] == s[i + k][j + l])
						++cou;
				}
			}
			if(cou == m * m)
				ans = 1;
			++l;
		}
		++k;
	}
	cout << (ans == 1 ? "Yes" : "No") << endl;
}

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

int main(void)
{
	char str[21];
	char strre[21];
	int i;
	
	scanf("%s", str);
	
	for (i = strlen(str) - 1; i >= 0; i--){
		printf("%c", str[i]);
	}
	
	printf("\n");
	
	return (0);
}

Measured memory_bytes: 524
/**
 * auther: moririn_cocoa
 */

#include <iostream>
#include <math.h>
using namespace std;

int main(void) {
  
  string S;

  cin >> S;

  
  if ( S == "SUN" ) {
    
    cout << 7 << endl;
  }
  
  else if ( S == "MON" ) {
    
    cout << 6 << endl;
  }
  
  else if ( S == "TUE" ) {
    
    cout << 5 << endl;
  }
  
  else if ( S == "WED" ) {
    
    cout << 4 << endl;
  }
  
  else if ( S == "THU" ) {
    
    cout << 3 << endl;
  }
  
  else if ( S == "FRI" ) {
    
    cout << 2 << endl;
  }
  
  else if ( S == "SAT" ) {
    
    cout << 1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3588
#python3ではTLE
#input
N = int(input())
A = list(map(int, input().split()))

#output
B = [(i, a) for i, a in enumerate(A)]
B = sorted(B, key = lambda x:x[1], reverse = True)

dp = [[0] * (N+1) for i in range(N+1)]
#dp[i, j]を左i, 右jまで場所が決まった状態の最大値とする。
#i+j = Nとなる場合の最大値が答えとなる。

answer = 0
for i in range(N):
    dp[i+1][0] = dp[i][0] + B[i][1]*(abs(B[i][0]-i))
    for j in range(N):
        dp[0][j+1] = dp[0][j] + B[j][1]*(abs(N-1-B[j][0]-j))
        if i+j+1 < N:
            dp[i+1][j+1] = max(dp[i][j+1]+B[i+j+1][1]*(abs(B[i+j+1][0]-i)), dp[i+1][j] + B[i+j+1][1]*(abs(N-1-B[i+j+1][0]-j)))
    answer = max(answer, dp[i][N-i])

print(answer)

Measured memory_bytes: 100976
objects = []

max_n = 123456*2

sosu_arr = []
sosu_set = {}

max_n.times.each do |ii|
  i = ii + 1
  next if i == 1
  next if sosu_set.key?(i)
  sosu_arr.push i
  sosu_set[i] = true
  (max_n/i).to_i.times.each do |j|
    next if j == 0
    sosu_set[i * (j+1)] = false
  end
end

lines = []
while num = gets
  num = num.to_i
  break if num == 0
  if num == 1
    puts 1
    next
  end
  sum = 0
  ((num+1)..(num*2)).each do |i|
    sum = sum + 1 if sosu_set[i]
  end
  puts sum
end

Measured memory_bytes: 22312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll X, Y, Z, K;
ll A[1005], B[1005], C[1005];

int main() {
    cin >> X >> Y >> Z >> K;
    for(int i = 1; i <= X; i++) cin >> A[i];
    for(int i = 1; i <= Y; i++) cin >> B[i];
    for(int i = 1; i <= Z; i++) cin >> C[i];
    vector<ll> tmp;
    for(int i = 1; i <= X; i++) {
        for(int j = 1; j <= Y; j++) {
            tmp.push_back(A[i] + B[j]);
        }
    }
    sort(tmp.begin(), tmp.end(), greater<ll>());
    if(tmp.size() >= K) tmp.resize(K);
    vector<ll> v;
    for(int i = 0; i < tmp.size(); i++) {
        for(int j = 1; j <= Z; j++) {
            v.push_back(tmp[i] + C[j]);
        }
    }
    sort(v.begin(), v.end(), greater<ll>());
    for(int i = 0; i < K; i++) {
        cout << v[i] << endl;
    }
    return 0;
}


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



int main(){
    string s;
    cin>>s;
    if(s=="ABC"){
        cout<<"ARC"<<endl;
    }else{
        cout<<"ABC"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3624
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		Integer[] a = new Integer[N];
		for (int i = 0; i < N; i++) {
			a[i] = in.nextInt();
		}
		Arrays.sort(a, Collections.reverseOrder());
		int count = 0;
		long sum = 1;
		for (int i = 0; i < a.length - 1;) {
			if (a[i].equals(a[i + 1])) {
				sum *= a[i];
				count++;
				if (count == 2) {
					break;
				}
				i += 2;
			} else {
				i++;
			}
		}
		System.out.println(count != 2 ? 0 : sum);
		in.close();
	}

}

Measured memory_bytes: 61560
package main

import "fmt"

func main() {
	var d int
	fmt.Scan(&d)

	if d == 25 {
		fmt.Println("Christmas")
	} else if d == 24 {
		fmt.Println("Christmas Eve")
	} else if d == 23 {
		fmt.Println("Christmas Eve Eve")
	} else if d == 22 {
		fmt.Println("Christmas Eve Eve Eve")
	}
}


Measured memory_bytes: 512
#include <stdio.h>
#include <inttypes.h>
#include <stdbool.h>

static inline bool same(uint_fast8_t x, uint_fast8_t y,
                        const uint_fast8_t *g, const size_t size)
{
    bool inx = false;
    bool iny = false;
    for (size_t i = 0; i < size; ++i) {
        if (g[i] == x) {
            inx = true;
        }
        if (g[i] == y) {
            iny = true;
        }
    }
    return inx && iny;
}

int main(void)
{
    const uint_fast8_t a[] = { 1, 3, 5, 7, 8, 10, 12 };
    const uint_fast8_t b[] = { 4, 6, 9, 11 };
    const uint_fast8_t c[] = { 2 };
    uint_fast8_t       x, y;
    scanf("%" SCNuFAST8 " %" SCNuFAST8, &x, &y);
    puts((same(x, y, a, sizeof(a))
          || same(x, y, b, sizeof(b))
          || same(x, y, c, sizeof(c))
          ) ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
import bisect
def near_abs_id(a,target,fast=True): # a:listの中で絶対値がもっともtargetに近い要素のindex
    # 複数存在する場合は一番indexが小さいもの
    if fast: # O(logn)　### 昇順にソート済みで，全て正の数であることが必要
        idx = bisect.bisect_left(a,target)
        if idx==0: return idx
        elif idx==len(a): return len(a)-1
        else:
            if idx==len(a)-1:
                if abs(a[idx-1]-target)<=abs(a[idx]-target):
                    return idx-1
                else:
                    return idx
            else:
                now = abs(a[idx+1]-target)
                ans = idx+1
                for i in (0,-1):
                    if abs(a[idx+i]-target)<=now:
                        ans -= 1
                        now = abs(a[idx+i]-target)
                return ans
    else: # O(n)
        idx = 0
        m = float('inf')
        for i in range(len(a)):
            if abs(a[i]-target) < m:
                m = abs(a[i]-target)
                idx= i
        return idx

n = int(input())
a = list(map(int,input().split()))

a.sort()
m = a[-1]
j=near_abs_id(a,m/2)
if j==n-1:
    j-=1
print(m,a[j])


Measured memory_bytes: 14424
N, M = map(int, input().split())
height = [int(i) for i in input().split()]
Good_Peak = []
for i in range(N):
  Good_Peak.append(True)
for i in range(M):
  A, B = map(int, input().split())
  if height[A-1] <= height[B-1]:
    Good_Peak[A-1] = False
  if height[B-1] <= height[A-1]:
    Good_Peak[B-1] = False
print(Good_Peak.count(True))

Measured memory_bytes: 20016
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string a;
	cin >> a;
	cout << "2018";
	for (int i = 4; i < a.size(); i++)
	{
		cout << a[i];
	}
	cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int A[1000000],n;

int bs(int key){
	int left=0;
	int right=n;
	int mid;
	while(left<right){
		mid=(left+right)/2;
		if(key==A[mid]) return 1;
		if(key>A[mid]) left=mid+1;
		else if(key<A[mid]) right=mid;
	}
	return 0;
}

int main(){
	int i,q,k,sum=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",&k);
		if(bs(k)) sum++;
	}
	printf("%d\n",sum);
	return 0;
	
}



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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)

#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(void)
{
    string a;
    int i;
    int sum;
    cin>>a;
    while('0'!=a[0]) {
        for(i=0;a[i]!='\0';i++) {
            sum+=a[i]-'0';
        }
        cout<<sum<<endl;
        sum=0;
        cin>>a;
    }
}



Measured memory_bytes: 3184
#include<bits/stdc++.h>							
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;
const ll maxsize = 100000009;



void solve() {
	int n;
	cin >> n;
	int arr[n];
	for(int i = 0; i < n; ++i) cin >> arr[i];
	sort(arr, arr + n);
	int l = arr[0], r = arr[n - 1];
	ll ans = maxn;
	for(int i = l; i <= r; ++i) {
		ll sum = 0;
		for(int j = 0; j < n; ++j) {
			sum += pow(abs(i - arr[j]), 2);
			}
			ans = min(ans, sum);
		}
		cout << ans << endl;
}


int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	int t;
	solve();
	return 0;
}
 
 
 


Measured memory_bytes: 3660
//============================================================================
// Name        : template.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <vector>
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

int main() {
    string s,t;
    cin >> s;
    cin >> t;

    int ln = s.length();
    int ans = 0;
    forn(i, ln) {
        if(s[i] == t[i]) ans += 1; 
    }

    cout << ans;
return 0;
}


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

using namespace std;

int main()
{
    while (true) {
        int n;
        int m;
        cin >> n >> m;
        if (n == 0 && m == 0) {
            break;
        }

        vector<int> v;
        for (int i = 0; i < n; ++i) {
            int a;
            cin >> a;
            v.push_back(a);
        }

        int r = -1;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                if (i == j) {
                    continue;
                }
                auto a = v[i] + v[j];
                if (a <= m) {
                    r = max(a, r);
                }
            }
        }
        if (r == -1) {
            cout << "NONE" << endl;
        }
        else {
            cout << r << endl;
        }
    }
}


Measured memory_bytes: 3120
#include<string>
using namespace std;
#include <stdio.h>
#include <limits.h>
#include "bits/stdc++.h"
int X = 700;
string s;

int main() {
	cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == 'o') {
			X = X + 100;
		}
	}
	cout << X;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for(i=0;i<n;i++)
#define fo(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define vl vector<ll>
#define mod 1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main(){
    //IOS
    ll l,i,j,n,t,tt;

    //cin>>t;
    t=1;
    while(t--){
        ll k,x,m,c,q,v,r,p,f,mid;
        string s;
        cin>>s;
        n=s.length();
        rep(i,n){
            if(s[i]=='?'){
                s[i]='D';
            }
        }
        cout<<s;







    }






    return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

struct UnionFind{
  vector<int> d;
  UnionFind(int n) : d(n, -1){}
  int find(int x){
    if(d.at(x) < 0) return x;
    return d.at(x) = find(d.at(x));
  }
  bool unite(int x, int y){
    x = find(x); y = find(y);
    if(x == y) return false;
    if(d.at(x) > d.at(y)) swap(x, y);
    d.at(x) += d.at(y);
    d.at(y)= x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d.at(find(x)); }
};

int main(){
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  vector<vector<int>> gr(n, vector<int>());
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    uf.unite(a, b);
    gr.at(a).push_back(b);
    gr.at(b).push_back(a);
  }
  vector<int> ans(n);
  rep(i, n){
    ans.at(i) = uf.size(i) - 1 - gr.at(i).size();
  }
  rep(i, k){
    int c, d;
    cin >> c >> d;
    c--; d--;
    if(uf.same(c, d) == true){
      ans.at(c)--;
      ans.at(d)--;
    }
  }
  rep(i, n){
    if(i != 0) cout << " ";
    cout << ans.at(i);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 10000
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

int main() {
    int N,C,K;
    cin>>N>>C>>K;
//    int* T = new int[N];
    vector<int> T(N);

    rep(i, N){
        cin>>T[i];
    }

    sort(T.begin(), T.end());
    int count = 0;
    int ans = 0;
    int t = 0;

    rep(i, N){
        if(t == 0){
            t = T[i];
        }
        if(T[i] - t > K){
            ans += 1;
            t = T[i];
            count = 0;
        }
        if(count == C){
            count = 0;
            ans += 1;
            t = T[i];
        }
        count += 1;
    }
    if(count != 0){
        ans += 1;
    }
    cout << ans;
}

Measured memory_bytes: 640
def examD():
    N, M = LI()
    V = [[] for _ in range(N)]
    ans = [0]*N
    Cnt=[0]*(N+1); Cnt[N]=1
    for i in range(N+M-1):
        a, b = LI()
        V[a-1].append(b-1)
        Cnt[b-1] += 1
    root = Cnt.index(min(Cnt))
    que = [root]
#    print(Cnt)
#    print(root)
    while que:
        v = que.pop()
        for u in V[v]:
            if Cnt[u] == 1:
                ans[u] = v+1
                que.append(u)
            else:
                Cnt[u] -= 1
    print(*ans, sep='\n')
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examD()


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

int main() {
  long long x, y;
  cin >> x >> y;
  
  long long z = x, cnt = 0;
  while (z <= y) {
    cnt++;
    z *= 2;
  }
  cout << cnt << endl;
}
    

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

int main()
{
	int N, x;
	cin >> N >> x;

	string ans = "No";
	int n = 2 * N - 1;
	vector<int> v( n );
	if( 1 < x && x < n ) {
		ans = "Yes";
		if( N == 2 ) {
			for( int i = 0; i < n; i++ ) v[i] = i + 1;
		}
		else {
			int n2 = n / 2;
			if( x == 2 ) {
				v[n2 - 1] = x + 1;
				v[n2] = x;
				v[n2 + 1] = x - 1;
				v[n2 + 2] = x + 2;
				int j = 1;
				for( int i = 0; i < n2 - 1; i++ ) {
					if( j == x - 1 ) j = x + 3;
					v[i] = j;
					j++;
				}
				for( int i = n2 + 3; i < n; i++ ) {
					if( j == x - 1 ) j = x + 3;
					v[i] = j;
					j++;
				}
			}
			else {
				v[n2 - 1] = x - 1;
				v[n2] = x;
				v[n2 + 1] = x + 1;
				v[n2 + 2] = x - 2;
				int j = 1;
				for( int i = 0; i < n2 - 1; i++ ) {
					if( j == x - 2 ) j = x + 2;
					v[i] = j;
					j++;
				}
				for( int i = n2 + 3; i < n; i++ ) {
					if( j == x - 2 ) j = x + 2;
					v[i] = j;
					j++;
				}
			}
		}
	}

	cout << ans << endl;
	if( ans == "Yes" ) {
		for( int i = 0; i < n; i++ ) {
			cout << v[i] << endl;
		}
	}
}


Measured memory_bytes: 2304