akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    bool ans = false;
    if (a <= c && c <= b)ans = true;
    if (ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main(){
    int H, W;
    cin >> H >> W;
    string S = "";
    rep(i, H){
        string temp = "";
        cin >> temp;
        S += temp;
    }
    //cout << S << endl;
    rep(i, H){
        rep(j, W){
            int x = i*W + j;
            if (S[x] == '#'){
                cout << '#' ;
            } else {
                int ans = 0;
                int x_ = x-W-1;
                if ((x_ >= 0) && (x_ >= (i-1)*W) && (x_ < i*W) && (S[x_] == '#')) ans += 1;
                x_ = x-W;
                if ((x_ >= 0) && (x_ >= (i-1)*W) && (x_ < i*W) && (S[x_] == '#')) ans += 1;
                x_ = x-W+1;
                if ((x_ >= 0) && (x_ >= (i-1)*W) && (x_ < i*W) && (S[x_] == '#')) ans += 1;

                x_ = x-1;
                if ((x_ >= 0) && (x_ >= i*W) && (x_ < (i+1)*W) && (S[x_] == '#')) ans += 1;
                x_ = x+1;
                if ((x_ >= 0) && (x_ >= i*W) && (x_ < (i+1)*W) && (S[x_] == '#')) ans += 1;

                x_ = x+W-1;
                if ((x_ < H*W) && (x_ >= (i+1)*W) && (x_ < (i+2)*W) && (S[x_] == '#')) ans += 1;
                x_ = x+W;
                if ((x_ < H*W) && (x_ >= (i+1)*W) && (x_ < (i+2)*W) && (S[x_] == '#')) ans += 1;
                x_ = x+W+1;
                if ((x_ < H*W) && (x_ >= (i+1)*W) && (x_ < (i+2)*W) && (S[x_] == '#')) ans += 1;
                cout << ans;
            }
        }
        cout << endl;
    }
}

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

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

string s,t; 
ll idx[30]; 


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

    cin >> s >> t;

    for (int i = 0; i < 26;i++){
        char c = 'a'+i;
        for (int j = 0;j < t.size() ;j++){
            if(t[j] == c){
                bool f = false;
                for (int k = 0;k < s.size();k++){
                    if(s[k] == c){
                        f = true;
                        break;
                    }
                }
                if(f == false){
                    cout << -1 << endl;
                    return 0;
                }
                break;
            }
        }
    }

    vector<ll> pos[30];

    for (int i = 0;i < 26;i++){
        char c = 'a'+i;
        for (int j = 0;j < s.size();j++){
            if(s[j] == c) pos[i].push_back(j);
        }
    }

    ll cnt = 0;
    ll las = -1;

    for (int i = 0;i < t.size();i++){
        ll num = t[i]-'a';
        ll tmp = upper_bound(pos[num].begin(), pos[num].end(), las) - pos[num].begin();
        //cout << tmp << " " << las << endl;

        if(idx[num] < tmp) idx[num] = tmp;
        //cout << s[pos[num][idx[num]]] << endl;

        //cout << idx[num] << endl;

        if(idx[num] >= pos[num].size()){
            memset(idx,0,sizeof(idx));
            idx[num] = 1;
            las = pos[num][0];
            cnt += 1;
            //cout << "fsadfasf" << endl;
        }else{
            las = pos[num][idx[num]];
            //cout << t[i] << endl;
            idx[num] += 1;
        }
        //cout << i << " " << cnt << " " << las << endl;
    }

    cout << s.size()*cnt+las+1LL << endl;

    return 0;

}

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

bool cmp(pair<int,int>a, pair<int,int>b)
{
    if(a.first==b.first)
        return (a.second > b.second);
    return a.first<b.first; 
}

