akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

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

        int[][] qs = new int[n][2];
        int max = 0;
        for(int i = 0; i < n; i++) {
        	qs[i][0] = sc.nextInt();
        	qs[i][1] = sc.nextInt();
        	max = Math.max(max, qs[i][1]);
        }
        boolean[] primes = new boolean[max + 1];
        Arrays.fill(primes, true);
        for(int i = 2; i <= max; i++) {
        	if(!primes[i]) continue;
        	for(int j = i * 2; j <= max; j = j + i) {
        		primes[j] = false; 
        	}
        }
        ArrayList<Integer> arr = new ArrayList<>();
        for(int i = 3; i <= max; i++) {
        	if(!primes[i]) continue;
        	if(primes[(i + 1) / 2]) 
        		arr.add(i);
        }
        for(int[] q : qs) {
        	int leftIdx = findUpperBound(arr, q[0]);
        	int rightIdx = findLowerBound(arr, q[1]);
        	System.out.println(rightIdx - leftIdx + 1);
        }
      	
    }

    private static int findUpperBound(ArrayList<Integer> arr, int target) {
    	int left = 0, right = arr.size() - 1;
    	while(left <= right) {
    		int mid = left + (right - left) / 2;
    		if(arr.get(mid) < target)
    			left = mid + 1;
    		else right = mid - 1;
    	}
    	return left;
    }

    private static int findLowerBound(ArrayList<Integer> arr, int target) {
    	int left = 0, right = arr.size() - 1;
    	while(left <= right) {
    		int mid = left + (right - left) / 2;
    		if(arr.get(mid) <= target)
    			left = mid + 1;
    		else right = mid - 1;
    	}
    	return right;
    }
}

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

