akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
const int N = 1e3 + 5;
const int M = 5e5 + 5;
 
int fir[N] , ne[M] , to[M] , cnt , x , y , scc[N] , scc_tot , dfs_clock , dfn[N] , low[N] , Id[M] , n , m;
int A[M] , B[M];
int stk[N] , top;
int ans[M];
int L[N][N], R[N][N];

void add(int x, int y) {
	ne[++ cnt] = fir[x];
	fir[x] = cnt;
	to[cnt] = y;
}

bool can[N][N];

queue <int> q;

vector <int> son[N];

#define Foreachson(i, x) for(int i = fir[x]; i; i = ne[i])

void solve(int x) {
	while(!q.empty()) q.pop();
	q.push(x);
	while(!q.empty()) {
		int ind = q.front();
		can[x][ind] = 1;
		q.pop();
		for(auto V : son[ind]) {
			if(can[x][V]) continue;
			q.push(V);
			can[x][V] = 1;
		}
	}
	
	Foreachson(i, x) {
		int V = to[i];
		while(!q.empty()) q.pop();
		if(!L[x][V]) {
			q.push(V);
			L[x][V] = V;
		}
		while(!q.empty()) {
			int ind = q.front();
			q.pop();
			for(int j = son[ind].size() - 1; j >= 0; -- j){
				int v = son[ind][j];
				if(!L[x][v] && v != x) {
					L[x][v] = V;
					q.push(v);
				}
			}
		}
	}
	
	for(int i = 0; i < (int) son[x].size(); ++ i) {
		int V = son[x][i];
		while(!q.empty()) q.pop();
		if(!R[x][V]) {
			q.push(V);
			R[x][V] = V;
		}
		while(!q.empty()) {
			int ind = q.front();
			q.pop();
			for(int j = 0; j < (int) son[ind].size(); ++ j) {
				int v = son[ind][j];
				if(!R[x][v] && v != x) {
					R[x][v] = V;
					q.push(v);
				}
			}
		}
	}
}

 
main(void) {
	scanf("%d%d" , &n , &m);
	for(int i = 1;i <= m;++ i) {
		scanf("%d%d" , &x , &y);
		A[i] = x , B[i] = y;
		add(x, y);
	}
	
	for(int i = 1; i <= n; ++ i) {
		Foreachson(j, i) {
			int V = to[j];
			son[i].push_back(V);
		}
		reverse(son[i].begin(), son[i].end());
	}
	
	for(int i = 1; i <= n; ++ i) {
		solve(i);
	}
	
	for(int i = 1; i <= m; ++ i) {
		if(L[A[i]][B[i]] != B[i] || R[A[i]][B[i]] != B[i]) {
			if(!can[B[i]][A[i]]) puts("diff");
			else puts("same");
		}
		else {
			if(can[B[i]][A[i]]) puts("diff");
			else puts("same");
		}
	}
}


Measured memory_bytes: 23040
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl



int main(){
  string s;
  cin>>s;
  vector<int> a(4);
  int ans=0;
  rep(i,4)
    a.at(i) = (int) s.at(i)-(int) '0';
  bitset<3> op;
  
  rep(trs,(1<<3)){
    bitset<3> r=trs;
    int sum=a.at(0);
    rep(i,3){
      if(r.test(i))
        sum+=a.at(i+1);
      else
        sum-=a.at(i+1);
    }
    if(sum==7){
      ans=1;
      op=r;
      break;
    }
  }
  cout<<a.at(0);
  rep(i,3){
    
    if(op.test(i))
      cout<<'+';
    else
      cout<<'-';
    cout<<a.at(i+1);
  }
  cout<<"=7"<<endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> heights = new ArrayList<Integer>();
		for(int i = 0; i < N; i++) {
			heights.add(sc.nextInt());
		}
		sc.close();
		int number = getHeight(heights);
		System.out.println(number);
	}
	
	static int getHeight(List<Integer> heights) {
		if(heights.size() == 0) return 0;
		if(heights.size() == 1) return heights.get(0);
		int number = findSmallest(heights);
		List<Integer> updatedList = updateHeights(heights, number);
		List<List<Integer>> partitions = divide(updatedList);
		for(List<Integer> list: partitions) {
			number += getHeight(list);
		}
		return number;
		
	}
	
	static int findSmallest(List<Integer> heights) {
		int temp = heights.get(0);
		for(int x : heights) {
			if(temp > x) {
				temp = x;
			}
		}
		return temp;
	}
	
	static List<Integer> updateHeights(List<Integer>heights, int number) {
		List<Integer> list = new ArrayList<Integer>();
		for(int x: heights) {
			list.add(x - number);;
		}
		return list;
	}
	
	static List<List<Integer>> divide(List<Integer> heights){
		List<List<Integer>> partitions = new ArrayList<List<Integer>>();
		List<Integer> list = null;
		for(int i = 0; i < heights.size(); i++) {
			if(i == 0 ||  heights.get(i) == 0) {
				if(list != null) {
					partitions.add(list);
				}
				list = new ArrayList<Integer>();
			}
			if(heights.get(i) != 0) {
				list.add(heights.get(i));
				if(i == heights.size() - 1) {
					partitions.add(list);
				}
			}
		}
		return partitions;
	}
		
}