int main()
{
    int n, m; cin>>n>>m;
    pair<int,int>a[n];
    for(int i=0; i<n; i++) cin>>a[i].first>>a[i].second;
    sort(a,a+n,cmp);
    //for(int i=0; i<n; i++) cout<<a[i].first<<" "<<a[i].second<<"\n"; cout<<endl;
    int ans=0;
    int from=a[0].first-1;
    //int to;
    priority_queue<int>pq;
    for(int i=0; i<n; i++)
    {
        if(a[i].first > m) { break; }
        if(i==0) 
        {
            ans+=a[i].second;
            from=a[i].first;
        }
        else
        {   
            pq.push(a[i].second);
            int dif=a[i].first-from;
            while(dif>0 and !pq.empty())
            {
                ans+=pq.top();
                pq.pop();
                dif--;
            }
            from=a[i].first;
        }
    }
    int dif=m-from;
    while(dif>0 and !pq.empty())
    {
        ans+=pq.top();
        pq.pop();
        dif--;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1660
#include <iostream>
using namespace std;
int main(void){
	int n,x,t,ans;
	cin >> n >> x >> t;
	if (n%x == 0) {
		ans = int(n/x) * t;
	} else {
		ans = (int(n/x)+1) * t;
	}
	cout << ans << '\n';
}


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

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

int main(){
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;

	vector<int>  Z;
	int now = 1;
	int cnt = 0;
	rep(i,N){
		if(S[i]=='0'+now)cnt++;
		else { Z.push_back(cnt); now ^= 1; cnt=1; }
	}
	if(cnt!=0)Z.push_back(cnt);
	if(Z.size()%2 == 0)Z.push_back(0);

	int Add = 2 * K + 1;

	int ans = 0;

	int left = 0;
	int right = 0;
	int tmp = 0;

	for(int i=0; i<(int)Z.size(); i+=2){
		int Nextleft = i;
		int Nextfight = min(i+Add, (int)Z.size());

		while(Nextleft > left){
			tmp -= Z[left];
			left++;
		}

		while(Nextfight > right){
			tmp += Z[right];
			right++;
		}

		ans = max(ans,tmp);
	}

	cout << ans << endl;

}



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

using Oct=array<int,8>;
void rotateA(Oct& o){
    Oct tmp=o;
    for(int i=0;i<4;i++){
        o[i]=tmp[(i+1)%4];
        o[i+4]=tmp[(i+1)%4+4];
    }
}
void rotateB(Oct& oct){
    Oct tmp=oct;
    oct[0]=tmp[4];
    oct[1]=tmp[5];
    oct[2]=tmp[1];
    oct[3]=tmp[0];
    oct[4]=tmp[7];
    oct[5]=tmp[6];
    oct[6]=tmp[2];
    oct[7]=tmp[3];
}

bool check(Oct oct,set<Oct> &s){
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            for(int k=0;k<4;k++){
                if(s.count(oct)) return false;             
                rotateA(oct);
            }
            rotateB(oct);
        }
        rotateA(oct);
    }
    return true;
}
int dfs(int x,const vector<int>& v,set<Oct>& s,Oct& oct){
    if(x==8){
        assert(count(oct.begin(),oct.end(),-1)==0);
        if(!check(oct,s)) return 0;
        s.insert(oct);
        return 1;
    }
    int res=0;
    for(int i=0;i<oct.size();i++){
        if(oct[i]==-1){
            oct[i]=v[x];
            res+=dfs(x+1,v,s,oct);
            oct[i]=-1;
        }
    }
    return res;
}
int main(){
    vector<string> color(8);
    while(cin>>color[0]){
        for(int i=1;i<8;i++) cin>>color[i];
        map<string,int> mp;
        for(int i=0;i<8;i++) mp[color[i]]++;
        vector<int> v;
        int idx=0;
        for(auto &e:mp){
            for(int i=0;i<e.second;i++) v.push_back(idx);
            idx++;
        }
        set<Oct> s;
        Oct oct;
        fill(oct.begin(),oct.end(),-1);
        cout<<dfs(0,v,s,oct)<<endl;
    }
    return 0;
}


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

using namespace std;

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define SQ(a) (a)*(a)

template <class T, class U> ostream& operator<< (ostream &out, pair<T,U> c) { out << "(" << c.first << " "; out << c.second << ")"; return out; }
template <class T> ostream& operator<< (ostream &out, vector<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
const double PI  = 3.141592653589793238463;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, k;
    cin >> a >> b >> k;
    if(b-a+1 <= 2*k){
        FOR(i,a,b+1){
            cout << i << endl;
        }
    }
    else{
        FOR(i,a,a+k){
            cout << i << endl;
        }
        FOR(i,b-k+1, b+1){
            cout << i << endl;
        }
    }
}   

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <map>
#include <vector>
#include <climits>
#include <cmath>

using integer = unsigned long long;

int main(void) {
  integer a, b, c;
  std::cin >> a >> b >> c;

  for (int i = 0; i <= 100; i++) {
    if ((a * i) % b == c) {
      std::cout << "YES" << std::endl;
      return 0;
    }
  }

  std::cout << "NO" << std::endl;
  return 0;
}


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

