akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#ifdef LOCAL
	#define debug(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define debug(...) 42
#endif

#define sf scanf
#define pf printf
#define nl printf("\n")
#define ps(s) printf("%s",s.c_str())
#define mem(x,val) memset(x,val,sizeof x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

inline string getString(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string getLine(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
typedef long long ll;

const int S=100100;
int main()
{
	int n,m;
	while(~sf("%d %d",&n,&m))
	{
		priority_queue<int>pq;
		for(int i=0;i<n;i++)
		{
			int x;
			sf("%d",&x);
			pq.push(x);
		}

		for(int i=0;i<m;i++)
		{
			int top=pq.top();
			pq.pop();

			top/=2;
			pq.push(top);
		}

		ll sum=0;
		while(!pq.empty())
		{
			sum+=pq.top();
			pq.pop();
		}
		pf("%lld\n",sum);
	}
    return 0;
}



































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

int main() {
  int N, alice = 0, bob = 0;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      alice += vec.at(i);
    }
    else {
      bob += vec.at(i);
    }
  }
  cout << alice - bob << endl;
}



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

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

    int ans = a + b;

    if (ans < 10)
        cout << ans << endl;
    else
        cout << "error" << endl;
    return 0;
}


Measured memory_bytes: 3596
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		int work[] = new int[m];
		int ans = 0;
		for(int i = 0; i < m; ++i){
			work[i] = sc.nextInt();
			ans += work[i];
		}
		ans = n - ans;
		if(ans < 0)ans = -1;
		sc.close();
		System.out.println(ans);
	}
}


Measured memory_bytes: 46360
n, k = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

cur = 0
cnt = Array.new(n, -1)
while cnt[a[cur] - 1] == -1 && k > 0
  cnt[a[cur] - 1] = cnt[cur] + 1
  cur = a[cur] - 1
  k -= 1
end

k %= (cnt[cur] - cnt[a[cur] - 1] + 1)

while k > 0
  cnt[a[cur] - 1] = cnt[cur] + 1
  cur = a[cur] - 1
  k -= 1
end

puts cur + 1

Measured memory_bytes: 30164
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll a,b,c,k;

int main(){
  ll ans=0;
  cin >> a>>b>>c>>k;

  ll i=0;
  b+=a;
  c+=b;

  if (k<=c)ans=a-(k-b);
  if (k<=b)ans=a;
  if (k<=a)ans=k;
  

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

Measured memory_bytes: 3592
[N, X, Y] = list(map(int, input().split()))
Answer = [0 for i in range(1, N)]
for i in range(1, N):
    for j in range(i+1, N+1):
        Z = min(abs(X-i)+abs(j-Y)+1, j-i)
        Answer[Z-1] += 1
[print(i) for i in Answer]

Measured memory_bytes: 3444
import java.util.*;

class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int H,W,A,B;
        H = sc.nextInt();
        W = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();

        sc.close();

        for (int i = 1;i <= H;i++) {       
            for (int j = 1;j <= W;j++) {

                if(i > B) {
                    if (j <= A) {
                        System.out.print("0");
                    } else {
                        System.out.print("1");
                    }
                } else {
                    if (j <= A) {
                        System.out.print("1");
                    } else {
                        System.out.print("0");
                    }
                }

            }
            System.out.println();
        }
}
}

Measured memory_bytes: 45120
from collections import deque
h, w = map(int, input().split())
a = ['#' * (w+2)] + ['#' + input() + '#' for i in range(h)] + ['#' * (w+2)]
for i in range(h+2):
    a[i] = list(a[i])

d = [(1, 0), (0, 1), (-1, 0), (0, -1)]
x = []
for i in range(1, h+1):
    for j in range(1, w+1):
        if a[i][j] == '#':
            x.append((i, j, 0))

q = deque(x)
ans = 0
while q:
    i, j, c = q.popleft()
    for di, dj in d:
        if a[i+di][j+dj] == '.':
            a[i+di][j+dj] = '#'
            q.append((i+di, j+dj, c+1))
    ans = max(ans, c)


print(ans)


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

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2 == 0) return false;

  double sqrtNum = sqrt(n);
  for(int i=3;i<=sqrtNum;i+=2){
    if(n%i==0){
      return false;
    }
  }
  return true;
}