Measured memory_bytes: 23252
#include<stdio.h>

int main() 
{
	float xa, ya, xb, yb, xc, yc, xd, yd;

	while (scanf("%f %f %f %f %f %f %f %f", &xa, &ya, &xb, &yb, &xc, &yc, &xd, &yd) != EOF) {
		if ((xb - xa)*(xd - xc) + (yb - ya)*(yd - yc) == 0)
			puts("YES");
		else
			puts("NO");
	}
	return 0;
}


Measured memory_bytes: 604
/*
    Problem 2
    https://atcoder.jp/contests/abc106/tasks/abc106_b
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
int div(int x) {
    int ret = 0;
    for (int i = 1; i * i <= x; i++) {
        if (x % i == 0) {
            ret++;
            if (i * i != x) ret++;
        }
    }
    return ret;
}
/* main */
int main(){
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 105; i <= n; i+=2){
        ans += (div(i) == 8);
        // cout << i << ' ' << div(i) << '\n';
    }
    cout << ans << '\n';
}


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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
	int n;
	cin >> n;
	map<int, int> mp;
	v1 key(n);
	ll sum = 0;
	rep(i, n){
		int a;
		cin>>a;
		sum += a;
		key.at(i) = a;
		if(mp.count(a)){
			mp.at(a)++;
		}else{
			mp[a] = 1;
		}
	}
	int q;
	cin >> q;
	vector<ll> sumv(q);
	rep(i, q){
		int b, c;
		cin >> b >> c;
		if(!mp.count(b)){
			sumv.at(i) = sum;
			continue;
		}else{
			sum += mp.at(b)*(c-b);
			if(mp.count(c)){
				mp.at(c) += mp.at(b);
			}else{
				mp[c] = mp.at(b);
			}
			mp.erase(b);
		}
		sumv.at(i) = sum;
	}
	rep(i,q){
		cout << sumv.at(i) << endl;
	}
}


Measured memory_bytes: 7376
#include <cstdio>
using namespace std;
#define MOD 1000000007
int f[45][262202];
long long fastpow(register int n){
	register long long t, p;
	for (t = 1, p = 10; n; n >>= 1, p = p * p % MOD) if (n & 1) t = p * t % MOD;
	return t;
}
int main(){
	register int n, x, y, z, i, j, S, T, A, B, ans;
	scanf("%d %d %d %d", &n, &x, &y, &z);
	B = ((1 << x | 1) << y | 1) << z - 1;
	T = (1 << x + y + z - 1) - 1;
//	fprintf(stderr, "%d %d\n", B, T);
	for (i = 0; i <= 9; ++i) f[1][1 << i & T] += 1;
	for (i = 1; i < n; ++i) {
		for (S = 0; S <= T; ++S) if (f[i][S]) {
			for (j = 0; j <= 9; ++j) {
				A = S << j + 1 | 1 << j;
				if ((A & B) != B) (f[i + 1][A & T] += f[i][S]) %= MOD;
			}
		}
	}
	ans = fastpow(n);
	for (S = 0; S <= T; ++S) (ans += MOD - f[n][S]) %= MOD;
	printf("%d", ans);
	return 0;
}

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

int main()
{
    int n,flag = 0;
    cin >> n;
    char s;
    for(int i = 0; i < n; i++){
        cin >> s;
        if(s == 'Y') flag = 1;
    }

    cout << (flag == 0 ? "Three" : "Four") << endl;

    return 0;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}


//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;

int main(){
  int N;cin>>N;
  if(N%1000==0){
   cout<<0<<endl;
  }
  else{
   cout<<1000-N%1000<<endl;
  }
}






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

int n;
double prob[3000];
double dp[3000][3000];

