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

using namespace std;

typedef long long lint;

lint n, a, b, c, d;

const lint MAX = (1e18) + (1e9);

priority_queue <pair<lint, lint>, vector <pair<lint, lint>>, greater<pair<lint, lint>>> q;

unordered_map <lint, bool> viz;
unordered_map <lint, lint> dp;

lint cost[10];

void cmp(lint nr, lint c, lint cat)
{
    if(dp[nr / cat] == 0 || dp[nr / cat] > c + cost[cat])
    {
        dp[nr / cat] = c + cost[cat];
        q.push({dp[nr / cat], nr / cat});
    }
}

void solve()
{
    cost[2] = a;
    cost[3] = b;
    cost[5] = c;

    q.push({0, n});
    dp[n] = 0;

    while(viz[0] == 0)
    {
        lint cr = q.top().second;
        lint x = q.top().first;
        q.pop();
        if(viz[cr] == 0)
        {
           // cout << " suntem " << cr << " " << x << "\n";

            viz[cr] = 1;

            if(cr % 2 == 0 && (dp[cr / 2] == 0 || dp[cr / 2] > x + a))
            {
                dp[cr / 2] = x + a;
                q.push({dp[cr / 2], cr / 2});
            }

            if(cr % 3 == 0 && (dp[cr / 3] == 0 || dp[cr / 3] > x + b))
            {
                dp[cr / 3] = x + b;
                q.push({dp[cr / 3], cr / 3});
            }

            if(cr % 5 == 0 && (dp[cr / 5] == 0 || dp[cr / 5] > x + c))
            {
                dp[cr / 5] = x + c;
                q.push({dp[cr / 5], cr / 5});
            }

            if(abs(cr - 1) <= MAX / d)
                cmp(1, x + abs(cr - 1) * d, 1);

            if(cr <= MAX / d)
                cmp(0, x + cr * d, 1);

            int r = cr % 2;
            lint nou = cr - r;

            if(nou != cr && abs(cr - nou) <= MAX / d)
                cmp(nou, x + abs(cr - nou) * d, 2);

            if(abs(cr - (nou + 2)) <= MAX / d)
                cmp(nou + 2, x + abs(cr - (nou + 2)) * d, 2);

            if(nou >= 2)
                if(abs(cr - (nou - 2)) <= MAX / d)
                    cmp(nou - 2, x + abs(cr - (nou - 2)) * d, 2);


            r = cr % 3;
            nou = cr - r;

            if(nou != cr && abs(cr - nou) <= MAX / d)
                cmp(nou, x + abs(cr - nou) * d, 3);
            if(abs(cr - (nou + 3)) <= MAX / d)
                cmp(nou + 3, x + abs(cr - (nou + 3)) * d, 3);

            if(nou >= 3)
                if(abs(cr - (nou - 3)) <= MAX / d)
                    cmp(nou - 3, x + abs(cr - (nou - 3)) * d, 3);


            r = cr % 5;
            nou = cr - r;

            if(nou != cr && abs(cr - nou) <= MAX / d)
                cmp(nou, x + abs(cr - nou) * d, 5);
            if(abs(cr - (nou + 5)) <= MAX / d)
                cmp(nou + 5, x + abs(cr - (nou + 5)) * d, 5);

            if(nou >= 5)
                if(abs(cr - (nou - 5)) <= MAX / d)
                    cmp(nou - 5, x + abs(cr - (nou - 5)) * d, 5);

        }
    }

    cout << dp[0] << "\n";
}

int main()
{
    int qq;
    cin >> qq;
    while(qq > 0)
    {
        qq --;

        dp.clear();
        viz.clear();
        while(q.size() > 0)
            q.pop();

        cin >> n >> a >> b >> c >> d;

        solve();
    }
    return 0;
}


Measured memory_bytes: 5548
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int AB = 26;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		int c = parseInt(sc.next());
		int d = parseInt(sc.next());
		sc.close();
		int dif = Math.min(b, d)-Math.max(a, c);
		dif = dif < 0?0:dif;
		out.println(dif);
	}
}


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

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

    int num = 0;
    int ans = 0;
    for (int karen = 0; karen < n; karen++){
        if (a[karen] == (num + 1)){
            num++;
        }
    }
    if (num == 0){
        ans = -1;
    }
    else{
        ans = n - num;
    }

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

Measured memory_bytes: 1024
N=int(input())
L=[list(map(int,input().split())) for i in range(N)]
L.sort(key=lambda x:x[2],reverse=True)
for i in range(101):
  for j in range(101):
    s=L[0][2]+abs(i-L[0][0])+abs(j-L[0][1])
    for l in L[1:]:
      h=l[2]+abs(i-l[0])+abs(j-l[1])
      if s==h:
        continue
      elif l[2]==0 and s<h:
        continue
      else:
        break
    else:
      print(i,j,s)
      exit()

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

#define MIN(a,b) ((a)<(b)?(a):(b))

typedef long long int int64;

typedef struct dnode{
  int v;
  int64 val;
} node;

int cmp(const node *a,const node *b){
  return a->val<=b->val;
}

typedef struct binaryHeap{
  node *h;
  int heapSize;
  int (*cmp)(const node *,const node *);
} heap;

