akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mkt make_tuple
#define act(a,v) (get<(long long)a>(v))
#define mod 1000000007
#define mod1 998244353
#define N 1000003
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c));
#define max3(a,b,c) max(a,max(b,c));
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define sumall(v) accumulate(all(v),(ll)0)
#define sum accumulate
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::floatfield );std::cout.precision(15)
#define PI M_PI
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define showzero cout<<std::showpoint
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define br "\n"
#define sp " "
#define zero (ll)0
using namespace  std ;
typedef double db;
typedef long long ll ;
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
void READ(vll &v, ll n)
{
    ll a ;
    for(ll i=0 ; i<n ; i=i+1)
    {
        cin>>a ;
        v.pb(a) ;
    }
}
void PRINT(vll &v , ll a = 0)
{
    //ll a ;
    for(ll i=a ; i<v.size() ; i=i+1)
    {
        v[i] = max((ll)0,v[i]);
        cout<<v[i]<<" " ;
    }
    cout<<"\n" ;
}
/*vbool isprime(N,true);
vll spf(N,0);
vll prime;
void sieve()
{
    isprime[0] = isprime[1] = false;
    for(ll i = 2 ; i<N ; i++)
    {
        if(isprime[i])
        {
            for(ll j=2*i ; j<N ; j+=i)
            {
                isprime[j] = false;
                if(spf[j]==0)
                {
                    spf[j] = i;
                }
            }
            prime.pb(i);
        }
    }
}*//*
ll nck(ll n , ll k ,ll m=1e18+7)
{
    ll i , j,b=1,c=1 ;
    if(n-k<k)
    {
        k = n-k ;
    }
    while(k)
    {
        b*=n ;
        c*=k ;
        ll g = __gcd(b,c) ;
        b/=g ;
        c/=g ;
        n--;
        k-- ;
    }
    return(b) ;
}*//*
long long power(long long k , long long n , long long m=mod)
{
    long long res = 1;
    while(n)
    {
        if(n%2!=0)
        {
            res = (res*k)%m ;
        }
        k = (k*k)%m ;
        n = n/2 ;
    }
    return(res) ;
}*/
ll n,m,k,l,r;
bool ok = false;
int main()
{
    FastIO ;
    PRECISION ;
    ll a,b,c,d,i,j,t,x,y,z;//,x1,y1,z1,e,f;
    ll p,q,r,u,w ;
    char ch,chr ;
    string str,st,str1,str2,str3,str4;
    //ll a1=0,a2=0,b1=0,b2=0,c1=0 ;
    //cin>>str>>str1;
    cin>>n>>m;
    vll v;
    READ(v,n);
    sort(rall(v));
    a = sumall(v);
    b = a/(4*m);
    d = (4*m*b!=a);
    c = 0;
    for(i=0 ; i<m ; i++)
    {
        if(v[i]<b+d)
        {
            c = 1;
            break;
        }
    }
    if(c)
    {
        cout<<"No\n";
        exit(0);
    }
    cout<<"Yes\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
	return x*f;
}
const int N=5e5+7;
int n,sl[N],sr[N];
ll ans;
char s[N];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='>') sl[i]=i;
		else sl[i]=sl[i-1];
	}
	sr[n]=n;
	for(int i=n-1;i>=0;i--)
	{
		if(s[i+1]=='<') sr[i]=i;
		else sr[i]=sr[i+1];
	}
	for(int i=0;i<=n;i++)
		ans+=max(i-sl[i],sr[i]-i);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4608
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

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


Measured memory_bytes: 256
N = int(input())

