akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll                          long long
#define in(a)                       ll a; cin>>a;
#define in2(a,b)                    ll a,b; cin>>a>>b;
#define in3(a,b,c)                  ll a,b,c; cin>>a>>b>>c;
#define in4(a,b,c,d)                ll a,b,c,d; cin>>a>>b>>c>>d;
#define in5(a,b,c,d,e)              ll a,b,c,d,e; cin>>a>>b>>c>>d>>e;
#define lelo(b)                     for(auto &i:b)cin>>i;
#define ff                          first
#define ss                          second
#define call(v)                     v.begin(),v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define show(x)                     for(auto t:x)cout<<t<<" ";
#define pb                          push_back
#define bhar(s,v)                   memset(s,v,sizeof(s))
#define endl                        "\n"                       
#define ce(x)                       cout<<x<<"\n";
#define nl                          cout<<endl;
#define jaldi                       ios_base::sync_with_stdio(false);cin.tie(NULL);
#define dekh_lo                     ce("dekh_lo");
#define sz(x)                       (ll)x.size()
#define re                          return

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;

const ll mod=1e9+7;
const ll N=4e5+5;

/*


*/

vi findDivisors(ll n){ 
    vi div(n+1,0); 
    for(ll i=1;i<=n;i++){ 
        for(ll j=1;j*i<=n;j++) 
            div[i*j]++; 
    } 
    re div; 
} 
  
void solve(){
    in(n);
    vi get=findDivisors(n-1);
    ll ans=0;
    for(ll i=1;i<sz(get);i++){
        ans+=get[i];
    }    
    ce(ans);
}

int32_t main(){
    // jaldi
    ll t; 
    // cin>>t;
    t=1;     
    while(t--){
        solve();
    }
}

/*


*/

  

Measured memory_bytes: 11172
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define F first
#define S second
typedef pair<int,int> pii;
int main(){
	vector<pii> v(5);
	while(cin>>v[0].F,v[0].F){
		int t;
		cin>>t;
		v[0].F+=t;
		v[0].S=0;
		for(int i=1;i<5;i++){
			cin>>t;v[i].F=t;
			cin>>t;v[i].F+=t;
			v[i].S=i;
		}
		sort(v.begin(),v.end());
		char r='A'+v[4].S;
		cout<<r<<" "<<v[4].F<<endl;
	}
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define read FILE *fp;\
fp=freopen("testcase.txt","r",stdin);
#define ll long long
#define ull unsigned long long
#define sf(n) scanf("%I64d",&n)
#define pf(n) printf("%I64d\n",n)
#define loop for(long long i=0;i<n;i++)
#define lp(b,n) for(long long i=b;i<=n;i++)
#define pb(n) push_back(n)
#define srt(v) sort(v.begin(),v.end())
#define rvs(v) sort(v.begin(), v.end(), greater<long long>());
#define F first
#define S second
#define mp(a,b) make_pair(a,b);
#define fio ios::sync_with_stdio(false); cin.tie(),cout.tie();
ll llmax = numeric_limits<long long>::max();
ll llmin= numeric_limits<long long>::min();
ll mark[5010];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(),cout.tie();
    ll n,k;
    cin>>n>>k;
    vector<pair<ll,ll> >v;
    ll a=0,b=0,c=0,d=0,e=0;
    for(ll i=1;i<=n-2;i++)
    {
        a+=i;
    }
    if(k>a)
    {
        cout<<-1<<endl;
        return 0;
    }
    for(ll i=2;i<=n;i++)
    {
        v.push_back(make_pair(1,i));
    }
    d=a-k;
    for(ll i=2;i<n;i++)
    {
        for(ll j=i+1;j<=n;j++)
        {
            if(d==0)
            {
                c=1;
                break;
            }
            d--;
            v.push_back(make_pair(i,j));
        }
        if(c)
            break;
    }
    cout<<v.size()<<endl;
    for(ll i=0;i<v.size();i++)
    {
        cout<<v[i].first<<" "<<v[i].second<<endl;
    }
}



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

using namespace std;