int main(){
  int q;
  cin>>q;
  vector<int> l(q),r(q);
  for(int i=0;i<q;i++) cin>>l[i]>>r[i];

  int range = 100001;
  vector<int> ans(range);
  ans[0]=0;
  ans[1]=0;
  ans[2]=0;
  for(int i=3;i<=range;i++){
    ans[i] = ans[i-1];
    if(isPrime(i) && isPrime((i+1)/2)) ans[i]++;
  }

  for(int i=0;i<q;i++){
    cout << ans[r[i]]-ans[l[i]-1] << endl;
  }
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
ll s[maxn];
ll f[maxn];
int main()
{
	ll n;cin>>n;
	for(ll i=0;i<n;i++)
	{
		scanf("%lld",&s[i]);
	}
	//ll c=1;
	ll mx=0;
	for(ll c=1;c<n-1;c++)
	{
		ll sz=(n-2)/c;
		unordered_map<ll,ll> mp;
		ll ans=0;
		for(ll k=1;k<=sz;k++)
		{
			if(n-1-k*c-c<=0) continue;
			if(mp.count(n-1-k*c)) break;
			mp[n-1-k*c]++;
			if(mp.count(k*c)) break;
			mp[k*c]++;
			ans+=s[k*c]+s[n-1-k*c];
			mx=max(ans,mx);
		 } 
	}
	cout<<mx<<endl;
}

Measured memory_bytes: 5168
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


int main(){
	int n,m;
	while(cin>>n,n){
		cin>>m;
		string s;
		cin>>s;
		int state=0;
		int ans=0;
		int cnt=0;
		REP(i,s.size()){
			if(s[i]=='I'){
				state=1;
				cnt=0;
			}else if(s[i]=='O'){
				if(state==1){
					if(i<s.size()-1&&s[i+1]=='I'){
						i++;
						cnt++;
					}else{
						state=0;
					}
				}
			}else{
				state=0;
			}
			if(cnt==n){
				ans++;
				cnt--;
			}
			if(state==0){
				cnt=0;
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define INF 100000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(i, vec.size()) cout << vec[i] << " "; print("");
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using vvs = vector<vector<string>>;


void solve(){

	ll N, K;
	cin >> N >> K;
	vl D(10);
	rep(i, K){
		ll in_;		
		cin >> in_;
		D[in_] = 1;
	}
	
	rep2(i, N, 100000){
		bool flg = 1;
		string s = to_string(i);
		rep(j, s.size()){
			if(D[s[j] - '0']) flg = 0;
		}
		if(flg){
			print(i);
			return;	
		}	
	}
	
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	solve();
    
	return 0;
	
}





Measured memory_bytes: 3704
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N = int(input())

A = []
for i in range(N):
    A.append(list(map(int, input().split())))

A = sorted(A, key=lambda x: x[1])

t = 0
for i in range(N):
    t += A[i][0]
    if t > A[i][1]:
        print("No")
        sys.exit()

print("Yes")




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

#define rep(i,n) for(int i = 0;i < n;++i)
#define rep2(i,n,m) for(int i = n;i < m;++i)
#define all(v) v.begin(),v.end()

using namespace std;
using ll = long long;

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

    ll n,h,k,l=0,sum = 0;
    cin >> h;

    while(h > 1){
        h /= 2;
        l++;
    }
    ll a = pow(2,l);
    a += a-1;
    cout << a << endl;
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
//library begin
int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int log(int a){
    int b=a;
    int cnt=0;
    while(b%2==0){
        b/=2;
        cnt++;
    }
    return cnt;
}
//library end
int n,m;
int pro[200000];
string jud[200000];
set<int>ac;
bool b[200000];
int acc=0,pen=0;
signed main(){
    cin>>n>>m;
    rep(i,m){
        cin>>pro[i]>>jud[i];
        if(jud[i]=="AC"){
            ac.insert(pro[i]);
        }
    }
    acc=ac.size();
    rep(i,m){
        if(jud[i]=="AC"){
            b[pro[i]]=true;
        }
        else{
            if(!b[pro[i]]&&ac.find(pro[i])!=ac.end()){
                pen++;
            }
        }
    }
    cout<<acc<<" "<<pen<<endl;
    return 0;
}



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

int x,y,ans;

int main(){
	cin>>x>>y;
	if(x==1) ans+=300000;
	if(x==2) ans+=200000;	
	if(x==3) ans+=100000;
	if(y==1) ans+=300000;
	if(y==2) ans+=200000;	
	if(y==3) ans+=100000;
	if(x==1&&y==1) ans+=400000;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
S = input()
p = len(S)
while 0<p:
  if 0<=p-5 and S[p-5:p]=='dream':
    p -= 5
    continue
  elif 0<=p-7 and S[p-7:p]=='dreamer':
    p -= 7
    continue
  elif 0<=p-6 and S[p-6:p]=='eraser':
    p -= 6
    continue
  elif 0<=p-5 and S[p-5:p]=='erase':
    p -= 5
    continue
  else:
    print('NO')
    break
else:
  print('YES')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  ll s;
  cin >> s;
  ll x1 = 0, y1 = 0;
  ll a = sqrt(s);
  while (a * a > s) --a;
  while (a * a < s) ++a;
  ll d = a;
  if (a * (a - 1) >= s) d = a - 1;
  ll b = a * d - s;
  ll c = 1;
  cout << x1 << ' ' << y1 << ' ' << a << ' ' << b << ' ' << c << ' ' << d << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<int> v;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }

  multiset<int> ms;
  rep(i,N){
    auto it = ms.upper_bound(-v[i]);
    if(it == ms.end()){
      ms.insert(-v[i]);
    }else{
      ms.erase(it);
      ms.insert(-v[i]);
    }
  }
    
  cout << ms.size() << endl;
  
  return 0;
}


Measured memory_bytes: 5368
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 200030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;

int main()
{
string s,ss,sss;
int a,b;
cin>>s>>ss>>a>>b>>sss;
if(sss==s)
a--;
else
b--;
cout<<a<<" "<<b;



	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int t=max({a, b, c}), ans=t*pow(2, k)+a+b+c-t;

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

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    long long a[n];
    REP(i, n)
    {
        cin >> a[i];
    }
    int cnt = 0;
    long long sum = 0;
    long long minv = 1e10;
    REP(i, n)
    {
        sum += abs(a[i]);
        if (abs(a[i]) < minv)
        {
            minv = abs(a[i]);
        }
        if (a[i] < 0)
        {
            cnt++;
        }
    }
    if (cnt % 2 == 0)
    {
        cout << sum << endl;
    }
    else
    {
        cout << sum - 2 * minv << endl;
    }
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
    int i,j,r,c,u,x[101][101],sum = 0,sumr[101] = {},sumc[101] = {};
    scanf("%d %d",&r,&c);
    for( i = 1 ; i <= r ; i += 1 ){
        for( j = 1 ; j <= c ; j += 1){
            scanf("%d",&x[i][j]);
            sumr[i] = sumr[i] + x[i][j];
        }
        sum = sum + sumr[i];
    }
    for( i = 1 ; i <= c ; i += 1){
        for( j = 1 ; j <= r ; j += 1){
            sumc[i] = sumc[i] + x[j][i];
        }
    }
    for( i = 1 ; i <= r + 1 ; i += 1){
        if( i == r + 1 ){
            for( j = 1 ; j <= c + 1 ; j += 1 ){
                if( j == c + 1 ){
                    printf("%d\n",sum);
                    break;
                }
                printf("%d ",sumc[j]);
            }
        }
        else{
            for( j = 1 ; j <= c + 1 ; j += 1 ){
                if( j == c + 1 ){
                    printf("%d\n",sumr[i]);
                }
                else{
                    printf("%d ",x[i][j]);
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <climits>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

#define cin_desync()                      \
	do {                                  \
		ios_base::sync_with_stdio(false); \
		cin.tie(0);                       \
	} while (0)                           \

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

typedef long double ld;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

int main()
{
	int X, Y;
	cin >> X >> Y;

	if (X % Y == 0) {
		cout << -1 << endl;
	} else {
		cout << X << endl;
	}
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll dmod=10000000000000000,keta=0;
  ll d,c,bf=0,M,ans=-1;
  cin>>M;
  while(M--){
    cin>>d>>c;
    ans+=c;
    bf+=d*c;
    ans+=(bf-1)/9;
    if(bf%9==0)bf=9;
    else bf%=9;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define p pair<int,int>
#define P pair<ll,ll>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define db double
#define zero(a) memset(a,0,sizeof(a))
#define inff(a,n) fill(a,a+n+1,inf)
#define all(a) a.begin(),a.end()
#define sz(a) int((a).size())
#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define write(x) printf("%d\n",x)

const int maxn=1e6;
const ll inf=1e9;
const int base1=31,base2=127;

int n,m,cnt,ans,flag=1,a[maxn];
vector<int>v[maxn];

void dfs(int u,int fa)
{
    for(auto i:v[u])
    {
        if(i==fa)continue;
        if(a[i]==-1)
        {
            a[i]=(a[u]^1);
            dfs(i,u);
        }
        else
        {
            if(a[i]==a[u])flag=0;
        }
    }
}

int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    memset(a,-1,sizeof(a));
    a[1]=0;
    dfs(1,0);
    if(flag)
    {
        for(int i=1;i<=n;i++)if(a[i])cnt++;
        cout<<1ll*cnt*(n-cnt)-m;
    }
    else
    {
        cout<<1ll*n*(n-1)/2-m;
    }
    return 0;
}

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

using namespace std;

template<typename T>
struct BinaryIndexedTree {
    vector<T> data;

    void init(int n) {
        data.assign(++n, 0);
    }

    T sum(int k) {
        T ret = 0;
        for (++k; k > 0; k -= k & -k) ret += data[k];
        return (ret);
    }

    void add(int k, T x) {
        for (++k; k < data.size(); k += k & -k) data[k] += x;
    }
};

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

    vector<BinaryIndexedTree<int>> BITs(26);
    for (int i = 0; i < 26; i++)BITs[i].init(n);
    for (int i = 0; i < n; i++) BITs[s[i] - 'a'].add(i, 1);

    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int ope;
        cin >> ope;
        if (ope == 1) {
            int index;
            char c;
            cin >> index >> c;
            index--;
            BITs[s[index] - 'a'].add(index, -1);
            s[index] = c;
            BITs[s[index] - 'a'].add(index, 1);
        } else {
            int l, r;
            cin >> l >> r;
            l--, r--;

            int ret = 0;
            for (int j = 0; j < 26; j++) {
                if (BITs[j].sum(r) != BITs[j].sum(l - 1)) ret++;
            }
            cout << ret << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 51716
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    a--; b--;
    swap(a, b);
    vector<vector<int>> G(n);
    for (int i = 0; i < n-1; ++i) {
        int x, y;
        scanf("%d %d", &x, &y);
        x--; y--;
        G[x].emplace_back(y);
        G[y].emplace_back(x);
    }
    vector<vector<int>> G2(n);
    vector<int> dep(n), par(n);
    auto dfs = [&](int x, int p, auto &&f) -> void {
        for (auto &&i : G[x]) {
            if(i != p){
                G2[x].emplace_back(i);
                par[i] = x;
                f(i, x, f);
            }
        }
    };
    dfs(a, -1, dfs);
    vector<int> dp(n);
    auto ff = [&](int x, int val, auto &&f) -> int {
        dep[x] = val;
        int a = 0;
        for (auto &&i : G2[x]) {
            a = max(a, f(i, val+1, f));
        }
        dp[x] = a;
        return a+1;
    };
    ff(a, 0, ff);
    int aa = dep[b]/2, bb = dep[b]-aa;
    {
        int c = b;
        for (int i = 0; i < bb; ++i) {
            c = par[c];
        }
        a = c;
    }
    for (int i = 0; i < aa; ++i) {
        b = par[b];
    }
    cout << dp[b]+bb-1 << "\n";
    return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, b, e) for (int i = (int)(b); i <= (int)(e); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long i64;
typedef unsigned long long u64;
typedef long double ld;
typedef long long ll;
// #define sz(x) int((x).size())

int k, n;
int a[105];

int main() {
#ifdef LOCAL
    freopen("b.in", "r", stdin);
#endif

    cin >> k >> n;
    forn(i, n) cin >> a[i];
    int last = -1;
    forn(i, k) {
        int mx = -1000000;
        int bj = 0;
        forn(j, n) {
            int sc = a[j] - (j == last) * 10000;
            if (sc > mx) mx = sc, bj = j;
        }
        if (bj == last || a[bj] == 0) { cout << k-i << endl; return 0; }
        last = bj;
        --a[bj];
//         cerr << bj << endl;
    }
    cout << 0 << endl;

#ifdef LOCAL
    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
#endif
    return 0;
}


Measured memory_bytes: 256
// memo : A is smaller than Z
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  vector<string> Taro, Hanako;
  string s1, s2;
  int i, j, n, Taro_Score = 0, Hanako_Score = 0, end_checker;
  
  cin >> n;
  for(i = 0; i < n; i++) {
	cin >> s1 >> s2;
	Taro.push_back(s1);
	Hanako.push_back(s2);
  }
  
  for(i = 0; i < Taro.size(); i++) {
	end_checker = 0;
	for(j = 0; j < Taro[i].length(); j++) {
	  //T:cat,H:dog -> Taro wins
	  if(Taro[i][j] > Hanako[i][j]) {
		Taro_Score += 3;
		end_checker = 1;
		break;
	  }
	  //T:dog,H:cat -> Hanako wins
	  else if(Taro[i][j] < Hanako[i][j]) {
		Hanako_Score += 3;
		end_checker = 1;
		break;
	  }
	}
	if(end_checker == 1) {
	  continue;
	}
	
	if(Taro[i].length() > Hanako[i].length()) {
	  Taro_Score += 3;
	  end_checker = 1;
	}
	else if(Taro[i].length() < Hanako[i].length()) {
	  Hanako_Score += 3;
	  end_checker = 1;
	}
	else  {
	  Taro_Score++;
	  Hanako_Score++;
	  end_checker = 1;
	}
  }
  cout << Taro_Score << " " << Hanako_Score << endl;
  return 0;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
#define MOD 1e9+7
int main(){
  lint i,n;cin>>n;string nam;
  lint m,a,r,c,h;m=0;a=0;r=0;c=0;h=0;
  for(i=0;i<n;i++){
    cin>>nam;
    if(nam.at(0) =='M'){
       m++;
    }else if(nam.at(0) =='A'){
      a++;
    }else if(nam.at(0) =='R'){
      r++;
    }else if(nam.at(0) =='C'){
      c++;
    }else if(nam.at(0) =='H'){
      h++;
    }
  }
  llint ans=0;
  ans+=m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split(" ").map!{|item| item.to_i}
num = 1
ans = 1
th = 10**18
a.sort!{|a,b| (-1)*(a <=> b)}
if a[n - 1] == 0
    #puts a[n -1]
    puts 0
    exit
end
for num in 1..n do
    ans = ans * a[num-1]
    num = num + 1
    if ans > th
        ans = -1
        break
    end
end
puts ans

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

int n,cr=0,cw = 0;

string s;
int res = 0;
queue <int> v;
int main(){
    cin >> n;
    cin >> s;
    for(int i = 0;i<s.size();i++){
        if(s[i] == 'R') cr++;
    }
    cw = n - cr;
    for(int i = cr;i<n;i++){
        if(s[i] == 'R') v.push(i);
    }
    for(int i = 0;i<cr;i++){
        if(s[i] == 'W' && !v.empty()){
            res++;
            v.pop();
        }
    }
    cout << res + v.size() << endl;
    

    return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
#define MOD 1000000009
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    queue<ll> q1;
    for(int i=1;i<10;i++)
    {
        q1.push(i);
    }
    ll k;
    cin>>k;
    ll ans;
    while(k>=1)
    {
        ans=q1.front();
        ll num=ans%10;
        q1.pop();
        if(num>0)
        {
            q1.push(10*ans+num-1);
        }
        q1.push(10*ans+num);
        if(num<9)
        {
            q1.push(10*ans+num+1);
        }
        k--;
    }
    cout<<ans;
}

Measured memory_bytes: 1792
N=(int)(input())
p=(input()).split(' ')

count=0


now=1
for k in p:
    if (int)(k)==now:
        p[now-1:(now+1 if now<len(p) else now-3)]=[p[now-2],p[now-1]]
        count=count+1
    now=now+1

print(count)

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

int n;

int solve()
{
	string s;
	int l = 0,r = n;
	cout << 0 << endl;
	int lc,rc;
	cin >> s;

	if(s == "Vacant")
	{
		return 0;
	}
	else if(s == "Male")
	{
		lc = 0;
	}
	else
	{
		lc = 1;
	}

	while(l < r)
	{
		int m = (l + r) / 2;
		int mc;
		cout << m << endl;
		cin >> s;
		if(s == "Vacant")
		{
			return m;
		}
		else if(s == "Male")
		{
			mc = 0;
		}
		else
		{
			mc = 1;
		}

		int len = m - l;
		int plus = len % 2;
		if((mc + plus) % 2 == lc)
		{
			l = m;
			lc = mc;
		}
		else
		{
			r = m;
		}
	}
	return -1;
}








int main()
{
	cin >> n;
	int ans = solve();
	return 0;
}


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

int main(void) {
int a, b;
cin >> a >> b;
if (a==1) a = 14;
if (b==1) b = 14;
if (a>b) cout << "Alice";
if (a<b) cout << "Bob";
if (a==b) cout << "Draw";
cout << endl;
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
  int N,i,ans;
  int K[1001],P[1001];
  cin >> N;
  for(i=0;i<N;i++){
    cin >> K[i] >> P[i];
    ans = K[i]%P[i];
    if(ans==0) ans = P[i];
    cout << ans << '\n';
  }
  
  return 0;
}

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

vector <string> a, b, c;

void gen(int x, string str, vector <string> &v) {
	if(x == 0) {
		v.push_back(str);
		return;
	}
	for(int i = 1; i <= x; i++) {
		gen(x - i, str + string(1, '0' + i), v);
	}
}


struct AC {
    static const int K = 1 << 8;
    struct node {
        int nxt[K], go[K], link, leaf, par; 
        char pch;
        node(int par = -1, char pch = '$') : par(par), pch(pch) {
            fill(begin(nxt), end(nxt), -1);
            fill(begin(go), end(go), -1);
            leaf = false;
            link = -1;
        }
    };
    vector <node> tree;
    AC() {
        tree.resize(1);
    }
    int add(string str) {
        int ptr = 0;
        for(auto ch: str) {
            if(tree[ptr].nxt[ch] == -1) {
                tree[ptr].nxt[ch] = tree.size();
                tree.push_back(node(ptr, ch));
            }
            ptr = tree[ptr].nxt[ch];
        }
        tree[ptr].leaf = true;
        return ptr;
    }

    int get_link(int v) {
        if(tree[v].link == -1) {
            if(v == 0 || tree[v].par == 0) {
                tree[v].link = 0;
            } else {
                tree[v].link = go(get_link(tree[v].par), tree[v].pch);
            }
        }
        return tree[v].link;
    }
    int go(int v, char ch) {
        if(tree[v].go[ch] == -1) {
            if(tree[v].nxt[ch] != -1) {
                tree[v].go[ch] = tree[v].nxt[ch];
            } else {
                tree[v].go[ch] = (v == 0) ? 0 : go(get_link(v), ch);
            }
        }
        return tree[v].go[ch];
    }

}ac;

const int N = 1000000, mod = 1e9 + 7;

vector <int> adj[N];

int t[N], dp[44][N][2];

void dfs(int v, int p = 0) {
	t[v] = ac.tree[v].leaf | t[p];
	for(int u: adj[v]) {
		dfs(u, v);
	}
}

int f(int pos, int v, int r) {
	if(pos < 1) {
		return r;
	}
	if(~dp[pos][v][r]) {
		return dp[pos][v][r];
	}
	int res = 0;
	for(int i = 1; i <= 10; i++) {
		res += f(pos - 1, ac.go(v, (char)('0' + i)), r | ac.tree[ac.go(v, (char)('0' + i))].leaf);
		res %= mod;
	}
	return dp[pos][v][r] = res;
} 


int main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, x, y, z; cin >> n >> x >> y >> z;
	gen(x, "", a);
	gen(y, "", b);
	gen(z, "", c);

	for(auto p: a) {
		for(auto q: b) {
			for(auto r: c) {
				ac.add(p + q + r);
			}
		}
	}

	for(int i = 1; i < ac.tree.size(); i++) {
		adj[ac.get_link(i)].push_back(i);
	}

	dfs(0);
	memset(dp, -1, sizeof dp);
	cout << f(n, 0, 0) << endl;
}

Measured memory_bytes: 439096
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

using mint = modint998244353;

struct S {
  mint num;
  mint d;
  S() : num(0), d(0) {}
  S(mint num, mint d) : num(num), d(d) {}
};

S op(S a, S b) {
  return S(a.num + b.num, a.d + b.d);
}

S e() {
  return S(0, 0);
}

int id() {
  return 0;
}

S mapping(int f, S x) {
  if (f != id()) return S(x.d * f, x.d);
  else return x;
}

int composition(int f, int g) {
  if (f != id()) return f;
  else return g;
}


int main() {
  int N, Q;
  cin >> N >> Q;
  
  vector<S> init(N);
  init[N - 1] = {mint(1), mint(1)};
  for (int i = N - 1; i > 0; i--) {
    init[i - 1] = {init[i].num * 10, init[i].d * 10};
  }
    
  lazy_segtree<S, op, e, int, mapping, composition, id> seg(init);
  
  while (Q--) {
    int L, R, D;
    cin >> L >> R >> D;
    seg.apply(L - 1, R, D);
    cout << seg.all_prod().num.val() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 9896
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<sstream>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;

int main()
{
    LL a,b,k;
    cin >> a >> b >> k;
    if(k > a){
        k-=a;
        b-=k;
        cout << 0 <<" "<< max(0LL,b) << endl;
    }
    else{
        cout << a - k <<" "<<  b << endl;
    }
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
li = [0] * 31
for _ in range(n):
    a = list(map(int, input().split()))
    k = a[0]
    for i in range(1, len(a)):
        li[a[i]-1] += 1

cnt = 0
for i in li:
    if i >= n:
        cnt += 1
print(cnt)

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

int main(){
    int n;
    cin >> n;
    vector <double> v(n);
    rep(i,n) cin >> v[i];
    sort(all(v));

    double ans=v[0];
    for(int i=1; i<n; i++){
        ans = (ans + v[i])/2;
    }

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

}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        an: [usize; n]
    };

    let mut an = an;
    an.sort();

    let mut lank = an.iter().map(|x| x / 400).collect::<Vec<usize>>();
    lank.dedup_by(|a, b| a == b && *a < 8);

    let overred = lank.iter().filter(|x| **x > 7).collect::<Vec<&usize>>().len();
    let noverred = lank.iter().filter(|x| **x < 8).collect::<Vec<&usize>>().len();
    let min = if noverred > 0 {noverred} else {1};
    let max = overred + noverred;

    println!("{} {}", min, max);
}


Measured memory_bytes: 2088
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    ll D,N;
    std::cin >> D>>N;
    if(N!=100){
        std::cout << (ll)pow(100,D)*N << std::endl;
    }else{
        std::cout << 101*(ll)pow(100,D) << std::endl;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int ar[200005],ar2[200005],n;
int32_t main(){
	cin>>n;for(int i=1;i<=n;i++){cin>>ar[i];ar2[i]=ar[i];}
	sort(ar2+1,ar2+n+1);
	for(int i=1;i<=n;i++){
		cout<<ar2[n-(ar[i]==ar2[n])]<<"\n";
	}
}


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

int main() {
    int N, M, a, b;
    cin >> N >> M;
    vector<int> ans(N, 0);
    rep(i, M){
        cin >> a >> b;
        ans[a - 1] += 1;
        ans[b - 1] += 1;
    }
    rep(i, N){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
 int K,A,B;
 cin>>K;
 cin>>A>>B;
 int flag=0;
 if((B-A)>=K){
     flag=1;
 }
 else{
     for(int i=A;i<=B;i++){
         if(i%K==0){
                          flag=1;

                 break;
         }
     }
 }
 if(flag==0){
     cout<<"NG"<<endl;
 }
 else{
     cout<<"OK"<<endl;
 }
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

map<ll,ll> prime_factors(ll n){
    map<ll,ll> res;
    if(n == 1){
        res[n] = 1;
        return res;
    }
    for(ll i = 2; i * i <= n; i++){
        while(n % i == 0){
            ++res[i];
            n /= i;
        }
    }
    if(n != 1){
        res[n] = 1;
    }
    return res;
}

int main()
{
    ll n,p;
    ll ans = 1;
    cin >> n >> p;
    map<ll,ll> mp = prime_factors(p);
    for(auto i : mp){
        if(i.second >= n){
            ll cnt = i.second / n;
            for(ll j = 1; j <= cnt ; j++){
                ans *= i.first;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
function Main(input) {
	input = input.split("\n");
    seigen = parseInt(input[0]);
    hantei = true;
    for(i = 2; i <= seigen; i++){
        if(input[i-1].slice(-1) !== input[i].slice(0,1)) hantei = false;
        for(j = 2; j <= seigen; j++){
            if(i-1 !== j && input[i-1] === input[j]) hantei = false;
        }
    }
    if(hantei) console.log('%s','Yes');
    else console.log('No')
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
const int N = 1e3 + 5, mod = 1e9 + 7;
int n, k, a[N];
ll f[N], inv[N];
ll dp[30][N];

ll C(ll n, ll m) {
    return f[n] * inv[n - m] % mod * inv[m] % mod;
}

int main() {
    f[0] = 1, inv[0] = inv[1] = 1;
    for (int i = 1; i < N; ++i) f[i] = f[i - 1] * i % mod;
    for (int i = 2; i < N; ++i) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
    for (int i = 2; i < N; ++i) inv[i] = inv[i] * inv[i - 1] % mod;
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= k; ++i) scanf("%d", &a[i]);
    dp[0][0] = 1;
    for (int i = 1; i <= k; ++i) {
        for (int j = 0; j <= n; ++j) {
            for (int k = 0; k <= min(j, a[i]); ++k) {
                dp[i][j] = (dp[i][j] + dp[i - 1][j - k] * C(n - j + k, k) % mod * C(n - k, a[i] - k) % mod) % mod;
            }
        }
    }
    cout << dp[k][n] << endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
  char s[11];
  int i,y,m,d;
  scanf("%s",s);
  y = (s[0]-48)*1000+(s[1]-48)*100+(s[2]-48)*10+(s[3]-48);
  m = (s[5]-48)*10+(s[6]-48);
  if((y<=2018)||((y<=2019)&&(m<=4))){
    printf("Heisei");
  }
  else{
    printf("TBD");
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int x;
    cin >> x;
    if (x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
/*
time:
wa:
反省:
考察:
*/
int main() {
    int n, k; cin >> n >> k;
    vector<int>a(n);
    vector<long long>grade(n-k+1,1);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n-k; i++){
        if(a[i] < a[k+i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 5560
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;


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

	int a,b;
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
		puts("Possible");
	else
		puts("Impossible");
	return 0;
}

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

#define ll long long int
#define str string

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Max = INF, Min = -1;
ll a = 0, b = 0, c = 0, n = 0, m = 0, kiroku = 0, sum = 0, MASK = 0;
ll A[50000][3] = {}, B[500000] = {}, dp[200000][3], rui[500000] = {}, dp2[1 << 12] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
str S, T;
bool check = true, check2 = false;


int main() {
	//Code Line
	cin >> a;

	for (int i = 1; i < 10; i++) {
		if (a % i == 0 && a / i < 10)check2 = true;
	}

	if (check2)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
/*author: hyperion_1724
  date: 
*/

//Required Libraries

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

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(int a=b;a<c;a++)
#define FORD(a,b,c) for(int a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

	READV(r);
	cout<<3*r*r<<endl;

	return 0;
}

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

string s;
string::iterator p;

int fact();
int term();
int exp();

int fact() {
  int x;
  string num;
  while(isdigit(*p)) {
    num += *p;
    ++p;
  }
  if(num.size()) {
    x = atoi(num.c_str());
  } else {
    ++p;
    x = exp();
    ++p;
  }
  return x;
}

int term() {
  int x = fact();
  while(*p == '*' || *p == '/') {
    if(*p == '*') {
      ++p;
      x *= fact();
    } else {
      ++p;
      x /= fact();
    }
  }
  return x;

}

int exp() {
  int x = term();
  while(*p == '+' || *p == '-') {
    if(*p == '+') {
      ++p;
      x += term();
    } else {
      ++p;
      x -= term();
    }
  }
  return x;
}

int main() {
  int n;
  cin >> n;
  while(n--) {
    cin >> s;
    p = s.begin();
    cout << exp() << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

int a,b;

string solve() {
    if (a + b == 15) {
        return "+";
    } else if (a * b == 15) {
        return "*";
    } else {
        return "x";
    }
}

signed main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> a >> b;
    cout << solve() << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define EB emplace_back
#define MP make_pair
#define all(o) (o).begin(), (o).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define fr(i,n) for(lli i=0;i<n;++i)
#define rep(i,a,b) for(lli i=a;i<=b;++i)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b)))
#define endl '\n'
typedef long long int lli;
typedef long double ld;
typedef pair< lli,lli > ii;
typedef vector<lli> vi;
typedef vector<ii> vii;
typedef vector<vi> graph;
lli MOD=1000000007;long double EPS=1e-9;


void pre(){

}

void solve(){
	lli n,m;
	cin>>n>>m;
	int cnt=0;
	vi instack;
	bool done[m+1];
	vii event;
	fr(i,m){
		int l,r;
		cin>>l>>r;
		if(l>r)swap(l,r);
		r--;
		event.EB(MP(l,-(i+1)));
		event.EB(MP(r,i+1));
	}
	sort(all(event));
	fr(i,m)done[i+1]=0;
	for(auto v:event){
		if(v.S<0){
			instack.EB(-v.S);
		}
		else{
			if(!done[v.S]){
				cnt++;
				for(auto u:instack){
					done[u]=1;
				}
				instack.clear();
			}
		}
	}
	cout<<cnt<<endl;
}	

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	pre();
	int t=1;
	//cin>>t;
	for(int i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}

Measured memory_bytes: 6564
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
typedef long long int ll;
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define m0(x) memset(x,0,sizeof(x))

int main(void)
{
	int n,m;
	scanf("%d %d",&n,&m);
	int a[n][m],k,l,c,count=0;
	m0(a);
	rep(i,n){
		scanf("%d",&k);
		rep(j,k){
			scanf("%d",&l);
			a[i][l-1]=1;
		}
	}
	rep(i,m){
		c=0;
		rep(j,n){
			if(a[j][i]==1) c++;
		}
		if(c==n) count++;
		//printf("%d\n",count );
	}
	printf("%d\n",count );
	return 0;
}

Measured memory_bytes: 128