l1 = []
for n in range(1,int(N**0.5)+1):
    if N%n==0:
        l1.append(n)
        l1.append(N//n)
l1 = list(set(l1))
l1.sort()

l2 = []
for n in range(1,int((N-1)**0.5)+1):
    if (N-1)%n==0:
        l2.append(n)
        l2.append((N-1)//n)
l2 = list(set(l2))
l2.sort()

l1 = l1[1:]
l2 = l2[1:]

ans = l2

def cal(n,k):
    if n%k==0:
        return cal(n//k,k)
    else:
        return n%k

for i in l1:
    if cal(N,i)==1:
        ans.append(i)

ans = len(set(ans))
print(ans)

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

int main() {
  int N,M,C;
  int count = 0;
  int sum = 0;
  cin >> N >> M >> C;
  vector<int> B(M);
  vector<vector<int>> data(N,vector<int>(M));
  for(int i = 0; i < M; i++){
    cin >> B.at(i);
  }
  for(int i = 0; i < N; i++){
    for(int j = 0; j < M; j++){
      cin >> data.at(i).at(j);
    }
  }
  for(int i = 0; i < N; i ++){
    sum = 0;
    for(int j = 0; j < M; j++){
      //毎回計算する
      //ここにsum入れるとi=0,j=1のsumとi=0,j=2のsumが分かれちゃうよ
      sum += B.at(j)*data.at(i).at(j);
      //ここにsum += C;おくと毎ループ足されてM*C足されてしまうので1回だけ行う判定で
      //ここにif入れると1個目の要素かけるだけで判断しちゃうよ
    }
    //各項足してからc足す
    if(sum + C > 0){
        count++;
      }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	i64 n; scanf("%lld", &n);
	i64 sum = 0;
	std::vector<i64> a(n);
	for(int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);

		sum += a[i];
	}

	bool ans = true;
	const i64 latte = n * (n + 1) / 2;
	if(sum % latte) ans = false;

	i64 c = 0;
	const i64 C = sum / latte;
	for(int i = 0; i < n; i++) {
		i64 D = a[(i + 1) % n] - a[i];

		i64 X = D - C + C * n;
		i64 Y = n;
		if(X % Y) ans = false;
		const i64 A = X / Y;
		const i64 B = C - A;
		if(A < 0 or B < 0) ans = false;
		c += B;
	}
	if(c != C) ans = false;

	if(ans) printf("YES\n");
	else printf("NO\n");
	return 0;
}


Measured memory_bytes: 1024
N,K=map(int,input().split())
sushi=[]
for i in range(N):
    t,d=map(int,input().split())
    sushi.append((t,d))
sushi.sort(key=lambda x:(x[0],-x[1]))
#print(sushi)
X=[sushi[0][1]]
Y=[]
for i in range(1,N):
    if sushi[i-1][0]==sushi[i][0]:
        Y.append(sushi[i][1])
    else:
        X.append(sushi[i][1])
X.sort(reverse=True)
Y.sort(reverse=True)
SX=[0]
SY=[0]
for i in X:
    SX.append(SX[-1]+i)
for i in Y:
    SY.append(SY[-1]+i)
ans=0
#print(X)
#print(Y)
#1<=x<len(X)
#K-len(Y)<=x<=
for x in range(max(1,K-len(Y)),min(len(SX),K+1)):
    ans=max(SX[x]+SY[K-x]+x*x,ans)
print(ans)

Measured memory_bytes: 27880
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 300009
#define mx 10000000000008
#define mod 998244353
ll n,tt,t[4*sz],q,arr[sz],brr[10][4*sz],laz[4*sz];
bool marked[4*sz];
void done(ll node,ll l,ll r)
{
    if(marked[node]==true)
    {
        marked[node]=false;
        marked[2*node]=marked[2*node+1]=true;
        laz[2*node]=laz[2*node+1]=laz[node];
        ll mid=(l+r)/2;
        t[2*node]=brr[laz[node]][mid-l+1];
        t[2*node+1]=brr[laz[node]][r-mid];
    }
    return;
}
void build(ll node,ll l,ll r)
{
    if(l==r)
    {
        t[node]=1;
        laz[node]=1;
        marked[node]=true;
        return;
    }
    ll mid=(l+r)/2;
    build(2*node,l,mid);
    build(2*node+1,mid+1,r);
    ll len=(r-mid);
    ll val=(arr[len]*t[2*node])%mod;
    t[node]=(val+t[2*node+1])%mod;
     laz[node]=1;
    marked[node]=true;
    return;
}
void update(ll node,ll l,ll r,ll le,ll ri,ll val)
{
    if(l>r || le>ri || le>r || l>ri)
        return;
    if(l>=le && r<=ri)
    {
       ll len=(r-l+1);
       t[node]=brr[val][len];
       laz[node]=val;
       marked[node]=true;
       return;
    }
    done(node,l,r);
    ll mid=(l+r)/2;
    update(node*2,l,mid,le,ri,val);
    update(node*2+1,mid+1,r,le,ri,val);
    ll len=(r-mid);
    ll val1=(arr[len]*t[2*node])%mod;
    t[node]=(val1+t[2*node+1])%mod;
    return;
}
ll query(ll node,ll l,ll r)
{
    if(l==r || marked[node]==true)
    return t[node];
    ll mid=(l+r)/2;
    ll val=query(2*node,l,mid);
    ll val1=query(2*node+1,mid+1,r);
    ll len=(r-mid);
    ll val2=(arr[len]*val)%mod;
    ll val3=(val1+val2)%mod;
    return ((val3)%mod);
}
int main()
{
    arr[0]=1;
    for(int i=1;i<=200000;i++)
    {
        arr[i]=(arr[i-1]*10)%mod;
    }
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=800000;j++)
        {
            if(j==1)
                brr[i][j]=i;
            else
            {
                brr[i][j]=(brr[i][j-1]*10+i)%mod;
            }
        }
    }
    //scanf("%lld",&t);
    tt=1;
    while(tt--)
    {
        scanf("%lld %lld",&n,&q);
        build(1,1,n);
       // printf("%lld\n",t[1]);
        for(int i=1;i<=q;i++)
        {
            ll l,r,d;
            scanf("%lld %lld %lld",&l,&r,&d);
            update(1,1,n,l,r,d);
            printf("%lld\n",t[1]);
        }
    }
    return 0;
}


Measured memory_bytes: 70392
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cassert>
#include<vector>
#define ll long long
#define inf 1000000000
using namespace std;
inline ll read(){
	ll re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
ll n,dep[200010],disd[200010],disu[200010],mind[200010],exc[200010],w[200010];
ll first[200010],cnte,fa[200010],siz[200010],high[200010],low[200010];
struct edge{
	ll to,next;
}a[400010];
inline void add(ll u,ll v){
	a[++cnte]=(edge){v,first[u]};first[u]=cnte;
	a[++cnte]=(edge){u,first[v]};first[v]=cnte;
}
void dfs(ll u,ll f){
	ll i,v;dep[u]=dep[f]+1;disd[u]=0;fa[u]=f;siz[u]=w[u];
	mind[u]=inf;
	if(((u==1&&first[u]==-1)||(u!=1&&a[first[u]].next==-1))){
		mind[u]=(w[u]?0:inf);return;
	}
	for(i=first[u];~i;i=a[i].next){
		v=a[i].to;if(v==f) continue;
		dfs(v,u);
		siz[u]+=siz[v];
		disd[u]=max(disd[u],disd[v]+1);
		if(mind[v]<inf) mind[u]=min(mind[u],disd[v]+1);
	}
	if(w[u]) mind[u]=min(mind[u],disd[u]);
//	cout<<"finish dfs "<<u<<' '<<f<<' '<<disd[u]<<' '<<mind[u]<<'\n';
}
vector<ll>tmp;
void dfs2(ll u,ll f){
//	cout<<"enter "<<u<<' '<<f<<'\n';
	ll i,v,maxn;tmp.clear();
	disu[u]=max(disu[u],(f!=0)+disu[f]); 
	if(f) exc[u]=max(0ll,disu[u]-1);
//	cout<<"dfs2 "<<u<<' '<<exc[u]<<' '<<disu[u]<<'\n';
	maxn=-1;
	for(i=first[u];~i;i=a[i].next){
		v=a[i].to;if(v==f) continue;
		disu[v]=max(disu[v],maxn+2);
		maxn=max(maxn,disd[v]);
		tmp.push_back(v);
	}
	maxn=-1;
	for(i=tmp.size()-1;i>=0;i--){
		v=tmp[i];
		disu[v]=max(disu[v],maxn+2);
		maxn=max(maxn,disd[v]);
	}
	for(i=first[u];~i;i=a[i].next) if((v=a[i].to)!=f) dfs2(v,u);
}
char s[200010];
int main(){
	memset(first,-1,sizeof(first));ll i,t1,t2,ans=0,u,v;
	n=read();
	for(i=1;i<n;i++){
		t1=read();t2=read();
		add(t1,t2);
	}
	scanf("%s",s);
	for(i=0;i<n;i++) w[i+1]=(s[i]=='1');
	dfs(1,0);dfs2(1,0);
	for(u=1;u<=n;u++){
		if(w[u]) low[u]=0;
		else low[u]=min(mind[u],(siz[u]==siz[1])?inf:disu[u]);
		high[u]=max(disu[u],disd[u])-1;
		for(i=first[u];~i;i=a[i].next){
			v=a[i].to;
			if(v==fa[u]) high[u]=min(high[u],disd[u]+1);
			else high[u]=min(high[u],exc[v]+1);
		}
//		cout<<u<<' '<<high[u]<<' '<<low[u]<<'\n'; 
		if(high[u]>=low[u]) ans+=high[u]-low[u]+1;
	}
	printf("%lld\n",ans+1);
}

Measured memory_bytes: 33408
#include <bits/stdc++.h>
using namespace std;
#define mem(a, b) memset(a, (b), sizeof(a))
#define fore(i,a) for(int i=0;i<a;i++)
#define fore1(i,j,a) for(int i=j;i<a;i++)
#define print(ar) for(int i=0;i<ar.size();i++)cout<<ar[i]<<" ";
#define END cout<<'\n'
const double pi=acos(-1.0);
 
typedef pair<int, int> PII;
 
typedef vector<int> VI;
 
typedef vector<string> VS;
 
typedef vector<PII> VII;
 
typedef vector<VI> VVI;
 
typedef map<int,int> MPII;
 
typedef set<int> SETI;
 
typedef multiset<int> MSETI;
 
typedef long int li;
 
typedef unsigned long int uli;
 
typedef long long int ll;
 
typedef unsigned long long int  ull;
ll fastexp (ll a, ll b, ll n) {
  ll res = 1;
  while (b) {
      if (b & 1) res = res*a%n;
      a = a*a%n;
      b >>= 1;
  }
  return res;
}
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
bool check(VI arr){
    fore1(i,1,arr.size()){
        if(arr[i]<arr.size()-1)return false;
    }
    return true;
}
int main()
 {  fast();
	int n,k;
	cin>>n>>k;

	VI arr(n+1,0);
	fore1(i,1,n+1)cin>>arr[i];
	while(k--){
	    if(check(arr)==false){
	    	VI vec(n+1,0);
	    fore1(i,1,n+1){
	        int a= (i-arr[i]>=1)?i-arr[i]:1;
	        int b= (i+arr[i]<=n)?i+arr[i]:n;
	        //cout<<a<<" "<<b<<endl;
	        vec[a]+=1;
	        if(b+1<=n)vec[b+1]-=1;
	    }
	    fore1(i,2,n+1)vec[i]+=vec[i-1];
	    fore1(i,1,n+1)arr[i]=vec[i];}
	    else {
	        break;
	    }
	}
	fore1(i,1,n+1)cout<<arr[i]<<" ";
	cout<<endl;
	
	  
	}

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

typedef vector<int> vec;
typedef vector<vec> mat;

const int INF = 1 << 28;

int N, T;

void solve() {
    vec t(T);
    for (auto& i : t) cin >> i;
    cin >> N;
    vec d(N), h(N);
    for (int i = 0; i < N; i++) {
        cin >> d[i] >> h[i];
        d[i]--;
    }

    vec times(101, INF);
    for (int i = 0; i < N; i++) {
        times[d[i]] = min(times[d[i]], h[i]);
    }

    mat dp(101, vec(T, INF));
    dp[0][0] = 0;
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < T; j++) {
            if (dp[i][j] == INF) continue;
            int next = (j + 1) % T;
            // use
            dp[i+1][0] = min(dp[i+1][0], dp[i][j] + 1);
            // do not using
            if (t[next] <= times[i+1]) {
                dp[i+1][next] = min(dp[i+1][next], dp[i][j]);
            }
        }
    }

    int ans = INF;
    for (int i = 0; i < T; i++) {
        ans = min(ans, dp[100][i]);
    }

    cout << ans << endl;
}

