akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb emplace_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<int, pii>
#define puu pair<ULL, ULL>
#define pdd pair<long double, long double>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

int a, b, c;
int main() {
	fio;
	cin >> a >> b >> c;
	cout << min(a*b, c) << endl;
	return 0;
} 

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

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

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

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

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

int n;

signed main() {
	cin >> n;
	cout << "AB" << (n<=999 ? 'C' : 'D') << ln;
}

Measured memory_bytes: 256
# Aizu Problem 0191: Baby Tree
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    n, m = [int(_) for _ in input().split()]
    if n == m == 0:
        break
    rates = [[float(_) for _ in input().split()] for __ in range(n)]
    growth = [[0.] * n for _ in range(m)]
    for k in range(n):
        growth[0][k] = 1.
    for day in range(1, m):
        for current in range(n):
            for previous in range(n):
                growth[day][current] = max(growth[day][current], \
                                    growth[day-1][previous] * rates[previous][current])
    print("%.2f" % max(growth[m-1]))

Measured memory_bytes: 8368
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

void chmin(long &a, long b) {
  if (a > b) a = b;
}

int main() {
  const long long INF = 1LL << 60;
  int n, k;
  cin >> n >> k;
  vector<long> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];

  vector<long> dp(n, INF);
  dp[0] = 0;

  for(int i = 1; i < n; i++) {
    for(int j = 1; j <= k; j++) {
      if (i > j - 1) chmin(dp[i], dp[i-j] + abs(h[i-j] - h[i]));    
    }
  }

  cout << dp[n-1] << endl;
}


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

int main() {
  vector<int> X(9);
  for(int i=0; i<9; i++)
    cin >> X.at(i);
  X.at(3) = X.at(3)-X.at(0);
  X.at(4) = X.at(4)-X.at(1);
  X.at(5) = X.at(5)-X.at(2);
  X.at(6) = X.at(6)-X.at(0);
  X.at(7) = X.at(7)-X.at(1);
  X.at(8) = X.at(8)-X.at(2);
  
  if  ((X.at(3) == X.at(4)) && (X.at(3)== X.at(5)) &&(X.at(6) == X.at(7)) && (X.at(6)== X.at(8)))
      cout <<"Yes"<<endl;
  else 
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long;
#define mass 1000000007
using namespace std;



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

	if(a>=b){
		cout<<"delicious"<<endl;
	}else if(a+x>=b){
		cout<<"safe"<<endl;
	}else{
		cout<<"dangerous"<<endl;
	}

	return 0;
	

}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
const ll MOD = 1e9+7;

