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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("E.in", "r", stdin);
	freopen ("E.out", "w", stdout);
#endif
}

const int N = 5e5 + 1e3;

int n, d[N], pre[N], f[N];

int main () {

	File();

	n = read(); pre[0] = read(); f[n + 1] = 1;

	For (i, 1, n) 
		pre[i] = min(pre[i - 1], abs(pre[i - 1] - (d[i] = read())));
	Fordown (i, n, 1) 
		f[i] = f[i + 1] + ((f[i + 1] << 1) > d[i] ? d[i] : 0);

	For (i, 1, read()) {
		int x = read();
		puts(pre[x - 1] >= f[x + 1] ? "YES" : "NO");
	}

	return 0;

}


Measured memory_bytes: 7808
#include <iostream>
#include <math.h>
using namespace std;

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

    int ans = 0;
    for (int ds = 1, minVal = 1; minVal <= N && ds <= 5; ds += 2, minVal *= 100) {
        int maxVal = min(N, minVal * 10 - 1);
        ans += (maxVal - minVal + 1);
    }

    cout << ans << endl;

    return 0;
}



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


int main(){
	ll n,k;
	cin >> n >> k;
  	vector<int> a(n+2);
  	for (int i=1; i<=n; i++) cin >> a[i];
  	vector<int> visited(n+2,0);
  	vector<int> ind(3*n+10,0);
  	ll curr=1;
  	ll steps=0;
  	ll st=0;
  	while (visited[curr]!=2){
      	//cerr<<curr<<" "<<steps<<endl;
      	if (visited[curr]==1 and st==0) st=steps;
      	visited[curr]++;
      	ind[steps]=curr;
      	curr=a[curr];
    	steps++;
    }
  	//cerr<<steps<<" "<<st<<endl;
  	if (k<=st) {cout<<ind[k]<<endl;}
  	else {
      k-=st;
      k%=(steps-st);
      cout<<ind[k+st]<<endl;
    }
  	
  	

}


Measured memory_bytes: 7164
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int checkHeight(double h);
const string COLORS[8] = {"black", "blue", "lime", "aqua"
                         , "red", "fuchsia", "yellow", "white"};

const int RGB_VALUES[8][3] = {{0, 0, 0},
                             {0, 0, 255},
                             {0, 255, 0},
                             {0, 255, 255},
                             {255, 0, 0},
                             {255, 0, 255},
                             {255, 255, 0},
                             {255, 255, 255}};

int toDec(char s);

int main()
{
    while(1)
    {
        string in_str;
        cin >> in_str;
        if(in_str == "0")
        {
            break;
        }
        
        int r = toDec(in_str[1]) * 16 + toDec(in_str[2]);
        int g = toDec(in_str[3]) * 16 + toDec(in_str[4]);
        int b = toDec(in_str[5]) * 16 + toDec(in_str[6]);

        double dist_min = 1000000;
        int index = 0;
        for(int i = 0; i < 8; i++)
        {
            double dist_square = (r - RGB_VALUES[i][0]) * (r - RGB_VALUES[i][0])
                                 + (g - RGB_VALUES[i][1]) * (g - RGB_VALUES[i][1])
                                 + (b - RGB_VALUES[i][2]) * (b - RGB_VALUES[i][2]);
            if(isless(dist_square, dist_min))
            {
                dist_min = dist_square;
                index = i;
            }
        }
        cout << COLORS[index] << endl;
    }
    return 0;
}

int toDec(char s)
{
    int value;
    if(s >= '0' && s <= '9')
    {
       value = s - '0';
    }
    else
    {
        value = s - 'a' + 10;
    }
    return value;
}