int main() {
    while (cin >> T, T) solve();
}

Measured memory_bytes: 3164
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
	IOS;
	string s;
	cin >> s;
	int n = s.size();
	if (n % 2 == 1) {
		put("No");
		return 0;
	}
	REP(i, n) {
		if (i % 2 == 0) {
			if (s[i] != 'h') {
				put("No");
				return 0;
			}
		} else {
			if (s[i] != 'i') {
				put("No");
				return 0;
			}
		}
	}
	put("Yes");
	return 0;
}

Measured memory_bytes: 256
def main():
  import sys
  b=sys.stdin.buffer
  input=b.readline
  n=int(input())
  d=[set()for _ in range(n)]+[{c}for c in input()]
  for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i]
  r=[]
  add=r.append
  input()
  for q,a,b in zip(*[iter(b.read().split())]*3):
    i=int(a)+n-1
    if q<b'2':
      d[i]={b[0]}
      while i:
        i>>=1
        d[i]=d[i+i]|d[i-~i]
      continue
    j=int(b)+n
    s=set()
    while i<j:
      if i&1:
        s|=d[i]
        i+=1
      if j&1:
        j-=1
        s|=d[j]
      i>>=1
      j>>=1
    add(len(s))
  print(' '.join(map(str,r)))
main()

Measured memory_bytes: 318428
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())
T = list(map(int, input().split()))
M = int(input())
for _ in range(M):
    P, X = map(int, input().split())
    ans = 0
    for i in range(N):
        if i + 1 == P:
            ans += X
        else:
            ans += T[i]
    print(ans)