double solve(int total_taken,int headsTaken){
    if(total_taken>=n){
        if(headsTaken>n-headsTaken) return 1;
        else return 0;
    }
    if((int)dp[total_taken][headsTaken]!=-1) return dp[total_taken][headsTaken];
    double &ans =dp[total_taken][headsTaken];
    ans=0;
    ans=prob[total_taken]*solve(total_taken+1,headsTaken+1)+(1-prob[total_taken])*solve(total_taken+1,headsTaken);

    return ans;
}

int main(){
    cout<<setprecision(12)<<fixed;
    cin>>n;
    for(int i=0;i<3000;i++) for(int j=0;j<3000;j++) dp[i][j]=-1;
    for(int i=0;i<n;i++) cin>>prob[i];
    cout<<solve(0,0)<<"\n";
    return 0;
}

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

int main() {
	int ch[26] = {};
	string str;
	cin >> str;

	for (int i = 0; i < str.size(); i++) {
		ch[str[i]-97]++;
	}
	
	int g = -1;
	for (int i = 0; i < 26; i++) {
		if (ch[i] == 0) {
			g = i;
			break;
		}
	}

	if (g == -1)cout << "None" << endl;
	else cout << char(g + 97) << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

vector<vector<int>> G;
vector<int> Tpl;
vector<bool> seen, finished;
bool dfs2(int cur, int par) {
  if(seen[cur] && !finished[cur]) return true;
  if(seen[cur] || finished[cur]) return false;
  seen[cur] = true;
  bool ret = false;
  for(int ne: G[cur]) {
    if(ne == par) continue;
    ret |= dfs2(ne, cur);
  }
  finished[cur] = true;
  Tpl.push_back(cur);
  return ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<vector<int>> A(n, vector<int>(n-1));
  rep(i, n) rep(j, n-1) {
    cin >> A[i][j];
    A[i][j]--;
  }
  G = vector<vector<int>>(n*(n-1)/2);
  seen = vector<bool>(n*(n-1)/2);
  finished = vector<bool>(n*(n-1)/2);
  map<pair<int, int>, int> id;
  vector<pair<int, int>> P(n*(n-1)/2);
  {
    int tmp = 0;
    rep(i, n) REP(j, i+1, n) {
      id[{i, j}] = tmp;
      P[tmp] = {i, j};
      tmp++;
    }
  }
  auto getId = [&](int i, int j) {
    pair<int, int> p = {min(i, j), max(i, j)};
    assert(id.count(p));
    return id[p];
  };
  auto getPair = [&](int id) {
    return P[id];
  };
  rep(i, n) rep(j, n-2) {
    G[getId(i, A[i][j])].push_back(getId(i, A[i][j+1]));
  }
  bool ret = false;
  rep(i, n*(n-1)/2) ret |= dfs2(i, -1);
  if(ret) { // loop
    cout << -1 << endk;
    return 0;
  } else {
    reverse(all(Tpl));
    int ans = 0;
    vector<bool> vis(n*(n-1)/2);
    vector<int> depth(n*(n-1)/2);
    auto dfs = [&](auto dfs, int cur, int dep) -> void {
      if(vis[cur]) {
        chmax(ans, dep+depth[cur]);
        return;
      }
      vis[cur] = true;
      for(auto ne: G[cur]) {
        dfs(dfs, ne, dep+1);
        chmax(depth[cur], depth[ne]);
      }
      depth[cur]++;
      chmax(ans, dep+depth[cur]);
    };
    for(int i: Tpl) dfs(dfs, i, 0);
    cout << ans << endk;
  }
  return 0;
}


Measured memory_bytes: 73904
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int x, t; cin >> x >> t;
  outl(max(0, x - t));
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 888
#include<stdio.h>
#include<stdlib.h>

int compare1_int(const void *a,const void *b){
	return *(int*)a - *(int*)b;
}

int compare2_int(const void *a,const void *b){
	return *(int*)b - *(int*)a;
}

int main(void){
	int n;
	int i,j;
	int a;
	int x[8];
	int big,small;
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf("%d",&a);
		for(j = 0;j < 8;j++){
			x[j] = a % 10;
			a = a / 10;
		}
		qsort(x,8,sizeof(int),compare1_int);
		small = x[0] * 10000000 + x[1] * 1000000 + x[2] * 100000 + x[3] * 10000
				+ x[4] * 1000 + x[5] * 100 + x[6] * 10 + x[7];
		qsort(x,8,sizeof(int),compare2_int);
		big =  x[0] * 10000000 + x[1] * 1000000 + x[2] * 100000 + x[3] * 10000
				+ x[4] * 1000 + x[5] * 100 + x[6] * 10 + x[7];
		printf("%d\n",big - small);
	}
	return 0;
}

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