Measured memory_bytes: 3152
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int result = 1;
    for (int i = 2; i*i <= N; i++) {
        int n = i*i;
        while (n <= N) {
            result = max(result, n);
            n *= i;
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 1000000007
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define INF 1LL << 30
#define ll long long
#define ull unsigned long long
#define RNG mt19937
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
const int N = 100005;
int cnt[N];

int main(){
	fast_io();
	int n;cin >> n;
	ll ans = 0;
	cu(i,0,n){
		int x;cin >> x;	
		while((x&1)==0){
			x>>=1;
			++ans;
		}
	}
	cout << ans << '\n';
}


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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int N;
	cin >> N;
	vector<int> v(N);
	rep(i,N) cin >> v[i];
	sort(v.begin(),v.end());
	double ans=v[0];
	rep(i,N-1){
		ans+=v[i+1];
		ans/=2;
	}
	cout << setprecision(15) << ans << endl;

	return 0;
}

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

#define FIO ios_base::sync_with_stdio(0); cin.tie(0);
#define T() int tt; cin >> tt; rep1(qq,1,tt)
#define rep(i,start,lim) for(int i=start;i<lim;i++)
#define rep1(i,start,lim) for(int i=start; i<=lim; ++i)
#define repd(i,start,lim) for(int i=start;i>=lim;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define br cout<<"\n"
#define MOD (1000000007LL)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define eps (1e-6)
#define what_is(x) cerr << #x << " is " << x << "\n";
#define int long long int
#define infll 9e18
#define inf 1e12

#define lnode (2 * node + 1)
#define rnode (2 * node + 2)

using namespace std;

typedef pair<int, int> pii;

const int N = 300005;

int n;
int x, y, z;

int32_t main(){

  FIO
  //cout << fixed << setprecision(10);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  cin  >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  cout<< x << ' ' << y << ' ' << z;


	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ll N;
  cin >> N;
  vector<ll> num(N + 1, 1);
  for (ll i = 2; i <= N; ++i) {
    ll cnt = 1;
    while (cnt * i <= N) {
      num.at(cnt * i) += 1;
      cnt += 1;
    }
  }
  ll ans = 0;
  for (ll i = 1; i <= N; ++i) {
    ans += num.at(i) * i;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 81404
/*
 *  Created on: 13 / 9 / 2020
 *  Author:     Eslam Waheed
 */

#define _CRT_SECURE_NO_WARNINGS
 //#define __USE_MINGW_ANSI_STDIO

#include <bits/stdc++.h>
//#include <bits/BIGINT.h>
//#include <bits/Int128.h>
using namespace std;

#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define ld   long double

#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n);
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)   s.size()
#define endl    '\n'

//ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }

//const ld PI = acos(-1);
//const ll mod = 1e9 + 7;
//const ld EPS = 1e-8;
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
    //stp(0)
    Eslam__Waheed;
    int n; cin >> n;
    cout << (n ^ 1);
}

Measured memory_bytes: 3648
n = int(input())
i = 1
l = []
while i <= n:
  x = i
  if x % 3 == 0:
    l.append(i)
  else:
    while x:
      if int(x) % 10 == 3:
        l.append(i)
        break
      x /= 10
  i += 1
for n in l:
  print(" {0}".format(n), end='')
print('', sep='\n')


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

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define SORT(v) sort(ALL(v))
//#define scanf scanf_s
typedef pair<int, int> P;

int n, m;
string s;
int a[100005];
int b[100005];
int c[10005];
set<int> used;

int main()
{
	int n, a, b, c, d;
	bool f = false;
	while (cin >> n >> a >> b >> c >> d, n)
	{
		if (f) cout << endl; f = true;
	//	cout << a << endl << b << endl << c << endl << d << endl;
		int c10 = a, c50 = b, c100 = c, c500 = d;
		if (c10 >= n % 50 / 10)
		{
			c10 -= n % 50 / 10;
			n -= n % 50;
		}
		while (c10 >= 5)
		{
			c10 -= 5;
			n -= 50;
		}
		if (c10 * 10 >= n)
		{
			c10 -= n / 10;
			n = 0;
		}

		if (c50 > 0 && n % 100 > 0 && n % 100 <= 50)
		{
			n -= 50;
			c50 -= 1;
		}
		while (c50 >= 2)
		{
			c50 -= 2;
			n -= 100;
		}
		if (c50 * 50 >= n)
		{
			c50 -= n / 50;
			n -= n / 50 * n;
			if (n > 0) c50--;
			n = 0;
		}

		if (c100*100 >= n % 500)
		{
			c100 -= (n + 90) % 500 / 100;
			n -= (n + 90) % 500 / 100 * 100;
		}
		while (c100 >= 5)
		{
			n -= 500;
			c100 -= 5;
		}
		if (c100 * 100 >= n)
		{
			c100 -= n / 100;
			n -= n / 100 * 100;
			if (n > 0) c100--;
			n = 0;
		}

		while (n > 0)
		{
			n -= 500;
			c500--;
		}

		while (c10 >= 5)
		{
			c10 -= 5;
			c50++;
		}
		while (c50 >= 2)
		{
			c50 -= 2;
			c100++;
		}
		while (c100 >= 5)
		{
			c100 -= 5;
			c500++;
		}



		a -= c10;
		b -= c50;
		c -= c100;
		d -= c500;
		if (a > 0) cout << "10 " << a << endl;
		if (b > 0) cout << "50 " << b << endl;
		if (c > 0) cout << "100 " << c << endl;
		if (d > 0) cout << "500 " << d << endl;
	}
	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
typedef long long lint;
const int N=2005;
int n,m,q,val[N],dv[N],dcnt,dlim;

namespace utils{
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x>y?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int getans(){
	static int buk[N];
	int cnt=0;
	for(int j,i=1; i<=n; i=j+1){
		for(j=i; val[j]>=dlim; ++j);
		if(j-i<m) continue;
		std::nth_element(val+i,val+j-m,val+j);
		for(int k=i; k+m<=j; ++k){
			buk[++cnt]=val[k];
		}
	}
	std::sort(buk+1,buk+cnt+1);
	return cnt<q?1e9:buk[q]-buk[1];
}

int main(){
	n=nxi(),m=nxi(),q=nxi();
	for(int i=1; i<=n; ++i){
		dv[i]=val[i]=nxi();
	}
	std::sort(dv+1,dv+n+1);
	dcnt=std::unique(dv+1,dv+n+1)-dv-1;
	int ans=1e9;
	for(int i=dcnt; i>=1; --i){
		dlim=dv[i];
		apn(ans,getans());
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)


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

vector<vector<int>> vv;
int dp[110000];

int dfs(int from)
{
  if (dp[from] > 0) return dp[from];
  if (vv[from].empty()) return dp[from] = 0;

  int ma = -1;
  for (auto to : vv[from]) ma = max(ma, dfs(to));
  return dp[from] = ma + 1;
}

int main()
{
  REP(i, 110000) dp[i] = -1;
  int N, M;
  cin >> N >> M;
  vv.resize(N);
  REP(i, M) {
    int x, y; cin >> x >> y;
    x--, y--;
    vv[x].PB(y);
  }

  int ans = 0;
  REP(i, N) {
    ans = max(ans, dfs(i));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli a, b;
	cin >> a >> b;

	cout << max(0LL, a - 2 * b) << endl;
	   
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N * 3);
  for (int i = 0; i < 3 * N; i++) {
      cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end(), greater<int>());
  int64_t res = 0;
  int count = 0;
  for(int i = 0; i < 3 * N; i++){
    if(i % 2 == 0) continue;
    res += vec.at(i);
    count++;
    if(count >= N) break;
  }
  cout << res << endl;
}


Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main(void){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int a=ty-sy;
    for(int i=0;i<a;i++){
        cout<<'U';
    }
    int b=tx-sx;
    for(int i=0;i<b;i++){
        cout<<'R';
    }
    for(int i=0;i<a;i++){
        cout<<'D';
    }
    for(int i=0;i<=b;i++){
        cout<<'L';
    }
    for(int i=0;i<=a;i++){
        cout<<'U';
    }
    for(int i=0;i<=b;i++){
        cout<<'R';
    }
    cout<<'D'<<'R';
    for(int i=0;i<=a;i++){
        cout<<'D';
    }
    for(int i=0;i<=b;i++){
        cout<<'L';
    }
    cout<<'U';
    return 0;
}


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

using namespace std;

int a[100000];

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

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 2 * 105000;

int n, a, b, c, d;
string s;
int canA[MAXN], canB[MAXN];

int main() { 

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

  canA[a] = true;
  for (int i = a + 1; i < n; i++) {
    if (s[i] == '#') {
      continue;
    }
    if (canA[i - 1] || (i - 2 >= 0 && canA[i - 2])) {
      canA[i] = true;
    }
  }

  canB[b] = true;
  for (int i = b + 1; i < n; i++) {
    if (s[i] == '#') {
      continue;
    }
    if (canB[i - 1] || (i - 2 >= 0 && canB[i - 2])) {
      canB[i] = true;
    }
  }

  if (d > c) {
    cout << (canB[d] && canA[c] ? "Yes" : "No") << endl;
    return 0;
  }

  for (int i = b; i <= d; i++) {
    if (canB[i] && (i - 1 >= 0 && canA[i - 1]) && (i + 1 < n && canA[i + 1]) && canA[c] && canB[d]) {
      puts("Yes");
      return 0;
    }
  }

  puts("No");

  return 0;
}


Measured memory_bytes: 1796
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
 
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INPUT1(n, a) for(int i##n = 0; i##n < n; i##n++) {cin >> a[i##n]; } //n = count, a = vector 
#define OUTPUT1(n, a) cout << "---count---" << endl << n << endl << "---content---" << endl; for(const auto b : a){cout << b << endl; }
#define INPUT2(x, y, field) for(int i##x = 0; i##x < y; i##x++) { for(int j##x = 0; j##x < x; j##x++) { cin >> field[i##x][j##x]; } }
#define OUTPUT2(x, y, field) cout << "---count---" << endl << x << " " << y << endl <<"---content---" << endl; for(int i##x = 0; i##x < y; i##x++) { cout << i##x << "   "; for(int j##x = 0; j##x < x; j##x++) { cout << field[i##x][j##x] << " "; } cout << endl; }
 
using namespace std;
using ll = long long;
 
const int INF = 1001001001;
 
int main()
{
	int a, b, c;
	cin>>a>>b>>c;
	if((a==b&&a!=c)||(a==c&&a!=b)||(c==b&&a!=c))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

const int N = 1e5 + 5;

vector<int> adj[N];
int p[N], deg[N];
bool visited[N];
vector<int> ans, ans2, tmp;
stack<int> S;

void dfs(int u, int prev){
	p[u] = prev;
	visited[u] = 1;
	for(auto v : adj[u]){
		if(!visited[v])	dfs(v, u);
	}
}

bool dfs_cycle(int u, int prev){
	visited[u] = 1;
	S.push(u);
	for(auto v : adj[u]){
		if(!visited[v]){
			if(dfs_cycle(v, u))	return true;
		}
		else if(v != prev){
			while(S.top() != v){
				ans2.push_back(S.top());
				S.pop();	
			}
			ans2.push_back(v);
			return true;
		}
	}
	S.pop();
	return false;
}

int dfs2(int u, int prev){
	p[u] = prev;
	visited[u] = 1;
	for(auto v : adj[u]){
		if(!visited[v]){
			return dfs2(v, u);
		}
	}
	return u;
}

int main(){
	int n, m, u, v;
	cin>>n>>m;
	
	for(int i = 0; i < m; i++){
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
		deg[u]++, deg[v]++;
	}

	if(m == n - 1){	//is tree
		for(int i = 1; i <= n; i++){
			if(deg[i] == 1){
				u = i;
				break;
			}
		}
		dfs(u, 0);
		for(int i = n; i >= 1; i--){
			if(deg[i] == 1){
				v = i;
				while(v){
					ans.push_back(v);
					v = p[v];
				}
				break;
			}
		}
	}
	else{	//aint tree
		dfs_cycle(1, 0);

		for(int i = 1; i <= n; i++)	visited[i] = 0;
		for(auto v : ans2)	visited[v] = 1;
		
		int a = dfs2(ans2[0], 0);

		while(a != ans2[0]){
			ans.push_back(a);
			a = p[a];
		}

		for(auto v : ans2)	ans.push_back(v);

		a = dfs2(ans2[ans2.size() - 1], 0);

		while(a != ans2[ans2.size() - 1]){
			tmp.push_back(a);
			a = p[a];
		}
		reverse(tmp.begin(), tmp.end());
		for(auto v : tmp)	ans.push_back(v);
	}

	cout<<ans.size()<<endl;
	for(auto v : ans)	cout<<v<<" ";
}

Measured memory_bytes: 14080
/*
  Contest 061
  Rakesh Kumar --> 28/08/2020
 */

#include <bits/stdc++.h>

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0);
    int a = 0, b = 0, c = 0;
    std::cin >> a >> b >> c;
    if (c >= a && c <= b)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;

    return 0;
}


Measured memory_bytes: 3624
N,M = map(int,(input().split()))
X = list(map(int,(input().split())))
X.sort()
if M > N:
    dist = [X[i+1]-X[i] for i in range(M - 1)]
    dist.sort(reverse = True)
    del dist[0:N-1]
    print(sum(dist))
else:
 print(0)

Measured memory_bytes: 13960
#include <iostream>
using std :: cout;
using std :: cin;
using std :: endl;
using std:: string;
int main()
{
    int S;
    int W;
    cin >> S >> W;
    if (W >= S)
    {
        cout << "unsafe" << endl;
    }
    else
    {
        cout << "safe" << endl;
    }
}

Measured memory_bytes: 3132
N = int(input())
A = list(map(int, input().split()))

a = 0
for i in range(N):
  a += A[i] * (1 if not i%2 else -1)

ans = [0] * N
ans[0] = a

for i in range(1, N):
  ans[i] = 2 * A[i-1] - ans[i-1]

print(*ans)
print()

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


public class A
{
	
	public static void Main()
	{
		string[] args = Console.ReadLine().Split(' ');
		long N = Int64.Parse(args[0]);
		long M = Int64.Parse(args[1]);
		
		string S = Console.ReadLine();
		string T = Console.ReadLine();

		long L = lcm(N,M);
		long LdivN = L/N;
		long LdivM = L/M;
		long interval = lcm(LdivN, LdivM);		
		bool result = true;
		for(long i = 0; i < L; i+=interval)
		{
			if(S[(int)(i/LdivN)] != T[(int)(i/LdivM)])
			{
				result = false;
				break;
			}
		}
		
		Console.WriteLine(result ? L : -1);
	}
	
	
	public static long gcd(long x, long y)
	{
		return ((y == 0) ? x : gcd(y, x%y));
	}
	
	
	public static long lcm(long x, long y)
	{
		return (x * y / gcd(x,y));
	}
	
	
}





Measured memory_bytes: 13140
x = raw_input().split()
s = []
for e in x:
    try:
        s.append(int(e))
    except:
        b = s.pop()
        a = s.pop()
        if e == '+':
            s.append(a+b)
        if e == '-':
            s.append(a-b)
        if e == '*':
            s.append(a*b)
print s.pop()

Measured memory_bytes: 6452
import java.util.Scanner;
 
public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
 
        final boolean poor = (a == b && a != c) ||
                (a == c && a != b) || (b == c && b != a);
        if (poor) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

void solv() {
    int N;
    vector<int> Bi;
    cin >> N;
    vector<int> Ai(N);
    int ans;
    rep(i, N) {
        int buf;
        cin >> buf;
        Bi.push_back(buf);
    }
    ans = Bi[0] + Bi[N - 2];
    rep(i, N-2) {
        ans += min(Bi[i], Bi[i + 1]);
    }
    cout << ans << endl;
}

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

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

int main()
{

	int h, m, s;
	int time[3];

	for(int i = 0; i < 3; i++) {
		cin >> h >> m >> s;
		time[i] = (h * 3600) + (m * 60) + s;
		cin >> h >> m >> s;
		time[i] = ((h * 3600) + (m * 60) + s) - time[i];
	}

	for(int i = 0; i < 3; i++) {
		cout << time[i] / 3600 << " " << (time[i] % 3600) / 60 << " " << time[i] % 3600 % 60 << endl;
	}

	return 0;

}

Measured memory_bytes: 3096
#include<stdio.h>
#define Y 1000
int main(){
  int v,i,j,A[Y],a,k;
  
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<a;i++){
    printf("%d",A[i]);
    if(i!=a-1)printf(" ");
    
  }
  printf("\n");/*??\????????????*/

  for(i=1;i<a;i++){
    v=A[i];
    j=i-1;
  
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
      A[j+1]=v;
    
    for(k=0;k<a;k++){
    printf("%d",A[k]);
    if(k!=a-1)printf(" ");
    
  }
    printf("\n");
  }
   

  return 0;
}

Measured memory_bytes: 608
N=int(input())
S = input()
SS= list(S)
i=0
if N%2==1:
  i=1
else:
  for x in range(0,N//2):
    if SS[x]!=SS[x+N//2]:
      i=1
if i==0:
  print("Yes")
if i==1:
  print("No")

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

int main() {
    string s;
    cin >> s;
    int c = -1, f = -1;
    for (int i = 0; i < s.length(); i++) {
        if (s[i]=='C') c = i;
        if (s[i]=='F') f = i;
    }
    if (c!=-1 && f!=-1 && c<f) cout << "Yes" << endl;
    else cout << "No\n";
}

Measured memory_bytes: 256
use std::io::*;
use std::str::*;

fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s
        .by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let s = stdin();
    let mut s = s.lock();
    let a: i32 = read(&mut s).unwrap();
    let b: i32 = read(&mut s).unwrap();
    println!("{}", (a - 1) * (b - 1));
}


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

long long solve2(long long H, long long W){
    long long a, b, best=LLONG_MAX, result;
    a = (H/2)*W; b=H*W - a;
    if(abs(a-b) < best) {
        best = abs(a-b);
        result = a;
    }
    a = H*(W/2); b=H*W - a;
    if(abs(a-b) < best) {
        best = abs(a-b);
        result = a;
    }
    return result;
}

long long myMin(long long x, long long y, long long z){
    return min(min(x, y), x);
}

long long myMax(long long x, long long y, long long z){
    return max(max(x, y), z);
}

void solve(long long H, long long W){
    long long best = LLONG_MAX, a, b, c, H1, W1;
    //* cut one third of H
    H1 = H/3;
    a = H1 * W;
    b = solve2(H-H1, W);
    c = (H-H1)*W - b;
    best = min(best, myMax(a, b, c) - myMin(a, b, c));
    
    H1 = H/3+1;
    a = H1 * W;
    b = solve2(H-H1, W);
    c = (H-H1)*W - b;
    best = min(best, myMax(a, b, c) - myMin(a, b, c));

    //* cut one third of W
    W1 = W/3;
    a = H * W1;
    b = solve2(H, W-W1);
    c = H*(W-W1) - b;
    best = min(best, myMax(a, b, c) - myMin(a, b, c));

    W1 = W/3+1;
    a = H * W1;
    b = solve2(H, W-W1);
    c = H*(W-W1) - b;
    best = min(best, myMax(a, b, c) - myMin(a, b, c));

    cout << best << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    solve(H, W);
    return 0;
}


Measured memory_bytes: 256
def main(argv)
  (n, a, b) = gets.chomp.split(' ').map(&:to_i)

  if a > b then
    puts 0.to_s
    return
  end

  if n == 1 then
    puts (a == b ? 1 : 0).to_s
    return
  end

  p = (n - 1) * a + b
  q = a + (n - 1) * b

  puts (q - p + 1).to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

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

int main() {
	int L; cin >> L;
	int l[30], g[30];
	int n=0, m=0;
	--L;
	while(L>0){
	    l[n]=1-L%2;
	    g[n]=1+L/2;
	    L=(L+1)/2 - 1;
	    m += 2+l[n];
	    ++n;
	}
	cout << n+1 << ' ' << m << endl;
	for(int i=0; i<n; ++i){
	    cout << i+1 << ' ' << i+2 << ' ' << l[i] << endl;
	    cout << i+1 << ' ' << i+2 << ' ' << g[i] << endl;
	    if(l[i]==1) cout << i+1 << ' ' << n+1 << ' ' << 0 << endl;
	}
	return 0;
}


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

int main()
{
	string s;
	cin >> s;
	bool flag1 = false, flag2 = false;
	for(int i = 0; i < (int)s.size(); ++i)
	{
		if(s[i] == 'C')
			flag1 = true;
		if(s[i] == 'F' && flag1)
			flag2 = true;
	}
	if(flag1 && flag2)
	{
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

//解説
//2^iで割ったあまりは上の桁により変えられない
int N;
signed main(){
    scanf("%lld",&N);
    int M=N;
    int anscnt=0;
    char ans[50];
    while(M){
        if(M%2!=0){ans[anscnt]='1';M-=1;}
        else ans[anscnt]='0';
        anscnt+=1;
        M=M/-2;
    }
    rep(i,anscnt)printf("%c",ans[anscnt-1-i]);
    if(anscnt==0)printf("0");
    printf("\n");
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------
-----問題ここまで----- */
/* -----解説等-----
----解説ここまで---- */

LL N;

LL ans = 0LL;
LL f(VI&a, LL b){
LL  sum=0;
FOR(i,0,SZ(a))sum+=abs(a[i]-b);
return sum;
}
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	cin >> N;
  VI a(N);
FOR(i,0,N)cin>>a[i],a[i]-=i+1;
SORT(a);

ans=f(a,a[N/2]);
ans=min(ans,f(a,a[N/2-1]));

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1024
from itertools import accumulate
inf = float('inf')

N = int(input())
A = list(map(int,input().split()))
A = list(accumulate(A))

ans = inf

for i in range(N-1):
    res = abs(A[i] - (A[-1] - A[i]))
    if res < ans:
        ans = res

print(ans)

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

int main(){
    int n,m;
    cin >> n >> m;
    priority_queue<int> q;
    rep(i,n){
        int a;
        cin >> a;
        q.push(a);
    }
    rep(i, m){
        int a = q.top(); q.pop();
        q.push(a/2);
    }
    ll ans=0;
    rep(i,n){
        ans += q.top(); q.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
#include<stdio.h>
#define N 10000
int main(){
  int a,b,i,j,key,A[N],B[N],count=0;

  scanf("%d",&a);
  for(i=0;i<a;i++)
    scanf("%d",&A[i]);

  
  scanf("%d",&b);
  for(i=0;i<b;i++){
    scanf("%d",&B[i]);
  
    j=0;
    A[a]=B[i];
    while(A[j]!=B[i]){
      
      j++;
      
      if(j==a) break;

    }
    if(j!=a) count++;
  }
  printf("%d\n",count);
 
  return 0;
}
  



Measured memory_bytes: 2104
def acgt(x):
  if x=="A" or x=="C" or x=="G" or x=="T":
    return True
  else:
    return False
txt=input()
ans=0
y=0
for i in range(len(txt)):
  if acgt(txt[i]):
    y+=1
  else:
    ans=max([ans,y])
    y=0
else:
  ans=max([ans,y])  
print(ans)
    


Measured memory_bytes: 3060
#ifndef LOCAL
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif // LOCAL

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define fst first
#define snd second
#define int ll
using namespace std;
using ll = long long; using ull = unsigned ll; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>;
template<typename T> bool mind(T &x, const T &y) {if (y < x) return x = y, true; return false;}
template<typename T> bool maxd(T &x, const T &y) {if (x < y) return x = y, true; return false;}
int log2f(int x) {return 32 - __builtin_clz(x) - 1;}
const int mod = 1e9+7, mod9 = 1e9+9, infi = 1e9+100; const ll infl = 1e18L+1000, modl = 1e18L+3; const ld infd = INFINITY;

#define x(a) real(a)
#define y(a) imag(a)
using G = ll; using point = complex<G>;
istream& operator>>(istream &is, point &p){G x, y; is >> x >> y; p = {x, y}; return is;}
ostream& operator<<(ostream &os, const point &p){os << p.x() << ' ' << p.y(); return os;}
G dot(const point &a, const point &b) {return (conj(a)*b).x();}
G crs(const point &a, const point &b) {return (conj(a)*b).y();}
G ori(const point &a, const point &b, const point &c) {return crs(b-a, c-b);};
bool cmpyx(const point &a, const point &b) {return a.y()<b.y() || (a.y()==b.y()&&a.x()<b.x());};

signed main()
{
    #ifdef LOCAL
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    #endif // LOCAL
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout << fixed << setprecision(15);
    int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
    int ra = min(a, 2*c), rb = min(b, 2*c), rab = min(2*c, ra+rb);
    int d = min(x, y);
    int ans = d*rab;
    x -= d, y -= d;
    ans += x*ra + y*rb;
    cout << ans;
}


Measured memory_bytes: 256
'use strict'


function Main(input) {

  input = input.trim().split(' ').map(s => parseInt(s))
  const N = input[0]
  const MAX = input[1]

  const res = 500 * N


  if (res >= MAX) {
    console.log('Yes')
  } else {
    console.log('No')
  }
  
  
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int a[205];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int k,p=0;
        scanf("%d",&k);
        while(k%2==0)
        {
            p++;
            k/=2;
        }
        a[i]=p;
    }
    sort(a+1,a+n+1);
    printf("%d\n",a[1]);
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pi;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
const int mxN=1e2+5;
vector<vector<int>> nums;
vector<ll> res;
vector<int> adj[mxN];
map<pair<int,int>,int> ma;
map<int,pair<int,int>> rma;
int n,k;

void bfs(int u)
{
    deque<pair<int,vector<int>>> q;
    vector<int> empty={};
    q.pb({u,empty});
    while(!q.empty()) {
        pair<int,vector<int>> cur=q[0]; 
        q.pop_front();
        vector<int> curv=cur.second;
        curv.pb(rma[cur.first].second);
        for(auto v : adj[cur.first]) {
            q.pb({v,curv});
        }
        if(adj[cur.first].empty())
            nums.pb(curv);
    }
}

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> k;
    int timer=0;
    FOR(i,1,10) {
        int val=timer++;
        ma.insert({{0,i},val});
        rma.insert({val,{0,i}});
    }
    FOR(i,1,10) {
        F0R(j,10) {
            int val=timer++;
            ma.insert({{i,j},val});
            rma.insert({val,{i,j}});
        }
    }
    for(auto p : ma) {
        int u=p.second;
        pair<int,int> e=p.first;
        if(e.first==9)
            continue;
        if(e.second-1>=0)
            adj[u].pb(ma[{e.first+1,e.second-1}]);
        adj[u].pb(ma[{e.first+1,e.second}]);
        if(e.second+1<=9)
            adj[u].pb(ma[{e.first+1,e.second+1}]);
    }
    for(auto p : ma) {
        if(p.first.second==0)
            continue;
        bfs(p.second);
    }
    F0R(i,sz(nums)) {
        ll val=nums[i][0];
        FOR(j,1,sz(nums[i])) {
            val*=10;
            val+=nums[i][j];
        }
        res.pb(val);
    } 
    SORT(res);
    cout << res[k-1];

    return 0;
}


Measured memory_bytes: 19308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
//ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
//ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}


int main(){
  ll n,k,ans=0;
  cin >> n >> k;

  if(k==0){
    cout << n*n << endl;
    return 0;
  }

  for(ll b=k+1;b<=n;b++){
    ll x = n/b;
    ans += (b-k)*x;
    ll p = n%b;
    ans += max(0LL,p-k+1);
  }

  cout << ans << endl;


}


Measured memory_bytes: 256
def f(x):
  if x==[]: return [0]
  e = min(x[0], 10)
  A = []
  for e1 in f(x[1:]):
    a = e+e1
    A += [a]
    if e==1: A += [a+10]
  return filter(lambda x: x<22, A)

while 1:
  x = map(int,raw_input().split())
  if x[0]==0: break
  a = f(x)
  print max(a) if a else 0

Measured memory_bytes: 4300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


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

    if(stoi(s.substr(0,4))<2019){cout << "Heisei" << endl; return 0;}
    if(stoi(s.substr(0,4))>2019){cout << "TBD" << endl; return 0;}
    if(stoi(s.substr(5,7))<4){cout << "Heisei" << endl; return 0;}
    if(stoi(s.substr(5,7))>4){cout << "TBD" << endl; return 0;}
    if(stoi(s.substr(8,10))<=30){cout << "Heisei" << endl; return 0;}
    if(stoi(s.substr(8,10))>30){cout << "TBD" << endl; return 0;}

    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**6 + 1000)


words = lambda t : list(map(t, input().split()))
n,q = words(int)
par = [0] * n
for i in range(n-1):
    a,b = words(int)
    par[b-1] = a-1

points = [0] * n
for i in range(q):
    p,x = words(int)
    points[p-1] += x

ans = [0] * n
ans[0] = points[0]
for i in range(1,n):
    ans[i] = ans[par[i]] + points[i]


print(" ".join(map(str,ans)))


Measured memory_bytes: 110156
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll fac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    ll n,m;cin >> n >> m;
    vector<string> v(n),t(m);
    rep(i,n)cin >> v[i];
    rep(i,m)cin >> t[i];
    rep(i,n-m+1){
        rep(j,n-m+1){
            ll count=0;
            rep(k,m){
                rep(l,m){
                    if(v[i+k][j+l]==t[k][l])count++;
                }
            }
            if(count==m*m){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

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

#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

//vector<vector<ll> > comb(ll n, ll b){
void comb(vector<vector <ll> > &v, ll n){
  cout << v.size();
  rep(i, n){
    v[i][0] = 1;
    v[i][i] = 1;
  }

  rep(j, n) {
    rep(k,j) {
      v[j][k] = (v[j-1][k-1] + v[j-1][k]);
    }
  }
}


int main(){
  ll n,W,w,v;
  cin >> n >>W;

  ll dp[n+1][W+1];
  dp[0][0] = 0;

  rep(j, W+1) dp[0][j] = 0;
  
  rep(i, n){
    cin >> w >> v;
    rep(j,W+1){
      dp[i+1][j] = dp[i][j];

      if(j-w<0) continue;
      dp[i+1][j] = max(dp[i][j-w] + v, dp[i+1][j])  ;
      }
  }
  
  //cout<< dp[2][7] << dp[2][3]<< endl;
  cout << dp[n][W] << endl;


}


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> X(N+1,0);
  vector<int> Y(M+1,0);
  cin >> X.at(N) >> Y.at(M);
  for(int i=0;i<N;i++){
    cin >> X.at(i);
  }
  for(int i=0;i<M;i++){
    cin >> Y.at(i);
  }
  sort(X.begin(),X.end());
  sort(Y.begin(),Y.end());
  if(X.at(N)<Y.at(0)){
    cout << "No War" << endl;
  }else{
    cout << "War" << endl;
  }
}

Measured memory_bytes: 256
using System;
namespace I_am_the_brown_coder{
    class ABC10000000{
        static void Main(){
            int n = int.Parse(Console.ReadLine());
            Restaurant[] sp = new Restaurant[n];
            for(int i=0;i<n;i++){
                string[] sps = Console.ReadLine().Split();
                sp[i] = new Restaurant();
                sp[i].s = sps[0];
                sp[i].p = int.Parse(sps[1]);
                sp[i].junjo = i+1;
            }
            Array.Sort(sp,Compare);
            for(int i=0;i<n;i++){
                Console.WriteLine(sp[i].junjo);
            }

        }

        static int Compare(Restaurant a, Restaurant b){
            if(a.s.CompareTo(b.s)>0){return 1;
            }else if(a.s.CompareTo(b.s)<0){
                return -1;
            }
            if(a.p>b.p){
                return -1;
            }else{
                return 1;
            }
        }
    }

    class Restaurant{
        public int p;
        public string s;

        public int junjo;
    }
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> count(N);
  // for each road
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    for(int j = 0 ; j < N; j++){
      if (a == j+1 || b == j+1) count.at(j) += 1;
    }
  }
  
  for (int k =0; k < N; k++)  cout << count.at(k) << endl;
    
}

Measured memory_bytes: 256
H, N = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]

INF = 10**10+1

dp = [[INF]*(H+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1, N+1):
    dp[i][0] = 0
    A = AB[i-1][0]
    for j in range(1, H+1):
        if j-AB[i-1][0]>=0:
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-AB[i-1][0]]+AB[i-1][1], dp[i][j-AB[i-1][0]]+AB[i-1][1])
        else:
            dp[i][j] = min(dp[i-1][j], AB[i-1][1])

print(dp[N][H])

Measured memory_bytes: 120284
#include<stdio.h>
#define N 36
#define FALSE -1
#define TRUE 1

typedef struct{
  char mark;
  int number;
}card;

int hantei(card *, card *, int);

int main(){
  int n, v, min, f;
  int i, j;
  char m;
  card a[N], b[N], in[N]; //inは比較用

  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf(" %c%d", &a[i].mark, &a[i].number);
    b[i] = a[i];
    in[i] = a[i];
  }

  /*for(i=0;i<n;i++){
    if(i == n-1) printf("%c%d\n", a[i].mark, a[i].number);
    else printf("%c%d ", a[i].mark, a[i].number);
    }*/
  
  //バブルソート
  //マークの交換も忘れずに
  f = 1;
  while(f){
    f = 0;
    for(i=n-1;i>=1;i--){
      if(a[i].number < a[i-1].number){
        v = a[i].number;
        a[i].number = a[i-1].number;
        a[i-1].number = v;
	m = a[i].mark;
	a[i].mark = a[i-1].mark;
	a[i-1].mark = m;
        f = 1;
      }
    }
  }

  for(i=0;i<n;i++){
    if(i == n-1) printf("%c%d\n", a[i].mark, a[i].number);
    else printf("%c%d ", a[i].mark, a[i].number);
  }

  if(hantei(in, a, n) == 1) printf("Stable\n");
  else printf("Not stable\n");

  //選択ソート
  //マークの交換も忘れずに
  for(i=0;i<=n-1;i++){
    min = i;
    for(j=i;j<=n-1;j++){
      if(b[j].number < b[min].number){
        min = j;
      }
    }
    v = b[i].number;
    b[i].number = b[min].number;
    b[min].number = v;
    m = b[i].mark;
    b[i].mark = b[min].mark;
    b[min].mark = m;
  }

  for(i=0;i<n;i++){
    if(i == n-1) printf("%c%d\n", b[i].mark, b[i].number);
    else printf("%c%d ", b[i].mark, b[i].number);
  }

  if(hantei(in, b, n) == 1) printf("Stable\n");
  else printf("Not stable\n");
  
   return 0;
}

int hantei(card *in, card *out, int n){
  int i, j, k, l;

  /*for(i=0;i<n;i++){
    if(i == n-1) printf("%c%d\n", in[i].mark, in[i].number);
    else printf("%c%d ", in[i].mark, in[i].number);
  }
  for(i=0;i<n;i++){
    if(i == n-1) printf("%c%d\n", out[i].mark, out[i].number);
    else printf("%c%d ", out[i].mark, out[i].number);
    }*/
  
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n-1;j++){
      for(k=0;k<n-1;k++){
	for(l=k+1;l<n-1;l++){
	  if(in[i].number == in[j].number &&
	     in[i].number == out[l].number &&
	     in[i].mark == out[l].mark &&
	     in[j].number == out[k].number &&
	     in[j].mark == out[k].mark) return FALSE;
	}
      }
    }
  }
  return TRUE;
}



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

using namespace std;

long long inf=1000000007;

int main(){
	long long n;
	cin>>n;
	long long ans=0;
	for(long long i=1;i<=n;i++){
		long long a;
		cin>>a;
		if(i%2==1 && a%2==1) ans++;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3632
def input_from_console():
    n, x = map(int, input().split())
    l_list = list(map(int, input().split()))
    return n, x, l_list


def solve(n, x, l_list):
    result = 0
    position = 0
    for i in range(n):
        if position > x:
            return result
        result +=1
        position += l_list[i]
    if position > x:
        return result 
    else:
        return result + 1



def main():
    n, x, l_list = input_from_console()
    print(solve(n, x, l_list))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()


Measured memory_bytes: 3064