int main()
{
    int N, flag = 3;
    cin >> N;
    string S;
    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
        if (S[i] == 'Y')
        {
            flag = 4;
            break;
        }
    }

    if (flag == 3)
    {
        cout << "Three" << endl;
    }
    else
    {
        cout << "Four" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
 
using namespace std;
 
int main() {
	int a, b;
	cin >> a >> b;
 
	int diff = b - a;
 
	int tower_a = 0;
	//int tower_b = 0;
	for (int i = 1; i <= diff; i++) {
		if (i < diff) {
			tower_a += i;
		}
		//tower_b += i;
	}
 
	//cout << tower_a << " " << tower_b << endl;
	cout << tower_a - a << endl;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 10000002
mt19937 myrand(time(0));

ll ans[mx];

void precalc(){
    for(int i=1;i<mx;i++){
        for(int j=i;j<mx;j+=i) ans[j]++;
    }
    for(int i=1;i<mx;i++){
        ans[i]=i*ans[i];
        ans[i]+=ans[i-1];
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    precalc();
    ll n;
    cin>>n;
    cout<<ans[n]<<endl;
    return 0;
}


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

using namespace std;

int main()
{
	int n; cin >> n;
	int mn = 1e9;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a; 
		cin >> a;
		if (a <= mn) {
			ans++;
			mn = a;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 888
def abc166_c():
  n, m = map(int, input().split())
  H = list(map(int, input().split()))
  path = dict([(i, []) for i in range(n)])
  for _ in range(m):
    a, b = map(int, input().split())
    path[a-1].append(b-1)
    path[b-1].append(a-1)

  ans = 0
  for i in range(n):
    my_h = H[i]
    if len(path[i]) == 0:
      ans += 1
    else:
      adj_h = [H[j] for j in path[i]]
      if my_h > max(adj_h):
        ans += 1

  print(ans)

abc166_c()

Measured memory_bytes: 44932
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 1;
  for(int i = 0; i < n; i++) {
    if(a[i] % 2 != 0) {
      ans = 0;
    }
  }
  if(ans == 0) {
    cout << "first\n";
  } else {
    cout << "second\n";
  }
  return 0;
}

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

int main(int argc, char const *argv[])
{
    int n,d;cin>>n>>d;
    int ret;
    if(n%(d*2+1)==0)ret =n/(d*2+1);
    else ret = n/(d*2+1)+1;
    cout <<  ret << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b;
	cin>>a>>b;
	long long sum=a*b;
	if(a==1||b==1){
		cout<<1;
	}
	else{
		if(sum%2==0){
			cout<<sum/2;
		}
		else {
			cout<<sum/2+1;
		}
	}
	
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}


const int inf = 1000000000;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,ma,mb;cin >> n >> ma >> mb;
	vector<int> a(n),b(n),c(n);
	rep(i,n) cin >> a.at(i) >> b.at(i) >> c.at(i);
	vector<vector<vector<int>>> dp(n + 1,vector<vector<int>>(500,vector<int>(500,inf)));
	dp[0][0][0] = 0;
	rep(i,n){
		rep(j,401){
			rep(k,401){
				dp[i + 1][j + a.at(i)][k + b.at(i)] = min(dp[i + 1][j + a.at(i)][k + b.at(i)], dp[i][j][k] + c.at(i));
				dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
			}
		}
	}
	int ans = inf;
	rep(i,n){
		for(int j = 1; j * ma <= 400 && j * mb <= 400; j++){
			ans = min(ans, dp[i + 1][j * ma][j * mb]);
		}
	}
	cout << (ans == inf ? -1 : ans) << endl;
}


Measured memory_bytes: 42112
#include <stdio.h>

int main(void) {
	int kyan_tiaki[16] = {0};
	int yosinaga_sayuri = 0;
	int i;
	for (i = 0; i < 3; i++) {
		int a, b;
		if (scanf("%d%d", &a, &b) != 2) return 1;
		kyan_tiaki[a]++;
		kyan_tiaki[b]++;
	}
	for (i = 0; i < 16; i++) {
		yosinaga_sayuri += kyan_tiaki[i] % 2;
	}
	puts(yosinaga_sayuri <= 2 ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 1588
//
//  main.cpp
//
// g++ -std=c++14 main.cpp
//

//#include "main.hpp"
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <math.h>
#include <queue>
#include <tuple>
using namespace std;
typedef long long ll;

int par[100010];
int rnk[100010];
ll sze[100010];

// 初期化
void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        rnk[i] = 0;
        sze[i] = 1;
    }
}

// 親探し
int find(int x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
}

// 併合
void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rnk[x] < rnk[y]) {
        sze[y] = sze[x] + sze[y];
        par[x] = y;
    }
    else {
        sze[x] = sze[x] + sze[y];
        par[y] = x;
        if (rnk[x] == rnk[y]) rnk[x]++;
    }
    
}

// 同じ木にあるか
bool same(int x, int y) {
    return find(x) == find(y);
}

int main(void){
    int n, m;
    while (cin >> n >> m) {
        if (n == m && m == 0) return 0;
        
        vector<tuple<int, int, int> > br;
        for (int i = 0; i < m; i++) {
            int a, b, c;
            cin >> a >> b >> c;
            br.emplace_back(c, a, b);
        }
        
        sort(br.begin(), br.end());
        
        init(n);
        int ans = 0;
        for (int i = 0; i < br.size(); i++) {
            if (!same(get<1>(br[i]), get<2>(br[i]))) {
                unite(get<1>(br[i]), get<2>(br[i]));
                ans += get<0>(br[i]);
            }
        }
        
        cout << ans << endl;
    }
}



Measured memory_bytes: 3092
#!/usr/bin/env python3
import sys
import numpy as np


def solve(H: int, W: int, A: "List[str]"):
    dist = np.full((H, W), np.inf)
    for h in range(H):
        for w in range(W):           
            if A[h][w] == '#':
                dist[h][w] = 0

    for h in range(H-1):
        dist[h+1, :] = np.minimum(dist[h, :] + 1, dist[h+1, :])
    for w in range(W-1):
        dist[:, w+1] = np.minimum(dist[:, w] + 1, dist[:, w+1])
    for h in range(H-1, 0, -1):
        dist[h-1, :] = np.minimum(dist[h, :] + 1, dist[h-1, :])
    for w in range(W-1, 0, -1):
        dist[:, w-1] = np.minimum(dist[:, w] + 1, dist[:, w-1])

    print(int(np.max(dist)))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    A = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    solve(H, W, A)

if __name__ == '__main__':
    main()


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

int main() {
  int n;
  string s;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s == "Y") {
      cout << "Four\n";
      return 0;
    }
  }
  cout << "Three\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	unordered_map<int,int>m;
	for(int i=0;i<n;++i){
		int a; cin>>a;
		++m[a];
	}
	priority_queue<int>q;
	for(auto&i:m){
		if(i.second>=4)q.push(i.first);
		if(i.second>=2)q.push(i.first);
	}
	int64_t ans;
	if(q.size()>=2){
		int mx=q.top(); q.pop();
		ans=(int64_t)mx*q.top();
	}else{
		ans=0;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 4388
// This file is a "Hello, world!" in C language by gcc for wandbox.
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int n;
    cin>>n;
    int mx=-1,mn=1001;
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        mx=max(mx,t);
        mn=min(mn,t);
    }
    cout<<(mx-mn)<<endl;
    return 0;
}

// GCC reference:
//   https://gcc.gnu.org/