Measured memory_bytes: 9092
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

void desperate_optimization(int precision){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(precision);
}



int main(){

    char arr[100];
    cin >> arr;
    int year,day,month;
    sscanf(arr,"%d/%d/%d",&year,&month,&day);
    if(year <= 2019 && month <= 4 && day <= 30){

        cout << "Heisei";
    } else
        cout << "TBD";
    return 0;
}




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

int main()
{
  string s;
  cin >> s;
  if (s == "SAT") cout << 1 << endl;
  if (s == "SUN") cout << 7 << endl;
  if (s == "MON")cout << 6 << endl;
  if (s == "TUE") cout << 5<< endl;
  if (s == "WED") cout << 4 << endl;
  if (s == "THU") cout << 3 << endl;
  if (s == "FRI") cout << 2 << endl;
  return 0;
}


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

int main(){
    vector<char> ue(3),sita(3);
    for(int i = 0; i < 3; i++){
        cin >> ue[i];
    }
    for(int i = 0; i < 3; i++){
        cin >> sita[i];
    }
    for(int i = 0; i < 3; i++){
        if(ue[i] != sita[2-i]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
      int count=0,maxcount=0;
    for(int i=0;i<s.length();i++)
    {
    	if(s.charAt(i)=='A' || s.charAt(i)=='C' || s.charAt(i)=='G' || s.charAt(i)=='T')
    	{
    		
    		count++;
    		//System.out.println("counting"+count);
    		if(maxcount<=count)
    		{
    			maxcount=count;
    		}
    	}

    	else
    	{
    		if(maxcount<=count)
    		{
    			maxcount=count;
    		}
    		count=0;
    		//System.out.println("died");
    	}
    }
    System.out.println(maxcount);
   }
 }
    


Measured memory_bytes: 23892
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()

print((len(s)//2)-s.count('p'))

Measured memory_bytes: 3316
import math
from functools import reduce


def lcm(a, b):
    if a % b == 0:
        return a
    elif b % a == 0:
        return b
    else:
        return a * b // math.gcd(a, b)


N = int(input())
clocks = [int(input()) for _ in range(N)]

print(reduce(lcm, clocks))


Measured memory_bytes: 9616
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();        
        int N = r.i();
        int n = String.valueOf(N).length();
        if(n == 1){
            println(N);
        } else {
            int d = n/2*2-1;
            long ans = 0;
            for(int i = 1; i <= d; i += 2){
                ans += count(i);
            }
            if(n%2 == 1){
                ans += N-(int)Math.pow(10, n-1)+1;
            }
            println(ans);
        }
        
    }
    static int count(int n){
        return 9*(int)Math.pow(10, n-1);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 23124
# coding: utf-8


def main():
    s = input()

    if s[0] != 'A':
        print("WA")
        return

    count = 0
    for c in s[2:-1]:
        if c == 'C':
            count += 1

    if count != 1:
        print("WA")
        return

    s = s[1:]
    s = s.replace('C', '', 1)
    if s.islower() == False:
        print("WA")
        return

    print("AC")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;
    if(x+r>w||x-r<0||y+r>h||y-r<0){
        cout<<"No"<<endl;
    }
    else{cout<<"Yes"<<endl;}
}


Measured memory_bytes: 3132
n = int(input())
a = list(map(int,input().split()))

l = [0,0,0,0,0,0,0,0,0]


for i in range(n):
  if a[i] <= 399:
    l[0] += 1
  elif 400 <= a[i] and a[i] <= 799:
    l[1] += 1
  elif 800 <= a[i] and a[i] <= 1199:
    l[2] += 1
  elif 1200 <= a[i] and a[i] <= 1599:
    l[3] += 1
  elif 1600 <= a[i] and a[i] <= 1999:
    l[4] += 1
  elif 2000 <= a[i] and a[i] <= 2399:
    l[5] += 1
  elif 2400 <= a[i] and a[i] <= 2799:
    l[6] += 1
  elif 2800 <= a[i] and a[i] <= 3199:
    l[7] += 1
  else:
    l[8] += 1
ans = 0

if n == 1 and a[0] >= 3200:
  print(1,1)
  exit()
  
for i in range(len(l)-1):
  if l[i] > 0:
    ans += 1

if ans >= 1:
  print(ans,ans + l[8])
elif ans == 0:
  print(1,l[8])


Measured memory_bytes: 62088
#include <stdio.h>

#define MAX_N 1000000
#define MAX_M 100
#define min(a,b) a < b ? a : b

void shellSort(int*,int);
void insertionSort(int*,int,int);
void print(int*,int*,int,int);

int cnt;

int main(){
  int N,i,a[MAX_N];

  scanf("%d" ,&N);
  for(i = 0 ; i < N ; i++){
    scanf("%d" ,&a[i]);
  }
  shellSort(a,N);


  return 0;
}

void shellSort(int a[],int N){
  int G[MAX_M],p = 0,m,i;
  cnt = 0;

  for(m = 1 ; m*3+1 < N ; m = m*3+1){};
  for(; m > 0 ; m /= 3){
    G[p++] = m;
  }

  p = min(p,100);
  for(i = 0 ; i < p ; i++){
    insertionSort(a,N,G[i]);
  }
  print(a,G,N,p);
}

void insertionSort(int a[],int N,int g){
  int i,v,j;

  for(i = g ; i < N ; i++){
    v = a[i]; j = i - g;
    while(j >= 0 && a[j] > v){
      a[j+g] = a[j];
      j -= g;
      cnt++;
    }
    a[j+g] = v;
  }
}

void print(int a[],int G[],int N,int m){
  int i;
  
  printf("%d\n" ,m);
  for(i = 0 ; i < m ; i++){
    if(i != m-1){
      printf("%d " ,G[i]);
    }else{
      printf("%d\n" ,G[i]);
    }
  }
  printf("%d\n" ,cnt);
  for(i = 0 ; i < N ; i++){
    printf("%d\n" ,a[i]);
  }
}

Measured memory_bytes: 4508
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
    int ans = 0;
      for(int i=0; i<3; i++){
       if(S.charAt(i) == T.charAt(i)){
         ans++;
      }
      }
    System.out.println(ans);
      }
}