ll X[100100];
ll Y[100100];
int main(){
    ll n, m;
    cin >> n >> m;
    REP(i,n){
        ll x;
        cin >> x;
        X[i] = x;
    }
    REP(i,m){
        ll y;
        cin >> y;
        Y[i] = y;
    }

    ll sum = 0;
    ll xx = X[0];
    ll s = n-1;
    for(int i = 1; i < n; i++){
        ll x = X[i]; 
        ll diff = x - xx;
        ll num = i*(s+1-i);
        sum += diff*num;
        sum %= MOD;
        //cout << "s " << sum << endl;
        xx = x;
    }

    ll yy = Y[0];
    ll t = m-1;
    ll ans = 0;
    for(int j = 1; j < m; j++){
        ll y = Y[j];
        ll diff = y - yy;
        ll sumdiff = sum*diff;
        sumdiff %= MOD;
        ll num = j*(t+1-j);
        ans += num * sumdiff;
        ans %= MOD;
        //cout << "a " << ans << endl;
        yy = y;
    }

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


Measured memory_bytes: 1920
#include "bits/stdc++.h"
using namespace std;
long long k;
int n;
long long x;
long long val;
int main(){
	cin >> k;
	n = 50;
	x = k / n;
	val = x + n - 1;
	printf("%d\n" , n);
	if(k % n == 0){
		for(int i = 1 ; i <= n ; ++i){
			printf("%lld " , val);
		}
		return 0;
	}
	long long extra = k % n;
	for(int i = 1 ; i <= n ; ++i){
		if(i <= extra){
			printf("%lld " , val + n + 1 - extra);
		}
		else{
			printf("%lld " , val - extra);
		}
	}
	printf("\n");
}

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

using namespace std;

int main()
{
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    int ans = 0;
    for (int i = 1; i < n - 1; i++) {
        vector <int> q = {p[i], p[i - 1], p[i + 1]};
        sort(q.begin(), q.end());
        if (q[1] == p[i]) ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
struct Node {int p,l,r;};
struct Node T[100000];
main()
{
  int n,id,k,i,j,c,tmp,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      T[i].p=T[i].l=T[i].r=-1;
    }
  for(i=0;i<n;i++)
    {
      scanf("%d%d",&id,&k);
      for(j=0;j<k;j++)
	{
	  scanf("%d",&c);
	  if(j==0)
	    {
	      tmp=c;
	      T[id].l=tmp;
	      T[c].p=id;
	    }
	  else 
	    {
	      T[tmp].r=c;
	      T[c].p=id;
	      tmp=c;
	    }
	}
    }
  
  for(i=0;i<n;i++)
    {
      if(T[i].p==-1)
	{
	  sum=0;
	  printf("node %d: parent = %d, depth = ",i,T[i].p);
	  tmp=T[i].p;	 
	  while(tmp!=-1)
	    {
	      sum++;
	      tmp=T[tmp].p;
	    }
	  printf("%d, root, [",sum);
	  tmp=T[i].l;
	  while(tmp!=-1)
	    {
	      printf("%d",tmp);
	      tmp=T[tmp].r;
	      if(tmp!=-1)
		{
		  printf(", ");
		}
	    }
	  printf("]\n");
	}
      else if(T[i].l==-1)
	{
	  sum=0;
	  printf("node %d: parent = %d, depth = ",i,T[i].p);
	  tmp=T[i].p;	 
	  while(tmp!=-1)
	    {
	      sum++;
	      tmp=T[tmp].p;
	    }
	  printf("%d, leaf, []\n",sum);
	}
      else 
	{
	  sum=0;
	  printf("node %d: parent = %d, depth = ",i,T[i].p);
	  tmp=T[i].p;	 
	  while(tmp!=-1)
	    {
	      sum++;
	      tmp=T[tmp].p;
	    }
	  printf("%d, internal node, [",sum);
	  tmp=T[i].l;
	  while(tmp!=-1)
	    {
	      printf("%d",tmp);
	      tmp=T[tmp].r;
	      if(tmp!=-1)
		{
		  printf(", ");
		}
	    }
	  printf("]\n");
	}

    }
  return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
int var[26][20];
int perm[26];
char in[2];
char str[1100];
int cur;
int n;
struct wolf{
    int p[20];
    wolf(){for(int i=0;i<20;i++)p[i]=i;}
};
wolf expr();
wolf term(){
    if(str[cur]=='('){
        cur++;
        wolf ret=expr();
        cur++;
        return ret;
    }
    if('A'<=str[cur]&&str[cur]<='Z'){
        char ch=str[cur];
        cur++;
        wolf ret;
        for(int i=0;i<n;i++)ret.p[i]=var[ch-'A'][i];
        return ret;
    }
    int ks=0;
    while('0'<=str[cur]&&str[cur]<='9'){
        ks*=10;
        ks+=str[cur]-'0';
        cur++;
    }
    wolf ret;
    wolf mat=term();
    wolf to;
    while(ks){
        if(ks%2){
            for(int i=0;i<n;i++)to.p[i]=mat.p[ret.p[i]];
            for(int i=0;i<n;i++)ret.p[i]=to.p[i];
        }
        ks/=2;
        for(int i=0;i<n;i++)to.p[i]=mat.p[mat.p[i]];
        for(int i=0;i<n;i++)mat.p[i]=to.p[i];
    }

    return ret;
}
wolf expr(){
    wolf ret=term();
    while(str[cur]=='+'){
        cur++;
        wolf tmp=term();
        wolf to;
        for(int i=0;i<n;i++)to.p[i]=tmp.p[ret.p[i]];
        ret=to;

    }

    return ret;
}
int ans[20];
int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    n=a;
    for(int i=0;i<b;i++){
        int p,q;
        scanf("%s%d",in,&q);
        for(int j=0;j<a;j++)perm[j]=j;
        for(int j=0;j<q-1;j++){
            for(int k=0;k<a-1;k++){
                int r;scanf("%d",&r);
                if(r)swap(perm[k],perm[k+1]);
            }
        }
        for(int j=0;j<a;j++){
            var[in[0]-'A'][perm[j]]=j;
        }
    }
    int c;
    scanf("%d",&c);
    while(c--){
        scanf("%s",str);
        cur=0;
        wolf ret=expr();
        for(int i=0;i<a;i++)ans[ret.p[i]]=i;
        for(int i=0;i<a;i++){
            if(i)printf(" ");
            printf("%d",ans[i]+1);
        }
        printf("\n");
    }
}

Measured memory_bytes: 3244
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
int father[510],n,m,pd[510],in[510],ou[510],p[510],len,totpoint,dst[510],x[510],bb[510][510];
struct bian{
	int next,point,f;
}b[4100000];
void ade(int k1,int k2,int k3){
	b[++len]=(bian){p[k1],k2,k3}; p[k1]=len;
}
void add(int k1,int k2,int k3){
//	cout<<"add "<<k1<<" "<<k2<<" "<<k3<<endl;
	ade(k1,k2,k3); ade(k2,k1,0);
}
bool bfs()
{
    int head=1,now=0,i,j; int pd[510];
    memset(dst,0xff,sizeof dst);
    memset(pd,0x00,sizeof pd);
    x[1]=0; pd[0]=1; dst[0]=0;
    while (head>now)
    {
        now++; i=p[x[now]];
        while (i!=-1)
        {
            j=b[i].point;
            if ((b[i].f)&&(!pd[j]))
            {
                pd[j]=1; dst[j]=dst[x[now]]+1;
                if (j==totpoint)
                {
                    return 1;
                }
                head++; x[head]=j;
            }
            i=b[i].next;
        }
    }
    return pd[totpoint];
}
int min(int k1,int k2)
{
    if (k1<k2)
    {
        return k1;
    }
    else
    {
        return k2;
    }
}
int change(int k1,int k2)
{
    if ((k1==totpoint)||(k2==0))
    {
        return k2;
    }
    int num=0,k,i,j;
    i=p[k1];
    while (i!=-1)
    {
        j=b[i].point;
        if ((b[i].f)&&(dst[k1]+1==dst[j]))
        {
            k=change(j,min(k2,b[i].f));
            k2=k2-k; num+=k;
            b[i].f=b[i].f-k; b[i^1].f+=k;
            if (k2==0)
            {
                break;
            }
        }
        i=b[i].next;
    }
    if (!num)
    {
        dst[k1]=-1;
    }
    return num;
}
const int inf=1e9;
int dinic()
{
    int num=0;
    while (bfs())
    {
        num+=change(0,inf);
    }
    return num;
}
vector<int>A,B;
int findfather(int k1){
	if (father[k1]==k1) return k1;
	father[k1]=findfather(father[k1]); return father[k1];
}
void link(int k1,int k2){
	bb[k1][k2]++;
	ou[k1]++; in[k2]++; pd[k1]=1; pd[k2]=1;
	father[findfather(k1)]=findfather(k2);
}
int main(){
	scanf("%d%d",&n,&m); len=-1; memset(p,0xff,sizeof p);
	for (int i=0;i<=m+m+2;i++) father[i]=i;
	for (int i=1;i<=n;i++){
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		int u=0,v=0;
		if (c==0) u=a+m+2; else u=c+1;
		if (d==0) v=b+1; else v=d+m+2;
		link(u,v);
	}
//	for (int i=1;i<=m+m+2;i++) cout<<in[i]<<" "<<ou[i]<<endl;
	for (int i=1;i<=m+m+2;i++)
		for (int j=1;j<=m+m+2;j++)
			if (bb[i][j]) add(i,j,bb[i][j]);
	for (int i=1;i<=m+1;i++) if (ou[i]>in[i]){
		printf("NO\n"); return 0;
	}
	for (int i=m+2;i<=m+m+2;i++) if (ou[i]<in[i]){
		printf("NO\n"); return 0;
	}
	for (int i=0;i<=m+m+2;i++)
		if (pd[i]==1){
			int flag1=0,flag2=0;
			for (int j=0;j<=m+m+2;j++)
				if (pd[j]&&findfather(j)==findfather(i)){
					if (in[j]>ou[j]) flag1=1;
					if (ou[j]>in[j]) flag2=1;
					pd[j]=2;
				}
			if (flag1==0||flag2==0){
				printf("NO\n"); return 0;
			}
		}
	int tot=0; totpoint=m+m+3;
	for (int i=0;i<=m+m+2;i++)
		if (in[i]>ou[i]) add(i,totpoint,in[i]-ou[i]),tot+=in[i]-ou[i];
		else if (ou[i]>in[i]) add(0,i,ou[i]-in[i]);
	if (dinic()!=tot){
		printf("NO\n"); return 0;
	} else printf("YES\n");
	return 0;
}

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

int main() {
	int N;
    cin >> N;
  	int ans = 0;
  	for (int i=1; i<=N; i++) {
      int num = i;
	  int digit = 0;
      while(num!=0) {
        num /= 10;
        digit++;
      }
      if (digit % 2 != 0) ans++;
    }
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    cout << (n+1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


int main() {
  int D,T,S;
  cin >> D >> T >> S;
  bool f = true;
  if(D > S*T) f = false;
  cans(f);

  
  return 0;
}



Measured memory_bytes: 3072
using System;

class MyClass
{
    static void Rotate(ref int a, ref int b, ref int c, ref int d)
    {
        int _a = a;
        a = b;
        b = c;
        c = d;
        d = _a;
    }

    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        for (int i = 0; i < n; i++)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);
            if (a * a + b * b == c * c || a * a + c * c == b * b || b * b + c * c == a * a)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


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

int main() {
  int N;
  cin >> N;
  int c0 = 0, c1 = 0, c2 = 0, c3 = 0;
  string s;
  rep(i, N) {
    cin >> s;
    if (s == "AC") c0++;
    if (s == "WA") c1++;
    if (s == "TLE") c2++;
    if (s == "RE") c3++;
  }

  cout << "AC x " << c0 << endl;
  cout << "WA x " << c1 << endl;
  cout << "TLE x " << c2 << endl;
  cout << "RE x " << c3 << endl;

  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <cstdio>   
#define PI              acos(-1)
#define pb              push_back 
#define endl            "\n"
#define mostrar(x,y)    cout<<x<<" "<<y<<endl;
#define f               first
#define s               second
#define mod             1000000007
#define EPS             1e-9
#define llenar(a,val)   memset(a,val,sizeof(a))
using namespace std;
typedef pair<int,int> ii;
typedef pair<pair<int,int>,int> iii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef long long ll;
    



int main(){
    ofstream out("output.txt");
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int a,b,c;
    cin>>a>>b>>c;

    cout<<max(0,c-(a-b))<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


vector<int> bfs(int s, int N, vector<vector<int>> &graph){
  vector<int> dist(N, INF);
  dist[s] = 0;
  queue<int> q;
  q.push(s);
  while(!q.empty()){
    int p = q.front(); q.pop();
    for(auto v : graph[p]){
      if(dist[v] != INF) continue;
      dist[v] = dist[p]+1;
      q.push(v);
    }
  }
  return dist;
}

signed main() {
  int N, M; 
  cin >> N >> M;

  vector<int> a(M), b(M);
  REP(i, M){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
  }

  int ans = 0;
  vector<vector<int>> dist(N);
  REP(i, M){
    vector<vector<int>> graph(N, vector<int>(N));
    REP(j, M) if(i != j){
      graph[a[j]].emplace_back(b[j]);
      graph[b[j]].emplace_back(a[j]);
    }
    REP(j, N) dist[j] = bfs(j, N, graph);

    bool flag = false;
    REP(j, N) REP(k, N){
      if(dist[j][k] == INF) flag = true;
    }
    if(flag) ans++;
  }

  cout << ans << "\n";

  return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

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

	FOR(n,0,sz(s)) FOR(c,'a','a'+26) {
		bool all_ok = true;
		FOR(j,0,sz(s)-n) {
			bool ok = false;
			FOR(k,j,j+n+1) if (s[k] == c) ok = true;
			all_ok = all_ok && ok;
		}
		if (all_ok) {
			cout << n << endl;
			return 0;
		}
	}
	assert(0);
}



Measured memory_bytes: 256
# coding: utf-8
# Your code here!

N, X = map(int, input().split())

L = []
P = []

for i in range(N):
    if i == 0:
        L.append(1)
        P.append(1)
        continue
    else:
        L.append(L[i-1] * 2 + 3)
        P.append(P[i-1] * 2 + 1)

def g(k, x):
    if x == 0:
        return 0
    
    if k == 0:
        return 1
    
    if x < L[k-1] + 2:
        return g(k-1, x-1)
    
    if x == L[k-1] + 2:
        return P[k-1] + 1
    
    if x > L[k-1] + 2:
        return P[k-1] + 1 + g(k-1, x - (L[k-1] + 2))

print(g(N, X))


Measured memory_bytes: 3064
from itertools import accumulate

# ある自然数未満までのエラトステネスの篩をつくる
def mark(s, x):
    for i in range(x + x, len(s), x):
        s[i] = False


def eratosthenes(n):
    s = [True] * n
    for x in range(2, int(n ** 0.5) + 1):
        if s[x]: mark(s, x)
    return [i for i in range(0, n) if s[i] and i > 1]


Prime = set(eratosthenes(10**5 + 1))
Target = [0] * (10**5 + 1)
for n in range(1, 10**5 + 1):
    if n in Prime and (n + 1) / 2 in Prime:
        Target[n] = 1

Target = list(accumulate(Target))

Q = int(input())
for q in range(Q):
    l, r = map(int, input().split())
    print(Target[r] - Target[l - 1])


Measured memory_bytes: 53460
#include <stdio.h>

int main(){
	int a, b;
	scanf("%d %d", &a, &b);
	if(a > b)
		printf("a > b\n");
	else if(a < b)
		printf("a < b\n");
	else	
		printf("a == b\n");

	return 0;

}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef pair < int , int > T;

inline void read(int &x) {
    char ch;
    bool flag = false;
    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;
    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
    x = flag ? -x : x;
}


inline void read(long long  &x) {
    char ch;
    bool flag = false;
    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;
    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
    x = flag ? -x : x;
}

const int maxn = 3100000;
int n;
struct zy{
long long x,y;
int op;
}a[maxn];

bool cmp( zy A ,zy B){
if (A.x!=B.x)
    return A.x<B.x;
return A.y < B.y;
}


long long  d[maxn],top;

int get_num( long long x ){
int l=1;
int r=top+1;
int ans=1;
while ( l <= r )
    {
        int mid=(l+r)/2;
        if ( d[ mid ] > x )
            {
                r=mid-1;
                ans=mid;
            }
        else
            l=mid+1;
    }
return ans;
}



int doit (int st,int ed ){
for (int i=1;i<maxn;i++)
    d[i]=120000000ll;
d[1]=a[st].y; top=1;
for (int i=st+1;i<ed;i++)
    {
        if ( a[i].y < a[st].y )
            continue;
        int tmp=get_num( a[i].y);
        d[tmp]=a[i].y;
        if (tmp > top )
            top++;
    }
int tmp=get_num( a[ed].y);
return tmp;
}

int main() {
    //printf("%.17f\n",40-( 900- 891.415926535897938 )  ) ;
    //printf("%.17f\n",acos(-1)  ) ;
    read(a[0].x); read(a[0].y); read(a[1].x); read(a[1].y);
    if (a[0].x > a[1].x )
        swap( a[0] ,a[1]);
    a[0].op=-1; a[1].op=1;
    read(n);
    n++;
    for (int i = 2;i<= n;i++)
    {
        read( a[ i ].x);
        read( a[ i ].y);
        a[i].op=0;
    }
    if ( a[0].y > a[1].y )
        {
            for (int i=0;i<=n;i++)
                a[i].y=-a[i].y;
        }
    sort ( a, a+n+1 , cmp );
    int st=0,ed=0;
    for (int i=0;i<=n;i++)
        if (a[i].op==-1)
        {
            st=i;
            break;
        }
    for (int i=0;i<=n;i++)
        if (a[i].op==1)
        {
            ed=i;
            break;
        }
    int tot=doit(st,ed)-2;
    long double PI=acos(-1);
    long double tmp=5.0l*PI*tot*1.0l -20.0l*tot*1.0l;
    long long ans=( (long long ) trunc( abs( a[st].x -a[ed].x) ) )*100ll + ( (long long ) trunc( abs( a[st].y - a[ed].y ) ) )*100ll ;
    if ( (tot*1ll) == ( min ( a[ed].x- a[st].x ,  (long long )abs( a[ ed ].y - a[st].y) )+1ll )  )
        tmp=tmp+5.0l*PI*1.0l;
    if (  ( a[st].x == a[ed].x ) || ( a[st].y == a[ed].y ) )
        if ( tot != 0 )
            tmp=10.0l*PI*tot*1.0l -20.0l*tot*1.0l;
    cout << fixed << setprecision(25) << ans+tmp << endl;
    return 0;
}


Measured memory_bytes: 30976
IDENTIFICATION DIVISION.
       PROGRAM-ID. ABC043-A.
       DATA DIVISION.
       FILE SECTION.
       WORKING-STORAGE SECTION.
       77 N PIC 9(3).
       77 ANS PIC 9(4).
       77 ANSS PIC ZZZ9.

       PROCEDURE DIVISION.
       MAIN-PROCEDURE.
               ACCEPT N FROM SYSIN.
               COMPUTE ANS = N * (N + 1) / 2.
               MOVE ANS TO ANSS.
               DISPLAY ANSS.
               STOP RUN.
       END PROGRAM ABC043-A.


Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200010];
int main()
{
    int i, j, k;
    ll H, N;
    ll ans = 0;
    cin >> N >> k;
    for(i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(a, a+N);
    for(i = 0; i < N-k; i++) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}


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

bool judge(int A, int B, int C){
  if( A < B && B<C) return true;
  else return false;
}

int nibai(int a, int l){
  for(int i=1; i<l+1; i++){
    a *= 2;
  }
  return a;
}


int main() { 
  int A,B,C,K;
  cin >> A >> B >> C >>K;
  
  bool can = false;
  
  for(int i =0; i<K+1; i++){
    for(int j=0; j<K+1-i; j++){
      int b,c;
      b = nibai(B, i);
      c = nibai(C,j);
      
      bool check = judge(A,b,c);
      if( check == true){
        can = true ;
        break;
      }
    }
  }
  
  
  if(can == true) cout << "Yes" << endl;
  else cout << "No" << endl;
      
}

Measured memory_bytes: 3616
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    packs = read_ints()
    S = sum(packs)
    for pack in packs:
        if pack == S-pack:
            return 'Yes'
    return 'No'


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 61812
#include<iostream>	// 入出力
#include<stdio.h>	// printf()が使える 小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;

using ll = long long;

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

	if (N % 10 == N / 100) 
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
string s1,s2;
int main()
{
	cin>>s1;
	cin>>s2;
	int flag=0;
	for(int i=0;i<s1.size();i++)
	{
		if(s1[i]!=s2[i])
		{
			flag=1;
			break;
		}
	}
	if(flag==0)cout<<"Yes";
	else cout<<"No";
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);


    int n;
    cin >> n;

    pair<int, int> prev = make_pair(0, 0);
    int time = 0;
    for(int i = 0; i < n; ++i){
        int t, x, y;
        cin >> t >> x >> y;


        int mnht = abs(x-prev.first) + abs(y-prev.second);
        int take = abs(t-time);
        if(take >= mnht){
            if((take - mnht) % 2 == 0){
                prev = make_pair(x, y);
                time = t;
                continue;
            }
        }

        No();
        return 0;
    }

    Yes();



    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc,char* argv[]){
  int i,j,k,l;
  int count,num;

  while(scanf("%d",&num) != EOF){
    count = 0;

    for(i = 0;i < 10;i++){
      for(j = 0;j < 10;j++){
	for(k = 0;k < 10;k++){
	  for(l = 0;l < 10;l++){
	    if((i+j+k+l) == num){count++;}
	  }
	}
      }
    }

    printf("%d\n",count);
    
  }
  
  return 0;  
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i,n) for (long long i=0;i<(n);i++)
#define FOR(i,a,b) for (long long i=(a);i<(b);i++)
#define RREP(i,n) for(long long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl
#define dump(x)  cerr << #x << " => " << (x) << endl


#define dumpP(p) cerr << "( " << p.first << " , " << p.second << " )" << ends
#define SORT(c) sort((c).begin(),(c).end())
#define MIN(vec) *min_element(vec.begin(), vec.end())
#define MAX(vec) *max_element(vec.begin(), vec.end())
#define UNIQ(vec) vec.erase(unique(vec.begin(), vec.end()),vec.end()) //ソートの必要あり
#define IN(n,m)  (!(m.find(n) == m.end()))
#define ENUM(m) for (auto itr = m.begin(); itr != m.end(); ++itr)
#define dump_MAP(m) for(auto itr = m.begin(); itr != m.end(); ++itr) { cerr << itr->first << " --> "  << itr->second << endl; }
#define FINDL(vec,x) (lower_bound(vec.begin(),vec.end(),x) - vec.begin())
#define FINDU(vec,x) (upper_bound(vec.begin(),vec.end(),x) - vec.begin())
#define ROUND(N) setprecision(N)
#define ROUND_PRINT(N,val) cout << fixed;cout << setprecision(N) << val << endl
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define INARR(h,w,x,y) (0 <= y && y < h && 0 <= x && x < w)
#define EQ(a,b) (abs(a - b) < 1e-10)
using namespace std;
constexpr int dx[4] = {0,1,0,-1};
constexpr int dy[4] = {1,0,-1,0};
constexpr long double pi = M_PI;
constexpr double eps = 1e-10;
constexpr long mod = 1000000007;
constexpr short shINF = 32767;
constexpr long loINF = 2147483647;
constexpr long long llINF = 9223372036854775807;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<LL,LL> pr;
typedef vector<bool> VB;
typedef vector<pr> VP;


void dijekstra(int start,vector<int> &D,vector<vector<pair<int,long>>> &E){
	priority_queue<pair<long,int>,vector<pair<long,int>>,greater<pair<long,int>>> que;
	vector<int> trace(E.size());
	D[start] = 0;
	trace[start] = start;
	que.push(make_pair(0,start));
	long d;int v;
	while(!que.empty()){
		pair<long,int> cur = que.top();que.pop();
		d = cur.first;v = cur.second;
		if (D[v] < d) continue; //既により最適が見つかっている
		for(int i = 0;i < E[v].size();i++){
			int next = E[v][i].first;
			long newCost = d + E[v][i].second;
			if (D[next] > newCost) {
				D[next] = newCost;
				trace[next] = v;
				que.push(make_pair(newCost,next));
			}
			else if (D[next] == newCost) {
				trace[next] = min(trace[next],v);
			}
		}
	}
}

int main(void){
	long V,E,R;
	long s,t,d;
	cin >> V >> E >> R;
	vector<vector<pair<int,long>>> e(V);
	vector<int> dist(V,loINF);
	REP(i,E){
		cin >> s >> t >> d;
		e[s].push_back(make_pair(t,d));
	}
	dijekstra(R,dist,e);
	REP(i,V) {
		if (dist[i] == loINF) cout << "INF" << endl;
		else cout << dist[i] << endl;
	}
		
	return 0;
}


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)

li n;

li t[100100];
li x[100100];
li y[100100];

int main(void)
{
	cin >> n;
	rep(i, n) {
		cin >> t[i] >> x[i] >> y[i];
	}

	pair<li, li> now = {0, 0};
	li t_now = 0;
	rep(i, n) {
		const li move_time = t[i] - t_now;
		const li amari_time = move_time - abs(x[i] - now.first) - abs(y[i] - now.second);
		if (amari_time < 0 || amari_time % 2 > 0) {
			puts("No");
			return 0;
		}
		t_now = t[i];
		now = {x[i], y[i]};
	}
	puts("Yes");


	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int N;
long long A[200001], dp[200001];
int main () {
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) scanf("%lld", &A[i]);
    dp[0] = dp[1] = 0;
    long long x = A[1];
    for (int i = 2; i <= N; i++) {
        if (i % 2 == 0) {
            dp[i] = max(dp[i-2]+A[i], x);
        }
        else {
            dp[i] = max(dp[i-2]+A[i], dp[i-1]);
            x += A[i];
        }
    }
    printf("%lld\n", dp[N]);
}

Measured memory_bytes: 6940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	reverse(begin(s),end(s));
	s+='0';
	int n=s.size();
	vector<vector<int>> dp(n+1,vector<int>(2,INF));
	dp[0][0]=0;
	rep(i,n)rep(j,2){
		int now=s[i]-'0';
		now+=j;
		rep(a,10){
			int ni=i+1,nj=0;
			int b=a-now;
			if(b<0){
				b+=10;
				nj=1;
			}
			chmin(dp[ni][nj],dp[i][j]+(int)a+b);
		}
	}
	cout<<dp[n][0]<<endl;
}

Measured memory_bytes: 55964
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>

using namespace std;

void inv_A ( string& str )
{
	reverse( str.begin(), str.end() );
}

void inv_C ( string& str )
{
	str = str.substr( 1 ) + str[0];
}

void inv_E ( string& str )
{
	int half = str.size() / 2, offset = ( str.size() + 1 ) / 2;
	for ( int i = 0; i < half; ++i ) {
		swap( str[i], str[i + offset] );
	}
}

void inv_J ( string& str )
{
	str = str[str.size() - 1 ] + str.substr( 0, str.size() - 1 );
}

void inv_M ( string& str )
{
	for ( int i = 0; i < str.size(); ++i ) {
		if ( isdigit( str[i] ) ) {
			str[i] = '0' + ( str[i] - '0' + 1 ) % 10;
		}
	}
}

void inv_P ( string& str )
{
	for ( int i = 0; i < str.size(); ++i ) {
		if ( isdigit( str[i] ) ) {
			str[i] = '0' + ( str[i] - '0' + 9 ) % 10;
		}
	}
}

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

	while ( n-- ) {
		string order,
			   message;
		cin >> order
			>> message;

		for ( int i = order.size() - 1; i >= 0; --i ) {
			switch ( order[i] ) {
			case 'A':
				inv_A( message );
				break;
			case 'C':
				inv_C( message );
				break;
			case 'E':
				inv_E( message );
				break;
			case 'J':
				inv_J( message );
				break;
			case 'M':
				inv_M( message );
				break;
			case 'P':
				inv_P( message );
				break;
			}
			// cout << i << ' ' << message << endl;
		}
		cout << message << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
b = [int(input()) for _ in range(N)]

for i in range(N):
    for j in range(3):
        if A1[j] == b[i]:
            A1[j] = -1
        if A2[j] == b[i]:
            A2[j] = -1
        if A3[j] == b[i]:
            A3[j] = -1

#たて
for i in range(3):
    if A1[i] == -1 and A2[i] == -1 and A3[i] == -1:
        print("Yes")
        exit()

#よこ
if A1[0] == -1 and A1[1] == -1 and A1[2] == -1:
    print("Yes")
    exit()
if A2[0] == -1 and A2[1] == -1 and A2[2] == -1:
    print("Yes")
    exit()
if A3[0] == -1 and A3[1] == -1 and A3[2] == -1:
    print("Yes")
    exit()

#ななめ
if A1[0] == -1 and A2[1] == -1 and A3[2] == -1:
    print("Yes")
    exit()

if A1[2] == -1 and A2[1] == -1 and A3[0] == -1:
    print("Yes")
    exit()

print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int N;
vint G[100];
int FLG[100];
int D[100];
int F[100];
const int NIL = -1;
int tt;

void dfs(int ii){

	tt++;
	D[ii] = tt;

	// cout << "reach " << ii << " " << tt << endl;

	rep(i, G[ii].size()){
		int to = G[ii][i];
		if (D[to] == NIL){
			dfs(to);
		}
	}

	tt++;
	F[ii] = tt;
	// cout << "back " << ii << " " << tt << endl;

}

void run_dfs(){
	rep(i, N){ D[i] = NIL; }
	int start = 0;
	tt = 0;
	rep(i, N){
		if (D[i] == NIL) dfs(i);
	}
}

int main() {

	cin >> N;
	rep(i, N){
		int id, n; cin >> id >> n; id--;
		rep(j, n){
			int id_to; cin >> id_to; id_to--;
			G[id].push_back(id_to);
		}
	}

	run_dfs();

	rep(i, N){
		cout << (i+1) << " " << D[i] << " " << F[i] << endl;
	}
}

Measured memory_bytes: 3156
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define rsort_v(v) std::sort(v.rbegin(), v.rend())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))
 
 // ^^^ Template ^^^ //

int main() {
	in(ll, H, W, K);
	vector<vector<ll>> mat(W, vector<ll>(W, 0));
	auto m0 = mat;
	loop(i, 1ll << (W-1)){
		//check if valid
		{
			bool valid = true, bef = false, bef_t = false;
			ll t = i;
			loop(u, W-1){
				bef_t = !!(t&1);
				if(bef && bef_t){
					valid = false;
					break;
				}
				bef = bef_t;
				t >>= 1;
			}
			if(!valid) continue;
		}
		//calc
		vector<ll> t(W);
		loop(k, W)
			t[k] = k;
		loop(k, W-1)
			if(i & (1ll<<k))
				swap(t[k], t[k+1]);
		loop(k, W)
			++mat[k][t[k]];
	}
	// mat^100
	auto mc = mat;	// mat_current
	loop(h_, H-1){
		auto mn = m0; // mat_next
		loop(x, W) loop(y, W)
			loop(i, W)
				(mn[y][x] += mc[y][i] * mat[i][x]) %= 1000000007;
		mc = mn;
	}
	// output
	out(mc[0][K-1]);
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
vector<vector<int>>a;
int dfs(int now_y,int now_x,int candy,int n){
    candy+=a[now_y][now_x];
    if(now_y==1&&now_x==n-1){
        return candy;
    }
    if(now_y==1){
        return dfs(now_y,now_x+1,candy,n);
    }else if(now_x==n-1){
        return dfs(now_y+1,now_x,candy,n);
    }    
    else {
        return max(dfs(now_y,now_x+1,candy,n),dfs(now_y+1,now_x,candy,n));
    }
}
int main(void){
 int n;
 cin>>n;
 a=vector<vector<int>>(2, vector<int>(n));
 for(int i=0;i<2;i++){
     for(int j=0;j<n;j++){
         cin>>a[i][j];
     }
 }
 int ans=0,now_x=0,now_y=0,candy=0;
 ans=dfs(now_y,now_x,candy,n);
 cout<<ans<<endl;
 return 0;
}

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

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

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

    ll ans = 0;
    for(int i = 1; i < n; i++){
        if(a[i] < a[i - 1]){
            ans += a[i - 1] - a[i];
            a[i] += a[i - 1] - a[i];
        }
    }

    cout << ans << endl;
}

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

int main(){
	int n,a,sum=0,ma=-1;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		sum+=a;
		ma=max(ma,a);
	}
	cout<<sum-(ma/2)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <tuple>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[])
{
	int i, n, m, x, j;
	int answer = -1;
	int bit, bitlimit, tmpcost;
	cin >> n >> m >> x;
	vector<int> cost(n);
	vector<vector<int>> al(n, vector<int>(m));
	vector<int> tmpal(m);
	for (i = 0; i < n; i++) {
		cin >> cost[i];
		for (j = 0; j < m; j++) 
		    cin >> al[i][j];
	}
	bitlimit = pow(2, n);

	for (bit = 0; bit < bitlimit; bit++) {
		tmpcost = 0;
		for (i = 0; i < m; i++) 
			tmpal[i] = 0;

		for (i = 0; i < n; i++) {
			if ((bit >> i) & 1) {
				tmpcost += cost[i];
				for (j = 0; j < m; j++) 
					tmpal[j] += al[i][j];
			}
		}
		for (j = 0; j < m; j++) {
			if (tmpal[j] < x)
				break;
		}
		if (j < m)
			continue;
		if (answer == - 1 || tmpcost < answer)
			answer = tmpcost;
	}

	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 4012
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;

vector<int> divisors(int n){
    vector<int> ret;
    for(int i=1;i*i<=n;i++){
        if(n%i==0){
            ret.push_back(i);
            if(i*i!=n){ret.push_back(n/i);}
            }
    }
    sort(ret.begin(),ret.end());//optional
    return ret;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<int>d=divisors(m);
    int ans = 1;
    rep(i,0,(int)d.size()){
        if(m/d[i]>=n){ans=max(ans,d[i]);}
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll md=1e9+7;
ll a[110][100100],b[110][100100];

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	int ub=100100;
	for(int i=1;i<ub;i++){
		a[1][i]=min(i,n);
		b[1][i]=n/i;
	}
	for(int i=2;i<=k;i++){
		a[i][0]=0;
		for(int j=1;j<ub;j++){
			a[i][j]=(a[i][j-1]+b[i-1][j])%md;
		}
		b[i][ub-1]=a[i][n/(ub-1)];
		for(int j=ub-2;j>=1;j--){
			b[i][j]=(b[i][j+1]+a[i-1][j]*(n/j-n/(j+1)))%md;
		}
	}
	printf("%lld\n",b[k][1]);
	return 0;
}


Measured memory_bytes: 159232
n,m=map(int, input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
ans = 1
for i in make_divisors(m):
    if i>=n:
        ans=max(ans,m//i)
print(ans)

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

int main() {
    int a, b;
    cin >> a >> b;
    if (((a+b) / 2) * 2 == (a + b)){
        cout << (a+b) / 2 << endl;
    }
    else {
        cout << ((a+b) / 2) + 1<< endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

using ll =  long long;

constexpr ll MOD = 998244353;
constexpr int N_MAX = 10000000;

ll modpow(ll a, ll t) {
    ll ret = 1LL;
    while(t){
        if(t & 1LL){
            ret *= a;
            ret %= MOD;
        }
        a *= a;
        a %= MOD;
        t >>= 1;
    }
    return ret;
}

ll fact[N_MAX+1], rfact[N_MAX+1];

ll perm(ll n, ll r){
    return (fact[n] * rfact[r]) % MOD;
}

ll comb(ll n, ll r){
    return (perm(n, r) * rfact[n-r]) % MOD;
}

void init(ll n){
    fact[0] = fact[1] = 1;
    rfact[0] = rfact[1] = 1;
    for(int i=2;i<=n;++i) {
        fact[i] = (fact[i-1] * (ll)i) % MOD;
        rfact[i] = 1;
        ll k = MOD-2;
        ll a = fact[i];
        while(k > 0){
            if(k & 1){
                rfact[i] *= a;
                rfact[i] %= MOD;
            }
            a *= a;
            a %= MOD;
            k  >>= 1;
        }
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n;
    cin >> n;
    init(n);

    ll ans = modpow(3LL, n);
    ll pow_2 = modpow(2LL, n/2);
    ll r2 = modpow(2LL, MOD-2);

    for(ll i=n/2+1;i<=n;++i) {
        pow_2 *= r2;
        pow_2 %= MOD;
        ans += MOD - (((2 * comb(n, i)) % MOD) * pow_2) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 156544