akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
    vector<int> L;
    int input;
    for (int i = 0; i < 3; i++)
    {
        int input;
        cin >> input;
        L.push_back(input);
    }
    sort(L.begin(), L.end());
    cout << L[0] + L[1] + L[2] * 10;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
M = list(map(int, [input() for _ in range(N)]))

l = []
for n in M:
  dup_flg = False
  for i in l:
    if n == i:
      dup_flg = True
  if not dup_flg:
    l.append(n)

print(len(l))

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define si scanf
#define so printf
#define N 
#define M 
#define INF  
template<typename TP>inline bool rd(TP& r)
{
	r=0;
	char tmp=getchar();
	while(tmp<'0'||tmp>'9')
	{
		if(tmp==EOF)
			return 0;
		tmp=getchar();
	}
	while('0'<=tmp&&tmp<='9')
	{
		r=(r<<3)+(r<<1)+tmp-'0';
		tmp=getchar();
	}
	return 1;
	
} 
int H,h,W,w;
long long pos,neg,sm;
long long mat[510][510];
int main()
{
	rd(H),rd(W),rd(h),rd(w);
	if(W%w==0&&H%h==0)
	{
		so("No\n");
		return 0;
	}
	pos=(1000000000-1)/(1LL*w*h-1);
	neg=-(pos*(1LL*w*h-1)+1);
	for(int i=1;i<=H;++i)
	for(int j=1;j<=W;++j)
		if(i%h==0&&j%w==0)
			mat[i][j]=neg,sm+=neg;
		else
			mat[i][j]=pos,sm+=pos;
	if(sm<=0)
		so("No\n");
	else
	{
		so("Yes\n");
		for(int i=1;i<=H;++i)
		{
			for(int j=1;j<=W;++j)
				so("%lld ",mat[i][j]);
			so("\n");
		}
	}
	return 0;
} 

Measured memory_bytes: 4864
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<limits>
#include<deque>
#include<string>
#include<map>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>

using namespace std;


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

	for (i = 0; i < n; i++) {
		if (s.substr(i) == t.substr(0, n - i)) {
			cout << n + i << endl;
			return 0;
		}
	}

	cout << 2 * n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
typedef long long ll;

pair<int ,int> nums[100000];
int cost[100000];

int main() {
    int H, W, D;
    cin >> H >> W >> D;
    
    int n;
    rep1( i, H) {
        rep1( j, W) {
            cin >> n;
            nums[n] = { i, j};
        }
    }
    
    mem( cost, 0);
    
    for ( int i = 1; i < 1+D; i++ ) {
        for ( int u = i; u+D <= H*W; u += D ) {
            cost[u+D] = abs( nums[u+D].first - nums[u].first ) + abs( nums[u+D].second - nums[u].second );
            cost[u+D] += cost[u];
            //cout4( u, cost[u],u+D,cost[u+D]);
        }
    }
        
    int Q, s, t;
    cin >> Q;
    rep( i, Q) {
        cin >> s >> t;
        cout1( cost[t]-cost[s]);
        //cout1( 100000000000000000-1);
    }
    
}

Measured memory_bytes: 2176
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <numeric>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(123456789012345678)


unsigned GetDigit(unsigned num) {
    return std::to_string(num).length();
}