int f(int x)
{
  int res = 0;
  while (x) {
    x /= 10;
    ++res;
  }
  return res;
}

signed main()
{
  cout << fixed << setprecision(10);
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  vector<int> h(n);
  for (int i = 0; i < n; ++i) cin >> h[i];

  int mx = 0;
  for (int i = 0; i < n; ++i) {
    if (mx <= h[i]) mx = h[i];
    else {
      if (mx - h[i] >= 2) {
        cout << "No\n";
        return (0);
      }
    }
  }

  cout << "Yes\n";

  return (0);
}


Measured memory_bytes: 3692
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

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

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let (mut x, y): (isize, isize) = (sc.input(), sc.input());
    let mut ans = 0;
    while x <= y {
        ans += 1;
        x *= 2;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    x, n = ns()
    p = na()

    set_p = set(p)

    res = -1

    for i in range(101):
        l = x + i
        s = x - i
        if s not in set_p:
            res = s
            break
        if l not in set_p:
            res = l
            break


    print(res)


if __name__ == '__main__':
    main()


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

using namespace std;

vector<pair<long long, bool> > A(1<<20);
int main() {
    long long int w, h;cin>>w>>h; long long int p;

    for(int i=0;i<w+h;i++) {
        if(i < w) {
            cin>>p;
            A[i].first = p;
            A[i].second = 1;
        } else {
            cin>>A[i].first;
            A[i].second = 0;
        }
    }

    sort(A.begin(), A.begin()+w+h);


    long long int nrow = 0;
    long long int ncol = 0;
    long long sum = 0;

    for(int i=0;i<w+h;i++) {
        if(A[i].second) {
            sum += (h-ncol+1)*(A[i].first);
            nrow++;
        } else {
            sum += (w-nrow+1)*(A[i].first);
            ncol++;
        }
    }

    cout<<sum;

    return 0;
}


Measured memory_bytes: 16768
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  int ans=0;
  rep(i,n-1) {
    if(a[i]==i+1) {
      swap(a[i],a[i+1]);
      ans++;
    }
  }
  if(a[n-1]==n) {
    swap(a[n-1],a[n-2]);
    ans++;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 1024
#include                        <bits/stdc++.h>
#include                        <ext/pb_ds/assoc_container.hpp>
#define lb                      lower_bound
#define ub                      upper_bound
#define fe(x)                   *(x.begin())
#define le(x)                   *(x.rbegin())
#define pb                      push_back
#define load(node,n)            bool operator < (const node &n) const
#define fbo(x)                  find_by_order(x)
#define ook(x)                  order_of_key(x)
#define all(x)                  (x).begin(),(x).end()
#define FOR(i,n)                for(int i = 1; i<=n; i++)
#define REP(i,n)                for(int i = 0; i<n;  i++)
#define TT                      int TC;  scanf("%d",&TC);  while(TC--)
#define read                    freopen("input.txt","r",stdin)
#define write                   freopen("output.txt","w",stdout)
#define set(x)                  tree<x,null_type,less<x>,rb_tree_tag,tree_order_statistics_node_update>
using                           namespace __gnu_pbds;
using                           namespace std;
typedef                         long long ll;
typedef                         pair<ll,ll> pll;
typedef                         pair<int,int> pii;






main(){
//read;

ll n,p;
cin>>p;
cin>>n;

ll x = 0;
for(ll i =0 ; i<n; i++){
    ll a;
    cin>>a;
    x+=a;
}

p = p-x;
p = max(p,-1ll);
cout<<p;

return 0;
}


Measured memory_bytes: 3636
N,A,B,C,D = map(int,input().split())
S = input()
if (A-B)*(C-D) < 0 and "..." not in S[max(A,B)-2:min(C,D)+1]:
  print("No")
elif "##" not in S[A-1:C] and "##" not in S[B-1:D]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 40816
// ABC_170_A

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

int main()
{
  vector<int> vec(5);
  for(int i = 0; i < 5; ++i) cin >> vec[i];

  int counter = 1;
  for(int i = 0; i < 5; ++i) {
    if(vec[i] != 0) ++counter;
    else break;
  }

  cout << counter << "\n";

  return 0;

}


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

typedef long long int   ll;
#define int             ll
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
#define scan(n)         scanf("%lld",&n)
#define pb              push_back
#define PI              3.1415926535897932384626433832795
#define rep0            for(int i=0;i<n;i++)
#define rep1            for(int i=1;i<=n;i++)
#define inputar0(ar)    for(int i=0;i<n;i++)cin>>ar[i]
#define inputar1(ar)    for(int i=1;i<=n;i++)cin>>ar[i]
#define showar0(ar)     for(int i=0;i<n;i++)cout<<ar[i]<<" "
#define showar1(ar)     for(int i=1;i<=n;i++)cout<<ar[i]<<" "
int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
int binpow(int a,int b){int res=1;while(b>0){if(b%2){res=(res*a);b--;}a=(a*a);b/=2;}return res;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

signed main(){
    int t=1;
//    scan(t);
    while(t--){
        int n;cin>>n;
        int ar[n];
        for(int i=0;i<n;i++){
            cin>>ar[i];
        }
        sort(ar,ar+n);
        int sum=ar[n-1];
        int k=n-2;
        bool sw=false;
        for(int i=0;i<n-2;i++){
            sum+=ar[k];
            if(sw) {
                k--;
            }
            sw=!sw;
        }
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 5180
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <queue>

using namespace std;
typedef  long long LL;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a<=0&&b>=0)printf("Zero\n");
    else
    {
        if(a>0)printf("Positive\n");
        else if((b-a+1)&1)printf("Negative\n");
        else printf("Positive\n");
    }
    return 0;
}


Measured memory_bytes: 256
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    println!("{}",if a%10==9||a/10==9{"Yes"}else{"No"})
}

Measured memory_bytes: 4352
import math
flaga=True
S='1'
N=int(input())
D=N
flag=0
p=1
K=0
if N==0:
    print(0)
    exit(0)
elif N==1:
    print(1)
    exit(0)
elif N>0:
    D-=1
    while flag==0:
        if D+1-p>0:
            D-=p
            p*=4
            K+=2
        else:
            #print(D)
            for i in range(K):
                if D<p//2:
                    if flaga==True:
                        S +='1'
                    else:
                        S +='0'
                else:
                    D-=p//2
                    if flaga==True:
                        S +='0'
                    else:
                        S +='1'
                p=p//2
                flaga = not flaga
                #print(D,flaga,p)
            print(S)
            exit(0)
else:
    D=abs(D)-1
    p+=1
    while flag==0:
        if D-p>=0:
            D-=p
            p*=4
            K+=2
            #print(D,p)
        else:
            #print(D,K)
            for i in range(K+1):
                if D<p//2:
                    if flaga==True:
                        S +='1'
                    else:
                        S +='0'

                else:
                    D-=p//2
                    if flaga==True:
                        S +='0'
                    else:
                        S +='1'
                flaga = not flaga
                p=p//2

            print(S)
            exit(0)





Measured memory_bytes: 3188
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    map<int, int> mp;
    ll ans = 0;
    rep(i, n) {
        ans += mp[i-a[i]];
        mp[a[i]+i]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 21028
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=300010;

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

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	ll x,a;
	cin>>x>>a;
	if(x<a){cout<<"0";}
	else{cout<<"10";}

	return(0);
}


Measured memory_bytes: 384
import sys
from copy import deepcopy as copy
from collections import deque
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())
    
    tree = [[] for _ in range(n)]
    edge = dict()
    for i in range(m):
        a, b = map(int, input().split())
        tree[a-1].append(b-1)
        edge[(a-1, b-1)] = i+1
    
    ans = 0
    for i in range(n):
        not_yet = deque([i])
        already = [False]*n
        dist = [0]*n
        par = [0]*n
        already[i] = True
        sub = []
        
        while not_yet:
            key = not_yet.popleft()
            for v in tree[key]:
                if already[v]:
                    
                    if v == i:
                        sub = [key+1]
                        now = key
                        while now != i:
                            sub.append(par[now]+1)
                            now = par[now]
                        break
                    continue
                
                not_yet.append(v)
                already[v] = True
                dist[v] = dist[key] + 1
                par[v] = key
            if sub:
                break
            
        if sub:
            if ans:
                if len(ans) > len(sub):
                    ans = copy(sub)
            else:
                ans = copy(sub)
            
        
    if ans:
        print(len(ans))
        for a in ans:
            print(a)
    else:
        print(-1)
        
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 9992
#include <iostream>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};
constexpr char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(void){
  int n, k, u; scanf("%d%d\n", &n, &k);
  Vint A(n), non_negative_A(n);
  Vlli subSum_A(n+1), subSum_non_negative_A(n+1);
  subSum_A[0] = 0; subSum_non_negative_A[0] = 0;
  REP(i, n){
    scanf("%d", &u); A[i] = u; non_negative_A[i] = ((u > 0) ? u : 0);
    subSum_A[i+1] = subSum_A[i] + u;
    subSum_non_negative_A[i+1] = subSum_non_negative_A[i] + non_negative_A[i];
  }
  lli res = -INFi;
  FOReq(i, 0, (const int)(n - k)){
    lli koho = subSum_non_negative_A[i] + subSum_non_negative_A[n] - subSum_non_negative_A[i + k],
        koho2 = subSum_A[i+k] - subSum_A[i];
    if(koho2 > 0) koho += koho2;
    if(res < koho) res = koho;
  }
  printf("%lld\n", res);
  return 0;
}

Measured memory_bytes: 2560
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define F0r(i, a, b) for(int i=a; i<(b); i++)
#define For(i, a)    for(int i=0; i<(a); i++)
#define F0rd(i,a,b)  for(int i = (b)-1; i >= a; i--)
#define Ford(i,a)    for(int i = (a)-1; i >= 0; i--)

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

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

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define setbits(x)  __builtin_popcountll(x)
#define zrobits(x)  __builtin_ctzll(x)
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	ll a,b,c,k;
	cin >> a >> b >> c >> k;
	ll sum = 0;
	if (a > k){
		sum += k;
		k = 0;
		
	} else{
		k -= a;
		sum += a;
	}

	if ( b > k){
		 k = 0;
	 } else {
		 k -= b;
	 }
	 
	 if( c > k){
		sum -= k;
		k = 0;
		
	} else {
		k -= c;
		sum -= c;
	}
	
	cout << sum << nl;
	return 0;
}


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