int main(){
    string S,T;
    cin >> S;
    cin >> T;
    int count = 0;
    rep(i,S.size()){
        if( S[i] != T[i] ) ++count;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3852
//35
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    int h=0,l=500;
    while(n--){
      int s=0;
      for(int i=0;i<5;i++){
	int t;
	cin>>t;
	s+=t;
      }
      h=max(h,s);
      l=min(l,s);
    }
    cout<<h<<' '<<l<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <utility>
#include <queue>
#include <algorithm>
using namespace std;

int main(){
	typedef pair<int,int> pii;
	priority_queue<pii> pq;
	int n, r, l, d, t, x, u = 0;
	scanf("%d%d%d", &n, &r, &l);
	vector<int> s(n + 1), c(n + 1);
	for(int i = 1; i <= n; ++i){
		pq.push(pii(0, ~i));
	}
	for(int i = 0; ; ++i){
		if(i == r){
			t = l;
		}
		else{
			scanf("%d%d%d", &d, &t, &x);
		}
		while(1){
			pii p = pq.top();
			if(s[~p.second] == p.first){
				c[~p.second] += t - u;
				break;
			}
			pq.pop();
		}
		if(i == r){
			break;
		}
		s[d] += x;
		pq.push(pii(s[d], ~d));
		u = t;
	}
	int ans = max_element(c.begin(), c.end()) - c.begin();
	printf("%d\n", ans);
}

Measured memory_bytes: 11700
#include <stdio.h>
int main(void){
  int n,k,d[10]={},i,y,t,s,l;
  bool con=true;
  scanf("%d%d",&n,&k);
  for (i=0;i<k;i++){
    scanf("%d",&y);
    d[y]=1;
  }
  t=n-1;
  while (con){
    t++;
    s=t;
    while (s){
      l=s%10;
      if (d[l]) break;
      s=(s-l)/10;
    }
    if (s==0) con=false;
  }
  printf("%d\n",t);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
 
int main() {
	int n,m,l;
	int a,b,c;
	long long A[100][100],B[100][100],C[100][100];
 
	cin >> n >> m >> l;
 
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> a;
			A[i][j] = a;
		}
	}
 
	for(int i = 0; i < m; i++){
		for(int j = 0; j < l; j++){
			cin >> b;
			B[i][j] = b;
		}
	}
 
	for(int i = 0; i < n; i++){
		for(int j = 0; j < l; j++){
			C[i][j] = 0;
			for(int k = 0; k < m; k++){
				C[i][j] += A[i][k]*B[k][j];
			}
			if(j)cout << " ";
			cout << C[i][j] ;
		}
		cout << endl;
	}
 
 
	return 0;
}

Measured memory_bytes: 3184
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

S = ins()
K = "keyence"


def solve():
    if len(S) < len(K):
        return False
    f = b = True
    x = y = 0
    ns = len(S)
    nk = len(K)
    for i in range(len(S)):
        if i < nk and S[i] == K[i]:
            if f:
                x += 1
        else:
            f = False
        if nk - 1 - i >= 0 and S[ns - 1 - i] == K[nk - 1 - i]:
            if b:
                y += 1
        else:
            b = False
    # debug(f"{x=} {y=}")
    return x + y >= nk


print("YES" if solve() else "NO")


Measured memory_bytes: 9128
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<cmath>
#include<queue>
#include<map>
#include<set>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
vector<int> ans;
int n,num2,num3;
inline void Push(int j)
{
    ans.push_back(2+j);
    ans.push_back(3+j);
    ans.push_back(4+j);
    ans.push_back(8+j);
    ans.push_back(9+j);
    ans.push_back(10+j);
}
int main()
{
    n=read();
    
    if(n==3) return 0*puts("2 5 63");
    if(n==4) return 0*puts("2 5 20 63");
    if(n==5) return 0*puts("2 3 4 6 9");
    Push(0);
    for(int j=2;ans.size()+5000<n;j+=2) Push(j*6);
    for(int k=6;ans.size()<n;k+=6) ans.push_back(k);
    for(int i=0;i<ans.size();++i) printf("%d ",ans[i]);
    return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1

using namespace std;

int main() {
  int n, m, p, x, sum, num;
  while (cin >> n >> m >> p, n | m | p) {
    sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> x;
      sum += x;
      if (i == m-1) num = x;
    }
    if (num == 0) cout << num << el;
    else cout << sum*(100-p)/num << el;
  }
}

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

const ll mod = 1e9 + 7;

// dp[x][y] := (x, y)から始まる(H, W)へ行く経路の個数
// dp[x][y] = dp[x+1][y] + dp[x][y+1]
// (x, y)が壁ますだったら0にする
// xが大きい順，yが大きい順

// dp[H][W] = 0

ll dp[3030][3030];
string field[3030];
int main() {
    int H, W;
    cin >> H >> W;

    for (int i = 0; i < H; ++i) cin >> field[i];

    dp[H-1][W-1] = 1;
    for (int y = H-1; y >= 0; --y) {
        for (int x = W-1; x>=0; --x) {
            dp[y][x] = (dp[y][x] + dp[y+1][x] + dp[y][x+1]) % mod;
            dp[y][x] %= mod;
            if (field[y][x] == '#') dp[y][x] = 0;
        }
    }

    cout << dp[0][0] << endl;
}


Measured memory_bytes: 24832
n,a,b,c=map(int,input().split())
l=[]
for i in range(n):
    l.append(int(input()))
op=[[0],[1],[2],[3]]
for i in range(n-1):
    tmp=[]
    for j in op:
        tmp.append(j+[0])
        tmp.append(j+[1])
        tmp.append(j+[2])
        tmp.append(j+[3])
    op=tmp
ans=1000000000
for i in op:
    ta=0
    tb=0
    tc=0
    mp=0
    for j in range(len(i)):
        if i[j]==0:
            if ta!=0:
                mp+=10
            ta+=l[j]        
        elif i[j]==1:
            if tb!=0:
                mp+=10
            tb+=l[j]
        elif i[j]==2:
            if tc!=0:
                mp+=10
            tc+=l[j]
    mp+=abs(a-ta)+abs(b-tb)+abs(c-tc)
    if ta==0 or tb==0 or tc==0:
        mp=1000000000
    ans=min(ans,mp)
print(ans)


Measured memory_bytes: 15092
function Main(input) {
		input = input.split(" ");
		const num = parseInt(input[0], 10);
		var min = 0;
		var res = 0;
		for (i = 1; i <= Math.sqrt(num); i++) {
				if (num % i == 0) {
						if (min == 0 || (i - 1) + (num / i - 1) < min) {
								res = i + (num / i) - 2;
								min = res;
						}
				}
		}
		console.log(res);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

void magic(int a,int b,int c,int k)
{
    for (int i = 0; i < k; i++)
    {
        if(a >= b)
        {
            if (b >= c)
                c*=2;
            else
                b*=2;
        }
        else  if (a < b) {
            if(b*2 < c)
                b*=2;
            else if(b*2 >= c)
                c*=2;
        }
    }
  //  cout<<a<<"  "<<b<<"  "<<c<<endl;

  if (a < b && b < c)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

int main ( )
{
    int a,b,c,k;
    cin>>a>>b>>c;
    cin>>k;
    magic(a,b,c,k);
    return 0;
}


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

const int N = 0;
const int INF = 2e9;
const int mod = 1e9+7;

int ans, n, m, k;

int main() {
  scanf("%d%d", &n, &m);
  ans = (n+m+1)/2;

  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    int a, b; cin >> a >> b;
    cout << a * b - a - b + 1 << endl;
    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for(auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n + 1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for(auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for(auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for(auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int>> name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num)) + 1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)                                                                                                          \
  cerr << "[";                                                                                                         \
  REPI(itr, v) { cerr << *itr << (itr != --v.end() ? ", " : ""); }                                                     \
  cerr << "]" << endl;
#define dpa(v)                                                                                                         \
  cerr << "[ " << endl;                                                                                                \
  REPI(itr, v) {                                                                                                       \
    cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl;            \
  }                                                                                                                    \
  cerr << "]" << endl;

void solve(long long N) {
  N = N % 10;

  string s = "";
  if(N == 3) {
    s = "bon";
  } else if(N == 0 or N == 1 or N == 6 or N == 8) {
    s = "pon";
  } else {
    s = "hon";
  }

  cout << s << endl;
}

signed main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
}


Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <list>

using namespace std;

static const int MAX = 100000;
static const int INFTY = ( 1 << 29);

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int s)
{
	queue<int> q;
	q.push(s);

	V[s] = true;
	while (!q.empty())
	{
		int u = q.front(); q.pop();
		out.push_back(u);
		for (int i = 0; i < G[u].size(); ++i)
		{
			int v = G[u][i];
			indeg[v]--;
			if (indeg[v] == 0 && !V[v])
			{
				V[v] = true;
				q.push(v);
			}
		}
	}

}

void tsort()
{
	for (int i = 0; i < N; ++i)
		indeg[i] = 0;

	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < G[i].size(); ++j)
		{
			int v = G[i][j];
			indeg[v]++;
		}
	}

	for (int i = 0; i < N; ++i)
	{
		if (indeg[i] == 0 && !V[i]) bfs(i);
	}

	for (list<int>::iterator it = out.begin(); it != out.end(); ++it)
		cout << *it << endl;
}

int main()
{
	int s, t, m;
	cin >> N >> m;


	for (int i = 0; i < N; ++i) V[i] = false;

	for (int i = 0; i < m; ++i)
	{
		cin >> s >> t;
		G[s].push_back(t);
	}

	tsort();
	return 0;
}

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

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int max,min,tmp;
  if(a > b){
    max = b;
  }
  else{
    max = a;
  }

  tmp = (a+b) - n;
  if(tmp < 0){
    min = 0;
  }
  else{
    min = tmp;
  }

  cout << max << " " << min << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
typedef long long int lli;

typedef struct Info{
    string city;
    int point;
    int number;
}infos;

bool is_need_swap(infos infos1, infos infos2){
    bool res;
    if(infos1.city > infos2.city){
        res = true;
    }else if(infos1.city == infos2.city){
        res = (infos1.point < infos2.point);
    }else{
        res = false;
    }
    return res;
}

/*void bubble_sort(vector<infos> info_vec){
    bool need_loop = true;
    while(need_loop){
        need_loop = false;
        for(int j = 1; j < info_vec.size(); ++j){
            if(is_need_swap(info_vec[j - 1], info_vec[j])){
                infos tmp_info = info_vec[j - 1];
                info_vec[j - 1] = info_vec[j];
                info_vec[j] = tmp_info;
                need_loop = true;
            }
        }
    }
}*/

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

    vector<infos> info_vec(n);
    for(int i = 0; i < n; ++i){
        cin >> info_vec[i].city >> info_vec[i].point;
        info_vec[i].number = i;
    }

    bool need_loop = true;
    while(need_loop){
        need_loop = false;
        for(int j = 1; j < n; ++j){
            if(is_need_swap(info_vec[j - 1], info_vec[j])){
                infos tmp_info = info_vec[j - 1];
                info_vec[j - 1] = info_vec[j];
                info_vec[j] = tmp_info;
                need_loop = true;
            }
        }
    }

    for(int i = 0; i < n; ++i){
        //cout << "i = " << i << ": (" << info_vec[i].city << ", " << info_vec[i].point << ", " << info_vec[i].number << ")" << endl;
        cout << (info_vec[i].number + 1) << endl;
    }

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

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

int main()
{
    int M, K;
    int bitsize;

    cin >> M >> K;
    
    bitsize = (1 << M);
    
    if ( K == 0 ) {
        for ( int i = 0; i < bitsize; i++ ) {
            cout << i << " " << i;
            if ( i < bitsize - 1 ) cout << " ";
        }
        cout << endl;
    } else if ( K >= bitsize || M == 1 ) {
        cout << -1 << endl;
    } else {
        for ( int i = 0; i < bitsize; i++ ) {
            if ( i != K ) cout << i << " ";
        }
        cout << K << " ";
        for ( int i = bitsize - 1; i >= 0; i-- ) {
            if ( i != K ) cout << i << " ";
        }
        cout << K << endl;
    }

    return ( 0 );
}


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

using namespace std;


int main() {
	int H, W;
	int x, y;
	vector<int> delta_x{-1, -1, -1, 0, 0, 1, 1, 1};
	vector<int> delta_y{1, 0, -1, 1, -1, 1, 0, -1};

	cin >> H >> W;

	vector<string> S(H);
	for (int i = 0; i < H; i++) {
		cin >> S.at(i);
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S.at(i).at(j) == '.') {
				S.at(i).at(j) = '0';
			}
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S.at(i).at(j) == '#') {
				for (int k = 0; k < 8; k++) {
					x = i + delta_x.at(k);
					y = j + delta_y.at(k);

					if (x >= 0 && y >= 0 && x < H && y < W && S.at(x).at(y) != '#') {
						S.at(x).at(y) += 1;
					}
				}
			}
		}
	}

	for (int i = 0; i < H; i++) {
		cout << S.at(i) << 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;
typedef long long ll;

int main() {
    int k,t;cin>>k>>t;
    int a[t];rep(i,t)cin>>a[i];
    sort(a,a+t,greater<int>());
    cout<<max(a[0]*2-1-k,0)<<endl;
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ld eps = (ld)1 / 1e6;
ll inf = LLONG_MAX, mod1 = 1e9 + 7, mod2 = 998244353;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ll a[10001];

int main()
{
    fast_io;
    ll n, i, x, y, z;
    cin >> n;
    for (x = 1; x <= 100; x++)
    {
        for (y = 1; y <= 100; y++)
        {
            for (z = 1; z <= 100; z++)
                if (sqr(x) + sqr(y) + sqr(z) + x * y + x * z + y * z <= 10000) a[sqr(x) + sqr(y) + sqr(z) + x * y + x * z + y * z]++;
        }
    }
    for (i = 1; i <= n; i++) cout << a[i] << '\n';
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<queue>
#include<string.h>
using namespace std;

const int MAX_V = 100, INF = 999999;
static int cost[MAX_V][MAX_V];
static int d[MAX_V];

bool used[MAX_V];
static int V;
int E;
void dijkstra(int s) {
	fill(d, d + V, INF);
	fill(used, used + V, false);
	d[s] = 0;

	while (true) {
		int v = -1;
		for (int u = 0; u < V; u++) {
			if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
		}
		if (v == -1) break;
		used[v] = true;

		for (int u = 0; u < V; u++) {
			d[u] = min(d[u], d[v] + cost[v][u]);
		}
	}
}

int main() {
	while (1) {
		memset(cost, 999999, sizeof(cost));
		cin >> E;
		if (E == 0) break;
		int v_max = -1;
		for (int i=0 ; i < E; i++) {
			int u, v, cos;
			cin >> u >> v >> cos;
			cost[u][v] = cos;
			cost[v][u] = cos;
			if (v > v_max)v_max = v;
		}
		V = v_max + 1;
		int sum_m = 999999, m_ind = -1;
		for (int i = 0; i < V; i++) {
			dijkstra(i);
			int sum = 0;
			for (int j = 0; j < V; j++) {
				sum += d[j];
			}
			if (sum < sum_m) {
				sum_m = sum;
				m_ind = i;
			}
		}

		cout << m_ind << " " << sum_m << endl;
	}
	return 0;
}

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

int power(int a, int b) {
    if (b == 1)
        return a;
    return a * power(a, b - 1);
}

int main() {
    int H;
    int W;

    scanf("%d", &H);
    scanf("%d", &W);

    char **a = malloc((H + 1) * sizeof(char*));
    int **DP = malloc((H + 1) * sizeof(int*));
    for (int i = 1; i <= H; i++) {
        a[i] = malloc((W + 1) * sizeof(char));
        DP[i] = malloc((W + 1) * sizeof(int));
        char *add = a[i] + 1;
        scanf("%s", add);
    }
    DP[1][1] = 1;
    // initialize
    for (int i = 2; i <= H; i++) {
        if (DP[i-1][1] == 0) {
            DP[i][1] = 0;
        } else {
            if (a[i][1] == '#') {
                DP[i][1] = 0;
            } else {
                DP[i][1] = 1;
            }
        }
    }

    for (int j = 2; j <= W; j++) {
        if (DP[1][j-1] == 0) {
            DP[1][j] = 0;
        } else {
            if (a[1][j] == '#') {
                DP[1][j] = 0;
            } else {
                DP[1][j] = 1;
            }
        }
    }

//    for (int i = 1; i <= H; i++) {
//        for (int j = 1; j <= W; j++) {
//            printf(" %d ", DP[i][j]);
//        }
//        printf("\n");
//    }
//
    for (int i = 2; i <= H; i++) {
        for (int j = 2; j <= W; j++) {
            if (a[i][j] == '#') {
                DP[i][j] = 0;
            } else {
                DP[i][j] = (DP[i-1][j] % (power(10, 9) + 7) + DP[i][j-1] % (power(10, 9) + 7)) % (power(10, 9)  + 7);
            }
        }
    }


    printf("%d\n", DP[H][W]);

    return 0;
}


Measured memory_bytes: 5120
import sys

n = int(input())
h_list = list(map(int, input().split()))
for i in range(n - 1):
    if h_list[i] <= h_list[i+1]:
        continue
    if h_list[i] - h_list[i+1] > 1:
        print('No')
        sys.exit()
    else:
        h_list[i+1] += 1
print('Yes')


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll l, r, d;
  cin >> l >> r >> d;
  cout << r/d - (l-1)/d;
  return 0;
}


Measured memory_bytes: 3588
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 998244353

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

void solve()
{
    int n;
    cin >> n;

    vector<int> a(n);

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

    ll XOR = 0;

    for(int i = 0; i < n; i++)
    {
        XOR ^= a[i];
    }

    for(int i = 0; i < n; i++)
    {
        cout << (a[i] ^ XOR) << " ";
    }

    cout << endl;
}

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

    int T = 1;
    //cin >> T;
    
    while (T--)
    {
        solve();
    }
    
    return 0;
}




Measured memory_bytes: 3980
#include<iostream>
#include<vector>
#include<iomanip>
#include<cmath>
#include<unordered_map>
using namespace std;

int main()
{
    unordered_map<long long int, long long int> dict;
    long long int N, a, i, count;
    cin>>N;
    count=0;
    for(i=0;i<N;i=i+1)
    {
        cin>>a;
        if(dict.find(i+1-a)!=dict.end())
        {
            count+=dict[i+1-a];
        }
        if(dict.find(i+1+a)==dict.end())
        {
            dict.insert(pair<int, int> (i+1+a, 1));
        }
        else
        {
            dict[i+1+a]+=1;
        }
    }    
    cout<<count<<endl;
}


Measured memory_bytes: 11200
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
long long n, r;
string s = "";
void solve() {
    cin >> n;
    if (n == 0) {
        cout << 0 << endl;
        return;
    }
    while (n != 0) {
        //2で割った余りを求める
        r = n % 2;
        //nが負数の場合は余りが-1となる場合があるので2を加算する
        if (r < 0) r += 2;
        //nから余りを除去して、-2で割る
        n = (n - r) / -2;
        //余りを文字列として連結する
        s = to_string(r) + s;
    }
    cout << s << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}

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

//#define int long long
#define DEBUG 0
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;

//??¶?´?????????£???????????? int:INF ll:INFL
#define INFG INFL
using Weight = ll;//int;

class Edge {
public:
	int s; //source
	int d; //destination
	Weight w; //weight
	Edge(int s = 0, int d = 0, Weight w = INFG) : s(s), d(d), w(w) {};
	bool operator<(const Edge &e)const { return w < e.w; }
};
using Edges = vector<Edge>;
//???????????\: g[u].push_back(Edge(u, v, c));
//????????¨???????????????????????°??????????????\?????????????????????
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

//?????¢?´¢, ??¢?´¢???, ??¢?´¢???
enum { WHITE, GRAY, BLACK };
//???????§?????????????(???????????????) Single Source Shortest Path
//Dijkstra O( |E|log|V| )
//dist: ?§????????????????????????§??????????????¢
//?????????: ???????????¨????????????(??????-1)
vector<int> dijkstra(const Graph &g, int s, vector<Weight> &dist) {
	typedef tuple<Weight, int, int> State; //?§?????????????????°?????????? ??? ???
	priority_queue<State, vector<State>, greater<State> >PQ;
	int n = g.size();
	vector<int> color(n, WHITE);
	vector<int> prev(n, -1);
	dist.assign(n, INFG); //distance
	dist[s] = 0; PQ.push(State(0, s, -1)); color[s] = GRAY; //?§????
	while (!PQ.empty()) {
		Weight d; int v; int u;
		tie(d, v, u) = PQ.top(); PQ.pop(); //dist???????°??????¨??????????´????????????????
		if (dist[v] < d) continue; //?????§???????????§???????????°??????
		color[v] = BLACK;
		prev[v] = u;
		for (auto &e : g[v]) { //??£??\????????????????????¨????????????		
			if (color[e.d] == BLACK)continue; //??¢?´¢????????????
			if (dist[e.d] > dist[v] + e.w) {
				dist[e.d] = dist[v] + e.w;
				PQ.push(State(dist[e.d], e.d, v));
				color[e.d] = GRAY;
			}
		}
	}
	return prev;
}

signed main() {
	int n, m; cin >> n >> m;
	Graph g(n);
	char cc;
	rep(i, 0, m) {
		int a, b, c, d; cin >> a >> cc >> b >> cc >> c >> cc >> d; a--, b--;
		g[a].emplace_back(a, b, c);
		g[b].emplace_back(b, a, d);
	}
	int s, d, V, P; cin >> s >> cc >> d >> cc >> V >> cc >> P; s--, d--;
	vector<Weight> dist;
	dijkstra(g, s, dist);
	vector<Weight> dist2;
	dijkstra(g, d, dist2);
	cout << V - P - dist[d] - dist2[s] << endl;
	return 0;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0,c-(a-b)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <functional>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

int solve(int N){
  if(N==2 || N==3) return 1;
  //return solve(((N+1)+2)/3)+1;
  return solve((N+2)/3)+1;
}

signed main(){
  int N;
  cin >> N;
  cout << solve(N) << endl;
  return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main(){
double A,B;
scanf("%lf\n%lf",&A,&B);
if(A>0&&B>0){
	if(A>B)
	printf("GREATER");
	else if (A<B){
	
	printf("LESS");
	}
	else
	printf("EQUAL");
	
}

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<stack>
#include <algorithm>
#include <functional>
//#include<stdlib.h>
using namespace std;


int main() {
	int n,m=0,s=0;
	cin >> n;
	vector<pair<int,int>>t(n);
	for (int a = 0; a < n; a++)
	{
		cin >> t[a].first;
		t[a].second = a;
	}
	std::sort(t.begin(), t.end(), greater<pair<int, int> >());
	for (int a = 0; a < n; a++)
	{
		cout << ((a!=t[0].second)?(t[0].first):(t[1].first))<<endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <cmath>
#define ll long long
using namespace std;

int main(void) 
{
    ll n;
    cin >> n;
    ll start = (ll)sqrt(n);
    for(int i = start; i >= 0; --i) {
        if (n % i == 0) {
            cout << (
                (n/i) + i - 2
            );
            break;
        }
    }
}

Measured memory_bytes: 256
def main():
    cookies = list(map(int, input().split()))
    answer = 0
    if cookies[0] == cookies[1] == cookies[2] and cookies[0] % 2 == 0:
        answer = -1
    elif all(cookies[i] % 2 == 0 for i in range(3)):
        half = [0, 0, 0]
        sum_cookies = sum(cookies)
        while all(cookies[i] % 2 == 0 for i in range(3)):
            for i in range(3):
                half[i] = (sum_cookies - cookies[i]) // 2
            cookies[0] = half[1] + half[2]
            cookies[1] = half[0] + half[2]
            cookies[2] = half[1] + half[0]
            answer += 1
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <string>

using namespace std;

int main(){
	string S;
	cin >> S;

	int box[27] = {};
	
	for(int i = 0; i < S.length(); ++i){
		box[S[i] - 'a']++;
		//cout << box[S[i] - 'a'] << " " << S[i] - 'a' << endl;
	}

	string ans = "yes";
	for(int i = 0; i < S.length(); ++i){
		if(box[i] >= 2) ans = "no";
	}

	cout << ans << endl;
}


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


// prime factorization
vector<pair<long long, int>> pf(long long N) {
	assert(N > 0);
	vector<pair<long long, int>> res;
	long long p = 2;
	for (long long p = 2; p * p <= N; p++) {
		if (N % p == 0) {
			int d = 0;
			while (N % p == 0) {
				N /= p;
				d++;
			}
			res.push_back(pair<long long, int>(p, d));
		}
	}
	if (N > 1) res.push_back(pair<long long, int>(N, 1));
	return res;
}

map<long long, int> pf_map(long long N) {
	map<long long, int> res;
	for (pair<long long, int> pd : pf(N)) {
		auto [p, d] = pd;
		res[p] = d;
	}
	return res;
}

vector<long long> pf_multi(long long N) {
	vector<long long> res;
	for (pair<long long, int> pd: pf(N)) {
		auto [p, d] = pd;
		for (int i = 0; i < d; i++) {
			res.push_back(p);
		}
	}
	return res;
}

// primarity test
bool is_prime(long long N) {
	assert(N > 0);
	if (N == 1) return false;
	for (long long p = 2; p * p <= N; p++) {
		if (N % p == 0) {
			return false;
		}
	}
	return true;
}

vector<bool> sieve(int N) {
	assert(N >= 0);
	vector<bool> res(N + 1, true);
	res[0] = false;
	if (N >= 1) res[1] = false;
	for (int p = 2; p <= N; p++) {
		if (res[p]) {
			for (int i = 2 * p; i <= N; i += p) {
				res[i] = false;
			}
		}
	}
	return res;
}

vector<int> prime(int N) {
	vector<int> res;
	vector<bool> se = sieve(N);
	for (int p = 2; p <= N; p++) {
		if (se[p]) res.push_back(p);
	}
	return res;
}

int main() {
	const int N_max = 1e5 + 7;
	vector<bool> is_p = sieve(N_max);
	vector<bool> a(N_max); // a[i]:iが条件を満たすか
	vector<int> b(N_max); // b[i]:[0,i)の条件を満たす数の個数
	for (int i = 1; i <= 1e5; i++) {
		if (is_p[i] and is_p[(i + 1) / 2]) {
			a[i] = true;
		}
		b[i + 1] = b[i] + a[i];
	}

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

Measured memory_bytes: 3564
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	int y, m, d;
	scanf("%d/%d/%d", &y, &m, &d);
	if (y > 2019) cout << "TBD";
	else if (y == 2019) {
		if (m > 4) cout << "TBD";
		else cout << "Heisei";
	} else cout << "Heisei";
	cout << endl;

	return 0;
}

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

#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define all(c) begin(c),end(c)
#define mt make_tuple

constexpr int INF=1e9;

struct Edge{
	int u,v,w;
	Edge(){}
	Edge(int u,int v,int w):u(u),v(v),w(w){}
};
using Tree=vector<vector<Edge>>;

vector<tuple<int,int>> dfs(const Tree& t,int x,int p)
{
	if(t[p].empty()) return {mt(0,0)};
	auto e0=t[p][0],e1=t[p][1];
	auto s0=dfs(t,x,e0.v),s1=dfs(t,x,e1.v);

	vector<tuple<int,int>> res;
	rep(_,2){
		for(int i=0,j=0;i<s0.size();i++){
			int a,b; tie(a,b)=s0[i];
			for(;j<s1.size();j++){
				int c,d; tie(c,d)=s1[j];
				if(e0.w+b+c+e1.w>x) break;
			}
			if(j>0){
				int d=get<1>(s1[j-1]);
				res.emplace_back(e0.w+a,d+e1.w);
			}
		}
		swap(e0,e1); swap(s0,s1);
	}

	sort(all(res),[](auto a,auto b){return a<b;});
	res.erase(unique(all(res),[](auto a,auto b){return get<1>(a)<=get<1>(b);}),end(res));
	return res;
}

bool ok(const Tree& t,int x)
{
	return dfs(t,x,0).size();
}

int main()
{
	for(int n;cin>>n&&n;){
		Tree t(n);
		rep(i,n-1){
			int u,v=i+1,w; cin>>u>>w; u--;
			t[u].emplace_back(u,v,w);
		}
		int lo=-1,hi=INF;
		while(hi-lo>1){
			int mi=(lo+hi)/2;
			(ok(t,mi)?hi:lo)=mi;
		}
		cout<<hi<<endl;
	}
}


Measured memory_bytes: 19712
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	int d;
	int e;
	
	scanf("%d %d %d", &a, &b, &c);
	
	e = 0;
	for (d = a; d <= b; d++){
		if (c % d == 0){
			e++;
		}
	}
	printf("%d\n", e);
	
	return (0);
}

Measured memory_bytes: 596
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
int INF = 1001001001;

int main()
{
    int a,b,c;
    in a>>b>>c;
    if(a==1)
    {
        cout<<"YES"<<endl;
        return 0;
    }
    for(int i=1;i<1000;i++)
    {
        if((a*i)%b==c)
        {
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
s = str(input())
s += "2"
if int(s[0]) == 0:
  a = [0]
  prev = "0"
  count = 1
else:
  a = []
  flag = False
  prev = "1"
  count = 1
ap = a.append
for i in range(1,n+1):
  if s[i] == prev:
    count += 1
  else:
    ap(count)
    count = 1
    prev = s[i]
if s[-2] == "0":
  ap(0)
if 2*k+1 >= len(a):
  print(sum(a))
  exit()
g = sum(a[0:2*k+1])
mx = g
i = 1
while 2*i+2*k < len(a):
  g -= (a[2*i-2]+a[2*i-1])
  g += (a[2*i+2*k-1]+a[2*i+2*k])
  if g > mx:
    mx = g
  i += 1
print(mx)

Measured memory_bytes: 4468