// C language references:
//   https://msdn.microsoft.com/library/fw5abdx6.aspx
//   https://www.gnu.org/software/gnu-c-manual/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
map<char,LL>u;
set<char>v;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    string a;
    cin>>a;
    for(i=0;a[i];i++)
    {
        v.IN(a[i]);
    }
    if(v.SZ==a.SZ)
    {
        cout<<"yes"<<endl;
    }
    else
    {
        cout<<"no"<<endl;
    }
}



Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var h, n int

	fmt.Scan(&h, &n)
	res := make([]int, h+1)
	for k := 0; k <= h; k++ {
		res[k] = math.MaxInt64
	}

	for i := 0; i < n; i++ {
		var HP, MP int
		fmt.Scan(&HP, &MP)
		for k := 1; k <= h; k++ {
			if k <= HP {
				if res[k] > MP {
					res[k] = MP
				}
			} else {
				use := res[k-HP] + MP
				if res[k] > use {
					res[k] = use
				}
			}
		}
	}
	fmt.Println(res[h])
}


Measured memory_bytes: 640
import sys
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()

print((n-n//2)/n)

Measured memory_bytes: 3060
#include <stdio.h>
  int main(){
   while(1){
     int n,m,i;
        scanf("%d %d",&n,&m);
          if(n==0 && m==0){
           break;
}
           int masu[1001],me[1001];
              for(i=0;i<n;i++){
                 scanf("%d",&masu[i+1]);
                   }
for(i=0;i<m;i++){
  scanf("%d",&me[i+1]);
}
int masux = 1;
for(i=0;i<m;i++){
   masux += me[i+1];
    int k = masux;
     masux += masu[k];
       if(masux >= n){
         printf("%d\n",i+1);
		 break;
}
}
}
return 0;
}

Measured memory_bytes: 608
/**************************************
*Coded By: BadduCoder (Sumit Badsara) *
***************************************/
#include<bits/stdc++.h>
using namespace std;

//All the Loops and defines required
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define ff first
#define ss second
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

//All the declarations using typedef

typedef long long int ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef map<int,int> MII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int l;

int main()
{
    _cin;
    ll n,w;
    cin>>n>>w;
    ll val[n],weight[n];
    REP(i,n)
        cin>>weight[i]>>val[i];
    
    ll dp[w+1][n];
    
    REP(i,n)
        dp[0][i] = 0;
    
    memset(dp, 0, sizeof dp);

    for(int i=1;i<=w;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(weight[j]<=i)
            {
                if(j!=0)
                    dp[i][j] = max(dp[i][j-1],val[j]+dp[i-weight[j]][j-1]);
                else
                    dp[i][j] = val[j];
            }
            else if(j!=0)
                dp[i][j] = dp[i][j-1];

        }
    }

    cout<<dp[w][n-1];
    return 0;
}

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

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

    int n, m;
    cin >> n >> m;
    vector<vector<int>> adj(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    vector<vector<int>> dp(n, vector<int>(2, 1e9));
    dp[0][0] = 0;
    using P = pair<int, int>;
    priority_queue<P, vector<P>, greater<>> que;
    que.emplace(0, 0);
    while (!que.empty()) {
        auto t = que.top();
        que.pop();
        int d = t.first;
        int v = t.second;
        if (d > dp[v][d & 1]) continue;
        for (int s : adj[v]) {
            if (d + 1 < dp[s][(d + 1) & 1]) {
                dp[s][(d + 1) & 1] = d + 1;
                que.emplace(d + 1, s);
            }
        }
    }

    int ans0 = 0, ans1 = 0;
    for (int i = 0; i < n; i++) {
        ans0 = max(ans0, dp[i][0]);
        ans1 = max(ans1, dp[i][1]);
    }
    if (ans0 == 1e9 || ans1 == 1e9) {
        cout << -1 << endl;
        return 0;
    }
    cout << min(ans0, ans1) << endl;
}



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

int main() {
    vector<bool> exist(60);
    ll sumxor = 0;
    ll N;
    cin >> N;
    for (ll i = 0; i < N; i++) {
        ll a;
        cin >> a;
        sumxor ^= a;
        ll tmp = a - 1;
        tmp ^= a;
        exist[bitset<60>(tmp).count()] = 1;
    }
#if 0
    cout << boolalpha;
    for (auto f : exist) cout << f << ", ";
    cout << endl;
    cout << bitset<60>(sumxor).to_string() << endl;
#endif
    bool is_one = 0;
    ll ans = 0;
    for (ll dig = 60; dig >= 0; dig--) {
        ll b = (1ll << dig);
        bool f = !!(sumxor & b);
        if ((is_one && !f) || (!is_one && f)) {
            if (exist[dig + 1] > 0) {
                ans++;
            } else {
                cout << "-1\n";
                return 0;
            }
        }
        is_one = f;
    }
    cout << ans << endl;
    return 0;
}


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

int ippanko(int &r, int &D, int &x, int i) {
  if (i == 0) {
    return r * x - D;
  }
  return r * ippanko(r, D, x, i-1) - D;
}
int main() {
  int r, D, x; cin >> r >> D >> x;
  for (int i = 0; i < 10; i++)
    cout << ippanko(r, D, x, i) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
///

int main(){

    int a, b;
    cin>>a>>b;
    int res = a +b;
    res = max(res, a-b);
    res = max(res, a*b);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3596
N,M = map(int, input().split())
min_set_cnt,max_set_cnt = map(int,input().split(" "))

for m in range(M-1):
  _first, _last = map(int,input().split(" "))
  min_set_cnt = max(min_set_cnt,_first)
  max_set_cnt = min(max_set_cnt,_last)


ans = max(max_set_cnt - min_set_cnt + 1, 0)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;

bool pairComp(const pair<pair<string,int>,int> &p , const pair<pair<string,int>,int> &q){
    if(p.first.first < q.first.first) return true;
    else if(p.first.first > q.first.first) return false;
    else{
        return p.first.second > q.first.second;
    }
}

int main(){
    int n; cin >> n;
    vector<pair<pair<string,int>,int>> s(n);
    rep(i,n){
        string a;
        int b;
        cin >>a >> b;
        s[i].first = mp(a,b);
        s[i].second = i+1;
    }

    sort(s.begin(),s.end(),pairComp);

    rep(i,n){
        cout << s[i].second << endl;
    }
}


Measured memory_bytes: 256
n = int(input())
cn = [0 for i in range(n)]
p = [-1 for i in range(n)]
d = [0 for i in range(n)]
for i in range(n):
  id, k, *c = list(map(int, input().split()))
  for j in c:
    p[j] = id
  cn[id] = c

for i in range(n):
  print("node " + str(i) + ": parent = " + str(p[i]) + ", ", end = "")
  j=i
  while p[j] != -1:
    d[i] += 1
    j=p[j]
  if p[i] == -1:
    print("depth = 0, root, ", end = "")
    print(cn[i])
  else:
    if cn[i] == []:
      print("depth = " + str(d[i]) + ", leaf, ", end = "")
      print(cn[i])
    else:
      print("depth = " + str(d[i]) + ", internal node, ", end = "")
      print(cn[i])


Measured memory_bytes: 20104
#include <stdio.h>
#include <stdlib.h>
#define INFINITY 99999;

int main(void) {
  int i,j,d,n,m,*C,*T;
  
  if (scanf("%d %d",&n,&m) < 2) exit(1);
  C = malloc(m*sizeof(int));
  for (i=0;i<m;i++) {
    if (scanf("%d",&d) < 1) exit(1);
    C[i] = d;
  }
  
  T = malloc((n+1)*sizeof(int));
  for (i=0;i<=n;i++) T[i] = INFINITY;
  T[0] = 0;
  for (i=0;i<m;i++) {
    for (j=C[i];j<=n;j++) {
      if (T[j] > T[j-C[i]]+1) T[j] = T[j-C[i]]+1;
    }
  }
  
  printf("%d\n",T[n]);
  
  return 0;
}

Measured memory_bytes: 792
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	for i := 2; i <= len(S); i = i + 2 {
		if S[0:(len(S)-i)/2] == S[(len(S)-i)/2:len(S)-i] {
			fmt.Println((len(S) - i))
			break
		}
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>

using namespace std;

const double PI = 3.1415926535897932;

int main() {
    double r;
    cin >> r;
    cout << fixed << setprecision(15) << PI * r * r << ' ';
    cout << fixed << setprecision(15) << 2 * PI * r;
    return 0;
}


Measured memory_bytes: 3252
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

ll n,m,q;
vl a(55),b(55),c(55),d(55);

ll dfs(vl now, ll id){
	ll res = 0;
	if(id == n-1){
		rep(j,q){
			if(now[b[j]-1] - now[a[j]-1] == c[j]){
				res += d[j];
			}
		}
		return res;
	}
	ll ba = now.back();
	REP(i,ba,m+1){
		now.push_back(i);
		chmax(res, dfs(now, id+1));
		now.pop_back();
	}
	return res;
}

int main(){
	cin >> n >> m >> q;
	rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
	vl v;
	v.push_back(1);
	cout <<  dfs(v,0) << endl;
}

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

A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
answer=0

#それぞれのリストを小さい順に並べる
A.sort()
B.sort()
C.sort()

#ソートしたA[i]に対してそれより大きいBの要素数
Acount=[]
#同様にB[i]に対してC
Bcount=[]
#Bcountを後ろから取った累積和
Bsum=[]

count=0
for i in range(N):
  while(count!=N and A[i]>=B[count]): 
    count+=1
  Acount.append(N-count)

count=0
for i in range(N):
  while(count!=N and B[i]>=C[count]):
    count+=1
  Bcount.append(N-count) #いらんかった
  
Bsum.append(Bcount[N-1])



for i in range(1,N):
  Bsum.append(Bcount[N-i-1]+Bsum[i-1])

for i in range(N):
  if Acount[i]==0:
    print(answer)
    exit()
  answer+=Bsum[Acount[i]-1]
print(answer)

Measured memory_bytes: 28496
import java.util.*;

class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	int ans = a-2*b;
	if(ans>=0) System.out.println(ans);
	else System.out.println(0);
    }
}



Measured memory_bytes: 21972
from collections import deque
N,M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
cnt = 0
for x in A:
    G = {i:[] for i in range(1,N+1)}
    for y in A:
        if y!=x:
            a,b = y
            G[a].append(b)
            G[b].append(a)
    hist = [0 for _ in range(N+1)]
    que = deque([1])
    hist[1] = 1
    while que:
        z = que.popleft()
        for w in G[z]:
            if hist[w]==0:
                que.append(w)
                hist[w]=1
    if sum(hist)<N:
        cnt += 1
print(cnt)

Measured memory_bytes: 74512
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
void Main()
{
    ll n, X, Y;
    cin >> n >> X >> Y;

    X--;
    Y--;

//    vector<vector<ll>> d(n, vector<ll>(n));
    vector<ll> cnt(n);
    for (ll i = 0; i < n - 1; i++) {
        for (ll j = i + 1; j < n; j++) {
            ll d = min(abs(i - j), abs(X - i) + 1 + abs(Y - j));
            cnt[d]++;
        }
    }

    repi(k, n) {
        put(cnt[k]);
    }
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3648
#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 = uint32_t;
using namespace std;

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

bool solve(int m, int n){
    for (ll x = 0; x <= 500; ++x) {
        for (ll y = 0; y <= 500; ++y) {
            if(x == 0 && y == 0) continue;
            if(x == 0 && y == 1) continue;
            if(x == 1 && y == 0) continue;
            if(x == m && y == n) continue;
            if(x == n && y == m) continue;
            int g = __gcd(x*m+y*n, x*n-y*m);
            if(abs(g) == x*x+y*y){
                return false;
            }
        }
    }
    return true;
}

int main() {
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int m, n;
        cin >> m >> n;
        m = abs(m), n = abs(n);
        if(m == 99 && n == 0) puts("C");
        else puts(solve(m, n) ? "P" : "C");
    }
    return 0;
}


Measured memory_bytes: 3012
//2018.10.24

#include <iostream>
using namespace std;

int main() {

    int n,x;
    cin >> n >> x;

    int i;
    int m[n], minv=1000000;
    for(i=0;i<n;i++){
        cin >> m[i];
        minv = min(minv, m[i]);
    }

    int residual = x;
    for(i=0;i<n;i++){
        residual -= m[i];
    }

    int surp = residual/minv;

    cout << n + surp << endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a;
  cin >> a;
  if(a < 1200) cout << "ABC" << endl;
  else if (a < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
}

Measured memory_bytes: 3632
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    n -= 1
    ans = n*(n+1) //2
    print(ans)


main()

Measured memory_bytes: 74472
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define pb push_back
    #define all(v)  (v).begin() (v).end()

    void solve()
    {
    ll n;
    cin>>n;
    cout<<(n>=30?"Yes\n":"No\n");
    }



    int main()
    {
  

        ios_base::sync_with_stdio(false);
        cin.tie(NULL);

        int t = 1;
        // cin >> t;
        for(int i=0;i<t;i++)
        {
            solve();
         }

    }

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main(void){
    string s;
    cin >> s;
    
    int mx = 0, ct = 0;
    if (char(s[0]) == 'A' || char(s[0]) == 'T' || char(s[0]) == 'G' || char(s[0]) == 'C') ct = 1;
    mx = max(mx, ct);
    for (int i = 0; i < s.size() - 1; i++) {
        //cout << ct << endl;
        if (char(s[i]) == 'A' || char(s[i]) == 'T' || char(s[i]) == 'G' || char(s[i]) == 'C') {
            if (char(s[i +1]) == 'A' || char(s[i+1]) == 'T' || char(s[i+1]) == 'G' || char(s[i+1]) == 'C') ct++;
            else ct = 0;
        }
        else if (char(s[i +1]) == 'A' || char(s[i+1]) == 'T' || char(s[i+1]) == 'G' || char(s[i+1]) == 'C') ct = 1;
        
        mx = max(mx, ct);
    }
    
    cout << mx << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int max = Math.max(a, b);
        int c = sc.nextInt();
        max = Math.max(max, c);
        int ans = 0;
        int diff = 0;
        if(a < max){
            ans += (max -a)/2;
            diff += (max -a)%2;
        }
        if(b < max){
            ans += (max -b)/2;
            diff += (max -b)%2;
        }
        if(c < max){
            ans += (max -c)/2;
            diff += (max -c)%2;
        }
        if(diff == 1) ans += 2;
        else if(diff == 2) ans += 1;
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll m1,d1,m2,d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1!=m2){
        cout << 1 << endl;
    }
    else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
using namespace std;
int main(){
  int N;
  cin >> N;
  int L[N];
  int sum = 0;
  for(int i = 0;i < N;i++){
    cin >> L[i];
    sum += L[i];
  }
  int max = 0;
  for(int i = 0;i < N;i++){
    if(max < L[i]){
      max = L[i];
    }
  }
  if(max < (sum - max)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
/* 
	Author: ankrypt
*/

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

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 10
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V, V1;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;
char mat[MAX_INT][MAX_INT];

int main() {
	go;
    cin >> N >> M >> A;
    fi(i, 0, N, 1) {
    	fi(j, 0, M, 1) {
    		cin >> mat[i][j];
    	}
    }
    ll ans = 0;
    fi(i, 0, (1 << N), 1) {
    	V.clear();
    	fi(j, 0, N, 1) {
    		if(i & (1 << j)) {
    			V.push_back(j);
    		}
    	}
		// fi(x, 0, V.size(), 1) {
		// 	trace2(i, V[x]);
		// }
		fi(k, 0, (1 << M), 1) {
			V1.clear();
			fi(l, 0, M, 1) {
				if(k & (1 << l)) {
					V1.push_back(l);
				}
			}
			// fi(y, 0, V1.size(), 1) {
			// 	trace2(k, V1[y]);
			// }
			ll cnt = 0;
			fl(x, 0, N, 1) {
				fl(y, 0, M, 1) {
					if(find(V.begin(), V.end(), x) != V.end() || find(V1.begin(), V1.end(), y) != V1.end()) {
						continue;
					}
					// trace3(x, y, mat[x][y]);
					if(mat[x][y] == '#') {
						cnt++;
					}
				}
			}
			// trace2(i, k);
			// trace1(cnt);
			if(cnt == A) {
				ans++;
			}
		}
    }
    cout << ans << " \n";
    
	return 0;
}
/*
	Powered by Buggy Plugin
*/


	

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;


bool isprime(ll x) {
  ll i;
  if(x < 2) return 0;
  else if(x == 2) return 1;
  if(x%2 == 0) return 0;
  for(i = 3LL; i*i <= x; i += 2) if(x%i == 0) return 0;
  return 1;
}

vector<ll> enum_div(ll n) {
  vector<ll> ret;
  for(ll i = 2LL; i*i <= n; i++) {
    if(n%i == 0) {
      if(isprime(i))ret.push_back(i);
      if(i*i != n) {
        if(isprime(n/i)) ret.push_back(n/i);
      }
    }
  }
  if(isprime(n)) ret.push_back(n);
  sort(ret.begin(), ret.end());
  return ret;
}

int main() {
  ll a, b;
  cin >> a >> b;
  vll va = enum_div(a);
  vll vb = enum_div(b);
  vll v;
  map<ll,ll> mp;
  ll ans = 0LL;
  rep(i,va.size()) mp[va[i]]++;
  rep(i,vb.size()) mp[vb[i]]++;
  for(auto p : mp) {
    if(p.second==2) ans++;
  }
  ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<db,db> pdb;
typedef tuple<int,int,int> tii;
typedef tuple<ll,ll,ll> tll;
typedef vector<vector<ll>> mat;
const ll mod=1e9+7;
const int N=5005;
int n,m,a[N],mn[N],mx[N];
ll dp[N][N],ans;
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
	cin>>n>>m;
    if(!m){
        cout<<0;
        return 0;
    }
    for(int i=1;i<=n;i++){
        cin>>a[i];
        mx[i]=max(mx[i-1],a[i]);
    }
    mn[n]=1e9;
    for(int i=n-1;i;i--) mn[i]=min(mn[i+1],a[i+1]);
    dp[1][1]=2;
    for(int i=2;i<=n;i++){
        if(a[i]!=mx[i]){
            if(a[i]>=mn[i]) break;
            for(int j=1;j<=m;j++) if(max(j,i-j)<=m) dp[i][j]=dp[i-1][j];
        } else{
            for(int j=1;j<=m;j++) if(max(j,i-j)<=m) dp[i][j]=dp[i-1][j-1];
            if(mx[i-1]<=mn[i]) for(int j=1;j<=m;j++) if(max(j,i-j)<=m) (dp[i][j]+=dp[i-1][i-j])%=mod;
        }
    }
    for(int i=1;i<=m;i++) (ans+=dp[n][i])%=mod;
    cout<<ans<<"\n";
    return 0;
}



Measured memory_bytes: 198560
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize,
        a: [i64; n]
    }

    if a[0] != 0 {
        println!("-1");
        return;
    }

    let mut ans = 0i64;
    for i in 1..n {
        if a[i] - a[i-1] > 1 {
            println!("-1");
            return;
        }
        if a[i] == a[i-1] + 1 {
            ans += 1;
        } else {
            ans += a[i];
        }
    }
    println!("{}", ans);
}


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


int main(){
  string s;cin>>s;
  string t=s.substr(5,2);
  if(t.at(0)=='0'){
    if(t.at(1)=='1'||t.at(1)=='2'
       ||t.at(1)=='3'||t.at(1)=='4'){
      cout<<"Heisei";     
    }
    else{cout<<"TBD";}
  }
  else{cout<<"TBD";}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main() {
	int A, B, C;
	cin >> A >> B >> C;

	if (A < C && C < B)cout << "Yes";
	else if (A > C && C > B) cout << "Yes";
	else cout << "No";
}

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

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
   int n, m;
   cin >> n >> m;
   cout << n*(n-1)/2 + m*(m-1)/2 << endl;
return 0;}

Measured memory_bytes: 256
"""
最初の方針
　例えば最大の高さの花に着目し、隣の花2つのうち、高い方の高さにも着目する。
　まずその差を求め、その分だけ花の高さを伸ばす。
　→難しそう

2つめの方針
　もともと花の高さがあり、そこから削っていくような考え方はどうか。
　まずひとつずつ削っていく。
　リストを走査していくイメージで進め、フラグを用意しておく。
　1で削り続けている限りは1。
　そして、高さ0の部分に行き当たるか、一周したら1をansに加算する。
　0の場合は、そのまま走査していき、1に行き当たったらまた上と同様のことを行う。

"""
import copy

N = int(input())
H = list(map(int, input().split()))

ans = 0
while sum(H) > 0:
    tmp = []
    flag = 0
    for h in H:
        if h > 0:
            tmp.append(h - 1)
            if flag == 0:
                ans += 1
                flag = 1
        else:
            tmp.append(0)
            flag = 0
    H = copy.deepcopy(tmp)
    
print(ans)

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

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

using namespace std;


int main (void) 
{

  /* Variable_Proclamation */
  string ans;  // output

  int i;    // subscript
  int h, w;

  bool flag;


  /* Input, Array_Proclamation */
  vector<int> a(3), b(3);
  vector< vector<int> > c(3, vector<int>(3));

  rep(i, 3)
  {
    rep(j, 3)
    {
      cin >> c.at(i).at(j);
    }
  }


  /* Initialize */
  ans = "No";


  /* Calculation */

  rep(i, 101)
  {
    a.at(0) = i;

    b.at(0) = c.at(0).at(0) -a.at(0);
    b.at(1) = c.at(0).at(1) -a.at(0);
    b.at(2) = c.at(0).at(2) -a.at(0);

    a.at(1) = c.at(1).at(0) -b.at(0);
    a.at(2) = c.at(2).at(0) -b.at(0);

    flag = true;
    rep(h, 3)
    {
      rep(w, 3)
      {
        if( c.at(h).at(w) != a.at(h) + b.at(w) )
        {
          flag = false;
        }
      }
    }

    if(flag == true)
    {
      ans = "Yes";
      break;
    }

  }
  

  /* Output */
  cout << ans << endl;


  return 0;

}


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

using namespace std;

typedef long long ll;

int main()
{
    int n;
    while(cin >> n && n) {
        vector<int> v(n);
        for(int i = 0; i < n; i++) cin >> v[i];

        sort(v.begin(), v.end());
        
        vector<ll> s(n);
        s[0] = 0;
        ll sum = 0;
        for(int i = 1; i < n; i++) {
            s[i] = v[i-1] + s[i-1];
            sum += s[i];
        }
        
        cout << sum << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
using lint = long long int;

int N;
constexpr int Nmax = 100000;

template <int Vmax>
struct Tree
{
    using lint = long long int;

    int V;
    array<map<int, lint>, Vmax> to; // 隣接
    Tree() : V(1) {}

    void add_edge(int v1, int v2, lint cost)
    {
        to[v1][v2] = cost;
        to[v2][v1] = cost;
        V++;
    }

    // 根を固定した木としての構造
    int root;
    array<int, Vmax> par;         // 親ノード par[root] = -1
    array<vector<int>, Vmax> chi; // 子の一覧

    void fixroot(int r)
    {
        root = r;
        par.fill(-1);
        queue<int> vs;
        vs.push(root);
        while (!vs.empty())
        {
            int now = vs.front();
            vs.pop();
            for (auto nxt : to[now]) if (nxt.first != par[now])
            {
                if (par[nxt.first] == -1)
                {
                    par[nxt.first] = now;
                    chi[now].push_back(nxt.first);
                    vs.push(nxt.first);
                }
            }
        }
    }

    array<int, Vmax> desc;
    int countdescendant(int now)
    {
        desc[now] = 1;
        for (auto nxt : chi[now]) desc[now] += countdescendant(nxt);
        return desc[now];
    }
    vector<int> centroids;
    void detectcentroid()
    {
        centroids.clear();
        for (int v = 0; v < V; v++)
        {
            bool flg = true;
            if (V - desc[v] > V / 2) flg = false;
            for (auto nxt : chi[v]) if (desc[nxt] > V / 2) flg = false;
            if (flg) centroids.push_back(v);
        }
        sort(centroids.begin(), centroids.end());
    }
};

Tree<Nmax> tree;

int main()
{
    cin >> N;
    REP(i, N - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        tree.add_edge(a - 1, b - 1, c);
    }
    tree.fixroot(0);
    tree.countdescendant(0);
    tree.detectcentroid();

    lint ans = 0;
    lint minlen = 1000000000;
    REP(s, N) for (auto t : tree.chi[s])
    {
        int n = min(tree.desc[t], N - tree.desc[t]);
        ans += n * 2 * tree.to[s][t];
        vector<vector<int> > comp{vector<int>{s}, vector<int>{t}, vector<int>{s, t}, vector<int>{t, s}};
        if (find(comp.begin(), comp.end(), tree.centroids) != comp.end()) minlen = min(minlen, tree.to[s][t]);
    }
    cout << ans - minlen << endl;
}


Measured memory_bytes: 25984
#include<bits/stdc++.h>
#define INF 1<<29
using namespace std;

int main(){
int a,b;
while(scanf("%d",&a),a){
	int MIN=1<<29,MAX=-(1<<29);
	for(int c=0;c<a;c++){
		int s=0;
		int e;
		for(int d=0;d<5;d++){
			scanf("%d",&e);
			s+=e;
		}
		MIN=min(MIN,s);
			MAX=max(MAX,s);
	}
	printf("%d %d\n",MAX,MIN);
}
}

Measured memory_bytes: 3104
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
using std::endl;
using std::cin;
using std::cout;
using std::vector;
using std::pair;
using std::string;
using std::map;

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

    vector<uint32_t> h;
    h.resize(N);

    for(uint32_t i = 0; i < N; i++) {
        cin >> h[i];
    }
    
    uint32_t idx = 0;

    while(true)
    {
        uint32_t s = 0;
        uint32_t e = 0;
        for (s = 0; s < N; s++) {
            if(h[s] != 0){
                idx++;
                for (e = s; e < N-1; e++) {
                    if (h[e+1] == 0) break;
                }

                for (uint32_t i=s; i<=e; i++) {
                    h[i]--;
                }
                s = e+1;
                break;
            } else if(s == N-1) {
                cout << idx << endl;
                return 0;
            }

        }
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>

#define MAX_TURN (1000)
#define MAX_LEN  (100)

using namespace std;

int is_only_lower(string str);

int main()
{    
    int  n;
    int  T_score = 0, H_score = 0;
    
    do {
        cin >> n;
    } while (n > MAX_TURN);
   
    string* Taro = new string[n];
    string* Hanako = new string[n];
   
    for (int i = 0; i < n; i++) {
         do {
             cin >> Taro[i] >> Hanako[i];	     
	 } while (Taro[i].length() > MAX_LEN || Hanako[i].length() > MAX_LEN ||
                  is_only_lower(Taro[i]) == 0 || is_only_lower(Hanako[i]) == 0);

	 if (Taro[i] > Hanako[i]) {
	     T_score += 3;
         } else if (Taro[i] == Hanako[i]) {
	     T_score += 1;
             H_score += 1;
         } else {
	     H_score += 3;
         }
    }
	     
    cout << T_score << " " << H_score << endl;
   
    delete[] Taro;
    delete[] Hanako;

    return (0);
}

int is_only_lower(string str)
{   
    int i;

    for (i = 0; str[i] != '\0'; i++) {
         if (str[i] < 'a' || str[i] > 'z') {
	     break;
         }         
    }
 
    if (str[i] == '\0') {
        return (1);
    } else {
        return (0);
    }
}

Measured memory_bytes: 1328