#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define line printf("\n")
#define pq priority_queue
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (int)i;k>=(int)j;k--)
#define ll long long
#define ALL(a) a.begin(),a.end()
#define vi vector<int>

using namespace std;

double EPS = 1e-9;
int INF = 1e9+7;;
long long INFLL = 1e17;
double pi = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

clock_t first_attempt = clock();
inline void cek_time(){
	clock_t cur = clock()- first_attempt;
	cerr<<"TIME : "<<(double) cur/CLOCKS_PER_SEC<<endl;
}
inline void OPEN (string s) {
	freopen ((s + ".in").c_str (), "r", stdin);
	freopen ((s + ".out").c_str (), "w", stdout);
}

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> bbst;
//find_by_order(idx) : i-th index 
//order_of_key(val)  : val has which index

//end of template

int n;
int main() {
	cin >> n;
	
	map<int, int> gg[2];
	rep(k, 0, n) {
		int a;
		cin >> a;
		gg[k % 2][a]++;
	}
	
	vector<pii> test[2];
	int ans = 0;
	rep(i, 0, 2) {
		for (auto a : gg[i]){
			test[i].pb({a.se, a.fi});
		}
		sort(ALL(test[i]));
		reverse(ALL(test[i]));
		while(test[i].size() > 2) test[i].pb2();
	}
	
	for (auto a : test[0]) for (auto b : test[1]) {
		int cur = a.fi + b.fi;
		if (a.se == b.se) cur = max(a.fi, b.fi);
		ans = max(ans, cur);
	}
	cout << n - ans << endl;
}