int main(void){
	int N, A, B, C; cin >> N >> A >> B >> C;
  int ans = INF;
  vector<int> end;  // 目的とする長さのリスト
  end.push_back(A);
  end.push_back(B);
  end.push_back(C);
  int l[N];
  rep(i, N) cin >> l[i];

  // N桁の4進数について考える
  int max_cnt = std::pow(4, N);
  
  // 1から4**Nまで
  rep(i, max_cnt)  {
    
    // 長さが4のリストassignに、A,B,C,未使用の竹の長さを割り当てる
    vector<vector<int> > assign;
    assign.resize(4);
    
    int cnt = i;
    rep(j, N) {
      // 4進数で表した時の一番下の桁を見る
      assign[cnt%4].push_back(l[j]);
      // 一番下の桁を抜く
      cnt = cnt/4;
    }
    if (assign[0].size()!=0 && assign[1].size()!=0 && assign[2].size()!=0)  {
      int cost = 0; // 操作に必要なコスト
      rep(i, 3) {
        cost += (assign[i].size()-1) * 10;  // mergeの操作
        cost += abs(end[i] - std::accumulate(assign[i].begin(), assign[i].end(), 0)); // 長さの調整
      }
      ans = min(ans, cost); // コストの小さい方が答え
    }
  }
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

const int N = 1e6 + 5;

int power(int x,int n,int mod){
    //(x^n)%mod
    int result=1;
    while(n){
        if(n%2)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return result;
}

int inverseMod(int x,int mod){
    return power(x,mod-2,mod);
}

int arr[N];

int spf[N]; 
map<int,int>fact;
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<N; i++) 
        spf[i] = i; 
  
    for (int i=4; i<N; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<N; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (int j=i*i; j<N; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
void  getFactorization(int x) 
{ 
    set<int> ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    for(auto i:ret){
        fact[i]++;
    }
} 
  
int32_t main() {

    fast
    int n;
    cin >> n;
    sieve();
    cin >> arr[0];
    int gcd = arr[0];
    getFactorization(arr[0]);
    for(int i = 1; i < n; i++) {
        cin >> arr[i];
        getFactorization(arr[i]);
        gcd = __gcd(arr[i], gcd);
    }
    bool flag=true;
    for(auto i:fact){
        if(i.second>=2){
            flag=false;
            break;
        }
    }
    if(gcd == 1 && flag) {
        cout << "pairwise coprime";
    } else if(gcd == 1 && !flag) {
        cout << "setwise coprime";
    } else {
        cout << "not coprime";
    }







    return 0;
}



Measured memory_bytes: 24088
#include <iostream>

using namespace std;

int main(){
  string o(""), e(""), pw("");
  cin >> o;
  cin >> e;
  string::iterator eit = e.begin();
  for (string::iterator oit=o.begin();oit!=o.end();oit++) {
    pw.push_back(*oit);
    if (eit != e.end()) {
      pw.push_back(*eit);
      eit++;
    }
  }
  cout << pw << endl;
}






Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String S = br.readLine();
	String[] weatherList = { "Sunny", "Cloudy", "Rainy" };
	int predict = 0;
	if (S.equals(weatherList[0]))
	    predict = 1;
	else if (S.equals(weatherList[1]))
	    predict = 2;
	else if (S.equals(weatherList[2]))
	    predict = 0;
	System.out.println(weatherList[predict]);
    }
}


Measured memory_bytes: 18772
from sys import stdin

N = int(stdin.readline().rstrip())

BAList=[]
for i in range (N):
  A,B = map(int,stdin.readline().rstrip().split())
  BAList.append((B,A))

BAList.sort()
deadend=0
jobsum=0
for (B,A) in BAList:
  deadend=B
  jobsum+=A
  if jobsum>deadend:
    print('No')
    exit()
print('Yes')
  


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

signed main(){

  int n; cin >> n;
  vector<int> a(n),b(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++) cin >> b[i];

  int ans = 0;
  for(int i = 30; i >= 0; i--){
    int T = 1 << i;
    for(int j = 0; j < n; j++){
      a[j] %= T*2;
      b[j] %= T*2;
    }
    sort(b.begin(),b.end());
    int res = 0;
    for(int j = 0; j < n; j++){
      if(a[j] <= T){
        res += lower_bound(b.begin(),b.end(),T*2 - a[j]) - lower_bound(b.begin(),b.end(),T - a[j]);
      }
      else {
        res += lower_bound(b.begin(),b.end(),T*2 - a[j]) - lower_bound(b.begin(),b.end(),0);
        res += lower_bound(b.begin(),b.end(),T*2) - lower_bound(b.begin(),b.end(),T*2 - (a[j] - T));
      }
    }
    if(res%2 == 1) ans += T;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int calc(const vector<int> &xi, const vector<int> &xj, int d){
    double dist;
    double dist_int;

    dist = 0.0;
    for(int i = 0;i < d;i++){
        dist += (double)(xi[i] - xj[i])*(xi[i] - xj[i]);
    }
    dist = sqrt(dist);
    dist_int = floor(dist);

    if(dist == dist_int)    return 1;
    else                            return 0;
}

int main(void){
    int n, d;
    cin >>  n >> d;

    vector<vector<int>> x(n, vector<int>(d));
    for(int i = 0;i < n;i++){
        for(int j = 0;j < d;j++){
            cin >> x[i][j];
        }
    }

    int ans = 0;
    for(int i = 0;i < n;i++){
        for(int j = i+1;j < n;j++){
            ans += calc(x[i], x[j], d);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

void solve(){
	string s;
	cin>>s;

	if(s[0] == s.back()){
		// odd 
		if(s.size()%2 ==0){
			cout<<"First"<<endl;
		}
		else{
			cout<<"Second"<<endl;
		}

	}
	else{
		if(s.size()%2 == 1){
			cout<<"First"<<endl;
		}
		else{
			cout<<"Second"<<endl;
		}
	}
}

int main(){
	fastread;
	int t = 1;
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int x[n+5],y[n+5],t[n+5];
	for(register int i=1;i<=n;i++)  cin>>t[i]>>x[i]>>y[i];
	
	int time=0,xn=0,yn=0;
	for(register int i=1;i<=n;i++){
		int vx=fabs(x[i]-xn),vy=fabs(y[i]-yn);
		int dist=vx+vy,past=t[i]-time;
		if(past>=dist)
			if((past%2)==(dist%2)){
				time=t[i];
				xn=x[i];
				yn=y[i];
				continue;
			}
		cout<<"No";
		return 0;
	}
	
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;

int main() {
 string S;
 cin>>S;
 vector<bool>t(26);
 for(int i=0;i<26;i++){
   t.at(i)=false;}
 for(int i=0;i<S.size();i++){
   t.at(S.at(i)-'a')=true;}
 for(int i=0;i<26;i++){
   if(!t.at(i)){cout<<(char)(i+'a')<<endl;return 0;}
 }
 cout<<"None"<<endl;
 return 0;}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{

    int n, m, a[112345];

    cin >> n >> m;

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

    int one = 0;

    REP(i, n - 1)
    one += (a[i] < a[0] && a[0] < a[i + 1]) || (a[0] < a[i + 1] && a[i + 1] < a[i]) || (a[i + 1] < a[i] && a[i] < a[0]);

    int imos[112345];

    fill(imos, imos + m + 1, 0);

    REP(i, n - 1)
    {
        imos[(a[i] + 1) % m + (a[i] + 1 == m) * m]++;
        imos[a[i + 1]]--;
    }

    for (int i = 1; i <= m; i++)
        imos[i] += imos[i - 1];

    int imos1 = imos[a[0]];

    for (int i = 1; i <= m; i++)
        imos[i] += one - imos1;

    int imos_[112345];

    for (int i = 1; i <= m; i++)
        imos_[i + 1] = imos[i];

    for (int i = 1; i <= m; i++)
        imos[i] = imos_[i];

    ll res = 1e18;
    ll sum = 0;

    REP(i, n - 1)
    {
        sum += (min(1 + (a[i + 1] - 1 + m) % m, (a[i + 1] - a[i] + m) % m));
    }

    ll add[112345];
    fill(add, add + m + 1, 0);

    REP(i, n - 1)
    add[(a[i + 1] + 1) /* % m + (a[i + 1] + 1 == m) * m*/] += (a[i + 1] - a[i] + m) % m - 1;

    res = sum;

    for (int i = 2; i <= m; i++)
    {
        sum += add[i];
        sum -= imos[i];

        res = min(res, sum);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
 
typedef vector<int> vi;
typedef vector<double> vd;
 
double mypow(double b ,int e){
      if(e == 0) return 1;
      if(e%2==0)
            return mypow( b*b, e/2 );
      else
            return mypow( b*b, e/2 ) * b;
}
 
int main(){
 
 
      int N,M,L; cin >> N >> M >> L ;
      if(N==1){
            cout << 1.0 << endl;
            return 0;
      }
      vector<vd> prob(N,vd(M+1,0.0));
      vector<vd> dist(N,vd(M+1,0.0));
 
      vd p(N),t(N),v(N);
      for(int i=0; i<N; i++) cin >> p[i] >> t[i] >> v[i];
 
      // PRE PROCESS
      for(int i=0; i<N; i++){
            dist[i][0] = (double)L / v[i];
            for(int j=1; j<=M; j++){
                  dist[i][j] = dist[i][j-1] + t[i];
            }
      }
      for(int i=0; i<N; i++)
            prob[i][0] = mypow((100-p[i])/100,M);
      for(int i=0; i<N; i++){
            for(int j=1; j<=M; j++){
                  if(p[i] != 100)
                        prob[i][j] = (prob[i][j-1] * (p[i]/100)) / ((100-p[i])/100);
                  else
                        prob[i][j] = 1.0;
            }
      }
      double comb = 1;
      for(int j=1; j<=M; j++){
            comb = comb * (M - j + 1) / j; 
            for(int i=0; i<N; i++){
                  prob[i][j] *= comb;
            }
      }
       
      vector<vd> sum = prob;
      for(int i=0; i<N; i++){
            for(int j=M-1; j>=0; j--){
                  sum[i][j] += sum[i][j+1];
                  if(sum[i][j] > 1) sum[i][j] = 1;
            }
      }
 
      vector<vd> ans = prob;
      for(int i=0; i<N; i++){
            for(int j=0; j<=M; j++){
                  for(int k=0; k<N; k++){
                        if(i==k) continue;
                        int id = upper_bound(dist[k].begin(),dist[k].end(), dist[i][j]) - dist[k].begin();
                        if(id > M) ans[i][j] = 0.0;
                        else       ans[i][j] *= sum[k][id];
 
                  }
            }
      }
 
      for(int i=0; i<N; i++){
            double tmp = 0.0;
            if(p[i] == 100) tmp = ans[i][M];
            else
                  for(int j=0; j<=M; j++)
                        tmp += ans[i][j];
            if(tmp > 1) tmp = 0;
            printf("%.10f\n",tmp);
      }
                         
}

Measured memory_bytes: 3376
N=int(input())
import collections
D= collections.Counter(list(map(int,input().split())))
M=int(input())
T= collections.Counter(list(map(int,input().split())))
for i,j in T.items():
   if D[i] >= j:
      pass
   else:
      print("NO")
      exit()
print("YES")

Measured memory_bytes: 55264
gets
ar = gets.split.map(&:to_i)
l = ar.size
co = 0
(l - 1).times do |i|
  min = i
  (i + 1).upto(l - 1) {|j| min = j if ar[j] < ar[min]}
  ar[min], ar[i] = ar[i], ar[min]
  co += 1 unless i == min
end
puts ar.join(" ")
puts co



Measured memory_bytes: 6852
def main():
    h, w = map(int, input().split())
    a = [list(input()) for _ in range(h)]
    pass_row = []
    pass_col = []
    for i in range(h):
        if "#" not in a[i]:
            pass_row.append(i)
    left_row = h - len(pass_row)
    for j in range(w):
        tmp = 0
        for i in range(h):
            if i not in pass_row and a[i][j] == ".":
                tmp += 1
        if tmp == left_row:
            pass_col.append(j)
    for i in range(h):
        if i not in pass_row:
            for j in range(w):
                if j not in pass_col:
                    print(a[i][j], end="")
            print()


if __name__ == '__main__':
    main()



Measured memory_bytes: 4596
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;

const int V = 100010;

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

	vector<ll> w(n), v(n);

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

	vector<vector<ll>> dp(n + 1, vector<ll>(V));
	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j < V; j++)
		{
			dp[i][j] = inf;
		}
	}

	dp[0][0] = 0;

	for (int i = 1; i <= n; i++)
	{
		for (int sv = 0; sv < V; sv++)
		{
			if (sv - v[i - 1] >= 0)
			{
				dp[i][sv] = min(dp[i][sv], dp[i - 1][sv - v[i - 1]] + w[i - 1]);
			}

			dp[i][sv] = min(dp[i][sv], dp[i - 1][sv]);
		}

	}

	ll res = 0;
	for (int sv = 0; sv < V; sv++)
	{
		if (dp[n][sv] <= weight)
		{
			res = sv;
		}
	}

	println(res);
}

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

int main() {
  vector<vector<char>> a(3, vector<char>(3));
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> a.at(i).at(j);
    }
  }
  for(int i = 0; i < 3; i++){
    cout << a.at(i).at(i);
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
const int mod =1'000'000'007;

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

    int cnt = 0;
    int min = n+1;
    rep(i,n){
        int p;
        cin >> p;
        if (p < min){
            cnt++;
            min = p;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3576
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;

const int N = 100;
const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;
int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u) {
    int v;
    color[u] = GRAY;
    d[u] = GRAY;
    d[u] = ++tt;
    for(v = 0; v < n;v++) {
        if(M[u][v] == 0) continue;
        if(color[v] == WHITE) {
            dfs_visit(v);
        }
    }
    color[u] = BLACK;
    f[u] = ++tt;
}
void dfs() {
    int u;
    for(u = 0;u < n;u++) {
        color[u] = WHITE;
    }
    tt = 0;
    for(u = 0;u < n;u++) {
        if(color[u] == WHITE) dfs_visit(u);
    }
    for(u = 0;u < n;u++) {
        cout << u+1 <<" " <<d[u] << " " << f[u] << endl;
    }
}

int main() {
    int u,v,k,i,j;
    cin >> n;
    for( i = 0;i < n; i++) {
        for( j = 0; j< n;j++) {
            M[i][j] = 0;
        }
    }
    for(i = 0;i < n;i++) {
        cin >> u >> k;
        u--;
        for(j = 0; j< k;j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    dfs();
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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 DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    if (b > a + d * (n - 1) || b < a - d * (n - 1)) {
        cout << "NO\n";
    } else {
        ll ueue = a, uesi = a, siue = a, sisi = a;
        for (ll i = 1; i < n; i++) {
            // 今の幅
            ueue += d, uesi += c, siue -= c, sisi -= d; 
            if (ueue - (n - i - 1) * c >= b && b >= uesi - (n - i - 1) * d) {
                cout << "YES\n";
                return 0;
            }
            if (sisi + (n - i - 1) * c <= b && b <= siue - (n - i - 1) * d) {
                cout << "YES\n";
                return 0;
            }
        }

        cout << "NO\n";
    }
    return 0;
}


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

int A[]{ 4,6,9,11 };
int main() {
	int x, y; scanf("%d%d", &x, &y);
	int a, b;
	if (x == 2)a = 0;
	else if (find(A, A + 4, x) != A + 4)a = 1;
	else a = 2;
	if (y == 2)b = 0;
	else if (find(A, A + 4, y) != A + 4)b = 1;
	else b = 2;
	puts(a == b ? "Yes" : "No");
}

Measured memory_bytes: 256
n,a,b = map(int,input().split())
s = input()
kokunai = 0
kaigai = 0

for i in range(n):
    if s[i] == "a" and a + b > kokunai + kaigai:
        print("Yes")
        kokunai += 1
    elif s[i] == "b" and a + b > kokunai + kaigai and b > kaigai:
        print("Yes")
        kaigai += 1
    else:
        print("No")

Measured memory_bytes: 9268
#include<iostream>

int main() {
  int n, q;
  std::cin >> n >> q;
  std::string s;
  std::cin >> s;
  int t[100000] = {};

  // 部分文字列系問題=>iまでいくつあるか配列を作っておく
  for(int i = 0; i < n-1; i++) {
    int tmp = (s[i] == 'A') && (s[i+1] == 'C') ? 1 : 0;
    t[i+1] = t[i] + tmp;
  }

  for(int j = 0; j < q; j++) {
    int start, end;
    std::cin >> start >> end;
    std::cout << t[end-1] - t[start-1] << std::endl;
  }
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,n;
    cin>>a>>b>>n;
    long long int i=b-1;
    long long int x=0;
    if(a*i>b && i<=n)
        x=i;
    else
        x=n;

    long long int z=a*x;

    long long int k=z/b;
    long long int l=(x/b);
    long long int h=a*l;
    long long int diff=k-h;
    cout<<diff<<endl;


}


Measured memory_bytes: 3548
from sys import maxsize
import numpy as np


def check(ls, x):
    for i in range(1, len(ls)):
        if ls[i] < x:
            return False
    return True


n, m, x = map(int, input().split())
ls = []
a = [i for i in range(n)]
for i in range(n):
    ls.append(list(map(int, input().split())))
dp = [np.zeros(m + 1) for i in range((1 << n))]
for i in range(n):
    dp[1 << i] = np.array(ls[i])
total_cost = maxsize
for subset in range(1, (1 << n)):
    for i in range(n):
        if subset & (1 << i):
            dp[subset] = np.add(dp[subset ^ (1 << i)], dp[(1 << i)])
    if check(dp[subset], x):
        total_cost = min(total_cost, dp[subset][0])
if total_cost == maxsize:
    print(-1)
else:
    print(int(total_cost))


Measured memory_bytes: 28044
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			h = scanner.nextInt();
			w = scanner.nextInt();
			if ((h | w) == 0)
				break;
			char[][] map = new char[h][w];
			for (int i = 0; i < h; i++) {
				map[i] = scanner.next().toCharArray();
				for (int j = 0; j < w; j++) {
					if (map[i][j] == 'A') {
						ay = i;
						ax = j;
					} else if (map[i][j] == 'B') {
						by = i;
						bx = j;
					}
				}
			}
			int[][] dp = new int[h][w];
			for (int[] dp1 : dp)
				Arrays.fill(dp1, 1 << 30);
			Deque<Point> deque = new ArrayDeque<Main.Point>();
			deque.push(new Point(ay, ax, 0));
			dp[ay][ax] = 0;
			while (!deque.isEmpty()) {
				Point p = deque.poll();
				int y = p.y;
				int x = p.x;
				int step = p.step;

				for (int[] m : move) {
					int ny = y + m[0];
					int nx = x + m[1];
					if (!isOK(ny, nx))
						continue;
					if (map[ny][nx] == '#')
						continue;
					if (dp[ny][nx] <= step + 1)
						continue;
					dp[ny][nx] = step + 1;
					deque.offer(new Point(ny, nx, step + 1));
				}

			}
			char[] p = scanner.next().toCharArray();
			int e;
			for (e = 0; e < 10000; e++) {
				if (dp[by][bx] <= e)
					break;
				char o = p[e % p.length];
				int ny = by + (o == '2' ? 1 : 0) - (o == '8' ? 1 : 0);
				int nx = bx + (o == '6' ? 1 : 0) - (o == '4' ? 1 : 0);
				if (!isOK(ny, nx))
					continue;
				by = ny;
				bx = nx;
			}
			System.out.println(e < 10000 ? e + " " + by + " " + bx
					: "impossible");
		}
	}

	private boolean isOK(int ny, int nx) {
		return 0 <= ny && ny < h && 0 <= nx && nx < w;
	}

	int ay, ax, by, bx, h, w;
	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

	class Point {
		int y, x, step;

		public Point(int y, int x, int step) {
			super();
			this.y = y;
			this.x = x;
			this.step = step;
		}

		@Override
		public String toString() {
			return "Point [y=" + y + ", x=" + x + ", step=" + step + "]";
		}

	}
}

Measured memory_bytes: 23964
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
int main(void){
    int n;string s;
    cin>>n>>s;
    if(s.substr(0, n/2)==s.substr(s.size()/2))co("Yes");
    else co("No");

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
typedef long long ll;
using namespace std;

int main() {
    int k;
    char s[101];
    scanInt(k);
    rep(i, 101) s[i] = '\0';
    scanf("%s", s);
    for (int i = 0; i < k && s[i] != '\0'; ++i)
        printf("%c", s[i]);
    if (s[k] != '\0') {
        printf("...");
    }
    printf("\n");
    return 0;
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const ll LINF = 1e18 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

ll n, m, s, t;

struct Edge {
  Edge(int _to, ll _yen, ll _snuke)
    :to(_to), yen(_yen), snuke(_snuke){}
  int to;
  ll yen;
  ll snuke;
};

vector< Edge > e[MAX_N];
ll yD[MAX_N];
ll sD[MAX_N];

typedef pair< ll, int > P;

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

  cin >> n >> m >> s >> t;
  s--; t--;
  REP(i, m) {
    LCIN(u, v, a, b);
    u--; v--;
    e[u].emplace_back(Edge(v, a, b));
    e[v].emplace_back(Edge(u, a, b));
  }

  priority_queue< P, vector< P >, greater< P > > q;
  fill_n(yD, MAX_N, LINF);
  // vector< bool > state(m, false);
  yD[s] = 0;
  // state[s] = true;
  q.push(P(0, s));

  while (!q.empty()) {
    ll dist; int from;
    tie(dist, from) = q.top(); q.pop();
    if (yD[from] < dist) continue;
    EACH(to, e[from]) {
      if (yD[to.to] > yD[from] + to.yen) {
	yD[to.to] = yD[from] + to.yen;
	q.push(P(yD[to.to], to.to));
      }
    }
  }

  q = decltype(q)();
  fill_n(sD, MAX_N, LINF);
  sD[t] = 0;
  q.push(P(0, t));

  while (!q.empty()) {
    ll dist; int from;
    tie(dist, from) = q.top(); q.pop();
    if (sD[from] < dist) continue;
    EACH(to, e[from]) {
      if (sD[to.to] > sD[from] + to.snuke) {
	sD[to.to] = sD[from] + to.snuke;
	q.push(P(sD[to.to], to.to));
      }
    }
  }
  
  vector< ll > ans(n + 1);
  RREP(i, n) {
    // debug(i);
    // debug(sD[i]);
    // debug(yD[i]);
    ll tmp = 1e15 - (sD[i] + yD[i]);
    ans[i] = max(ans[i + 1], tmp);
  }

  REP(i, n) {
    cout << ans[i] << endl;
  }

  return 0;
}



Measured memory_bytes: 13772
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

	static class B_Path {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int[] deg = new int[4];
			for (int i = 0; i < 3; i++) {
				int a = in.nextInt() - 1;
				int b = in.nextInt() - 1;
				++deg[a];
				++deg[b];
			}
			Arrays.sort(deg);
			out.println(Arrays.equals(deg, new int[]{1, 1, 2, 2}) ? "YES" : "NO");
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



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

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

  vector<int> b(n);
  rep(i, n){
    int a;
    cin >> a;
    a--;
    b[a] = i+1;
  }

  rep(i, n){
    cout << b[i];
    if(i != n-1) cout << " ";
  }
  cout << endl;

}


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

#define ull unsigned long long
#define ll long long
#define imei(...)   "[ "<< #__VA_ARGS__ <<" = "<< __VA_ARGS__ <<" ] "

using namespace std;

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

int main(int argc, char *argv[])
{
    ll a, b, c, d;
    ll ans;
    cin >> a >> b >> c >> d;

    ans = max({a*c, b*d, a*d, b*c});
    if ((a <= 0 && b >= 0) || (c <=0 && d >= 0))
            ans = max(0LL, ans);
    
    cout <<ans;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>  // This will work only for g++ compiler. 
using namespace std;
#define fo(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define fon(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
//short hand for usual tokens
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
#define INF (int)1e9
// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
// traversal function to avoid long template definition. Now with C++11 auto alleviates the pain.
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)// find if a given value is present in a container. Container version. Runs in log(n) for set and map
#define present(c,x) ((c).find(x) != (c).end())
//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())
// Avoiding wrap around of size()-1 where size is a unsigned int.
#define sz(a) int((a).size())
// Shorthand for commonly used types
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    int x,y;
    cin>>x>>y;
     bool flag = 0;
    int crne = 0;
    int trtle =0;
    for(int i=0;i<x+1;i++){
        crne = i;
        trtle = x-i;
        if(crne*2+trtle*4==y){
            flag  = 1;
            break;
        }

    
    }
    cout<<(flag ? "Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 3612
fn read_line() -> String {
  let mut tmp = String::new();
  std::io::stdin().read_line(&mut tmp).unwrap();
  tmp.trim().to_string()
}

fn ans(length: i32, width: i32, interval: i32) -> i32 {
  (length - interval) / (width + interval)
}

fn main() {
  let nums: Vec<i32> 
    = read_line().split(" ").map(|x| x.parse().unwrap()).collect();
/*
  let tests = vec![
    vec![13, 3, 1, 3],
    vec![12, 3, 1, 2],
    vec![100000, 1, 1, 49999],
    vec![64146, 123, 456, 110],
    vec![64145, 123, 456, 109],
  ];
  for vec in &tests {
    let ans = ans(vec[0], vec[1], vec[2]);
    assert_eq!(ans, vec[3]);  
  }
*/
  println!("{}", ans(nums[0], nums[1], nums[2]));
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long[] a = new long[1010];
		// 2 * 3 * 4 * .... * n
		for(int i = 2 ; i <= n ; i++) {
			for(int j = 2 ; j <= n ; j++) {
				if(isPrime(j) && i % j == 0) {
					a[j] += func(i, j);
				}
			}
		}
		long ans = 1;
		for(int i = 2 ; i <= 1000 ; i++) {
			ans = ans * (a[i] + 1) % 1000000007;
		}
		System.out.println(ans);
	}

	public static boolean isPrime(int x) {
		boolean ok = true;
		for(int i = 2 ; i * i <= x ; i++) {
			if(x % i == 0) {
				ok = false;
			}
		}
		return ok;
	}

	public static long func(int a, int b) {
		long ret = 0;
		while(a % b == 0) {
			ret++;
			a /= b;
		}
		return ret;
	}

}


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

int n;
bool p[5050][5050];

void rot(int &a, int &b)
{
  int c = a;
  a = b;
  b = -1 * c;
}

inline bool in(int x, int y){return (0 <= x && 0 <= y && x <= 5000 && y <= 5000);}

int main()
{

  while (cin >> n, n){
    vector<pair<int, int> > g;
    for (int i = 0; i < n; i++){
      int x, y;
      cin >> x >> y;
      p[x][y] = true;
      g.push_back(make_pair(x, y));
    }

    sort(g.begin(), g.end());

    double max_a = 0.0;
    for (auto &s : g){
      for (auto &v : g){
        int nx = v.first - s.first;
        int ny = v.second - s.second;
        int x = s.first, y = s.second;

        int cnt = 0;
        for (int i = 0; i < 3; i++){
          if (!in(x + nx, y + ny)) break;
          if (!p[x + nx][y + ny]) break;
          x += nx; y += ny;
          rot(nx, ny);
          cnt++;
        }
        if (cnt == 3){
          double po = sqrt(pow(nx, 2) + pow(ny, 2));
          max_a = max(max_a, po * po);
        }
      }
    }
    cout << setprecision(0) << fixed;
    cout << max_a << endl;
  }
}

Measured memory_bytes: 22968
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll rec(ll n, ll x)
{
    if (n == 0)
    {
        return 1;
    }

    if (x == 1)
    {
        return 0;
    }

    ll p = pow(2, n) - 1;
    ll h = pow(2, n + 1) - 3;

    if (x <= h + 1)
    {
        return rec(n - 1, x - 1);
    }
    else if (x == h + 2)
    {
        return p + 1;
    }
    else if (x <= h * 2 + 2)
    {
        return p + 1 + rec(n - 1, x - h - 2);
    }
    else
    {
        return p * 2 + 1;
    }
}

int main(void)
{
    ll n, x;

    cin >> n >> x;

    cout << rec(n, x) << endl;
}


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

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<int> A(1000001, 0);
    int a;
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        A[a]++;
    }
    if (A[1] == 1)
    {
        cout << 1 << endl;
        return;
    }
    if (A[1] > 1)
    {
        cout << 0 << endl;
        return;
    }
    int ans;
    ans = 0;
    for (int i = 2; i < 1000001; i++)
    {
        if (A[i])
        {
            for (int j = 0; i * (j + 2) <= 1000001; j++)
            {
                A[i * (j + 2)] = 0;
            }
        }
        if (A[i] == 1)
        {
            ans ++;
        }
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 7136
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    long int n;
    cin >> n;
    long int a[n];
    rep(i, n) cin >> a[i];
    long int ans = 0;
    rep(i, n - 1){
        ans += a[i] / 2;
        a[i] -= (a[i] / 2) * 2;
        if (a[i+1] > 0){
            ans += a[i];
            a[i+1] -= a[i]; 
        }
        // cout << ans << endl;
    }
    ans += a[n-1] / 2;
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
using namespace std;
int main(int argc, char *argv[]){
  int sec,mini,hour;
  sec = 0;
  mini = 0;
  hour = 0;
  scanf("%d",&sec);
  
  hour = sec / 60 / 60;
  sec = sec % (60*60);
  mini = sec / 60;
  sec = sec % 60;

  cout << hour << ":" << mini << ":" << sec <<endl;
  return 0;
}

Measured memory_bytes: 1200
N=int(input())
if 100<=N<=111:
    print(111)
elif 112<=N<=222:
    print(222)
elif 223<=N<=333:
    print(333)
elif 334<=N<=444:
    print(444)
elif 445<=N<=555:
    print(555)
elif 556<=N<=666:
    print(666)
elif 667<=N<=777:
    print(777)
elif 778<=N<=888:
    print(888)
else:
    print(999)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <numeric>
#include <bitset>
#include <cstdint>
using namespace std;

#ifdef DEBUG
#include <cassert>
#else
#define assert(x)
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
using ll = long long;

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // 浮動小数の表示の精度
    cout << setprecision(15);

    ll n, a, b;
    cin >> n >> a >> b;
    ll x = n / (a + b), y = n % (a + b);
    cout << x * a + min(y, a) << "\n";

    return 0;
}


Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
long long gcd(long long a, long long b) {
  if (b == 0) return a;

  return gcd(b, a % b);
}

long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }

const int maxn = 1e5 + 1000;

ll N, K;
ll A[maxn];
ll maxa;

int main() {
  cin >> N >> K;
  rep(i, 0, N) {
    cin >> A[i];
    chmax(maxa, A[i]);
  }

  if (N == 1) {
    if (K == A[0]) {
      cout << "POSSIBLE" << endl;
      return 0;
    } else {
      cout << "IMPOSSIBLE" << endl;
      return 0;
    }
  }

  if (K > maxa) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }

  ll g = gcd(A[0], A[1]);
  rep(i, 2, N) { g = gcd(g, A[i]); }

  rep(i, 0, N) {
    if (abs(K - A[i]) % g == 0) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }

  cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef map<int,int>mp;
int main(){
int n,a;
cin>>n;
mp m;
for(int i=1;i<=n;i++){
    cin>>a;
    m[a]=i;
}
for(int i=1;i<=n;i++){
    cout<<m[i]<<' ';
}
return 0;
}


Measured memory_bytes: 5504
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;


int main() {
  int n, m, p;
  std::string s;
  int ac = 0;
  int wa = 0;
  int cnt[100000 + 100] = {};
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> p >> s;
    if (s == "AC") {
      if (cnt[p] != -1) {
	ac++;
	wa += cnt[p];
	cnt[p] = -1;
	}
      }
    else {
      if (cnt[p] != -1) {
      cnt[p] += 1;
      }
    }
  }
  cout << ac << ' ' << wa;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main() {
	int a[21][21];
	char b[2];
	int n, m;
	int sn, sm;
	int kn, km;
	int x, y, z;
	while (true) {
		f(i, 21) {
			f(j, 21)a[i][j] = 0;
		}
		scanf("%d", &n);
      if(n==0)return 0;
		f(i, n) {
			scanf("%d %d", &x, &y);
			a[x][y] ++;
		}
		scanf("%d", &m);
		x = 10;
		y = 10;
		f(i, m) {
			b[0] = 0;
			b[1] = 0;
			scanf("%s", b);
			scanf("%d", &z);
          f(j,z){
			if (b[0] == 'E') {
				x++;
				if (a[x][y] > 0) {
					n -= a[x][y];
					a[x][y] = 0;
				}
			}
			else if (b[0] == 'W') {
				x--;
				if (a[x][y] > 0) {
					n -= a[x][y];
					a[x][y] = 0;
				}
			}
			else if (b[0] == 'N') {
				y++;
				if (a[x][y] > 0) {
					n -= a[x][y];
					a[x][y] = 0;
				}
			}
			else {
				y--;
				if (a[x][y] > 0) {
					n -= a[x][y];
					a[x][y] = 0;
				}
			}
          }
		}
	if (n == 0)printf("Yes\n");
	else printf("No\n");
	}
	
	return 0;
}


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

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;

	writeln(N*800 - (N/15)*200);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(){
	int a,b,c,result=0;
	while(cin>>a>>b>>c)
	{
		if(a%2!=0 || b%2!=0 || c%2!=0 ) {
		   result=0;
		}else{
		   while(a%2 == 0 && b%2 == 0 && c%2==0 && a!=b && b!=c)
		{	
			result++;
			int temp=a;
			a=(b+c)/2; 
			int temp2=b;
			b=(temp+c)/2;
			c=(temp+temp2)/2;
		}
		if(result==0) result=-1;
		}
 
		cout<<result<<endl;
	}
   return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.function.*;
import java.lang.*;
import java.io.*;


public class Main {
    
    static boolean contains(long e, long[] array){
        for(int i=0; i<array.length; i++){
            if(array[i]==e) return true;
        }
        return false;
    }

    static long mults(long[] array){
        if(contains(0, array)) return 0;
        long ans = 1;
        for(int i=0; i<array.length; i++){
            if(ans > 1 + 1000000000000000000L / array[i]) return -1;
            ans *= array[i];
        }
        return ans > 1000000000000000000L ? -1 : ans;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        for(int n=0; n<N; n++) A[n]=sc.nextLong();
        System.out.println(mults(A));
    }
}


Measured memory_bytes: 61360