Measured memory_bytes: 21844
from collections import deque

H,W=map(int,input().split())
sy,sx=map(int,input().split())
gy,gx=map(int,input().split())
field=[list(input()) for _ in range(H)]
sy,sx,gy,gx=sy-1,sx-1,gy-1,gx-1

Walk=[[1,0],[0,1],[-1,0],[0,-1]]
Warp=[[i,j] for i in range(-2,3) for j in range(-2,3)] 

dist=[[-1]*W for _ in range(H)]
que=deque()
dist[sy][sx]=0
que.append([sy,sx])

while que:
    y,x=que.popleft()
    for walk in Walk:
        nx,ny=x+walk[0],y+walk[1]
        if nx<0 or nx>=W or ny<0 or ny>=H: continue
        if field[ny][nx]=="#": continue
        if dist[ny][nx]!=dist[y][x]:
            dist[ny][nx]=dist[y][x]
            que.appendleft([ny,nx])
    
    for warp in Warp:
        nx,ny=x+warp[0],y+warp[1]
        if nx<0 or nx>=W or ny<0 or ny>=H: continue
        if field[ny][nx]=="#": continue
        if dist[ny][nx]==-1:
            dist[ny][nx]=dist[y][x]+1
            que.append([ny,nx])

print(dist[gy][gx])


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

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<bool>> con(8, vector<bool>(8, false));
  for (int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b; a--; b--;
    con.at(a).at(b) = con.at(b).at(a) = true;
  }
  vector<int> path(n - 1);
  for (int i = 1; i < n; i++){
    path.at(i - 1) = i;
  }
  
  int ans = 0;
  do{
    bool ok = true;
    int p = 0;
    for (int i = 0; i < n - 1; i++){
      if (!con.at(p).at(path.at(i))) ok = false;
      p = path.at(i);
    }
    if (ok) ans++;
  }while(next_permutation(path.begin(), path.end()));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int D[107][7],i,j,N;
int G[55][6]={
    {1,2,3},{1,3,5},{1,5,4},{1,4,2},
    {2,1,4},{2,4,6},{2,6,3},{2,3,1},
    {3,1,2},{3,2,6},{3,6,5},{3,5,1},
    {4,1,5},{4,2,1},{4,6,2},{4,5,6},
    {5,1,3},{5,3,6},{5,4,1},{5,6,4},
    {6,2,4},{6,4,5},{6,5,3},{6,3,2}};
 
int ch(int a,int b)
{
    int i;
    for(i=0;i<24;i++)
    {
        if(D[a][1]==D[b][G[i][0]]&&
           D[a][2]==D[b][G[i][1]]&&
           D[a][3]==D[b][G[i][2]]&&
           D[a][6]==D[b][7-G[i][0]]&&
           D[a][5]==D[b][7-G[i][1]]&&
           D[a][4]==D[b][7-G[i][2]])
        return 1;
    }
    return 0;
}
 