int main() {
  int x, ans = 1;
  scanf("%d", &x);
  for (int i = 0; i < 32; i++) {
    if (i * i <= x) {
      ans = i * i;
    }
  }
  for (int i = 0; i < 11; i++) {
    if (i * i * i > ans && i * i * i <= x) {
      ans = i * i * i;
    }
  }
  for (int i = 0; i < 6; i++) {
    if (i * i * i * i > ans && i * i * i * i <= x) {
      ans = i * i * i * i;
    }
  }
  for (int i = 0; i < 5; i++) {
    if (i * i * i * i * i > ans && i * i * i * i * i <= x) {
      ans = i * i * i * i * i;
    }
  }
  for (int i = 0; i < 4; i++) {
    if (i * i * i * i * i * i > ans && i * i * i * i * i * i <= x) {
      ans = i * i * i * i * i * i;
    }
  }
  for (int i = 0; i < 10; i++) {
    int a = 2;
    for (int j = 0; j < i; j++) {
      a *= 2;
    }
    if (a > ans && a <= x) {
      ans = a;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ll n;
  cin >> n;
  ll p[n];
  for (ll i = 0; i < n; ++i) cin >> p[i];
  ll ans = 0;
  if (p[0]==1) {
    ll b = p[0];
    p[0] = p[1];
    p[1] = b;
    ans++;
  }
  for (ll i = 1; i < n; ++i) {
    if (p[i]==i+1) {
      if (i < n-1 && p[i+1] == i+2) {
        ll b = p[i];
        p[i] = p[i+1];
        p[i+1] = b;
      } else {
        ll b = p[i];
        p[i] = p[i-1];
        p[i-1] = b;
      }
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second
#define Mat vector<vector<ll>>
#define Arr vector<ll>
#define Matd vector<vector<ld>>
#define Arrd vector<ld>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, d;
    cin >> n >> d;
    Mat p(n, Arr(d));
    forn(i, n) forn(j, d) cin >> p[i][j];
    ll ans = 0;
    forn(i, n) fori(j, i + 1, n)
    {
        ll v = 0;
        forn(k, d) v += (abs(p[i][k] - p[j][k])) * (abs(p[i][k] - p[j][k]));
        ll q = sqrt(v);
        if(q * q == v) ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int a,b,c;
        a=scan.nextInt();
        b=scan.nextInt();
        c=scan.nextInt();
        
        if(a<b & a<c & b<c){
            System.out.println("Yes");
        }
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 26212
import sys
input = sys.stdin.readline
N,M = [int(i) for i in input().split()]
nes = [0] * (N+1)
for i in range(1,N+1) :
    nes[i] = []
for i in range(M) :
    a,b = [int(i) for i in input().split()]
    nes[a].append(b)
    nes[b].append(a)
ans = "IMPOSSIBLE"
for i in nes[1] :
    for j in nes[i] :
        if j == N :
            ans = "POSSIBLE"
            break
print(ans)

Measured memory_bytes: 79568
#include<iostream>
#include<cmath>
#define LL long long
#define DB double
using namespace std;

const int M=2e5+3;
const DB pi=acos(-1.0);
struct XS
{
	double s,f;
}a[M<<2],b[M<<2];
XS operator +(XS x,XS y)
{
	XS t;
	t.s=x.s+y.s;
	t.f=x.f+y.f;
	return t;
}
XS operator -(XS x,XS y)
{
	XS t;
	t.s=x.s-y.s;
	t.f=x.f-y.f;
	return t;
}
XS operator *(XS x,XS y)
{
	XS t;
	t.s=x.s*y.s-x.f*y.f;
	t.f=x.s*y.f+x.f*y.s;
	return t;
}
int fftn;
int rk[M<<2];
void fft(XS *A,DB type)
{
	int i,j,k;
	for(i=0;i<fftn;i++)
		if(i<rk[i]) swap(A[i],A[rk[i]]);
	for(i=1;i<fftn;i<<=1)
	{
		XS t1; t1.s=cos(pi/i); t1.f=sin(pi/i)*type;
		for(j=0;j<fftn;j+=(i<<1))
		{
			XS t2; t2.s=1; t2.f=0;
			for(k=0;k<i;k++)
			{
				XS t3=A[k+j],t4=t2*A[k+j+i];
				A[k+j]=t3+t4;
				A[k+j+i]=t3-t4;
				t2=t2*t1;
			}
		}
	}
}
void mul(XS *A,XS *B,int l)
{
	int i,j=1;
	l<<=1;
	while((1<<j)<l) j++;
	for(i=0;i<(1<<j);i++)
		rk[i]=(rk[i>>1]>>1)|((i&1)<<(j-1));
	fftn=1<<j;
	fft(A,1); fft(B,1);
	for(i=0;i<fftn;i++)
		A[i]=A[i]*B[i];
	fft(A,-1);
}
int n;
LL ans=0;
int g[M+5],pow2[M+5];
int main()
{
	int i;
	LL j=1;
	for(i=0;i<M-1;i++)
	{
		g[j]=i;
		pow2[i]=j;
		j=j*2%M;
	}
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&j);
		if(j==0) continue;
		a[g[j]].s+=1;
		b[g[j]].s+=1;
		ans-=j*j%M;
	}
	mul(a,b,M);
	for(i=0;i<fftn;i++)
		ans+=(LL)(a[i].s/fftn+0.5)*pow2[i%(M-1)];
	printf("%lld",ans>>1);
	return 0;
}

Measured memory_bytes: 24104
import java.util.*;
import java.math.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println( Math.min(a*b, c));
        sc.close();
    }
}

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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double eps = 1e-7;
#define Loop(i, n) for(int i = 0; i < int(n); i++)
#define Loopll(i, n) for(ll i = 0; i < ll(n); i++)
#define Loop1(i, n) for(int i = 1; i <= int(n); i++)
#define Loopll1(i, n) for(ll i = 1; i <= ll(n); i++)
#define Loopr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = ll(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = int(n); i >= 1; i--)
#define Looprll1(i, n) for(ll i = ll(n); i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
#define INF INFINITY
bool feq(double x, double y) { return abs(x - y) <= eps; }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
int ceillog2(ll x) { int ret = 0;	x--; while (x > 0) { ret++; x >>= 1; } return ret; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

/*******************************************************/

int main() {
	int ans = INT_MAX;
	int n; cin >> n;
	vi a(n); Loop(i, n) cin >> a[i];
	vi s(n);
	Loop(i, n) {
		if (i == 0) s[i] = a[i];
		else s[i] = s[i - 1] + a[i];
	}
	Loop(i, n - 1) {
		int x = s[i];
		int y = s[n - 1] - s[i];
		ans = min(ans, abs(x - y));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
constexpr ll mod = 1000000007;
map<pll,ll> mp;
ll pw(ll a,ll x){
    ll ret = 1;
    while(x){
        if(x&1) (ret *= a) %= mod;
        (a *= a) %= mod; x /= 2;
    }
    return ret;
}

ll gcd(ll a, ll b){
    if(a<0) a *= -1;
    if(b<0) b *= -1;
    if(a<b) swap(a,b);
    if(b==0) return a;
    return gcd(a%b,b);
}

int main(){
    int i,n,cnt = 0;
    cin >> n;
    for(i=0;i<n;i++){
        ll a,b; cin >> a >> b;
        if(a==0 && b==0){
            cnt++;
        }else{
            ll x = gcd(a,b);
            a /= x; b /= x;
            if(a<0){
                a *= -1; b *= -1;
            }
            if(a==0) b = 1;
            mp[{a,b}]++;
        }
    }
    ll ans = 1;
    for(auto p:mp){
        auto pp = p.first;
        ll a = pp.first,b = pp.second;
        ll aa = -b,bb = a;
        if(aa<0){
            aa *= -1; bb *= -1;
        }
        if(aa==0) bb = 1;
        if(mp.find({aa,bb})!=mp.end()){
            ll s = mp[{aa,bb}],t = p.second;
            (ans *= ((pw(2,s) + pw(2,t) - 1)%mod)) %= mod;
            mp.erase({aa,bb});
        }else{
            (ans *= pw(2,p.second)) %= mod;
        }
    }
    ans += cnt;
    cout << (ans + mod - 1)%mod << endl;
}

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

using namespace std;

int main(){

    int A, B, C;

    cin >> A >> B >> C;

    if(A <= C && C <= B){
	cout << "Yes" << endl;
    }else if(A >= C && C >= B){
	cout << "Yes" << endl;
    }else{
	cout << "No" << endl;
    }

}


Measured memory_bytes: 256
D,G = map(int,input().split())
PC = [list(map(int,input().split())) for _ in range(D)]
comp = [PC[i][0]*(i+1)*100+PC[i][1] for i in range(D)]
ans = float("inf")
for i in range(2**D):
    Gt = 0
    cnt = 0
    lis = [0]*D
    tmp = str(bin(i))[2:]
    for j in range(len(tmp)):
        lis[-j-1] = int(tmp[-j-1])
    for k in range(D):
        if lis[k]:
            Gt += comp[k]
            cnt += PC[k][0]
        else:
            hanpa = k
    if Gt>=G:
        ans = min(ans,cnt)
        continue
    if G-Gt > (PC[hanpa][0]-1)*(hanpa+1)*100:
        continue
    cnt += -(-(G-Gt)//((hanpa+1)*100))
    ans = min(ans,cnt)
print(ans)


Measured memory_bytes: 3064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <queue>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int gcd(int a, int b){
   int tmp;
   while(a%b==0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}

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

bool prime_number(int n){
   if(n < 2){
      return false;
   }
   else if(n == 2){
      return true;
   }
   if(n % 2 == 0){
      return false;
   }
   for(int i=3;i<=n/i;i+=2){
      if(n % i == 0) return false;
      return true;
   }
}

int main(){
   vector<int> l(10),v(2);
   double sum=0;
   char c;
      
   while(cin >> l[0] >> c){
      FOR(i,1,10) cin >> l[i] >> c;
      cin >> v[0] >> c >> v[1];
      sum=accumulate(ALL(l),0);
      sum = sum*v[0]/(v[0]+v[1]);
      REP(i,10){
         sum-=l[i];
         if(sum<=0){
            cout << i+1 << endl;
            break;
         }
      }
   }
   
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	int a[110];
	scanf("%d",&n);
	for(int i=0;i<n;++i) scanf("%d",&a[i]);
	for(int i=0;i<n;++i){
		if(a[i]%2==0&&a[i]%3&&a[i]%5){
			printf("DENIED");
			break;
		}
		else if(i==n-1) printf("APPROVED");
	}
	return 0;
}

Measured memory_bytes: 256
## atcoder problem 3 ever
n, m = map(int, input().split())
solved = {}
penalty = {}
for case in range(m):
    p, s = input().split()
    p = int(p)

    if s=='AC':
        solved[p] = True
    else: ## s is WA
        if p in solved:
            continue ## ignore
        else:
            penalty[p] = penalty.get(p, 0) + 1

total_penalty = 0
for key in solved:
    total_penalty += penalty.get(key, 0)

print(len(solved), total_penalty)


Measured memory_bytes: 15072
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var k = int.Parse(Console.ReadLine());

        Console.WriteLine(Search(k));
    }

    static string Search(int k)
    {
        var lun = new int[16];
        int msd = 0;
        int i = 0;
        lun[i] = 1;
        while (k > 1 && lun[i] < 10)
        {
            --k;
            ++lun[i];
        }
        while (true)
        {
            while (i < msd && lun[i] > Math.Min(9, lun[i + 1] + 1))
            {
                ++lun[++i];
            }
            if (lun[msd] > 9)
            {
                ++lun[++msd];
                i = msd;
            }
            while (i > 0)
            {
                --i;
                lun[i] = Math.Max(0, lun[i + 1] - 1);
            }
            if (k < 2)
            {
                break;
            }

            var end = Math.Min(10, lun[i + 1] + 2);
            while (k > 1 && lun[i] < end)
            {
                --k;
                ++lun[i];
            }
        }

        Array.Reverse(lun);
        return new string(lun.SkipWhile(x => x == 0).Select(x => (char)(x + '0')).ToArray());
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    string s;
    cin>>s;
    int n=s.length();
    int res=n;
    for(ri int i=1;i<n;i++)
    {
        if(s[i]^s[i-1]) res=min(res,max(i,n-i));
    }
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 3848
//あみだくじは「置換」で表せる。これは6通りしかないので、実質N ≦ 6。よって全部試せる。
//同じ「置換」を表すあみだくじを2つ以上使うケースは存在するか？　→ 存在するかもしれない…。    
//嘘解法？：同じあみだくじを4つ以上使うケースがないものとして考える。　→　書いてみよう
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int n;
int w, a;
map<vector<int>, int> mp;
vector<vector<int>> ts;

bool dfs(int used, vector<int> perm) {
	int i, j;
	
	if (used > 0 && perm[0] == 0 && perm[1] == 1 && perm[2] == 2) return true;
	for (i = 0; i < ts.size(); i++) {
		if ((used >> i) & 1) continue;
		
		vector<int> nP;
		for (j = 0; j < 3; j++) {
			nP.push_back(ts[i][perm[j]]);
		}
		bool res = dfs(used + (1 << i), nP);
		if (res) return true;
	}
	return false;
}

int main() {
	int i, j;
	
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> w;
		int hoge[3] = {0, 1, 2};
		for (j = 0; j < w; j++) {
			cin >> a;
			swap(hoge[a], hoge[a + 1]);
		}
		
		vector<int> tikan;
		tikan.resize(3);
		for (j = 0; j < 3; j++) tikan[hoge[j]] = j;
		if (mp.find(tikan) == mp.end()) mp[tikan] = 0;
		mp[tikan]++;
	}
	
	for (map<vector<int>, int>::iterator it = mp.begin(); it != mp.end(); it++) {
		for (i = 0; i < min((it->second), 3); i++) {
			ts.push_back(it->first);
		}
	}
	
	//for (i = 0; i < ts.size(); i++) { for (j = 0; j < 3; j++) cout << ts[i][j] << " " ; cout << endl; }
	bool res = dfs(0, {0, 1, 2});
	if (res) cout << "yes" << endl;
	else cout << "no" << endl;
	return 0;
}


Measured memory_bytes: 3168
#include<iostream>
#include<string>
using namespace std;
int main(){
	string S;
	cin >> S;
	bool flag;
	if(S[0]==S[1] && S[2]==S[3]){
		flag=true;
	}
	else if (S[0]==S[2] && S[1]==S[3]){
		flag=true;
	}
	else if (S[0]==S[3] && S[1]==S[2]){
		flag=true;
	}
	else{
		flag=false;
	}
	
	if(S[0]==S[1]&&S[0]==S[2]&&S[0]==S[3])flag=false;
	
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

template <class A> class unionfind
{
public:
  vector<int> parent;
  vector<int> rank;
  vector<A> diffw;

  unionfind(int N, A U = 0)
  {
    parent = vector<int>(N, -1);
    rank = vector<int>(N, 0);
    diffw = vector<A>(N, U);
  }

  int root(int X)
  {
    if (parent.at(X) < 0) return X;
    int R = root(parent.at(X));
    diffw.at(X) += diffw.at(parent.at(X));
    return parent.at(X) = R;
  }

  int size(int X)
  {
    return -parent.at(root(X));
  }

  A weight(int X)
  {
    root(X);
    return diffw.at(X);
  }

  A diff(int X, int Y)
  {
    return weight(Y) - weight(X);
  }

  bool same(int X, int Y)
  {
    return (root(X) == root(Y));
  }

  bool unite(int X, int Y, A W)
  {
    W += weight(X);
    W -= weight(Y);

    X = root(X);
    Y = root(Y);
    if (X == Y) return false;
    
    if (rank.at(X) < rank.at(Y)) 
    {
      swap(X, Y);
      W = -W;
    }
    if (rank.at(X) == rank.at(Y)) rank.at(X)++;
    parent.at(X) += parent.at(Y);
    parent.at(Y) = X;
    diffw.at(Y) = W;
    return true;
  }
};

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

  unionfind<int> uf(N);

  for (int i = 0; i < M; i++)
  {
    int L, R, D;
    cin >> L >> R >> D;
    L--; R--;
    if (uf.same(L, R))
    {
      if (abs(uf.diff(L, R)) != D)
      {
        cout << "No" << endl;
        return 0;
      }
    }
    else
      uf.unite(L, R, D);
  }

  cout << "Yes" << endl;

  for (int i = 0; i < N; i++)
  {
    uf.root(i);
    cerr << uf.parent.at(i) << " " << uf.rank.at(i)
         << " " << uf.diffw.at(i) << endl;
  }
}

Measured memory_bytes: 2560
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String arg = sc.nextLine();
		
		String[] argument = arg.split(" ");
		
		int num1 = Integer.parseInt(argument[0]);
		int num2 = Integer.parseInt(argument[1]);
		int num3 = Integer.parseInt(argument[2]);
		
		if (num1 == num2 + num3 || num2 == num1 + num3 || num3 == num1 + num2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}

Measured memory_bytes: 9044
n, m = map(int, input().split())
listX=list(map(int, input().split()))
listX.sort()
listSa=[]
index=0
while index < len(listX)-1:
    dist = listX[index+1]-listX[index]
    listSa.append(dist)
    index+=1
listSa.sort()
index2=0
sum=0
while index2 < len(listSa)-(n-1):
    sum+=listSa[index2]
    index2+=1
print(sum)

Measured memory_bytes: 13968
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int N,Q;
string S;
LL cc[1000011];
int main(){
	cin>>N>>S;
	cin>>Q;
	REP(i,N){
		if(S[i]=='M'){
			cc[i]++;
		}
		if(i!=0){
			cc[i]+=cc[i-1];
		}
	}
	REP(i,Q){
		int k;
		cin>>k;
		LL temp=0;
		LL now=0;
		LL ans=0;
		REP(i,N){
			if(S[i]=='D'){
				temp++;
			}
			if(i>=k){
				if(S[i-k]=='D'){
					temp--;
					now-=(cc[i-1]-cc[i-k]);
				}
			}
			if(S[i]=='M'){
				now+=temp;
			}
			if(S[i]=='C'){
				ans+=now;
			}
		}
		cout<<ans<<endl;
	}
    return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    vector<bool> v(a.back(), true);
    for (int e : a) {
        for (size_t i = 2; e * i - 1 < v.size(); ++i) {
            v[e * i - 1] = false;
        }
    }
    int answer = 0;
    for (size_t i = 0; i < a.size(); ++i) {
        if (i + 1 < a.size() && a[i + 1] == a[i]) {
            int m = a[i];
            while (i < a.size() && a[i + 1] == m) ++i;
        } else if (v[a[i] - 1]) {
            ++answer;
        }
    }
    cout << answer << endl;
}


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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

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



int main(void) {
	int n, q;
	int now = 0;
	string name;
	int time;
	pair<int, string> pai;
	queue<pair <int, string> > que;
	queue<pair <int, string> > result;

	cin >> n >> q;
	
	FOR(i, 0, n - 1) {
		cin >> name >> time;
		que.push(make_pair(time, name));
	}
	while (que.empty() != 1) {
		pai = que.front();
		que.pop();
		if (pai.first <= q) {
			now += pai.first;
			pai.first = now;
			result.push(pai);
		}
		else {
			now += q;
			pai.first -= q;
			que.push(pai);
		}
	}
	while (result.empty() != 1) {
		pai = result.front();
		result.pop();
		cout << pai.second << " " << pai.first << endl;
	}

	return 0;
}



Measured memory_bytes: 6260
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String str[] = s.split(",");;
    for(int i = 0 ; i < 3 ; ++i){
      System.out.print(str[i] + " ");
    }

  }
}

Measured memory_bytes: 38480
from fractions import gcd

S = input()
odd = [0,0]
even = [0,0]
for i,s in enumerate(S):
  if i % 2 == 0:
    even[int(s)]+=1
  else:
    odd[int(s)]+=1
o0e1 = odd[1]+even[0]
o1e0 = odd[0]+even[1]
print(min(o0e1,o1e0))
  

Measured memory_bytes: 5344
n,m=map(int,input().split())
x=[2,5,5,4,5,6,3,7,6]#各数に使うマッチ棒の本数
a=[]#使う数字でけ格納するリスト
for i in map(int,input().split()):
    a.append([i,x[i-1]])#数と使う本数をリストで入力
    #ここでタプルにするとソートできない
a.sort(reverse=True)
#tuple(a)#タプルにしても実行時間、メモリーに大きな変化なし
#ソートしないと、大きい数字が先に来ないので間違う
#(OK)print(a)使える数字だけ
dp=[0]*(n+1)
#dp[i]：ちょうどi本使った時に表せる最大の数
#ループの順番が、いまひとつ、腑に落ちない
for i in range(m):
#外側ループが使用できる数、最初１番大きい数字、その後、使える数字が増える
    for j in range(n+1):#マッチ棒は0からnまで使える
        if j==0 or dp[j]!=0:
        #(NG)if dp[j]!=0: 「jの範囲を1始め」でもNG
            if j+a[i][1]<=n:#マッチ棒が使用範囲内なら
                #print(dp[j+a[i][1]],dp[j]*10+a[i][0])
                #print(max(dp[j+a[i][1]],dp[j]*10+a[i][0]))
                dp[j+a[i][1]]=max(dp[j+a[i][1]],dp[j]*10+a[i][0])
#この更新はDP典型。右１項が左と同じ。右は両項とも、前から使っているj本に
#新しく使うi番目を使った　本数での数を表している。
print(dp[n])

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

// yen / BTC
#define YPB 380000

int main(void){
  int n;
  double ans;
  
  ans = 0;
  cin >> n;
  for (int i=0; i<n; i++){
    double x;
    string s;
    cin >> x >> s;
    if (s[0]=='J') ans += x;
    else ans += x*YPB;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
cnt = 1
while n = gets.to_i
  break if n == 0
  xs = []
  ys = []
  ps = []
  n.times do
    x, y, r = gets.split.map(&:to_f)
    ps << [x, y, r]
    xs << x - r << x + r
    ys << y - r << y + r
  end
  xs.sort!.uniq!; ys.sort!.uniq!
  p = ys.size.times.map{ [0] * xs.size }
  ps.each do |x, y, r|
    (xs.index(x - r)...xs.index(x + r)).each do |i|
      (ys.index(y - r)...ys.index(y + r)).each do |j|
        p[j][i] += 1
      end
    end
  end
  ret = 0
  xs.each_cons(2).with_index do |(x0, x1), i|
    ys.each_cons(2).with_index do |(y0, y1), j|
      ret += (x1 - x0) * (y1 - y0) if p[j][i] > 0
    end
  end
  puts "%d %.2f" % [cnt, ret]
  cnt += 1
end

Measured memory_bytes: 8908
<?php
fscanf(STDIN, "%d %d", $H, $W);
$s = array_pad(array(), $H, array_pad(array(), $W, null));
$s[0][0] = 0;
$next[0][0] = 1;
$next2 = [];
$ans = 0;
for ($i = 0; $i < $H; $i++) {
    $str = trim(fgets(STDIN));
    $ans += substr_count($str, '.');
    $m[$i] = str_split($str);
}
$x = $y = $step = 0;
while(true) {
    foreach ($next as $y => $v1) {
        foreach ($v1 as $x => $dummy) {
            $s[$y][$x] = $step;

            // 右に進む
            if (isset($m[$y][$x+1]) && is_null($s[$y][$x+1]) && $m[$y][$x+1] === '.') {
                $next2[$y][$x+1] = 1;
            }
            // 左に進む
            if (isset($m[$y][$x-1]) && is_null($s[$y][$x-1]) && $m[$y][$x-1] === '.') {
                $next2[$y][$x-1] = 1;
            }
            // 上に進む
            if (isset($m[$y-1][$x]) && is_null($s[$y-1][$x]) && $m[$y-1][$x] === '.') {
                $next2[$y-1][$x] = 1;
            }
            // 下に進む
            if (isset($m[$y+1][$x]) && is_null($s[$y+1][$x]) && $m[$y+1][$x] === '.') {
                $next2[$y+1][$x] = 1;
            }

        }
    }
    if (empty($next2)) break;

    // リセット
    $next = $next2;
    $next2 = [];
    $step++;
}

if (is_null($s[$H - 1][$W - 1])) {
    echo "-1";
} else {
    printf("%d", $ans - $s[$H - 1][$W - 1] - 1);
}


Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll n, k;
	cin >> n >> k;
	Vec a(n);
	rep(i, n) cin >> a[i];

	ll cnt = 0;
	rep(i, n){
		if (a[i] == 0) cnt++;
		if (i < k) continue;
		if (a[i - k] == 0) cnt--;
		if (a[i] > a[i - k] && cnt == 0) puts("Yes");
		else
			puts("No");
	}

	return 0;
}


Measured memory_bytes: 4840
//be name khoda
#include<bits/stdc++.h>

typedef long long ll;
typedef long double ld;

using namespace std;

const ll INF = 1e18;
const ll maxn = 2e5+10;
const ll mod = 1e9+7;

ll n , m;
ll bl[maxn], wh[maxn], par[maxn];
vector<ll> g[maxn];

void dfs(ll u)
{
    bl[u] = 1; wh[u] = 1;
    for(ll i = 0; i < g[u].size(); i++)
        if(g[u][i] != par[u])
        {
            par[g[u][i]] = u;
            dfs(g[u][i]);
            bl[u] = (bl[u] * wh[g[u][i]]) % mod;
            wh[u] = (wh[u] * ((wh[g[u][i]] + bl[g[u][i]]) % mod)) % mod;
        }
}

int main()
{
    cin>> n;
    for(ll i = 1; i < n; i++)
    {
        ll u, v; cin>> u >> v;
        g[v].push_back(u);
        g[u].push_back(v);
    }

    dfs(1);
    cout<< (bl[1] + wh[1]) % mod;
}










Measured memory_bytes: 17536
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <cstdlib>
#include <random>
#define EVAL 1
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 1048576
#define PI 3.1415926535
int main() {
	long long a, b, c;
	cin >> a >> b >> c;
	a -= b;
	cout << a % c << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
 string a,b,ans;
 ans="No";
 cin>>a>>b;
 int ab=stoi(a+b);
 for(int i=1;i<ab;i++){
      if(i*i==ab){
        ans="Yes";
        break;
      }
      if(i*i>ab){
        break;
      }
    }
  cout<<ans<<endl;  
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	int s, w;

	cin >> s >> w;

	if(w >= s) cout << "unsafe\n";
	else cout << "safe\n";

	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    if(n % 2 == 0) {
        ll m = 5;
        while(m <= n) {
            ans += n / (2 * m);
            m *= 5;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
N = int(input())
lst = []


for i in range(N):
  lst.append(int(input()))

M = lst[1] - lst[0]
m = lst[0]

for j in range(1, N):
    M = max([M, lst[j] - m])
    m = min([m, lst[j]])
            
print(M)


Measured memory_bytes: 13584
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n;
	cin>>n;
	int res = 100;
	rep(i, n){
		int r = 0;
		int a;
		cin>>a;
		while(a%2==0){
			r++;
			a >>= 1;
		}
		res = min(res, r);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    if(a+b == c+d){
        cout << "Balanced" << endl;
    }else if(a+b > c+d){
        cout << "Left" << endl;
    }else{
        cout << "Right" << endl;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+9;
int main(){
	int n;cin>>n;
	char s[maxn];cin>>s;
	int lb=0,rw=0;
	for(int i=0;s[i];++i)
		rw+=s[i]=='.';
	int ans=rw;
	for(int i=0;s[i];++i){
		lb+=s[i]=='#';
		rw-=s[i]=='.';
		ans=min(ans,lb+rw);
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(b-a)<=d and abs(c-b)<=d){
        cout<<"Yes"<<endl;
    }else if(abs(c-a)<=d){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#1_7_C
N = int(input())

preorder_list = []
inorder_list = []
postorder_list = []

rooted_tree = [{} for i in range(N)]
for _ in range(N):
    row = input()
    id, left, right = list(map(int, row.split()))
    rooted_tree[id]["id"] = id
    rooted_tree[id]["right"] = right
    rooted_tree[id]["left"] = left
    #子供のparentを左右で設定する。
    if left > -1:
        left_child_id = left
        rooted_tree[left_child_id]["parent"] = id
    if right > -1:
        right_child_id = right
        rooted_tree[right_child_id]["parent"] = id
        
def preParse(node):
    preorder_list.append(node["id"])
    if node["left"] != -1:
        preParse(rooted_tree[node["left"]])
    if node["right"] != -1:
        preParse(rooted_tree[node["right"]])
    
def inParse(node):
    if node["left"] != -1:
        inParse(rooted_tree[node["left"]])
    inorder_list.append(node["id"])
    if node["right"] != -1:
        inParse(rooted_tree[node["right"]])
    
def postParse(node):
    if node["left"] != -1:
        postParse(rooted_tree[node["left"]])
    if node["right"] != -1:
        postParse(rooted_tree[node["right"]])
    postorder_list.append(node["id"])
    
def get_parent(node):
    parent = -1
    if "parent" in node:
        return node["parent"]
    return parent

for node in rooted_tree:
    if get_parent(node) == -1:
        root_id = node["id"]
        break

print("Preorder")
preParse(rooted_tree[root_id])
print(" "+" ".join(map(str, preorder_list)))
# print(*preorder_list)
print("Inorder")
inParse(rooted_tree[root_id])
# print(*inorder_list)
print(" "+" ".join(map(str, inorder_list)))
print("Postorder")
postParse(rooted_tree[root_id])
# print(*postorder_list)
print(" "+" ".join(map(str, postorder_list)))


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, K;
    ll current = 0;
    set<ll> already;
    vector<ll> A;
    vector<ll> phase, phase2;
    cin >> N >> K;
    A.resize(N);
    rep(i, N) {
        cin >> A[i];
        A[i]--;
    }
    while(already.find(current) == already.end()) {
        already.insert(current);
        phase.push_back(current);
        current = A[current];
    }
    phase2 = vector<ll>(find(phase.begin(), phase.end(), current), phase.end());
    if(K < phase.size()) cout << phase[K % phase.size()] + 1 << endl;
    else cout << phase2[(K - phase.size()) % phase2.size()] + 1 << endl;
    return 0;
}


Measured memory_bytes: 16272
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;

int LIS(int n,vector<int>& a){
    vector<int> dp(n,max_int);
    REP(i,n){
        dp[lower_bound(All(dp),a[i]) - dp.begin()] = a[i];
    }
    print(lower_bound(All(dp),max_int) - dp.begin());
}


signed main(){
    cin >> n;
    vec(a,n);
    input(a,n);
    LIS(n,a);
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}




Measured memory_bytes: 4388
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    long long a[10001]={0}; //10001個
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    long long int min = 1000000, max = -1000000, sum = 0;
    for(int i = 0; i < n; i++){
        if(a[i]<min)
            min = a[i];
        if(a[i]>max)
            max = a[i];
        sum = sum + a[i];
    }
    cout << min << " " << max << " " << sum << endl;
}



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

typedef long long ll;

int n,m;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	bool spas = 0;
	for(int i=-n+1;i<=n-1;i++){
		int cur = i+m;
		if(cur <-1000000 || cur > 1000000) continue;
		if(spas) cout << " ";
		cout << cur;
		spas = 1;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
//#define int unsigned long long
#define all(x) (x).begin(), (x).end()
#define double long double

using namespace std;

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

const int MOD = 1e9+7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;



int dp[100010][15];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S; cin >> S;
	if (S[0] == '?') {
		REP(i, 10) {
			dp[1][i] = 1;
		}
	}
	else {
		int num = S[0] - '0';
		dp[1][num] = 1;
	}
	int N = S.size();
	FOR(i, 1, N) {
		REP(r, 13) {
			if (S[i] == '?') {
				REP(k, 10) {
					dp[i + 1][(r * 10 + k) % 13] += dp[i][r]%MOD;
					dp[i + 1][(r * 10 + k) % 13] %= MOD;
				}
			}
			else {
				int pos = S[i] - '0';
				//print(pos);
				dp[i + 1][(r * 10 + pos) % 13] += dp[i][r]%MOD;
				dp[i + 1][(r * 10 + pos) % 13] %= MOD;
			}
		}
	}
	/*REP(i, 5) {
		REP(r, 13) {
			pe(i)pe(r)print(dp[i][r]);
		}
	}*/
	int ans = dp[N][5];
	print(ans%MOD);
}


Measured memory_bytes: 12240