heap* newHeap(int maxSize,int (*cmpF)(const node *,const node *)){
  heap *res=(heap *)malloc(sizeof(heap));
  res->h=(node *)malloc(sizeof(node)*(maxSize+1));
  res->heapSize=0;
  res->cmp=cmpF;
  return res;
}

void freeHeap(heap *h){
  free(h->h);
  free(h);
  return;
}

void push(heap *q,node *p){
  q->heapSize+=1;
  node *h=q->h;
  int k=q->heapSize;
  int (*cmp)(const node *,const node *)=q->cmp;
  h[k]=*p;
  while(k>1){
    if(cmp(h+k/2,h+k)) return;
    node swap=h[k];
    h[k]=h[k/2];
    h[k/2]=swap;
    k/=2;
  }
  return;
}

void pop(heap *q,node *res){
  node *h=q->h;
  *res=h[1];
  h[1]=h[q->heapSize];
  q->heapSize-=1;
  int (*cmp)(const node *,const node *)=q->cmp;
  int n=q->heapSize;
  int k=1;
  while(2*k+1<=n){
    int next=cmp(h+2*k,h+2*k+1)?2*k:2*k+1;
    if(cmp(h+k,h+next)) return;
    node swap=h[k];
    h[k]=h[next];
    h[next]=swap;
    k=next;
  }
  if(2*k<=n && cmp(h+2*k,h+k)){
    node swap=h[k];
    h[k]=h[2*k];
    h[2*k]=swap;
  }
  return;
}

void dijkstra(int from,int64 *dp,int *start,int *vertex,int *cost,int *next,int n){
  heap *h=newHeap(100000,cmp);
  int *used=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) dp[i]=10000000000000000LL;
  dp[from]=0;
  node t={from,0};
  push(h,&t);
  while(h->heapSize>0){
    pop(h,&t);
    int v=t.v;
    if(used[v]) continue;
    used[v]=1;
    int p;
    for(p=start[v];p!=-1;p=next[p]){
      int u=vertex[p];
      if(dp[v]+cost[p]>=dp[u]) continue;
      dp[u]=dp[v]+cost[p];
      node s={u,dp[u]};
      push(h,&s);
    }
  }
  free(used);
  freeHeap(h);
  return;
}

#define ADD(i,u,v,a,b) do{vertex[i]=v;costA[i]=a;costB[i]=b;next[i]=start[u];start[u]=i;}while(0)

void run(void){
  int n,m,s,t;
  scanf("%d%d%d%d",&n,&m,&s,&t);
  s--;t--;
  int i;
  int *start=(int *)malloc(sizeof(int)*n);
  int *vertex=(int *)malloc(sizeof(int)*2*m);
  int *costA=(int *)malloc(sizeof(int)*2*m);
  int *costB=(int *)malloc(sizeof(int)*2*m);
  int *next=(int *)malloc(sizeof(int)*2*m);
  next[0]=0;
  for(i=0;i<n;i++) start[i]=-1;
  for(i=0;i<m;i++){
    int u,v,a,b;
    scanf("%d%d%d%d",&u,&v,&a,&b);
    u--;v--;
    ADD(2*i  ,u,v,a,b);
    ADD(2*i+1,v,u,a,b);
  }
  int64 *sTo=(int64 *)malloc(sizeof(int64)*n);
  dijkstra(s,sTo,start,vertex,costA,next,n);
  int64 *tTo=(int64 *)malloc(sizeof(int64)*n);
  dijkstra(t,tTo,start,vertex,costB,next,n);
  int64 *min=(int64 *)malloc(sizeof(int64)*n);
  min[n-1]=sTo[n-1]+tTo[n-1];
  for(i=n-2;i>=0;i--){
    min[i]=MIN(min[i+1],sTo[i]+tTo[i]);
  }
  const int64 mm=1000000000000000LL;
  for(i=0;i<n;i++) printf("%lld\n",mm-min[i]);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 8052
#include <iostream>
using namespace std;
int main()
{
	int n,m,t=0,s,u;
	int a[30][30],k[30];
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		cin >> k[i];
		for (int j = 0; j < k[i]; ++j) {
			cin >> a[i][j];
		}

	}
	for (int i = 1; i < m + 1; ++i) {
		s = 0;
		for (int j = 0; j < n; ++j) {
			u = 0;
			for (int h = 0; h < k[j]; ++h) {
				if (a[j][h] == i)u = 1;
			}
			if (u == 0) {
				s = 1;
				break;
			}
		}
		if (s == 1)continue;
		else ++t;
	}
	cout << t << "\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int r = in.nextInt();
        int d = in.nextInt();
        int x = in.nextInt();
        for(int i=1; i<=10; i++) {
            x = x * r - d;
            System.out.println(x);
        }
    }
}