int main()
{
    scanf("%d",&N);
    for(i=0;i<N;i++)
        for(j=1;j<=6;j++)
            scanf("%d",&D[i][j]);
    for(i=0;i<N;i++)
        for(j=i+1;j<N;j++)
        {
            if(ch(i,j))
            {
                puts("No");
                return 0;
            }
        }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int n;
    cin>>n;
    map<string,int> dict;
    rep(i,n){
        string s;
        cin>>s;
        dict[s]++;
    }
    int m;
    cin>>m;
    rep(i,m){
        string s;
        cin>>s;
        dict[s]--;
    }
    int res = 0;
    for(auto i:dict){
        res = max(res,i.second);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

r1=0
for jj in range(n):
  r1=r1^a[jj]

r=[0]*n
for ii in range(n):
  r[ii]=r1^a[ii]
"""
for ii in range(n):
  print(bin(a[ii]),bin(r[ii]))
"""
print(*r)

Measured memory_bytes: 30660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
struct tri{
    ll gde,kad,id;
};
vector <tri> prefektura[100005];
bool cmp(tri a,tri b){
    return a.kad < b.kad;
}
string sol[100005];
int main(){
    ios_base::sync_with_stdio(false);
    ll n,m,gd,kd;
    cin >> m >> n;
    for(long i = 1; i <= n; i++){
        cin >> gd >> kd;
        prefektura[gd].push_back({gd,kd,i});
    }
    for(long i = 1; i <= m; i++){
        sort(prefektura[i].begin(),prefektura[i].end(),cmp);
    }
    for(long i = 1; i <= m; i++){
        for(long j = 0; j < prefektura[i].size(); j++){
            stringstream ss1,ss2;
            ss1 << i;
            ss2 << (j+1);
            string s1 = ss1.str(),s2 = ss2.str();
            while(s1.size() < 6){
                string r = "0";
                s1 = r+s1;
            }
            while(s2.size() < 6){
                string r = "0";
                s2 = r+s2;
            }
            sol[prefektura[i][j].id] = s1+s2;
        }
    }
    for(long i = 1; i <= n; i++){
        cout << sol[i] << endl;
    }
}


Measured memory_bytes: 12672
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <complex>
using namespace std;

int main()
{
	int A,B;
	double T;
	cin>>A>>B>>T;

	int result = int((T+0.5)/A)*B;
	cout<<result<<endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
int main() {
  string S; cin >> S;
  int N = S.size();
  bool f = true;
  rep(i, N) {
    if(((i%2==0)&&(S[i]=='L')) || ((i%2!=0)&&(S[i]=='R'))) {f=false; break;}

  }
if(f)cout << "Yes" << endl;
else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo K
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000

int main(){
	
	int N,M,L;
	cin>>N>>M>>L;
	
	vector<vector<long long>> W(N,vector<long long>(N,Inf));
	for(int i=0;i<N;i++)W[i][i]=0LL;
	
	for(int i=0;i<M;i++){
		long long A,B,C;
		cin>>A>>B>>C;
		A--;B--;
		W[A][B]=min(W[A][B],C);
		W[B][A]=min(W[B][A],C);
	}
	
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			for(int k=0;k<N;k++){
				W[j][k] = min(W[j][k],W[j][i]+W[i][k]);
			}
		}
	}
	
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(W[i][j]<=L)W[i][j]=1;
			else W[i][j]=Inf;
		}
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			for(int k=0;k<N;k++){
				W[j][k] = min(W[j][k],W[j][i]+W[i][k]);
			}
		}
	}
	
	int Q;
	cin>>Q;
	
	for(int i=0;i<Q;i++){
		int s,t;
		cin>>s>>t;
		s--;t--;
		if(W[s][t]>=Inf)cout<<-1<<endl;
		else cout<<W[s][t]-1<<endl;
	}
	
	
	return 0;
}


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

