akhauriyash/Code-Regression huggingface dataset:
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max =2999+20;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}

double dp[Max][Max];

ll n;


double ara[Max+10];
bool vis[Max+10][Max+10];

double call(int i,int head)
{
    double &ret=dp[i][head];

    if(head<0)return 0.0;


 //     vis[i][head]=true;

      if(i<0)
       return (head==0);

        if(vis[i][head])return ret;


        vis[i][head]=true;

       ret=(ara[i]*call(i-1,head-1))+((1.0-ara[i])*call(i-1,head));

       return ret;


}


int main()
{

   fastread();

   ll i,j,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;

      bool flag=false;

      memset(dp,0,sizeof(dp));
      memset(vis,false,sizeof(vis));

      cin>>n;

      for(i=0; i<n; i++)
        cin>>ara[i];


        double ans=0;
    for(ll head=0; head<=n; head++)
    {
        ll tail=n-head;

       // cout<<head<<" "<<tail<<endl;
        if(head>tail)
            {
                ans+=call(n-1,head);

                //cout<<head<<endl;
            }
    }

    cout<<setprecision(9)<<fixed<<ans<<endl;




}


Measured memory_bytes: 84120
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=10;j<=m;j++)
		{
			if(j%10>=2&&j/10>=2&&j%10*(j/10)==i)
			  ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main()
{
    int N, K, Q;
    cin >> N >> K >> Q;

    vector<int> point(N, K - Q);

    vector<int> A(Q);
    for (int &a : A)
    {
        cin >> a;
        a--;
        point[a]++;
    }

    for (int p : point)
    {
        if (p > 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}


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

#define rep(i,n)	for(int i=0;i<n;i++)

int main(){
  int n;	cin >>n;
  vector<int>	b(n+1);
  rep(i,n-1)	cin >> b[i];
  b[n-1]=b[n-2];
  
  vector<int>	a(n);
  a[0]=b[0];
  for(int i=1;i<n;i++){
    a[i]=min(b[i-1],b[i]);
  }
  int sum=0;
  rep(i,n)	sum+=a[i];
  cout << sum;
}

Measured memory_bytes: 3616
n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(n)]
cd = [tuple(map(int, input().split())) for _ in range(m)]

for i in range(n):
    x = 1 << 30
    y = -1
    a, b = ab[i]
    for j in range(m):
        c, d = cd[j]
        d = abs(a - c) + abs(b - d)
        if x > d:
            x = d
            y = j
    print(y + 1)


Measured memory_bytes: 9200
#include<iostream>
#include<string>
using namespace std;
int main() {
  string s;
  cin >> s;
  int ans=0;
  int l=s.length();
  for(int i=0;i<l;++i) {
    if(s[i]!=s[l-i-1]) ++ans;
  }
  cout << ans/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;

    list<int> li;
    int ignore = 0;

    for (int i=0; i<n; ++i) {
        string op; cin >> op;
        if (op == "insert") {
            int key; cin >> key;
            li.push_front(key);
        } else if (op == "delete") {
            int key; cin >> key;
            list<int>::iterator pos = find(li.begin(), li.end(), key);
            if (pos != li.end()) {
                li.erase(pos);
            }
        } else if (op == "deleteFirst") {
            li.pop_front();
        } else if (op == "deleteLast") {
            ignore ++;
        }
    }

    list<int>::iterator it2 = li.end();
    advance(it2, -ignore);
    for (list<int>::iterator it = li.begin(); it != it2; ++it) {
        cout << ((it == li.begin()) ? "" : " ") << *it;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 32480
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
using namespace std;
#define ll long long
const int mod = 1e9+7, maxn = 1e5+10;
int N, M, K;
int dp[1010][1010];
char maze[1010][1010];

int main()
{
    scanf("%d %d", &N, &M);
    for(int i = 1; i <= N; i++)
        scanf("%s", maze[i]+1);
    dp[1][1] = 1;
    for(int i = 1; i <= N; i++)
        for(int j = 1; j <= M; j++)
            if(maze[i][j] == '.')
            {
                if(dp[i-1][j])
                    dp[i][j] = (dp[i][j]+dp[i-1][j])%mod;
                if(dp[i][j-1])
                    dp[i][j] = (dp[i][j]+dp[i][j-1])%mod;
            }
    printf("%d\n", dp[N][M]);
    return 0;
}


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

#define MAX 500000

void maxHeapify(int list[], int i, int H){
    int l, r, largest;
    l = 2 * i;
    r = 2 * i + 1;
// 左の子、自分、右の子で値が最大のノードを選ぶ
    if ( l <= H && list[l] > list[i] ) largest = l;
    else largest = i;
    if ( r <=  H && list[r] > list[largest] ) largest = r;
    if ( largest != i ){// i の子の方が値が大きい場合
        swap(list[i], list[largest]);
        maxHeapify(list, largest, H);
    }
}

int main(){
    int H, list[MAX+1];
    cin >> H;
    
    for (int i = 1; i <= H; i++ ){
        cin >> list[i];
    }
    
    for (int i = H / 2; i >= 1; i-- ){
        maxHeapify(list, i, H);
    }
    
    for (int i = 1 ; i <= H; i++ ){
        cout << " " << list[i];
    }
    cout << endl;
    
    return 0;
    
}



Measured memory_bytes: 4924
n,m = map(int,input().split())
L = []
R = []

for _ in range(m):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)
tmp = min(R)-max(L)+1

if tmp >= 1:
    print(tmp)
else:
    print(0)

Measured memory_bytes: 10996
//                          VIVEK UPADHYAY
//                         MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                         TAB -TAK CHODEGA NHI :D
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<endl
#define ok cout<<"ok\n" ;
typedef long long ll;
const int MAXN = 45000 + 10 ;
const int MAX = 1e7 ;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e18 ;
int main() {
    
    int A , B ;
    cin >> A>>B;
    if(A==2 || B==2){
        cout<<"No\n" ;
        return 0 ;
    }
    else {
        cout<<"Yes\n" ;
    }
    
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
vector<long> fact_inv,inv,Com;
void init_nCk(int n,int k){
  fact_inv.resize(k+1);
  inv.resize(k+1);
  fact_inv[0]=fact_inv[1]=inv[1]=1;
  for(int i=2;i<=k;i++){
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    fact_inv[i]=fact_inv[i-1]*inv[i]%MOD;
  }
  Com.resize(k+1);
  Com[0]=1;
  for(int i=1;i<=k;i++){
    Com[i]=Com[i-1]*((n-i+1)*inv[i]%MOD)%MOD;
  }
}
int nCk(int k){
  return Com[k];
}
int K,i,a;
long x=1,ans=0;
int main(){
  string S;
  cin>>K>>S;
  a=K+S.size();
  init_nCk(a,K);
  for(i=0;i<=K;++i){
    ans+=x*nCk(i);
    ans%=MOD;
    x=x*25%MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 27648
#!/usr/bin/python3

while True:
    n = int(input())
    if n == 0 : break

    gems = []
    for i in range(n):
        gem = tuple(map(int, input().split()))
        gems.append(gem)
    
    m = int(input())
    bot = [10, 10]
    history = [(10, 10)]
    for j in range(m):
        move = list(input().split())
        move[1] = int(move[1])
        if move[0] == 'N':
            index = 1 #y
            direc = 1 # pos
        elif move[0] == 'S':
            index = 1
            direc = -1 # neg
        elif move[0] == 'E':
            index = 0 #x
            direc = 1
        else: #W
            index = 0
            direc = -1
        for j in range(abs(move[1])):
            bot[index] += direc
            history.append(tuple(bot))
    f = True
    for g in gems:
        if g not in history:
            f = False
            break
    print("Yes" if f else "No")

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

int counteven(int a){
  int n=0;
  while (a%2==0){
    n++;
    a /= 2;
  }
//  cout << 'e' << a << ':' << n << endl;
  return n;
}

void solve(void){
  int N, count; 
  
  cin >> N;
  
  int a[N];
  
  for (int i=0; i<N; i++){
    cin >> a[i];
  }
 
  count = 0;
  
  for (int i=0; i<N; i++){
    count += counteven(a[i]);
  }  

  cout << count << endl;
  
  return;
}

int main(int argc, const char * argv[]) {

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

  solve();
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int calc(int x)
{
	int cnt = 0;
	while (x % 2 == 0)
	{
		cnt++;
		x /= 2;
	}
	return cnt;
}
int main()
{
	int n, ans = 1, cnt = 0, tmp;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		tmp = calc(i);
		if (tmp > cnt)
			cnt = tmp, ans = i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string S;
    int N;
    cin >> S >> N;
    string ans = "";
    for(int i = 0;i < S.length();i += N){
        ans += S[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
	vector<int> v;
	while(1){
		v.clear();
		int n,r;
		cin>>n>>r;
		if(n==0&&r==0)break;
		for(int i=n;i>0;i--){
			v.push_back(i);
		}
		vector<int> q;
		for(int i=0;i<r;i++){
			q.clear();
			int p,s;
			cin>>p>>s;
			p--;
			for(int j=p;j<p+s;j++)
				q.push_back(v[j]);
			for(int j=p-1;j>=0;j--)
				v[s+j]=v[j];
			for(int j=0;j<s;j++)
				v[j]=q[j];

		}
		cout<<v[0]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3040
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n, k;
    cin >> n >> k;

    vector<int> s(n + 1);

    map<int, int> mp;
    mp[0]++;

    ll r = 0;

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        a--;

        s[i + 1] = (s[i] + a) % k;

        if (i + 1 - k >= 0) mp[s[i + 1 - k]]--;
        r += mp[s[i + 1]]++;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 10368
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include <assert.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
#include <climits>
using namespace std;
typedef unsigned long long ull;
#define ll long long int
static const double PI = 3.141592653589793;
const ll INF = 100000000000000;
ll mod = 1000000007;
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;

ll dp[3005][3005];



int main() {
	ll a, c, b, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	dp[0][0] = 1;
	for (int i = 0; i <= f; i++) {
		for (int j = 0; j + i <= f; j++) {
			if (dp[i][j] == 1) {
				if(i + 100 * a+j<=f)dp[i + 100 * a][j] = 1;
				if(i + 100 * b+j<=f)dp[i + 100 * b][j]=1;
				if(i+j+c<=f)dp[i][j + c] = 1;
				if(i+j+d<=f)dp[i][j + d] = 1;
			}
		}
	}
	ll aa=0, bb = 0;
	for (int i = 0; i <= f; i++) {
		for (int j = 0; j + i <= f; j++) {
			if (dp[i][j] == 1&&(i+j)!=0) {

				if ((i+j)*bb<=(aa+bb)*j&&100*j<=i*e) {
					aa = i;
					bb = j;
				}
			}
		}
	}
	cout << aa + bb << " " << bb << endl;

	return 0;
}

Measured memory_bytes: 45312
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    m = sum(A)
    d = []
    for i in range(1, int(m**0.5)+1):
        if m % i == 0:
            d.append(i)
            if i != m // i:
                d.append(m//i)
    d.sort(reverse=True)
    for j in d:
        if j > K + max(A):
            continue
        l = []
        for i in A:
            l.append(i % j)
        t = N - sum(l) // j
        l.sort()
        if sum(l[:t]) <= K:
            print(j)
            return
    print(1)
main()


Measured memory_bytes: 3064
s = input()
gu = 1
pa = 0
point = 0
if s[0] == "p":
  point -= 1
  
for hand in s[1:]:
  if hand == "g":
    if pa<gu:
      point += 1
      pa += 1
    else:
      gu += 1
  elif hand == "p":
    if pa<gu:
      pa += 1
    else:
      gu += 1
      point -= 1
print(point)

Measured memory_bytes: 9248
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int x[6];
    for(int i=1;i<=5;i++)
    {
        cin>>x[i];
        if(x[i]==0)
        {
            cout<<i;
            return 0;
        }
    }

} 

 


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int32_t main()
{
	IOS;
	int x;
	cin>>x;
	int k=1;
	while(true)
	{
		if((k*x)%360==0)
		{
			cout<<k<<endl;
			return 0;
		}
		k++;
	}
	
}

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

int main() {
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  double a_square = (x2 - x1) * (x2 - x1);
  double b_square = (y2 - y1) * (y2 - y1);
  double c_square = a_square + b_square;

  double ans = sqrt(c_square);
  printf("%.5f\n", ans);
  return 0;
}


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

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

int main()
{
	int n, x, m[1000];

	cin >> n >> x;
	REP(i, n) cin >> m[i];
	sort(m, m+n);

	int ans = 0;
	REP(i, n)
	{
		if (x >= m[i])
		{
			x -= m[i];
			ans++;
		}
	}
	while (x >= m[0])
	{
		x -= m[0];
		ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();

			if (numA > 16 / 2 || numB > 16 / 2) {
				System.out.println(":(");
				return;
			}

			System.out.println("Yay!");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numD = 0;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numD = scanner.nextInt();
			numN = scanner.nextInt();
			if (numN == 100) {
				numN++;
			}
			switch (numD) {
			case 0:
				System.out.println(numN);
				break;
			case 1:
				System.out.println(numN * 100);
				break;
			case 2:
				System.out.println(numN * 10000);
				break;
			default:
				break;
			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 21844
/*
"Won't stop until I'm phenomenal."
- Phenomenal, Eminem
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;

struct E{
    ll to;
    ll co;
    ll ti;
};

struct P{
    ll ti;
    ll id;
    ll re;
};
bool operator <(const P &a,const P &b){return a.ti>b.ti;}
ll dp[55][5001];
ll ans[55];
vector<E> edge[55];

int main(){
    Shazam;
    int n; cin>>n;
    int m; cin>>m;
    ll s; cin>>s;
    for(int i = 0 ; i < m; i++){
        ll a,b,c,d; 
        cin>>a>>b>>c>>d;
        edge[a].push_back({b,c,d});
        edge[b].push_back({a,c,d});
    }
    vector<ll> c(n+1),d(n+1);
    for(int i = 1; i < n+1; i++){
        cin>>c[i]>>d[i];
    }
    priority_queue<P> q;
    q.push({0,1,min(5000LL,s)});
    while(!q.empty()){
        P p = q.top();
        q.pop();
        if(dp[p.id][p.re]) continue;
        dp[p.id][p.re] = p.ti;
        if(!ans[p.id]) ans[p.id] = p.ti;
        for(E e : edge[p.id]){
            if(p.re>=e.co && ! dp[e.to][p.re-e.co])
                q.push({ p.ti + e.ti, e.to , p.re- e.co});
        }
        if(p.re + c[p.id] <= 5000){
            q.push({p.ti + d[p.id], p.id, p.re + c[p.id]});
        }

    }
    for(int i = 2; i < n+1; i++) 
        cout<<ans[i]<<endl;
    return 0;

}

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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define SZ(x) (int)x.size()

typedef  vector<string> vs;
typedef  vector<int> vi;


int main(){
	
	int n,m; 
	
	string s; 
	
	cin >> n >> m; 
	
	vs v;
	
	int ans[n+1][m+1];
	
	f(i,0,n){
		f(j,0,m){
			ans[i][j] = 0;
		}
	}
	
	
	f(i,0,n){
		cin >> s;
		
		v.pb(s);
	}
	
	bool ok;
	
	f(i,0,n){
		ok = true;
		f(j,0,m){
			if(v[i][j]=='#'){
				ok = false;
				break;
			}
		}
		
		if(ok){
			f(j,0,m){
				ans[i][j] = 1;
			}
		}
	}
	
	f(j,0,m){
		ok = true;
		f(i,0,n){
			if(v[i][j]=='#'){
				ok = false; 
				break;
			}
		}

		if(ok){
			f(i,0,n){
				ans[i][j] = 1;
			}
		}
	}
	
	f(i,0,n){
		ok = true;
		f(j,0,m){
			if(!ans[i][j]){
				cout <<v[i][j];
				ok = false;
			}
		}
		
		if(!ok)cout << endl;
	}
	
	return 0;
	
	
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, m = [int(w) for w in input().split()]
ls = [[int(w) for w in input().split()] for _ in range(n)]
lp = [[int(w) for w in input().split()] for _ in range(m)]

for a, b in ls:
    ans = -1
    dist = 10e10
    for i, (c, d) in enumerate(lp):
        d = abs(a-c) + abs(b-d)
        if d < dist:
            ans = i
            dist = d
    print(ans+1)


Measured memory_bytes: 9160
class Dice_roll:
    face_num = []
    def move(self,way):
        if way == "N":
            self.face_num = [self.face_num[1],self.face_num[5],self.face_num[2],self.face_num[3],self.face_num[0],self.face_num[4]]
            
        elif way == "S":
            self.face_num = [self.face_num[4],self.face_num[0],self.face_num[2],self.face_num[3],self.face_num[5],self.face_num[1]]
            
        elif way == "W":
            self.face_num = [self.face_num[2],self.face_num[1],self.face_num[5],self.face_num[0],self.face_num[4],self.face_num[3]]
            
        elif way == "E":
            self.face_num = [self.face_num[3],self.face_num[1],self.face_num[0],self.face_num[5],self.face_num[4],self.face_num[2]]        

dice = Dice_roll()
               
dice.face_num = list(map(int,input().split()))

direction = str(input())
  
for i in direction:
    dice.move(i)

print(dice.face_num[0])


Measured memory_bytes: 5600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main()
{
    ll N;
    cin >> N;
    vector<ll> X(N);
    rep(i, N) cin >> X[i];
    ll xtotal = accumulate(all(X), (ll)0);
    double P = (double)xtotal / N;
    if ((P - floor(P)) >= 0.5)
    {
        P = ceil(P);
    }
    else
    {
        P = floor(P);
    }
    double ans = 0;
    rep(i, N)
    {
        ans += pow(X[i] - P, 2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define endl "\n"
using namespace std;


int main() {
ll n,ac=0,tle=0,wa=0,re=0;
cin>>n;
for(ll i=0;i<n;i++)
{
    string s;
    cin>>s;
    if(s=="AC")
    ac++;
    else
    if(s=="WA")
    wa++;
    else if(s=="TLE")
    tle++;
    else
    if(s=="RE")
    re++;
    
}
cout<<"AC x "<<ac<<endl<<"WA x "<<wa<<endl<<"TLE x "<<tle<<endl<<"RE x "<<re<<endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int a,b;
  cin>>a>>b;
  cout<<((a-1)*(b-1))<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,a,b;
    cin>>n;
    int res=inf;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        res=min(res,a+b);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n,a,b;
  cin>>n;
  if(n == 1) {
    cout << "Hello World" << endl;
    return 0;
  } else {
    cin>>a>>b;
    cout << a + b << endl;
  }

  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    ll a[100100]; rep(i, N) cin >> a[i];
    if(N % 3 == 0) {
        sort(a, a + N);
        if(a[0] == 0 && a[N - 1] == 0) Yes();
        int n = N / 3;
        ll b = a[0], c = a[n], d = a[2 * n];
        if((b ^ c) == d && a[n - 1] == b && a[2 * n - 1] == c && a[N - 1] == d) {
            Yes();
        }
        No();
    } else {
        sort(a, a + N);
        if(a[0] == 0 && a[N - 1] == 0) Yes();
        No();
    }
	return 0;
}

Measured memory_bytes: 1024
h,w=map(int,input().split())
g=[input() for _ in range(h)]

dp=[[0]*w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if g[i][j]=="#":
            continue
        if i==0 and j==0:
            dp[i][j]=1
        elif i==0:
            dp[i][j]=dp[i][j-1]
        elif j==0:
            dp[i][j]=dp[i-1][j]
        else:
            dp[i][j]=dp[i-1][j]+dp[i][j-1]

print(dp[h-1][w-1]%(10**9+7))


Measured memory_bytes: 212476
N = int(input())
H = [int(i) for i in input().split()]

lastHeight = 0
for idx in range(len(H)):
    if H[idx] < lastHeight:
        print("No")
        break
    elif H[idx] == lastHeight:
        lastHeight = H[idx]
    else:
        lastHeight = H[idx] - 1
else:
    print("Yes")


Measured memory_bytes: 14396
using System;

namespace Project
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			int N = int.Parse(Console.ReadLine());
			string[] s = Console.ReadLine().Split(' ');
			int[] a = new int[s.Length];
			for (int i = 0; i < s.Length; i++)
			{
				a[i] = int.Parse(s[i]);
			}

			for (int i = 0; i < s.Length; i++)
			{
				Console.Write(a[i]);
				if (i < s.Length - 1) Console.Write(" ");
				if (i == s.Length - 1) Console.Write("\n");
			}

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

				for (int k = 0; k < s.Length; k++)
				{
					Console.Write(a[k]);
					if (k < s.Length - 1) Console.Write(" ");
					if (k == s.Length - 1) Console.Write("\n");
				}
			}
		}
	}
}

Measured memory_bytes: 9296
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;

void main()
{
	foreach (line; stdin.byLine) {
		auto x = line.chomp.to!int;
    if (!x) break;
    int sum;
		foreach (i; 0..x/4) {
      sum += readln.chomp.to!int;
    }
    sum.writeln;
	}
}

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

using namespace std;
typedef long long ll;

const int maxn = 2e5 + 10;

vector<int> t[maxn];
int h[maxn];

void dfs(int v, int par = -1){
	for (auto u : t[v])
		if (u != par){
			h[u] = h[v] + 1;
			dfs(u, v);
		}
}

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++){
		int v, u;
		cin >> v >> u;
		t[v].push_back(u);
		t[u].push_back(v);
	}
	dfs(1);
	int v = max_element(h + 1, h + n + 1) - h;
	h[v] = 0;
	dfs(v);
	int q = *max_element(h + 1, h + n + 1) + 1;
	if (q % 3 == 2)
		return cout << "Second\n", 0;
	cout << "First\n";
}


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

constexpr int N = 100009, X = 7;
int n;
int A, B, C;
int8_t dp[N][X][X][X];
char choice[N][X][X][X];
string s[N];

auto go(int i, int a, int b, int c) -> int8_t {
  if(a < 0 || b < 0 || c < 0 || a >= X || b >= X || c >= X) return 0;
  if(i == n + 1) return 1;
  if(dp[i][a][b][c] != -1) return dp[i][a][b][c];
  if(s[i] == "AB") {
    dp[i][a][b][c] = go(i + 1, a - 1, b + 1, c) | go(i + 1, a + 1, b - 1, c);
    if(go(i + 1, a - 1, b + 1, c)) choice[i][a][b][c] = 'B';
    else choice[i][a][b][c] = 'A';
  }
  if(s[i] == "AC") {
    dp[i][a][b][c] = go(i + 1, a - 1, b, c + 1) | go(i + 1, a + 1, b, c - 1);
    if(go(i + 1, a - 1, b, c + 1)) choice[i][a][b][c] = 'C';
    else choice[i][a][b][c] = 'A';
  }
  if(s[i] == "BC") {
    dp[i][a][b][c] = go(i + 1, a, b + 1, c - 1) | go(i + 1, a, b - 1, c + 1);
    if(go(i + 1, a, b + 1, c - 1)) choice[i][a][b][c] = 'B';
    else choice[i][a][b][c] = 'C';
  }
  return dp[i][a][b][c];
}

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  fill((int8_t*) dp, (int8_t*) dp + N * X * X * X, -1);
  cin >> n >> A >> B >> C;
  for(int i = 1; i <= n; ++i) {
    cin >> s[i];
  }
  A = min(A, 5);
  B = min(B, 5);
  C = min(C, 5);
  if(go(1, A, B, C) == 0) {
    cout << "No\n"; 
  } else {
    cout << "Yes\n";
    int i = 1;
    while(i != n + 1) {
      char x = choice[i][A][B][C];
      cout << x << '\n';
      if(x == 'A') A += 1;
      if(x == 'B') B += 1;
      if(x == 'C') C += 1;
      char y;
      if(s[i][0] != x) y = s[i][0];
      else y = s[i][1];
      if(y == 'A') A -= 1;
      if(y == 'B') B -= 1;
      if(y == 'C') C -= 1;
      i += 1;
    }
  }
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001;

int N;
vint G[111111];

int K;

int dfs(int v,int p){
    vint a;
    for(auto u:G[v]){
        if(u==p)continue;
        int tmp=dfs(u,v);
        if(tmp==INF)return INF;
        a.pb(tmp);
    }

    sort(all(a));
    if(p==-1)return 0;
    if(a.size()==0)return 1;

    if(a.size()%2==0){
        bool f=true;
        rep(i,a.size()/2)if(a[i]+a[a.size()-i-1]>K)f=false;
        if(f)return 1;
        a.pop_back();
    }

    int lb=-1,ub=a.size();
    while(ub-lb>1){
        int mid=(ub+lb)/2;

        bool f=true;
        int l=0,r=a.size()-1;
        rep(i,a.size()/2){
            if(l==mid)l++;
            if(r==mid)r--;
            if(a[l]+a[r]>K)f=false;
            l++;r--;
        }
        if(f)ub=mid;
        else lb=mid;
    }
    if(ub==a.size())return INF;
    if(a[ub]+1>K)return INF;
    return a[ub]+1;
}

bool C(int x){
    K=x;
    rep(i,N)if(G[i].size()==1)return dfs(i,-1)!=INF;
}

signed main(){
    cin>>N;
    rep(i,N-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);G[b].pb(a);
    }

    int cnt=0;
    rep(i,N)if(G[i].size()%2)cnt++;

    int A=cnt/2;

    int lb=0,ub=N;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        if(C(mid))ub=mid;
        else lb=mid;
    }

    cout<<A<<" "<<ub<<endl;
    return 0;
}


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

#define PI 3.141592653589
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vv vector
int MOD=1e9+7;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
ll min(ll a,ll b){return (a>b)?b:a;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime[1000001];
vi primes;
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for(int p=2;p<1000001;p++)
        if(prime[p])
            primes.pb(p);
}
ll fact[1001];
void factorial(int n){
    fact[0]=1;
    for(int i=1;i<=n;i++)
        fact[i]=fact[i-1]*i,fact[i]%=MOD;
}
ll ncr(ll n,ll r)
{
    if(n<r)
        return -1;
    else{
        ll x=fact[r]*fact[n-r]%MOD;
        return fact[n]*fermat_inv(x)%MOD;
    }
}

ll check(vi v,ll c[],int k)
{
    int l=v.size();
    ll x=k/l,y=k%l;
    ll sum=0;
    for(int i:v)
        sum+=c[i];
    ll a[l+1];
    a[0]=0;
    for(int i=0;i<l;i++)
        v.pb(v[i]);
    for(int i=1;i<=l;i++){
        ll s=0;
        for(int j=0;j<i;j++)
            s+=c[v[j]];
        a[i]=s;
        for(int j=1;j<l;j++)
            s+=c[v[j+i-1]]-c[v[j-1]],a[i]=max(a[i],s);
    }
    ll ans=LLONG_MIN;
    if(!x||sum<=0){
        for(int i=1;i<=min(l,k);i++)
            ans=max(ans,a[i]);
    }
    else if(sum>0){
        ans=x*sum;
        for(int i=1;i<=l;i++){
            if(i<=y)
                ans=max(ans,x*sum+a[i]);
            else
                ans=max(ans,(x-1)*sum+a[i]);
        }
    }
    return ans;
}

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

    int t=1;
    //cin>>t;
    //SieveOfEratosthenes(1000000);
    //factorial(1000);
    while(t--){
        int n,k;
        cin>>n>>k;
        int p[n+1];
        ll c[n+1];
        for(int i=1;i<=n;i++)
            cin>>p[i];
        for(int i=1;i<=n;i++)
            cin>>c[i];
        ll ans=LLONG_MIN;
        int vis[n+1]={0};
        for(int i=1;i<=n;i++){
            if(vis[i])
                continue;
            vis[i]=1;
            int j=p[i];
            vi v;
            v.pb(i);
            while(!vis[j]){
                v.pb(j);
                vis[j]=1;
                j=p[j];
            }
            ans=max(ans,check(v,c,k));
        }
        cout<<ans<<'\n';
    }
}


Measured memory_bytes: 3844
#include<bits/stdc++.h>
#include<array>
using namespace std;
#define int long long
// #define ll long long
#define endl "\n"
#define fast_cin ios_base::sync_with_stdio(false); cin.tie(NULL)

void solve(){
 
    int n;
    cin >> n;
    cout << !n;
}
 
int32_t main(){
 
    fast_cin;
    // int t;
    // cin >> t;
    // while(t-- > 0){
        solve();
        cout << "\n";
    // }
    
    return 0;
}

Measured memory_bytes: 3648
////////////////いろいろあるよ//////////////////////////////////
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream>
 #include<bitset>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;

//bit
 /*
 const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
 const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
 const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
 const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
 const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
 const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
 const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
 const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000 
 */

//variable
 //const int INF = 1000000;
 //int dp[INF][INF];
 //int ans=0;

 //int dx[4]={1,0,-1,0};
 //int dy[4]={0,1,0,-1};

int N=0;
int M=0;
////////////////いろいろあるよ//////////////////////////////////

int main(){
 	cin >> N >> M;
  	bool tf[N];
  	REP(i,N)tf[i] = false;
  	int acsu=0;
  	int wasu[N];
  	pair<int,string> data[M];
  	REP(i,M)cin >> data[i].first >> data[i].second;
  	REP(i,M){
      	if(data[i].second == "AC" && tf[data[i].first-1]==false){
        	tf[data[i].first-1]=true;
          	acsu++;
        }else if(data[i].second == "WA" && tf[data[i].first-1]==false){
        	wasu[data[i].first-1]++;
        }
      
    }
  int wasuans=0;
  	REP(i,N){
    if(tf[i]==true){
      	wasuans += wasu[i];
    }
    }
	
  	cout << acsu << " " << wasuans << endl;
  	
	
 	return 0;
}

Measured memory_bytes: 6912
#include "bits/stdc++.h"
#include<cstdio>
#include<fstream>
#include<vector>
#include<string>
#include<iostream>
#include<math.h>

using namespace std;

int main(void){

    int year, month, day;
    char c1, c2;

    cin >> year >> c1 >> month >> c2 >> day;

    if(month >=5){
        cout << "TBD" << endl;
    }
    else{
        cout << "Heisei" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
def main():
  S=input()
  N=int(input())
  cnt=0
  f=''
  b=''
  for i in range(N):
    tmp=[i for i in input().split() ]
    if tmp[0]=='1':
      cnt+=1
    else:
      if (cnt+int(tmp[1]))%2==1:
        f=tmp[2]+f
        
      else:
        b=b+tmp[2]
  ans=f+S+b        
  if cnt%2!=0:
    ans=''.join(list(reversed(ans)))

  print(ans)
if __name__=='__main__':
  main()
   


Measured memory_bytes: 6396
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    string S, T;
    cin >> S >> T;

    map<char, char> map1;
    map<char, char> map2;
    REP(i, S.size()) {
        char s = S[i];
        char t = T[i];

        if (map1.count(s) > 0)
        {
            char ns = map1[s];
            if (ns != t) {
                cout << "No" << endl;
                return 0;
            }
        }

        if (map2.count(t) > 0) {
            char nt = map2[t];
            if (nt != s) {
                cout << "No" << endl;
                return 0;
            }
        }

        if (map1.count(s) == 0) {
            map1[s] = t;
        }
        if (map2.count(t) == 0) {
            map2[t] = s;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 916
#include <cstdio>

int gdp(int a, int b) {
	int r = a % b;
	if(r == 0){
		return b;
	}else {
		return gdp(b, r);
	}
}

int main() {
	int x, y;
	scanf("%d %d", &x, &y);
	printf("%d\n",gdp(x ,y));
	return 0;
}


Measured memory_bytes: 2760
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    V, E = next(it), next(it)

    ee = [-1] * V
    def find(a):
        q = []
        while ee[a] >= 0:
            q.append(a)
            a = ee[a]
        for i in q:
            ee[i] = a
        return a
    def union(a, b):
        ai = find(a)
        bi = find(b)

        r1, r2 = ee[ai],  ee[bi]
        if r1 > r2:
            ai, bi = bi, ai

        ee[bi] = ai
        if r1 == r2:
            ee[ai] -= 1
    def same(a, b):
        ai = find(a)
        bi = find(b)

        return ai == bi

    ans = 0
    for si, ti, wi in sorted(zip(it, it, it), key=lambda x: x[2]):
        if same(si, ti):
            continue
        ans += wi
        union(si, ti)

    print(ans)

if __name__ == "__main__":
    resolve()



Measured memory_bytes: 42600
#include<bits/stdc++.h>
using namespace std;
string s;
int main ()
{
	  cin>>s;
	
	int n=s.size();
	int cnt=0;
	for(int i=0;i<n;i++){
		if(s[i]!=s[n-1-i])
		cnt++;
		
	}
	
	cout<<cnt/2<<endl;
	
 
 
}
 

Measured memory_bytes: 3552
#include<bits/stdc++.h>
#define Mod 998244353
#define N 305
using namespace std;
int n,m,x,ans,bin[N],vis[N];bitset<N>a[N],tmp[N];
int main(){
	bin[0]=1;
	for (int i=1;i<N;i++) bin[i]=1ll*bin[i-1]*2%Mod;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			scanf("%d",&x);
			a[i][j]=x;
		}
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			if (a[i][j]){
				if (vis[j])
					a[i]^=tmp[j];
				else {
					vis[j]=1;
					tmp[j]=a[i];
					break;
				}
			}
		}
	}
	for (int i=1;i<=m;i++) ans+=vis[i];
	int tmpp=(bin[n]-bin[n-ans]+Mod)%Mod;
	tmpp=1ll*tmpp*bin[m-1]%Mod;
	printf("%d\n",tmpp);
	return 0;
}

Measured memory_bytes: 256
// C - Write and Erase
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	set<int> S;
	rp(i, 0, N){
		int a; scanf("%d", &a);
		if(S.find(a) == S.end()) S.insert(a);
		else S.erase(a);
	}
	printf("%d\n", (int)S.size());
}

Measured memory_bytes: 4864
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt(),b=scan.nextInt();
		if((a+b)%3==0 || a%3==0||b%3==0) {
			System.out.println("Possible");
		}
		else {
			System.out.println("Impossible");
		}

	}

}

Measured memory_bytes: 35804
import java.util.*;

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

		int a=sc.nextInt();
		int b=sc.nextInt();
		int total=1;
		int count=0;
		for(int i=0;;i++){
			if(total>=b){
				break;
			}
			total--;
			total+=a;
			count++;
		}
		System.out.println(count);


	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void solve(){
  #ifndef ONLINE_JUDGE    
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
struct ans{
ll c,nn;
vector<ll> b; 
};
inline bool chmin(ll &a,ll b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf   
    ll n,m;
    cin>>n>>m; 
    struct ans x[m];
    set<ll> p; 
    for(ll i=0;i<m;i++){
      cin>>x[i].c>>x[i].nn;
      for(ll j=0;j<x[i].nn;j++){
        ll a; 
        cin>>a; 
        x[i].b.pb(a);
        p.insert(a);
      } 
    }
    if(p.size()<n){
      cout<<-1;
      exit(0);
    }
    else{
     ll M=1e9;
     vector<ll> u(5000,M); 
     u[0]=0;
     for(ll i=0;i<m;i++){
       ll ans=0;
       for(ll j=0;j<(x[i].nn);j++){
         ans|=1<<(x[i].b[j]-1);
       }
       for(ll j=0;j<(1<<n);j++){
         chmin(u[ans|j],u[j]+x[i].c);
       }
     }
     //if(u[(1<<n)-1]==m) u[(1<<n)-1]=-1;
     cout<<u[(1<<n)-1]<<endl; 
    }
    //printclock;
    return 0;
}
    

Measured memory_bytes: 512