Measured memory_bytes: 21332
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define SORT(x) (sort(x.begin(),x.end()))
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    int A,B,K,C;cin>>A>>B>>K;
    C=0;
    for(int i=100;i>0;i--){
        if(A%i==0&&B%i==0){
            C++;
        }
        if(C==K){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 384
#include <vector>
#include <array>
#include <map>
#include <string>
#include <algorithm>
#include <iostream>
#include <set>
#include <random>
#include <cassert>
#include <fstream>

const int MOD = 1e9 + 7;
using namespace std;

int64_t dp[1001][1001];
int64_t fac[1001];
int64_t inv[1001];
int64_t rev[1001];
int64_t add(int64_t a, int64_t b) {
    a += b;
    if (a >= MOD) {
        a -= MOD;
    }
    return a;
}

int64_t mul(int64_t a, int64_t b) {
    return a * b % MOD;
}

void prep() {
    fac[0] = 1;
    fac[1] = 1;
    rev[1] = 1;
    inv[0] = 1;
    inv[1] = 1;
    for (int i = 2; i <= 1000; ++i) {
        fac[i] = mul(fac[i - 1], i);
        rev[i] = mul(MOD - MOD / i, rev[MOD % i]);
        inv[i] = mul(inv[i - 1], rev[i]);
        assert(mul(inv[i], fac[i]) == 1);
    }
}

int64_t C(int64_t n, int64_t k) {
    return mul(mul(fac[n], inv[k]), inv[n - k]);
}
int64_t pw(int64_t a, int64_t b) {
    int64_t res = 1;
    while (b) {
        if (b & 1) {
            res = mul(res, a);
        }
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}
int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    prep();
    int n;
    cin >> n;
    int a, b;
    cin >> a >> b;
    int c, d;
    cin >> c >> d;
    dp[a - 1][0] = 1;

    for (int i = a; i <= b; ++i) {
        for (int j = 0; j <= n; ++j) {
            int up = j / i;
            int64_t cur_pw = pw(inv[i], c);
//            cout << "calc " << i << " " << j << endl;
            for (int e = c; e <= up && e <= d; ++e) {
//                cout << i - 1 << " " << j - e * i << endl;
                int64_t coef = mul(mul(dp[i - 1][j - e * i], C(j, j - e * i)), cur_pw);
                coef = mul(coef, inv[e]);
                coef = mul(coef, fac[e * i]);
                dp[i][j] = add(dp[i][j], coef);
                cur_pw = mul(cur_pw, inv[i]);
            }
            dp[i][j] = add(dp[i][j], dp[i - 1][j]);
//            cout << i - 1 << " " << j << endl;
//            cout << i << " " << j << " " << dp[i][j] << endl;
        }
    }
    cout << dp[b][n];
}



Measured memory_bytes: 8064
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << (H-h)*(W-w) << 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++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  REP(i, K) {
    if (B <= A) {
      B *= 2;
    } else if (C <= B) {
      C *= 2;
    } else {
      break;
    }
  }
  if (A < B && B < C) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s, ans;
    cin >> s;
    if(s.at(0) == s.at(1) && s.at(1) == s.at(2)) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
//Create Time: 2018-04-24 23:16:38
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <functional>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cctype>
#include <ctime>
#include <utility>
#include <complex>
#include <cassert>
#include <climits>
#include <iterator>
#include <tuple>
using namespace std;
#define snuke(i,x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,n,a) for (int i=(n)-1;i>=(a);i--)
// #define OUT(x) std::cout<<(#x)<<":"<<(x)<<std::endl
// #define TST(x) std::cout<<(#x)<<":"<<(x)<<" "
#define OUT(args...) {string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);OUT_TST("\n",_it,args);}
#define TST(args...) {string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);OUT_TST("",_it,args);}
#define SZ(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define unq(x) sort(all(x)),(x).erase(unique(all(x)),(x).end())
#define mem(f,x) memset((f), (x), sizeof(f))
#define clr(f) mem(f,0)
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define DEBUG
void OUT_TST(string s,istream_iterator<string> it) {cerr<<s;}
template<typename T, typename... Args> void OUT_TST(string s,istream_iterator<string> it,T a,Args... args){cerr<<*it<<"="<<a<<" ";OUT_TST(s,++it,args...);}
template<class T> void rd(T&ret){ret=0;bool ok=0,u=0;for(;;){int c=getchar();if(c>='0'&&c<='9')ret=(ret<<3)+(ret<<1)+c-'0',ok=1;else if(c=='-')u=1;else if(ok){if(u)ret*=-1;return;}}}
long long powmod(long long p,long long n,long long mod){long long ret=1;for(;n;n>>=1){if(n&1)ret=ret*p%mod;p=p*p%mod;}return ret;}
template <class T> bool chmin(T& a, const T &b) {return b < a? a = b, 1: 0;}
template <class T> bool chmax(T& a, const T &b) {return b > a? a = b, 1: 0;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii > vii;
/****head****/
int main(){
    int n;scanf("%d",&n);
    ll s=0,mi=1ll<<60;
    rep(i,0,n){
        int a,b;
        scanf("%d%d",&a,&b);
        s+=a;
        if(a>b)chmin(mi,(ll)b);
    }
    if(mi==1ll<<60)cout<<"0"<<endl;
    else{
        cout<<s-mi<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        String relation;
        if (a < b){
            relation = "<";
        } else if (a > b){
            relation = ">";
        } else{
            relation = "==";
        }
    System.out.printf("a %s b\n", relation);
    }
}



Measured memory_bytes: 26264
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<functional>
#include<climits>
#include<utility>
#include<iomanip>
#include<map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define REP(i,x) FOR(i,0,x)
#define CLR(a) memset((a), 0 ,sizeof(a))


const ll MOD = 1e+9+7;
const double PI  = acos(-1.0);

int main(){
  int n,x,y;
  cin>>n>>x>>y;
  cout<<((y-x)%2?"Borys":"Alice")<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;
#define PI 3.14159265358979

int main(){
  double a, b, x;
  cin >> a >> b >> x;
  double h = x/(a*a);

  double result;
  if(a*h < a*b/2) result = atan(b*b/(2*a*h));
  else result = atan((2*b-2*h)/a);

  cout << fixed << setprecision(10);
  cout << (double)180 * result / PI << endl;

}

Measured memory_bytes: 384
# coding: utf-8
while 1:
    x,y,s=map(int,input().split())
    if s==0:
        break
    ans=0
    for i in range(1,s):
        for j in range(i,s):
            sumx=i*(100+x)//100 + j*(100+x)//100
            if sumx==s:
                sumy = i*(100+y)//100 + j*(100+y)//100
                ans=max(ans,sumy)
    print(ans)


Measured memory_bytes: 5604
import numpy as np
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
 
cycles, check = [], [False]*n
for pi in p:
    if not check[pi-1]:
        curr, cycle = pi, []
        check[pi-1] = True
        while pi != p[curr-1]:
            check[curr-1] = True
            cycle.append(c[curr-1])
            curr = p[curr-1]
        check[curr-1] = True
        cycles.append(cycle + [c[curr-1]])

scores = []
for cycle in (np.array(cycle) for cycle in cycles):
    for i in range(cycle.size):
        cum = np.roll(cycle, i).cumsum()
        if cum[-1] > 0 and k > cycle.size:
            scores.append(cum[-1]*(k//cycle.size-1) + np.concatenate([cum, cum[:k % cycle.size]+cum[-1]]).max())
        else:
            scores.append(cum[:min(k, cum.size)].max())
print(max(scores))

Measured memory_bytes: 28440
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        p: [usize; n]
    };

    let mut count = 0;
    for i in 1..n - 1 {
        if (p[i - 1] > p[i] && p[i] > p[i + 1]) || (p[i + 1] > p[i] && p[i] > p[i - 1]) {
            count += 1;
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 2144
#include <algorithm>
#include <cstdio>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <cassert>
#include <cfloat>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

int main() {
	int  N;
	cin >> N;
	vector <int> L(2 * N);
	for (int i = 0; i < 2 * N; i++) {
		cin >> L[i];
	}
	sort(L.begin(), L.end());
	int res = 0;
	for (int i = 0; i < 2 * N; i+=2) {
		res += L[i];
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
int a[10005];

int fun(int c,int b)
{

    if(b%2==0)
    {
       c++;
        fun(c,b/2);
    }
    else
        return c;
}
int main()
{
    int n;
     cin>>n;
     int sum=0;
     for(int i=0;i<n;i++)
        cin>>a[i];
     for(int j=0;j<n;j++)
     {

        int s=fun(0,a[j]);
        sum=sum+s;
     }
     cout<<sum<<endl;


    return 0;
}


Measured memory_bytes: 256
//Author- Vaibhav singh
//will be expert soon 
// *#####################################################################################*
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=n;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define mp make_pair
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define re return 0;
// *#######################################################################################*
// *#########################################################################################*
    //      ll ans=0,b[5000005]={0},a[5000005],i,n,x=0;                
    

int main()
{
      
      fast
    
    
    string a,b,c;
    cin>>a>>b>>c;
    
    char z='a';
    ll i=0,j=0,k=0;
    while(true)
    {
        if(z=='a')
        {
            if(i==a.size())
            {
                o("A")
                re
            }
            else
            {
                z=a[i];
                i++;
            }
        }
        if(z=='b')
        {
            if(j==b.size())
            {
                o("B")
                re
            }
            else
            {
                z=b[j];
                j++;
            }
        }
        
        else if(z=='c')
        {
            if(k==c.size())
            {
                o("C")
                re
            }
            else
            {
                z=c[k];
                k++;
            }
        }
        
        
    }
    
    
    
    
    
        
        
        
	re
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll A[2], B[2];

int main()
{
  rep( i, 2 )
    std::cin >> A[i];
  rep( i, 2 )
    std::cin >> B[i];

  std::cout << std::min(A[0], A[1])+std::min(B[0], B[1]) << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lor(a,b,c) for(register int a=b;a<=c;++a)
#define ror(a,b,c) for(register int a=c;a>=b;--a)

const int MAXN=1e5+5;

int n;

int main(){
	scanf("%d",&n);
	if(n==3){
		puts("Yes"); lor(i,1,5) printf("%d %d\n",i,i+1); return 0;
	}
	int num=1,k=0;
	while(num<=n) num<<=1,++k; num>>=1; --k;
	if(num==n) return puts("No"),0;
	puts("Yes");
	lor(i,1,num-2) printf("%d %d\n",i,i+1);
	printf("%d %d\n",num-1,1+n);
	lor(i,1,num-2) printf("%d %d\n",i+n,i+1+n);
	printf("%d %d\n",num,1); printf("%d %d\n",num+1,num);
	printf("%d %d\n",num+1+n,1); printf("%d %d\n",num+1+n,num+n);
	lor(i,num+2,n) printf("%d %d\n%d %d\n",i,i-1+n,i+n,i-num);

	return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)

int main() {
#ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
#endif
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   long long n;
   cin >> n;
   long long res = LLONG_MAX;
   for(long long i = 1 ; i * i <= n ; ++i){
      if(n % i == 0){
         res = min(res , i - 1 + n / i - 1);
      }
   }
   cout << res << "\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

const int N = 10000000;
bool prime[N];

void sieve() {
	rep(i, N) prime[i] = true;
	prime[0] = prime[1] = false;
	for(int i = 2; i < N; ++i) {
		if(prime[i])	for(int j = 2 * i; j < N; j+=i) prime[j] = false;
	}
}

int main() {
	sieve();
	int n;
	while(cin>>n, n){
		int i = n;
		while(!(prime[i] && prime[i-2] && prime[i-6] && prime[i-8])) --i;
		cout << i << endl;
  }
}

Measured memory_bytes: 10924
#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>

#define sqr(a) (a)*(a)

using namespace std;

int main () {
    int n;
    cin >> n;
    vector<int> v(n, 0);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    int avg = round(accumulate(v.begin(), v.end(), .0) / static_cast<double> (n));
    int result = 0;
    for (int i = 0; i < n; ++i) {
        result += sqr(v[i] - avg);
    }
    cout << result;
}


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

using namespace std;

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	vector<vector<char>> v(h, vector<char>(w));
	for(int i = 0; i < h; i++) {
	    for(int j = 0; j < w; j++) {
	        cin >> v[i][j];
	    }
	}
	int count, ans = 0;
	for(int maskr = 0; maskr < (1 << h); maskr++) {
	    for(int maskc = 0; maskc < (1 << w); maskc++) {
	        count = 0;
	        for(int i = 0; i < h; i++) {
	            for(int j = 0; j < w; j++) {
	                if(!(maskr & (1 << i)) && !(maskc & (1 << j)) && (v[i][j] == '#')) count++;
	            }
	        }
	        if(count == k) {
	            ans++;
	        }
	    }
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3604
from collections import defaultdict


def split_all(s: str):
    n = len(s)

    ans = []
    for k in range(2 ** (n - 1)):
        t = s
        tmp = []
        b = format(k, "b").zfill(n - 1)
        for i in range(n - 2, -1, -1):
            if b[i] == "1":
                x, y = t[:i + 1], t[i + 1:]
                tmp.append(y)
                t = x
        if t:
            tmp.append(t)
        ans.append(tmp[::-1])

    return ans


def main():
    s = input()
    ans = 0
    for x in split_all(s):
        ans += eval("+".join(x))
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
#include <stdio.h>
int main(){
    int a = 0,
        b = 0,
        i = 0,
        min = 1000000,
        max = -1000000;
    long sum = 0;
    scanf("%d", &a );
    for (i=0;i<a;i++){
        scanf("%d", &b );
        if (b>max) { max = b; }
        if (b<min) { min = b; }
        sum +=b;
    }
    printf("%d %d %ld\n", min, max, sum);
    return 0;
}

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

int main(void) {
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;

  int ans;
  if(a>=2*c && b>=2*c){
    ans = max(x,y) * 2 * c;
  } else if(a>=2*c) {
    ans = x*2*c + max(0, y-x) * b;
  } else if(b>=2*c) {
    ans = y*2*c + max(0, x-y) * a;
  } else if(a+b <= 2*c) {
    ans = a*x+b*y;
  } else if(x>y) {
    ans = y*2*c + a*(x-y);
  } else {
    ans = x*2*c + b*(y-x);
  }

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


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int x2 = sc.nextInt();
        int x3 = sc.nextInt();
        int x4 = sc.nextInt();
        int x5 = sc.nextInt();
        
        if(x1 == 0) System.out.println(1);
        if(x2 == 0) System.out.println(2);
        if(x3 == 0) System.out.println(3);
        if(x4 == 0) System.out.println(4);
        if(x5 == 0) System.out.println(5);
        
    }
}


Measured memory_bytes: 35712
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


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

        int A = Math.max(Math.max(T,R),Y);
        int B = Math.min(Math.min(T,R),Y);

        System.out.println(A-B);
    }
}


Measured memory_bytes: 21844
(let ((a (read))
    (b (read))
    (kazu 1)
    (ans 0))
    (loop for i below b while (< kazu b) do
        (progn
            (decf kazu)
            (incf kazu a)
            (incf ans)
        )    
    )
    (format t "~D~%" ans)
)


Measured memory_bytes: 24352
#include<stdio.h>

int main(void){
	char s[11];
	char t[12];

	scanf("%s",s);
	scanf("%s",t);

	for(int i=0;s[i];i++) {
		if(s[i]!=t[i]) {
			printf("No");
			return 0;
		}
	}

	printf("Yes");
	return 0;
}


Measured memory_bytes: 1728
#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) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putintsp(int X) {
	if (X < 0) {
		*di++ = '-';
		X = -X;
	}
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = ' ';
}
inline void putint(int X) {
	if (X < 0) {
		*di++ = '-';
		X = -X;
	}
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	fread_unlocked(cn, 1, cm, stdin);
	int N = 0;
	while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';

	int A[100000] = {};
	int saidai = -1e9;
	int saishou = 1e9;
	int isaidai, isaishou;

	char CC[100000][6];
	int CN[100000];

	rep(i, N) {

		int pn = 1;
		int kazu = 0;
		if (ci - cn + 16 > cm) {
			if ((ct = getcha()) == '-') { pn = -1; ct = getcha(); CC[i][kazu] = '-'; kazu++; }
			A[i] = ct - '0';
			CC[i][kazu] = ct;
			kazu++;
			while ((ct = getcha()) >= '0') { A[i] = A[i] * 10 + ct - '0'; CC[i][kazu] = ct; kazu++; }
			CN[i] = kazu;
			A[i] *= pn;
		}
		else {
			if ((ct = *ci++) == '-') { pn = -1; ct = *ci++;  CC[i][kazu] = '-'; kazu++; }
			A[i] = ct - '0';
			CC[i][kazu] = ct;
			kazu++;
			while ((ct = *ci++) >= '0') { A[i] = A[i] * 10 + ct - '0'; CC[i][kazu] = ct; kazu++; }
			CN[i] = kazu;
			A[i] *= pn;
		}

		if (A[i] > saidai) {
			saidai = A[i];
			isaidai = i;
		}
		else if (A[i] < saishou) {
			saishou = A[i];
			isaishou = i;
		}
	}
	for (int i = 0; i < N; i++) {
		if (i != isaidai && i != isaishou) {
			if (A[i] < 0) {
				putintsp(saidai);
				rep(j, CN[i]) *di++ = CC[i][j];
				*di++ = '\n';
				saidai -= A[i];
			}
			else {
				putintsp(saishou);
				rep(j, CN[i]) *di++ = CC[i][j];
				*di++ = '\n';
				saishou -= A[i];
			}
		}
	}
	putintsp(saidai);
	putint(saishou);

	int X = saidai - saishou;

	if (X == 0) {
		putchar_unlocked('0');
		putchar_unlocked('\n');
	}
	else {
		if (X < 0) {
			putchar_unlocked('-');
			X = -X;
		}
		int keta = 0;
		char C[10];
		while (X) {
			*(C + keta) = '0' + X % 10;
			X /= 10;
			keta++;
		}
		for (int i = keta - 1; i >= 0; i--) putchar_unlocked(*(C + i));
		putchar_unlocked('\n');
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

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

int checkMap(int w, int h, int map[52][52]){
	if(map[w][h]){
		map[w][h]=0;
		 checkMap(w+1, h+1, map);
		 checkMap(w+1, h, map);
		 checkMap(w+1, h-1, map);
		 checkMap(w, h-1, map);
		 checkMap(w-1, h-1, map);
		 checkMap(w-1, h, map);
		 checkMap(w-1, h+1, map);
		 checkMap(w, h+1, map);
		 return 1;
	}else return 0;
		 
}


int main(){
	int w,h;

	while(cin >> w >> h, w){
	int map[52][52] = {{0}};
		int ans=0;
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++){
				cin >> map[i][j];
			}
		}
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++){
			ans += checkMap(i, j, map);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1324
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  ll l=1e9,r=1e10; l--; r--;
  char c;
  while(r-l>1){
    ll m=(r+l+1)>>1;
    cout<<"? "<<m<<"000"<<endl;
    cin>>c;
    if(c=='Y'){r=m;}
    else{l=m;}
  }
  l=r;
  set<ll> S;
  for(ll i=10;i<MOD;i*=10){S.insert(i-1);}
  while(l%10==0){
    if(S.count(l/10)){
      cout<<"? "<<l/10+1<<endl;
      cin>>c;
      if(c=='Y'){break;}
    }
    else{
      cout<<"? "<<l/10+1<<endl;
      cin>>c;
      if(c=='N'){break;}
    }
    l/=10;
  }
  cout<<"! "<<l<<endl;
  cout<<flush;

  return 0;
}


Measured memory_bytes: 596
hoge = 0
while True:
	try:
		hit = 0
		blow = 0
		a = map(int, raw_input().split())
		b = map(int, raw_input().split())
		for i in range(4):
			try:
				if a.index(b[i]) == i:
					hit += 1
				else:
					blow += 1
			except ValueError:
				continue
		print hit, blow
	except EOFError:
		break


Measured memory_bytes: 4228
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<functional>
using namespace std;
long long inf = ((long long)1 << 63) - 1;
class room {
public:
	int x, y;
	long long fast;
	room() : fast(inf) {

	}
};
class player {
public:
	long long time;
	room *n;
	bool tate;
	player(room *a, long long c, bool d) :n(a), time(c), tate(d) {

	}
};
bool operator<(const player &a, const player &b) {
	return a.time < b.time;
}
bool operator>(const player &a, const player &b) {
	return a.time > b.time;
}

int main() {
	int M, N, K;
	cin >> M >> N >> K;
	vector<vector<room*> > tate(M + 1), yoko(N + 1);
	room *map;
	map = new room[K + 1];
	for (int i = 0; i < K; ++i) {
		cin >> map[i].x >> map[i].y;
		tate[map[i].x].push_back(&map[i]);
		yoko[map[i].y].push_back(&map[i]);
	}
	map[K].x = M;
	map[K].y = N;
	tate[M].push_back(&map[K]);
	yoko[N].push_back(&map[K]);
	vector<room*>::iterator ps, pe;
	priority_queue<player, vector<player>, greater<player> > que;
	for (ps = tate[1].begin(), pe = tate[1].end(); ps != pe; ++ps) {
		que.push(player(*ps, (*ps)->y, false));
		(*ps)->fast = (*ps)->y;
	}
	while (!que.empty()) {
		player dummy = que.top(); que.pop();
		if (dummy.n->x == M&&dummy.n->y == N) {
			cout << dummy.time - 1 << endl;
			return 0;
		}
		if (dummy.time == dummy.n->fast) {
			if (dummy.tate) {
				for (ps = tate[dummy.n->x].begin(), pe = tate[dummy.n->x].end(); ps != pe; ++ps) {
					long long nt = dummy.time + abs(dummy.n->y - (*ps)->y) + 1;
					if ((*ps)->fast > nt) {
						que.push(player(*ps, nt, false));
						(*ps)->fast = nt;
					}
				}
			}
			else {
				for (ps = yoko[dummy.n->y].begin(), pe = yoko[dummy.n->y].end(); ps != pe; ++ps) {
					long long nt = dummy.time + abs(dummy.n->x - (*ps)->x) + 1;
					if ((*ps)->fast > nt) {
						que.push(player(*ps, nt, true));
						(*ps)->fast = nt;
					}
				}
			}
		}
	}
	cout << -1 << endl;
	return 0;
}

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

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const unsigned int mod = 1e9 + 7;

using namespace std;

int32_t main() {
	fastio;

	int n;
	cin >> n;
	int a[n + 1], freq[n + 1];
	memset(freq, 0, sizeof(freq));
	for(int i = 2; i <= n; ++i) cin >> a[i];
	for(int i = 2; i <= n; ++i) ++freq[a[i]];
	for(int i = 1; i <= n; ++i) cout << freq[i] << '\n';

	return 0;
}

/*
C - management / 
Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 
300
 points

Problem Statement
A company has 
N
 members, who are assigned ID numbers 
1
,
.
.
.
,
N
.

Every member, except the member numbered 
1
, has exactly one immediate boss with a smaller ID number.

When a person 
X
 is the immediate boss of a person 
Y
, the person 
Y
 is said to be an immediate subordinate of the person 
X
.

You are given the information that the immediate boss of the member numbered 
i
 is the member numbered 
A
i
. For each member, find how many immediate subordinates it has.

Constraints
2
≤
N
≤
2
×
10
5
1
≤
A
i
<
i
Input
Input is given from Standard Input in the following format:

N

A
2
 
.
.
.
 
A
N

Output
For each of the members numbered 
1
,
2
,
.
.
.
,
N
, print the number of immediate subordinates it has, in its own line.

Sample Input 1 
Copy
5
1 1 2 2
Sample Output 1 
Copy
2
2
0
0
0
The member numbered 
1
 has two immediate subordinates: the members numbered 
2
 and 
3
.

The member numbered 
2
 has two immediate subordinates: the members numbered 
4
 and 
5
.

The members numbered 
3
, 
4
, and 
5
 do not have immediate subordinates.

Sample Input 2 
Copy
10
1 1 1 1 1 1 1 1 1
Sample Output 2 
Copy
9
0
0
0
0
0
0
0
0
0
Sample Input 3 
Copy
7
1 2 3 4 5 6
Sample Output 3 
Copy
1
1
1
1
1
1
0
*/


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,T;
int C[1010],A[1010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>T;
	int be=101010;
	FOR(i,N) {
		cin>>C[i]>>A[i];
		if(A[i]<=T) be=min(be,C[i]);
	}
	if(be==101010) cout<<"TLE"<<endl;
	else cout<<be<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int n;
int v[100][100];
int color[100], d[100], f[100], tt;
/*
  color: ???????????¶???
    0: ???????¨??????????????????????;
    1: ?¨??????????????????????;
    2: ???????????????;
  d: ?????????????????????;
  f: ?????????????????????;
  tt: ?¨??????????;
*/


int dfs(int u)
{
  color[u] = 1;
  d[u] = ++tt; //????????????????¨????
  for (int i = 0; i < n; i++) {
    if (v[u][i] == 0) continue;
    if (color[i] == 0) {
      dfs(i);
    }
  }
  color[u] = 2;
  f[u] = ++tt; //?¨?????????????
}

signed main()
{
  int u, k;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    u--;
    for (int j = 0; j < k; j++) {
      int tmp;
      cin >> tmp;
      tmp--;
      v[u][tmp] = 1;
    }

  }

  for (int u = 0; u < n; u++) {
    if (color[u] == 0) dfs(u);
  }

  for (int i = 0; i < n; i++) {
    cout << i + 1 << " " << d[i] << " " << f[i] << endl;
  }

  return (0);
}

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

using namespace std;

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

  for (auto &c : s) {
    if (c != s[k - 1]) {
      c = '*';
    }
  }
  cout << s << '\n';
  return 0;
}


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

int main(){
  string x;
  int k=753;
  cin>>x;
  int ans=9999;
  for(int i=0;i<x.size()-2;i++){
    ans=min(ans,abs(k-((x[i]-'0')*100+(x[i+1]-'0')*10+(x[i+2]-'0'))));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for i in range(n)]
cnt=0
for i in range(n):
  ans=c
  for j in range(m):
    ans+=a[i][j]*b[j]
  if ans>0:
    cnt+=1
print(cnt)

Measured memory_bytes: 3060
n,k = [int(x) for x in input().split()]
a = [0] * (n + 1)
for i in range(1,n+1):
  a[i] = a[i-1] + i
#print(a)
res = 0
for i in range(k,n+1):
  ma = a[n] - a[n-i]
  mi = a[i-1]
  res += ma - mi + 1
  #print(i,res,ma,mi)
res += 1
res %= 10 ** 9 + 7
print(res)

Measured memory_bytes: 19024
//0047

#include<cstdio>
#include<algorithm>
using namespace std;

int main(void)
{
	bool ball[3] = {true,false,false};
	char str[8];
	while(fgets(str,8,stdin))
	{
		swap(ball[str[0]-'A'], ball[str[2]-'A']);
	}

	printf("%c\n", 
		(ball[0]?'A' : (ball[1]?'B':'C') )
		);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define MOD 1000000007

using namespace std;
typedef long long int ll;

int main(void){
	// #ifndef ONLINE_JUDGE
	// freopen("in.txt", "r", stdin);
	// #endif
	fast;
	int n; cin >> n;
	ll a[n];
	ll ans = 0;
	for (int i = 0; i < n; ++i){
		cin >> a[i];
		ans += a[i]-1;
	}
	cout << ans;
	// ll lim = *max_element(a, a+n);
	// for (int i = 1; i <= lim; ++i){
	// 	cur += n;
	// 	cur -= 
	// }
}

Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
double s(long long n)
{
    long long x=n;
    long long y=0;
    while (x)
    {
        y+=x%10;
        x/=10;
    }
    return (double)n/y;
}
int main()
{
    long long K;
    long long n=1;
    long long x=1;
    scanf("%lld",&K);
    for (int i = 0; i < K; i++)
    {
        printf("%lld\n",n);
        if (s(n+x)>s(n+x*10))
            x*=10;
        n+=x;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<int, int> mp;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        mp[a[i]] = i + 1;
    }
    for (auto ans : mp)
    {
        cout << ans.second << ' ';
    }
    cout << endl;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename Ostream,typename Container>
Ostream& operator<<(Ostream& os,const Container& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

struct UnionFind{
	vi data;
	UnionFind(int n):data(n,-1){}
	int Find(int i){
		return data[i]<0?i:(data[i]=Find(data[i]));
	}
	bool Unite(int a,int b){
		a=Find(a),b=Find(b);
		if(a==b) return false;
		if(-data[a]<-data[b]) swap(a,b);
		data[a]+=data[b];
		data[b]=a;
		return true;
	}
	int Size(int i){
		return -data[Find(i)];
	}
};

struct Edge{
	int src,dst,weight;
	Edge(){}
	Edge(int s,int d,int w):src(s),dst(d),weight(w){}
};
typedef vector<vector<Edge>> Graph;
bool operator<(const Edge& a,const Edge& b){return a.weight<b.weight;}
bool operator>(const Edge& a,const Edge& b){return a.weight>b.weight;}

ostream& operator<<(ostream& os,const Edge& e){
	return os<<'('<<e.src<<','<<e.dst<<','<<e.weight<<')';
}

int main()
{
	for(int n,m;cin>>n>>m && n|m;){
		vi ts(n);
		rep(i,n) cin>>ts[i];
		
		vector<Edge> es;
		rep(i,m){
			int u,v,w; cin>>u>>v>>w; u--,v--;
			es.emplace_back(u,v,w);
		}
		sort(all(es));
		
		vi ts2=ts;
		sort(all(ts2));
		ts2.erase(unique(all(ts2)),end(ts2));
		
		int k;
		for(k=0;k<ts2.size();k++){
			UnionFind uf(n);
			int cc=count_if(all(ts),[&](int x){return x>=ts2[k];});
			for(auto e:es) if(ts[e.src]>=ts2[k] && ts[e.dst]>=ts2[k])
				cc-=uf.Unite(e.src,e.dst);
			if(cc>1) break;
		}
		
		UnionFind uf(n);
		vi use(n);
		int res=0;
		per(i,k)
			for(auto e:es) if(ts[e.src]>=ts2[i] && ts[e.dst]>=ts2[i])
				if(uf.Unite(e.src,e.dst))
					res+=e.weight;
		cout<<res<<endl;
	}
}

Measured memory_bytes: 1700
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int h = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int r = scan.nextInt();
		
		boolean ans = !(x-r < 0 || y-r < 0 || x+r > w || y+r > h);
		
		if(ans)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}

}



Measured memory_bytes: 26184
#include<bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
const int inf=0x3f3f3f3f;
const long long inf2=(1<<62)-1;
const double eps=1e-6;
const int mod=1000000007;
void sol(char &x){
if(x=='1')x='9';
else if(x=='9')x='1';
}
int main(){
	char a,b,c;
a=getchar();b=getchar();c=getchar();
sol(a);sol(b);sol(c);
cout<<a<<b<<c;
	return 0;
}


Measured memory_bytes: 764