int main(){
  int n, m; cin >> n >> m;
  int h[n];
  int cnt = 0;
  bool d[n];
  for (int i = 0; i < n; i++) d[i] = true;
  for (int i = 0; i < n; i++) cin >> h[i];
  for (int i = 0; i < m; i++){
    int a, b; cin >> a >> b;
    if (h[a - 1] == h[b - 1]) {
      d[a - 1] = false;
      d[b - 1] = false;
    }
    else if (h[a - 1] > h[b - 1]) d[b - 1] = false;
    else if (h[a - 1] < h[b - 1]) d[a - 1] = false;
  }
  for (int i = 0; i < n; i++){
    if (d[i]) cnt += 1;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 4112
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1e9+1
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n,m;
  cin >> n >> m;
  int ans = 1,i=0;
  while(ans < m)
  {
    ans += n-1;
    i++;
  }
  cout << i << endl;
  return 0;
} 


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long MOD = 1000000007;

        public void Run()
        {
            N = Input.ReadInt();

            long[,,,] DP = new long[5,5,5,N+1];
            DP[0, 0, 0, 0] = 1;

            for (int i = 1; i <= N; i++)
            {
                for (int i1 = 0; i1 <= 4; i1++)
                for (int i2 = 0; i2 <= 4; i2++)
                for (int i3 = 0; i3 <= 4; i3++)
                for (int x = 1; x <= 4; x++)
                {
                    if (i1 == 1 && i2 == 3 && x == 2) continue;
                    if (i1 == 1 && i3 == 3 && x == 2) continue;
                    if (i2 == 3 && i3 == 1 && x == 2) continue;
                    if (i2 == 1 && i3 == 3 && x == 2) continue;
                    if (i2 == 1 && i3 == 2 && x == 3) continue;

                    DP[i2, i3, x, i] += DP[i1, i2, i3, i-1];
                    DP[i2, i3, x, i] %= MOD;
                }
            }

            long ret = 0;
            {
                for (int i1 = 0; i1 <= 4; i1++)
                for (int i2 = 0; i2 <= 4; i2++)
                for (int i3 = 0; i3 <= 4; i3++)
                {
                    ret += DP[i1, i2, i3, N];
                    ret %= MOD;
                }
            }

            Console.WriteLine(ret);
        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 11160
n, x = map(int, input().split())
p = n
if x * 2 > n:
  x = n - x
ans = 0
while(x > 0):
  if n == p:
    ans += 3 * x * (n // x - 1)
  else:
    ans += 3 * x * (n // x)
  n, x = x, n % x
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,p[1000],a,b,x,y,z;
int main(){
    cin>>n>>a>>b;
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    sort(p,p+n);
    for(int i=0;i<n;i++){
        if(p[i]<=a)x++;
        if(p[i]>=a+1&&p[i]<=b)y++;
        if(p[i]>=b+1)z++;
    }
    cout<<min(min(x,y),z)<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a[1000];
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
        scanf("%d",&a[n-i]);
    }
    for(int i = 0; i < n-1;i++) printf("%d ",a[i]);
    printf("%d\n",a[n-1]);
}



Measured memory_bytes: 2616
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int N;
    string S;
    cin >> N >> S;
    res = 0;
    int tmp = 0;
    for (int i = 0; i < N; i++)
    {
        if (S[i] == 'I')
        {
            res++;
        }
        else
        {
            res--;
        }
        tmp = max(tmp, res);
    }
    cout << tmp << endl;
    return 0;
}

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


int main(int argc, char const *argv[]) {
  int n, key, cnt=0;
  std::cin >> n;

  std::vector<int> S; S.reserve(10001);

  for (size_t i = 0; i < n; i++) {
    std::cin >> S[i];
  }

  int q;  std::cin >> q;

  for (size_t i = 0; i < q; i++) {
    std::cin >> key;
    for (size_t j = 0; j < n; j++) {
      if (key==S[j]) {
        cnt++;
        break;
      }
    }
  }

  std::cout << cnt << '\n';

  return 0;
}



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

using namespace std;

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;
int h[26];
int main() {
    int n;
    string s;
    cin >> n >> s;

    for(auto ch : s) {
        h[ch - 'a']++;
    }
    long long ans = 1;
    for(int i = 0; i < 26; i++) ans = ans * (h[i] + 1) % MOD;
    cout << (ans + MOD - 1) % MOD;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int N,D;
int p[60][60];
int dp[60][60][60];
int pre[60][60][60];
const int INF = 1000000000;

int rec(int pos,int x,int y){
  if(dp[pos][x][y]!=-1)return dp[pos][x][y];

  if(y<0){
    return dp[pos][x][y]=INF;
  }
  
  if(x==D){
    return dp[pos][x][y]=(y==0?0:INF);
  }

  int res=INF;
  
  for(int to=0;to<N;to++){
    if(to==pos){
      if(res>rec(to,x+1,y)+p[to][x]){
        res=rec(to,x+1,y)+p[to][x];
        pre[pos][x][y]=to;
      }
    }else{
      if(res>rec(to,x+1,y-1)+p[to][x]){
        res=rec(to,x+1,y-1)+p[to][x];
        pre[pos][x][y]=to;
      }
    }
  }

  return dp[pos][x][y]=res;
}

int main(){
  memset(dp,-1,sizeof(dp));
  memset(pre,-1,sizeof(pre));
      
  cin>>N>>D;
  for(int i=0;i<N;i++)
    for(int j=0;j<D;j++)
      cin>>p[i][j];


  int mini=INF;
  int pos,x=0,y;
  vector<int> ans;
  for(int i=0;i<=D;i++){
    for(int j=0;j<N;j++){
      if(mini > rec(j,0,i)){
        mini=rec(j,0,i);
        pos=j;
        y=i;
      }
    }
  }

  cout<<mini<<' '<<y<<endl;
  
  while(1){
    int to=pre[pos][x][y];

    x++;
    if(to!=pos)y--;
    pos=to;
    if(y<0 || pos<0)break;
    ans.push_back(pos);
  }
  for(int i=0;i<(int)ans.size();i++){
    cout<<ans[i]+1<<endl;
  }

  return 0;
}



Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,k;
  cin>>a>>b>>k;
  if(a>=k){
    cout<<a-k<<' '<<b<<endl;
  }
  else if(b>=k-a){
    cout<<0<<' '<<b-(k-a)<<endl;
  }
  else{
    cout<<0<<' '<<0<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#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 INF 1<<30
#define LINF 1LL<<62
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int main(){
    int x,y; cin >> x >> y;
    cout << x + y/2 << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
int V,E;
vector<int> g[100100];
int dep[100100],low[100100],ord[100100];
int cnt = 0;
void dfs(int v,int p,int d){
    dep[v] = d;
    ord[v] = cnt++;
    low[v] = ord[v];
    for(int i=0;i<g[v].size();i++){
        if(g[v][i]==p)continue;
        int ch = g[v][i];
        if(ord[ch]==-1){
            dfs(ch,v,d+1);
            low[v] = min(low[v],low[ch]);
        }else{
            low[v] = min(low[v],ord[ch]);
        }
    }
}
int main(){
    scanf("%d %d",&V,&E);
    vector<P> es(E);
    for(int i=0;i<E;i++){
        int s,t;
        scanf("%d %d",&s,&t);
        g[s].pb(t);
        g[t].pb(s);
        if(s>t)swap(s,t);
        es[i]=P(s,t);
    }
    memset(ord,-1,sizeof(ord));
    dfs(0,-1,0);
    vector<P> ans;
    for(int i=0;i<E;i++){
        int s = es[i].fi,t = es[i].sec;
        if(dep[s]>dep[t])swap(s,t);
        if(ord[s]<low[t])ans.pb(es[i]);  
    }
    sort(all(ans));
    for(int i=0;i<ans.size();i++)printf("%d %d\n",ans[i].fi,ans[i].sec);
    return 0;
}


Measured memory_bytes: 7536
def f(k,n):

    r=1
    t = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if t%i==0:
            c=0
            while t%i==0:
                c+=1
                t //= i
            if c>=k:
                r*=i**(c//k)
    if k==1 and t!=1:r*=t
    if r==k==1:r*=n
    print(r)

f(*map(int,input().split()))


Measured memory_bytes: 3064
// MAGRANT - GNC20 - TEMPLATE 3.3
// 2017/8/26 - AtCoder Grand Contest 019 - Alpha

// FOR COMPATIBILITY:
#define _CRT_SECURE_NO_WARNINGS

// UNIVERSAL DEFINITIONS:
#define N (1<<17)
#define MODULO (1000000007)
#define HA1 (2420609)
#define HA2 (19260817)

// FREQUENT HEADER FILES:
#include <cstdio>
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <complex>
using namespace std;

// TEMPLATE BEGINS HERE.
//#define MAGRANT_ALLOWS_CTMP
// IMPORTANT: DO NOT OPEN UNLESS AS CONTESTANT.
// CAUTION: BEWARE OF CONFLICT.
#ifdef MAGRANT_ALLOWS_CTMP
namespace CTMP
{
	// ELEMENTARY MATHEMATICAL COMPUTATIONS:
	long long fact[N], inv[N];
	long long KissMe(long long xx, long long yy)
	{
		if (yy == 0LL)
		{
			return 1LL;
		}
		long long Res = KissMe((xx*xx) % (long long)MODULO, yy >> 1);
		if (yy % 2LL == 1LL)
		{
			Res *= xx;
			Res %= (long long)MODULO;
		}
		return Res;
	}
	inline void InitFactInv()
	{
		fact[0] = 1LL;
		for (int i = 1;i < N - 4;i++)
		{
			fact[i] = fact[i - 1] * (long long)i;
			fact[i] %= (long long)MODULO;
		}
		inv[N - 5] = KissMe(fact[N - 5], (long long)(MODULO - 2));
		for (int i = N - 6;i >= 0;i--)
		{
			inv[i] = inv[i + 1] * (long long)(i + 1);
			inv[i] %= (long long)MODULO;
		}
	}
	inline long long Choose(int xx, int yy)
	{
		if (xx < yy)
		{
			return 0LL;
		}
		else if (xx == yy)
		{
			return 1LL;
		}
		long long Res = fact[xx];
		Res *= inv[yy];
		Res %= (long long)MODULO;
		Res *= inv[xx - yy];
		Res %= (long long)MODULO;
		return Res;
	}
	inline long long GridWays(int fx, int fy, int sx = 0, int sy = 0)
	{
		fx -= sx, fy -= sy;
		if (fx < 0 || fy < 0)
		{
			return 0LL;
		}
		long long Res = fact[fx + fy];
		Res *= inv[fx];
		Res %= (long long)MODULO;
		Res *= inv[fy];
		Res %= (long long)MODULO;
		return Res;
	}
}
#endif
// TEMPLATE FINISHES HERE.

long long a[10];
long long n;
long long Ans;

int main()
{
	// IMPORTANT: DO NOT OPEN UNLESS AS CONTESTANT.
	// CAUTION: BEWARE OF CONFLICT.
	//using namespace CTMP;

	// REAFFIRM THE FOLLOWING BEFORE CODING.
	// 1. THE ALGORITHM IS CORRECT.
	// 2. THE COMPLEXITY IS PROPER.
	// 3. THE ALGORITHM CANNOT BE SIMPLER.
	// 4. CODING DETAILS WERE CONSIDERED.

	for (int i = 0;i < 4;i++)
	{
		scanf("%lld", &a[i]);
		if (i)
		{
			if (a[i] > (a[i - 1] << 1))
			{
				a[i] = a[i - 1] << 1;
			}
		}
	}
	/*
	for (int i = 2;i >= 0;i--)
	{
		if (a[i + 1] < a[i])
		{
			a[i] = a[i + 1];
		}
	}
	*/
	scanf("%lld", &n);
	n <<= 2;
	for (int i = 3;i >= 0;i--)
	{
		Ans += (n / (1LL << i)) * a[i];
		n %= (1LL << i);
	}
	printf("%lld\n", Ans);

	// REAFFIRM THE FOLLOWING BEFORE SUBMITTING.
	// 1. THE ARRAYS ARE IN PROPER SIZE.
	// 2. THE CORNER CASES WILL NOT LEAD TO VIOLATION.
	// 3. NO TYPO LIKE N->M EXISTS.
	// 4. THE INPUT/OUTPUT IS IN THE SPECIFIED FORMAT.
	// 5. ALL CATEGORIES DO NOT INTERSECT.
	//system("pause");
	return 0;
}


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

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

  string ans;

  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) != 'B') ans += S.at(i);
    else if (S.at(i) == 'B' && ans != "") ans.pop_back();
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int H,W,a,b;
    cin >> H >> W;
    vector<vector<string>> S(H,vector<string>(W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> S.at(i).at(j);
            if(S.at(i).at(j)=="snuke"){
                a=i+1;
                b=j;
                break;
            }
        }
    }
    string s ="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    cout << s.at(b) << a << endl;
    
}

Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N, D = M()
print(math.ceil(N/(2*D+1)))

Measured memory_bytes: 74536
from collections import deque
number=list(map(int,input().split()))
H,W=number[0],number[1]
C=list(map(int,input().split()))
D=list(map(int,input().split()))
S=[str(input()) for i in range(H)]

INF=10**9
dp=[[INF]*W for i in range(H)]
trans_a=[(1,0),(0,1),(-1,0),(0,-1)]
trans_b=[(i,j) for i in range(-2,3) for j in range(-2,3) if (i,j) not in [(0,0)]+trans_a]
Q=deque()
t=0
C.append(t)
Q.append((C[0]-1,C[1]-1,C[2]))
dp[C[0]-1][C[1]-1]=t

while Q:
    x,y,t=Q[0][0],Q[0][1],Q[0][2]
    Q.popleft()
    for dx,dy in trans_a:
        nx=x+dx
        ny=y+dy
        if 0<=nx<H and 0<=ny<W and S[nx][ny]!="#" and dp[nx][ny]>t:
            dp[nx][ny]=t
            Q.appendleft((nx,ny,t))
    
    for dx,dy in trans_b:
        nx=x+dx
        ny=y+dy
        if 0<=nx<H and 0<=ny<W and S[nx][ny]!="#" and dp[nx][ny]>t+1:
            dp[nx][ny]=t+1
            Q.append((nx,ny,t+1))

if dp[D[0]-1][D[1]-1]==INF:
    print(-1)

else:
    print(dp[D[0]-1][D[1]-1])

Measured memory_bytes: 95960