Measured memory_bytes: 6136
#include <iostream>
#include <random>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

ull powmod(ull  a,ull b, ull mod) {
  ull res=1;
  for(; b; b >>= 1){
    if(b & 1){
      res = res * a % mod;
    }
    a = a * a % mod;
  }
  return res;
}

bool MillerRabin(ull n, ull k){
  if (n == 2){
    return true;
  }
  if (n == 1 || (n & 1) == 0){
    return false;
  }

  random_device rd;
  mt19937 rand_src(rd());
  uniform_int_distribution<ull> rand_dist(1, n - 1);

  ull d = n - 1;
  while ((d & 1) == 0){
    d >>= 1;
  }
  while(k--){
    ull a = rand_dist(rand_src);
    ull t = d;
    ull y = powmod(a, t, n);
    while (t != n - 1 && y != 1 && y != n - 1){
      y = (y * y) % n;
      t <<= 1;
    }
    if (y != n - 1 && (t & 1) == 0){
      return false;
    }
  }
  return true;
}

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

  int n;
  vector<ull> vc;
  int c = 0;
  cin >> n;
  while(n--){
    ull x;
    cin >> x;
    vc.push_back(x);
  }

  for (size_t i = 0; i < vc.size(); i++){
    if (MillerRabin(vc[i], 20)){
        c ++;
    }
  }
  cout << c << "\n";
}



Measured memory_bytes: 3376
#include <iostream>
using namespace std;
int n,m,maps[10][10],a[10][10],i,i2,c[10],g,ans;
bool tmp[10];
int find(int a,int b,bool t[])
{
	int x=2147483647;
	if(a==1)return b;
	for(int i=0;i<10;i++)
	{
		if(!t[i])t[i]=1,x=min(x,find(i,b+maps[a][i],t)),t[i]=0;
	}
	return x;
}
int main()
{
	cin>>n>>m;
	for(i=0;i<10;i++)
		for(i2=0;i2<10;i2++)
			cin>>maps[i][i2];
	for(i=0;i<10;i++)
		tmp[i]=1,c[i]=find(i,0,tmp),tmp[i]=0;
	for(i=0;i<n;i++)
		for(i2=0;i2<m;i2++)
		{
			cin>>g;
			if(g!=1&&g!=-1)ans+=c[g];
		}
	cout << ans<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
 
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
#define ll long long int
 
int main() {
	ll n;
	cin >> n;
	vector<ll>l(n);
	rep(i,n){
		cin >> l[i];
	}
	
	ll sum = 0;
	
	ll flag = 0;
	rep(i,n){
		   rep(j,n){
			   
			 if(i < j && l[i] != l[j]){
				
		rep(k,n){
				
		if(i < k && j < k && l[i] != l[k] && l[k] != l[j]){
						
			sum= max({l[i],l[j],l[k]});
	       		
	       		if(l[i]+l[j]+l[k] >2 * sum ){
					
					flag++;
				
						}
					}
				}
			 }
		   }
	}
	cout << flag;
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

int p[N];
void solve()
{
	
	string s;
	cin >> s;
	bool ok = 0;
	int x = atoi(s.substr(0, 4).c_str()), y = atoi(s.substr(5, 2).c_str()), z = atoi(s.substr(8, 2).c_str());	
	if(x < 2019 || (x == 2019 && y < 4) || (x == 2019 && y == 4 && z <= 30)) ok = 1; 
	cout << (ok ? "Heisei" : "TBD");
	
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define INF 200000

using namespace std;

int main(void){
  int A, B, M;
  cin >> A >> B >> M;
  int a[A], b[B];
  int i;
  for(i=0; i<A; i++)
    cin >> a[i];
  for(i=0; i<B; i++)
    cin >> b[i];
  int x[M], y[M], c[M];
  for(i=0; i<M; i++)
    cin >> x[i] >> y[i] >> c[i];

  int min_ref = INF, min_len = INF, min_sum = 2*INF;
  //冷蔵庫の最小
  for(i=0; i<A; i++)
    if(a[i] < min_ref)
      min_ref = a[i];
  //レンジの最小
  for(i=0; i<B; i++)
    if(b[i] < min_len)
      min_len = b[i];

  min_sum = min_ref + min_len;

  int sum;
  //割引券
  for(i=0; i<M; i++){
    sum = a[ x[i]-1 ] + b[ y[i]-1 ];
    sum -= c[i];
    if(sum < min_sum)
      min_sum = sum;
  }
  
  cout << min_sum << endl;
  
  return 0;
}


Measured memory_bytes: 2176
alphabetlist=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

def ind(b,n):
    check=0
    if n==0:
        return 0
    res=1
    while n>=check:
        check+=26*(res)
        res+=1
    return res-1

N=int(input())
if 26>=N:
    print(alphabetlist[N-1])
    exit()
ans=[]
L=-1
check=0
for i in range(0,50):
    test=check+26**i
    if test>N:
        L=i
        break
    else:
        check=test
ans=[""]*L
n=N-check
for i in range(L-1,-1,-1):
    q=n//(26**i)
    ans[-i-1]=alphabetlist[q]
    n=n-q*26**i
print("".join(ans))


Measured memory_bytes: 61976
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int n=gi();
	    int k=gi();
	    
        System.out.println((n-1)*(k-1));
//        if (n%k==0) {
//        	System.out.print(0);
//        }else {
//        	System.out.print(1);
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35536
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, x, dp[100001];
vector <int> a;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i = 0 ; i < n && cin >> x ; i++)
        a.push_back(x);
    dp[1] = abs(a[1] - a[0]);
    for(int i = 2 ; i < n ; i++)
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1144
import { readFileSync } from "fs";

const quotient = (dividend: number, divisor: number): number =>
  Math.floor(dividend / divisor);

const summention = (n: number, step = 1): number => {
  const q = quotient(n, step);
  return step * ((q + 1) * quotient(q, 2) + (q % 2) * (quotient(q, 2) + 1));
};

export const solveB = (n: number): number =>
  summention(n) - summention(n, 3) - summention(n, 5) + summention(n, 15);

if (require.main === module)
  console.log(solveB(+readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 29612
S = input()
T = input()
S_dict = dict()
T_dict = dict()
for i in range(len(S)):
    s = S[i]
    t = T[i]
    if s not in S_dict:
        S_dict[s] = []
    if t not in T_dict:
        T_dict[t] = []
    S_dict[s].append(i)
    T_dict[t].append(i)
S_Value = []
T_Value = []
for s in S_dict.values():
    S_Value.append(s)
for t in T_dict.values():
    T_Value.append(t)
S_Value.sort()
T_Value.sort()
if S_Value == T_Value:
    print('Yes')
else:
    print('No')

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif

using namespace std;

#define REP(i, a, b) for(int i = (a); i < int(b); ++i)
#define rep(i, n) REP(i, 0, n)
#define ALL(x) begin(x), end(x)

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }


struct edge {
	int to, need;
	edge(int to_, int need_):to(to_), need(need_) {}
};

typedef pair<int, int> state;
typedef vector<vector<edge>> graph;
constexpr int ok = 0;
constexpr int INF = (1 << 29);

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

	int n, m, e, s, t, r;
	cin >> n >> m >> e >> s >> t >> r;

	vector<int> event(n, 0);
	graph G(n);

	for(int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		G[a].emplace_back(b, ok);
		G[b].emplace_back(a, ok);
	}

	for(int i = 0; i < e; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		const int bit = 1 << i;
		event[c] = bit;
		G[a].emplace_back(b, bit);
		G[b].emplace_back(a, bit);
	}

	int ans = INF;
	vector<vector<int>> dist(n, vector<int>(1 << e, INF));
	vector<vector<int>> day(n, vector<int>(1 << e, INF));
	queue<state> que;

	dist[s][event[s]] = 0;
	day[s][event[s]] = 0;
	que.emplace(s, event[s]);

	for(int i = 0; i <= e; ++i) {
		while(!que.empty()) {
			const int v = que.front().first;
			const int bit = que.front().second;
			que.pop();

			dump(i, v, bit, dist[v][bit], day[v][bit]);

			if(day[v][bit] >= r) continue;

			for(const auto &E : G[v]) {
				dump(E.to, E.need);
				if(E.need == ok || (E.need & bit)) {
					const int next_bit = bit | event[E.to];
					if(dist[E.to][next_bit] > dist[v][bit] + 1) {
						dist[E.to][next_bit] = dist[v][bit] + 1;
						day[E.to][next_bit] = day[v][bit] + 1;
						que.emplace(E.to, next_bit);
					}
				}
			}
		}

		for(int bit = 0; bit < (1 << e); ++bit) {
			chmin(ans, dist[t][bit] + i);

			bool update = false;
			for(int v = 0; v < n; ++v) {
				if(v == s) continue;

				if(dist[s][bit] > dist[v][bit]) {
					dist[s][bit] = dist[v][bit];
					update = true;
				}
				dist[v][bit] = INF;
			}

			if(update) {
				day[s][bit] = 0;
				que.emplace(s, bit);
			}
		}
	}

	cout << (ans == INF ? -1 : ans) << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1656
package main

import (
	"fmt"
)

func main() {
	var l, r int
	fmt.Scan(&l, &r)
	var ans, temp int
	if r-l <= 2019 {
		ans = 2018
		for i := 0; i <= r-l; i++ {
			for j := 0; j <= r-l; j++ {
				if i < j {
					temp = (l + i) * (l + j) % 2019
					if temp < ans {
						ans = temp
					}
				}
			}
		}
	}
	fmt.Println(ans)
}

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

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 999999999999999

using namespace std;

#define int long long

int32_t main(){
	string str;
	cin >> str;
	stack<char> st;
	st.push('#');
	REP(i, str.size()){
		if(str[i]=='S') st.push('S');
		else{
			if(st.top()=='S') st.pop();
			else st.push('T');
		}
	}
	cout << st.size()-1 << endl;
}

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

int main(){
	lld a,b;
	cin>>a>>b;
	
	if(a%3==0 || b%3==0 || (a+b)%3==0){
		cout<<"Possible";
	}
	else{
		cout<<"Impossible";
	}
	
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);

int main() {
  int n,m;
  cin>>n>>m;
  vector<int> h(n);
  rep(i,n) cin>>h[i];
  vector<bool> ja(n,true);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    if(h[a]==h[b]){
      ja[a]=false;
      ja[b]=false;
    }
    if(h[a]<h[b]){
      ja[a]=false;
    }
    if(h[a]>h[b]){
      ja[b]=false;
    }
  }
  int ans=0;
  rep(i,n){
    if(ja[i]) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3792