akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

using namespace std;
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;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,a; cin >> n >> a;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    vector<vector<vector<ll>>> dp(n+1, vector<vector<ll>>(n+1, vector<ll>(2510,0)));
    dp[0][0][0]=1;
    rep(i,n){
        rep(j,n+1){
            rep(k,2510){
                dp[i+1][j][k]+=dp[i][j][k]; //erabanai
                if(k-x[i]>=0&&j+1<=n)dp[i+1][j+1][k]+=dp[i][j][k-x[i]]; //erabu
            }
        }
    }
    ll ans=0;
    rep(j,n+1){
        rep(k,2510){
            if(a*j==k&&k!=0)ans+=dp[n][j][k];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 55444
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//
//

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

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

using ll = long long;

template<class T> inline bool chmin(T& a, T b){ if(a>b){a=b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b){ if(a<b){a=b; return 1;} return 0;}

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__

bool check(string T){
  int a=(int)T.size();
  REP(i,(a+1)/2){
    if(T[i]!=T[a-i-1]){
      return false;
    }
  }
  return true;
}


void solve(void){
  
  string S;
    
  cin >> S;

  int A=((int)S.size()-1)/2;
  int B=((int)S.size()+3)/2;
  
  int ans=0;
    
  if(check(S)){ans++;}
  if(check(S.substr(0,A))){ans++;}
  if(check(S.substr(B-1,S.size()-B+1))){ans++;}
  
  puts(ans==3?"Yes":"No");

  return;
   
}


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

    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    vector<ll> A(100000);
    int N; cin >> N;
    ll ans = 0;
    rep(i, N){
        int a; cin >> a;
        A[a-1]++;
        ans += a;
    }
    int Q; cin >> Q;
    rep(i, Q){
        int B, C;
        cin >> B >> C;
        ans += A[B-1] * (C-B);
        A[C-1] += A[B-1];
        A[B-1] = 0;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3804
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

/* 値を入れ替える関数 */
void swap (int *x, int *y) {
    int temp;    // 値を一時保存する変数
    
    temp = *x;
    *x = *y;
    *y = temp;
}

/***
 * pivotを決め、
 * 全データをpivotを境目に振り分け、
 * pivotの添え字を返す
 ***/
int partition (int array[], int left, int right) {
    int i, j, pivot;
    i = left;
    j = right + 1;
    pivot = left;   // 先頭要素をpivotとする
    
    do {
        do { i++; } while (array[i] < array[pivot]);
        do { j--; } while (array[pivot] < array[j]);
        // pivotより小さいものを左へ、大きいものを右へ
        if (i < j) { swap(&array[i], &array[j]); }
    } while (i < j);
    
    swap(&array[pivot], &array[j]);   //pivotを更新
    
    return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
    int pivot;
    
    if (left < right) {
        pivot = partition(array, left, right);
        quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
        quick_sort(array, pivot+1, right);
    }
}

int main(void){
    int i,j,k;
    int N,index1 = 0,index2 = 0,temp,count = 0,pre;
    int p[50],gen[50];
    
    scanf("%d",&N);
    for(i = 0;i < N-1;i++){
        scanf("%d\n",&p[i]);
        gen[i] = p[i];
    }
    scanf("%d",&p[i]);
    gen[i] = p[i];
    
    quick_sort(p,0,N-1);
    
    for(i = 0;i < N;i++){
        if(gen[i] != p[i]){
            count++;
        }
    }
    
    if(count == 2 || count == 0){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
    return 0;
}



Measured memory_bytes: 128
#include<stdio.h>
long long MIN(long long a,long long b){return a<b?a:b;}
int main(){
  long long a,b,s;
  scanf("%lld %lld",&a,&b);
  s=MIN(a,b/2);
  b-=s*2;
  printf("%lld\n",s+b/4);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static long check = 1000000000000000000L;

    public static void main(String[] args) {
        int n = sc.nextInt();
        long arr[] = new long[n];
        for (int i = 0; i < n; i++){
            arr[i] = sc.nextLong();
        }
        long ans = 1;
        for (int i = 0; i < n; i++){
            long tmp = ans;
            ans *= arr[i];
            if (ans < 0 || ans < arr[i] || ans < tmp){
                ans = -1;
                break;
            }
        }
        for (int i = 0; i < n; i++){
            if (arr[i] == 0){
                ans = 0;
                break;
            }
        }
        if (ans > check){
            System.out.println(-1);
        } else {
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 61800
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	long long int n, k[200005];
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> k[i];
		k[i] -= i + 1;
	}
	sort(k, k + n);
	long long int mon;
	if (n % 2) mon = k[n / 2];
	else mon = (k[n / 2] + k[n / 2 - 1]) / 2;
	long long int ans = 0;
	for (int i = 0; i < n; ++i) {
		ans += std::abs(k[i] - mon);
	}
	cout << ans << endl;
}

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

int main()
{
  int n,m,x,kari,cnt,cnt2;
  cnt=0;
  cnt2=0;
  cin >> n >> m >> x;
  int mo[n+1]={0};
  for(int i=0;i<m;i++){
    cin >> kari;
    ++mo[kari];
  }
  for(int i=x;i>0;--i) cnt+=mo[i];
  for(int i=x;i<n;i++) cnt2+=mo[i];
  cout << ((cnt>cnt2)? cnt2:cnt) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '1') cnt++;
    }

    cout << cnt << endl;

    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,true):false;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,true):false;}

int nextInt() {
  int x; scanf("%d", &x); return x;
}

struct BIT {
  int n;
  vector<ll> tree;
  BIT(int n):n(n),tree(n+1) {} 
  void fill(ll val) {
    REP(i, n+1) tree[i] = (i&-i) * val;
  }
  void add(int idx, ll val) {
    for (int x=idx+1; x<=n; x+=x&-x) tree[x] += val;
  }
  ll range(int idx) {
    ll sum=0;
    for (int x=idx+1; x>0; x-=x&-x) sum += tree[x];
    return sum;
  }
};

ll f(const vector<ll>& A) {
  vector<ll> C(A.begin(), A.end());
  C.push_back(0);
  sort(C.begin(), C.end());
  C.erase(unique(C.begin(), C.end()), C.end());
  int M = (int)C.size();
  BIT bit(M + 10);

  int one = (int)(lower_bound(C.begin(), C.end(), 0) - C.begin());
  bit.add(one, +1);

  ll ans = 0;
  REP(i, A.size()) {
    int idx = (int)(lower_bound(C.begin(), C.end(), A[i]) - C.begin());
    ans += bit.range(idx);
    bit.add(idx, +1);
  }
  return ans;
}

const int MAX_N = 200000 + 10;
ll a[MAX_N];
ll b[MAX_N];

int main2() {
  int N = nextInt();
  int K = nextInt();
  REP(i, N) a[i] = nextInt() - K;
  vector<ll> b;
  b.push_back(a[0]);
  for (int i = 1; i < N; i++) b.push_back(b[i-1] + a[i]);
  // REP(i, b.size()) cout << b[i] << " "; cout << endl;
  ll ans = f(b);
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}


Measured memory_bytes: 8176
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iomanip>
#define faster       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f(i,a,b) for(ll i=a;i<b;i++)
#define r(i,a,b) for(ll i=a;i>b;i--)
using namespace std;
typedef long long ll;
typedef long double ld;
const ll INF=1e18;

int main(){
 ll n; cin >> n;
 ll k; cin >> k;
 vector <ll> v(n);
 f(i,0,n){
   cin>>v[i];
 }

 vector <ll> dp(n,INF);
 dp[0]=0;

 f(i,0,n){
   f(j,i+1,i+k+1){
     if(j<n){
     dp[j]=min(dp[j],dp[i]+abs(v[j]-v[i]));
     }
   }
 }

 cout << dp[n-1] << endl;

}



Measured memory_bytes: 1792
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();
		
       if(B%A==0) {
    	   System.out.println(A+B);
       }
       else {
		System.out.println(B-A);
       }
	}

}



Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

vector<string> split(string,string);

//template<typename T>
//void swap(T*,T*);
//char ToUpper (char cX) { return toupper(cX); }

int main()
{
    int A,B;
    cin >> A >> B;
    cout <<(A*B %2==0?"Even":"Odd");
}

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

int N,K;
int p[100000];

int main(){
	cin >> N >> K;
	for(int i = 0; i < N; i++){
		cin >> p[i];
	}
	sort(p,p+N);
	int ans = 0;
	for(int i = 0; i < K; i++){
		ans += p[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3648
abc=list(map(int,input().split()))
abc.sort()
a,b,c = abc[0],abc[1],abc[2]

ans=0

ans+=c-b
c+-(c-b)
a+=(c-b)

if((c-a)%2==0):
    ans+=(c-a)//2
    print(ans)
else:
    ans+=-(-(c-a)//2)
    ans+=1
    print(ans)


Measured memory_bytes: 3064
function main(input) {
  var temp = input.split('\n');
  var arr = temp;
  var marks = ["S", "H", "C", "D"];
  var answer = "";
  for (var i = 0; i < marks.length; i++) {
    for (var j = 0; j < 13; j++) {
      var card = marks[i] + " " + (j + 1);
      if (arr.indexOf(card) < 0) {
        answer += (card + "\n");
      }
    }
  }
  if (answer.length != 0)
    console.log(answer.trim());
}

var x = require('fs').readFileSync('/dev/stdin', 'utf-8');
main(x);


Measured memory_bytes: 15104
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define Graph vector<vector<int>>;
#define iterG(next_v, G, v) for(auto next_v : G[v]
int numdiv(int n){
    if (n <= 3){
        return 1;
    }
    int tmp, res;
    map<int, int>  dic;
    tmp = n;
    for(int i = 2; i <= sqrt(n);++i){

        while(tmp == i * (tmp/ i)){
            if(dic.count(i)){
                dic[i] = dic[i] + 1;
            }else{
                dic[i] = 2;
            }
            tmp = tmp / i;
        }
    }
    res = 1;
    for(auto const& x:dic){
        res = res * x.second;
    }
    return res;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int tmp, res;
    res = 0;
    rep(i, n){
        tmp = i + 1;
        if(tmp % 2 == 0){
            continue;
        }
        if (numdiv(tmp) == 8){
            res++;
        }        
        
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
n=int(input())
v=[0]*n
c=[0]*n
v=list(map(int,input().split()))
c=list(map(int,input().split()))

x=0
y=0
for i in range(n):
  if (v[i]>c[i]):
    x+=v[i]
    y+=c[i]
    
print(x-y)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 20005;
const int K = 50;
bitset < 5001 > bs1, bs2, bs3, s[N], p[N], bs;
int a[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n, k;
    cin >> n >> k;
    int ans = 0;
    int sum = 0;
    int c = 0;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        if (a[i] > k){
            a[i] = 0;
            c++;
        }
        sum += a[i];
    }
    p[0][0] = 1;
    for (int i = 1; i <= n; i++){
        p[i] = p[i - 1] | (p[i - 1] << a[i]);
    }
    s[n + 1][0] = 1;
    for (int i = n; i >= 1; i--){
        s[i] = s[i + 1] | (s[i + 1] << a[i]);
    }
    if (sum < k){
        cout << n - c;
        return 0;
    }
    for (int i = 1; i <= n; i++){
        int r = k - 1;
        int l = k - a[i];
        bs.reset();
        for (int j = l; j <= r; j++) bs[j] = 1;
        bs1 = p[i - 1];
        bs2 = s[i + 1];
        int r1 = 0;
        int r2 = 0;
        for (int j = 0; j < k; j++) if (bs1[j]) r1 = max(r2, j);
        for (int j = 0; j < k; j++) if (bs2[j]) r2 = max(r1, j);
        int f = 0;
        if (a[i] == 0) continue;
        if (r - l + 1 < K){
            for (int j = l; j <= r && f == 0; j++){
                for (int q = 0; q <= j && f == 0; q++){
                    if (bs1[q] && bs2[j - q]) f = 1;
                }
            }
        }
        if (bs1.count() > bs2.count()) swap(bs1, bs2);
        if ((bs1 & bs).count() != 0) f = 1;
        if ((bs2 & bs).count() != 0) f = 1;
        vector < int > v;
        for (int j = 0; j < k; j++){
            if (bs1[j]){
                v.pb(j);
            }
        }
        random_shuffle(v.begin(), v.end());
        for (auto j: v){
            if (((bs2 << j) & bs).count() != 0) f = 1;
            if (f) break;
        }
        if (f == 0){
            ans++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 8448
N = int(input())
p = 1
num = 0
for i in range(N):
    a = int(input())
    if i == 0:
        num += a - 1
    elif a == p + 1:
        p += 1
    elif a > p + 1:
        num += (a - 1) // (p + 1)

print(num)


Measured memory_bytes: 48616
#include <cstdio>
using namespace std;
#define M 1000000007
#define N 1000100
int f[N][2][2];
int main(){
    int n; scanf("%d",&n);
    f[1][0][0]=8;
    f[1][1][0]=1;
    f[1][0][1]=1;
    for (int i=2;i<=n;i++){
        f[i][0][0]=1LL*f[i-1][0][0]*8%M;
        f[i][1][0]=(1LL*f[i-1][1][0]*9%M+f[i-1][0][0])%M;
        f[i][0][1]=(1LL*f[i-1][0][1]*9%M+f[i-1][0][0])%M;
        (f[i][1][1]=(1LL*f[i-1][1][1]*10%M+f[i-1][1][0])%M+f[i-1][0][1])%=M;
    }
    printf("%d\n",f[n][1][1]);
    return 0;
}


Measured memory_bytes: 18664
import math
import fractions
import copy
#以下てんぷら
def j(q):
    if q==1: print("YES")
    elif q == 0:print("NO")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
m,n= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
left = 1
right = m
for p in range(n):
    l,r = (int(i) for i in input().split())
    left = max(l,left)
    right = min(r,right)
if left<=right:
    print(right-left+1)
else:
    print(0)

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int h,w;cin>>h>>w;
    vector<vector<char>>a(h+2,vector<char>(w+2));
    ll dp[h+2][w+2];
    rep(i,h+2){
        rep(j,w+2)dp[i][j]=INF;
    }
    for(int i=1;i<=h;++i){
        for(int j=1;j<=w;++j){
            cin>>a[i][j];
        }
    }
    if(a[1][1]=='.')dp[1][1]=0;
    else dp[1][1]=1; 
    for(int i=1;i<=h;++i){
        for(int j=1;j<=w;++j){
            dp[i][j]=min(dp[i][j],dp[i-1][j]+(a[i-1][j]=='.'&&a[i][j]=='#'));
            dp[i][j]=min(dp[i][j],dp[i][j-1]+(a[i][j-1]=='.'&&a[i][j]=='#'));
        }
    }
    cout<<dp[h][w]<<endl;
}

Measured memory_bytes: 384
n, k = map(int, input().split())

ps = list(map(int, input().split()))
cur = 0
for i in range(k):
    cur += ps[i] + 1

mx = cur

for i in range(n-k):
    j = i+k
    cur += -ps[i] + ps[j]
    mx = max(mx, cur)

print(mx / 2)


Measured memory_bytes: 25060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
   string s;
   cin>>s;
   ll i,n=s.length();
   ll flag=0;

    string str="";
    for(i=0;i<4;i++)
    {
        str+=s[i];
    }
    ll a = stoll(str);

    if(a>2019)
    {
        flag=1;
    }
    if(a<2019)
    {
        cout<<"Heisei";
        exit(0);
    }
    if(a==2019)
    {
        string ss="";
        ss+=s[6];
        int p = stoi(ss);
        if(s[5]=='1' || p>4)
        {
            flag=1;
        }
    }
    if(s=="2019/04/31")
    {
        flag=1;
    }
    if(flag)
    {
        cout<<"TBD";
    }
    else
    {
        cout<<"Heisei";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int T;
    cin >> n >> T;
    int c[n], t[n];
    rep(i, n){
        cin >> c[i] >> t[i];
    }
    
    bool j = false;
    int min_c = 1000;
    rep(i, n){
        if(t[i] <= T){
            j = true;
            if(min_c > c[i]){
                min_c = c[i];
            }
        }
    }
    if(j){
        cout << min_c << endl;
    }else{
        cout << "TLE" << endl;
    }
}

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

// 2数の最大公約数を求める
int GCD(int a, int b){
	
	int c = a;
	if(a<b){
		int temp = a;
		a = b;
		b = temp;
	}
	while (c!= 0){
		a = b;
		b = c;
		c = a % b;
	}

	return b;
}

int main(){

	long N;
	long value;
	long ans;
	cin >> N;

	vector<long> v;
	for (long i = 0; i < N; i++){
		cin >> value;
		v.push_back(value);
	}
	sort(v.begin(),v.end());//昇順ソート


	ans = v[0];

	for (long i = 0; i < N-1; i++){

		ans = GCD(v[i+1],ans);
		if (ans == 1){
			break;
		}

		//ans = v[i+1]% ans;
		
		//if (ans == 0 || ans > tmp){
		//	ans = tmp;
		//}
		//cout << ans << endl;
	}


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



Measured memory_bytes: 1400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _001_FindingMissingCards
{
    class Dice
    {
        private int[] num = new int[7];
        private int[] reverse = new int[100];

        public Dice(int[]given)
        {
            num[1] = given[0];
            num[2] = given[1];
            num[3] = given[2];
            num[4] = given[3];
            num[5] = given[4];
            num[6] = given[5];

            reverse[given[0]] = 1;
            reverse[given[1]] = 2;
            reverse[given[2]] = 3;
            reverse[given[3]] = 4;
            reverse[given[4]] = 5;
            reverse[given[5]] = 6;
        }

        private int rightNum(int numa, int numb)
        {
            int x = 0;

            if ((numa == 2 && numb == 3) ||
                (numa == 3 && numb == 5) ||
                (numa == 4 && numb == 2) ||
                (numa == 5 && numb == 4))
            {
                x = 1;
            }
            else if (
                (numa == 1 && numb == 4) ||
                (numa == 3 && numb == 1) ||
                (numa == 4 && numb == 6) ||
                (numa == 6 && numb == 3))
            {
                x = 2;
            }
            else if (
                (numa == 1 && numb == 2) ||
                (numa == 2 && numb == 6) ||
                (numa == 5 && numb == 1) ||
                (numa == 6 && numb == 5))
            {
                x = 3;
            }
            else if (
                (numa == 1 && numb == 5) ||
                (numa == 2 && numb == 1) ||
                (numa == 5 && numb == 6) ||
                (numa == 6 && numb == 2))
            {
                x = 4;
            }
            else if (
                (numa == 1 && numb == 3) ||
                (numa == 3 && numb == 6) ||
                (numa == 4 && numb == 1) ||
                (numa == 6 && numb == 4))
            {
                x = 5;
            }
            else if (
                (numa == 2 && numb == 4) ||
                (numa == 3 && numb == 2) ||
                (numa == 4 && numb == 5) ||
                (numa == 5 && numb == 3))
            {
                x = 6;
            }

            return x;
        }


        public int setTopFront(int a, int b)
        {

            return num[rightNum(reverse[a],reverse[b])];
        }



    }

    class Program
    {
        static void Main()
        {
            var tmp1 = Console.ReadLine().Split(' ');
            var sample1 = new int[tmp1.Length];
            for (int i = 0; i < tmp1.Length; i++)
            {
                sample1[i] = Convert.ToInt32(tmp1[i]);
            }
            Dice a = new Dice(sample1);

            var numOfComm = Convert.ToInt32(Console.ReadLine());
            for (int i = 0; i < numOfComm; i++)
            {
                var commands = Console.ReadLine().Split(' ');
                Console.WriteLine(a.setTopFront(Convert.ToInt32(commands[0]),Convert.ToInt32(commands[1])));
            }

        }
    }
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;

lli n;
lli a[e5];
lli ans;

lli gcd(lli a,lli b){
	while(a != 0){
		b %= a;
		swap(a,b);
	}
	return b;
}

int main(){
	cin >> n;
	for(lli i = 0;i < n;i++) cin >> a[i];
	ans = gcd(a[0],a[1]);
	for(lli i = 2;i < n;i++){
		ans = gcd(ans,a[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    int A, B ,K;
    cin >> A >> B >> K;
    for(int i = 100; i >= 1; i--) {
        if(A%i == 0 && B%i == 0) {
            K--;
            if(K==0) {
                cout << i << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;

int main(int argc, char const *argv[]) {
    ll x;
    ll bank = 100;
    int cnt = 0;
    cin >> x;
    while(x>bank){
        bank*=1.01;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//end



int main(){
   string s; cin>>s;
   if(count(ALL(s),'A')&&count(ALL(s),'B'))puts("Yes");
   else puts("No");
   return 0;
}

Measured memory_bytes: 256
using System;

namespace B___Different_Distribution
{
    class Program
    {
        static void Main (string[] args)
        {
            var n = int.Parse (Console.ReadLine ());
            var a = new int[n];
            var b = new int[n];
            var max = 0;
            for (var i = 0; i < n; i++)
            {
                var input = Console.ReadLine ().Split (' ');
                a[i] = int.Parse (input[0]);
                b[i] = int.Parse (input[1]);
                max = Math.Max (a[i], max);
            }
            for (var i = 0; i < n; i++)
            {
                if (a[i] == max)
                {
                    Console.WriteLine (max + b[i]);
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 17308
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#ifdef _MSC_VER
#  define __builtin_popcount __popcnt
#endif
#define int long long
using namespace std;
using ll = long long;
using ld = long double;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const long double PI = acos(-1.0);
inline void my_io() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cout << fixed << setprecision(15);
}
int N, M;
vector< int > divisor(int n) {
	vector< int > ret;
	for (int 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);
}
signed main() {
	my_io();
	cin >> N >> M;
	vector<int>v = divisor(M);
	int ans = -1;
	for (int i = v.size() - 1; i >= 0; i--) {
		if (M / v[i] >= N) {
			ans = max(ans, v[i]);
		}
	}
	if (ans == -1) {
		cout << 1 << endl;
	}
	else cout << ans << endl;
	return 0;
}


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

int main(){
  int N, i, max, sum=0;
  cin >> N;
  int a[N];
  for(i=0; i<N; i++){
    cin >> a[i];
    if(i == 0) max = a[i];
    else{
      if(max < a[i]) max = a[i];
    }
  }
  for(i=0; i<N; i++){
    if(a[i] == max){
      a[i] /= 2;
      max = 0;
    }
    sum = sum + a[i];
  }
  cout << sum << "\n";
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Linq.Enumerable;
using static System.Math;

class Program
{
    static void Main()
    {
        var S = ReadLine();

        var ans = S.Last() == 's' ? S + "es" : S + "s";

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 26244
#include <bits/stdc++.h>
using namespace std;
#define inf 2000000000
#define INF 1e18
typedef long long ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define togglebit(n,i) ((n)^(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
ll a[100005];
int main()
{
    fastread;
     ll i,j,k,n,m,y,t;
    cin>>n;
   // m=(ll)(pow(n,1/5));
    //cout<<m;
    ll res;
   for(i=-150;i<=150;i++){
   // k=(ll)(pow(i,5));
   for(j=-150;j<=150;j++){
    res=(i*i*i*i*i)-(j*j*j*j*j);
    if(res==n){
        cout<<i<<" "<<j;
        return 0;
              }
         }
     }
   return 0;
}


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

int main()
{
    int x,y;
    cin>>x>>y;
    if(x<y)cout<<min(y-x,abs(x+y)+1);
    if(x>y)cout<<min(abs(y-x)+2,abs(x+y)+1);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int x=0;
	if(n%10==0){
		cout<<10<<endl;
		return 0;
	}
	while(n>0){
		x+=n%10;
		n/=10;
	}
	
	cout<<x<<endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

bool kaibun(const string&s)
{
    for(int i=0;i<s.length()/2;++i){
        if(s[i]!=s[s.length()-1-i])return false;
    }
    return true;
}
int main()
{
    string s;cin>>s;
    cout<<(kaibun(s)&&kaibun(s.substr(0,(s.length()-1)/2))&&kaibun(s.substr((s.length()+1)/2,(s.length()-1)/2))?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
a, b, c, d = map(int, input().split())
d_ab = b - a
d_bc = c - b
d_ac = c - a
if d_ab <0:
    d_ab = a - b
if d_bc <0:
    d_bc = b - c
if d_ac <0:
    d_ac = a - c

if (1 <= a & a <= 100) & (1 <= b & b <= 100) & (1 <= c & c <= 100) & (1 <= d & d <= 100):
    if 0 <= d_ac & d_ac <= d:
        print('Yes')
    elif (0 <= d_ab & d_ab <= d) & (0 <= d_bc & d_bc <= d):
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

int n;
long long int a[200005];
vector<long long int> b;

int main(void) {

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	if (n % 2 == 0) {
		int m = n;
		while (m > 0) {
			b.push_back(a[m]);
			m -= 2;
		}
		m = 1;
		while (m < n) {
			b.push_back(a[m]);
			m += 2;
		}
	}
	else {
		int m = n;
		while (m >= 1) {
			b.push_back(a[m]);
			m -= 2;
		}
		m = 2;
		while (m < n) {
			b.push_back(a[m]);
			m += 2;
		}

	}

	for (int i = 0; i < n; i++) {
		if (i != 0) { cout << " "; }
		cout << b[i];
	}
	cout << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 5488
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3005;

int n, dp[maxn][maxn], pa[maxn], pb[maxn], c[maxn<<1];
char s[maxn<<1], a[maxn<<1], b[maxn<<1];
bool used[maxn<<1];

bool check(int x)
{
	int cnta = 0, cntb = 0;
	for(int i = x; i <= n; ++i)
		if(dp[x][i])
		{
			used[pa[i]] = 1;
			used[pb[i]] = 1;
		}
	for(int i = min(pa[x], pb[x]); i <= (n << 1); ++i)
		if(used[i])
		{
			a[++cnta] = s[i];
			used[i] = 0;
		}
	for(int i = x + 1; i <= n; ++i)
		if(dp[x+1][i])
		{
			used[pa[i]] = 1;
			used[pb[i]] = 1;
		}
	for(int i = min(pa[x+1], pb[x+1]); i <= (n << 1); ++i)
		if(used[i])
		{
			b[++cntb] = s[i];
			used[i] = 0;
		}
	for(int i = 1; i <= min(cnta, cntb); ++i)
		if(a[i] != b[i])
			return b[i] > a[i];
	return cntb > cnta;
}

int main()
{
	scanf("%d", &n);
	scanf("%s", s + 1);
	int cnta = 0, cntb = 0;
	for(int i = 1; i <= (n << 1); ++i)	
	{
		if(s[i] == 'a')
		{
			pa[++cnta] = i;
			c[i] = cnta;
		}
		else
		{
			pb[++cntb] = i;
			c[i] = cntb;
		}
	}
	dp[n][n] = 1;
	for(int i = n - 1; i >= 1; --i)
	{
		dp[i][i] = 1;
		if(pa[i] > pb[i])
		{
			int p = n + 1, tot = 0;
			for(int j = i + 1; j <= n; ++j)
			{
				if(pb[j] > pa[i])
				{
					p = j;
					break;
				}
				++ tot;
				dp[i][j] = 1;
			}
			for(int j = pa[i] + 1; j <= (n << 1); ++j)
			{
				if(s[j] == 'b')
				{
					if(tot == 0)
					{
						dp[i][c[j]] = dp[p][c[j]];
					}
					else
					{
						dp[i][c[j]] = 1;
						++ tot;
					}
				}
				else
				{
					if(tot == 0)
					{
						dp[i][c[j]] = dp[p][c[j]];
					}
					else
					{
						dp[i][c[j]] = 1;
						p = max(p, c[j] + 1);
						-- tot;
					}
				}
			}
		}
		else
		{
			int p = n + 1;
			for(int j = i + 1; j <= n; ++j)
				if(pa[j] > pb[i])
				{
					p = j;
					break;
				}
			for(int j = p; j <= n; ++j)
				dp[i][j] = dp[p][j];
		}
		if(check(i))
		{
			for(int j = i; j <= n; ++j)
				dp[i][j] = dp[i+1][j];
		}
	}
	for(int i = 1; i <= n; ++i)
		if(dp[1][i])
		{
			used[pa[i]] = 1;
			used[pb[i]] = 1;	
		}
	for(int i = 1; i <= (n << 1); ++i)
		if(used[i])
			printf("%c", s[i]);
	return 0;
}


Measured memory_bytes: 35200
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>

using namespace std;


int main() {
	int i, j, k;
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	bool flag = false;
	int cnt = 0;
	for (i = c; i <= d; i++) {
		if (i >= a && i <= b) {
			if (flag == true) cnt++;
			flag = true;
		}
		//cout << "i->" << i << " cnt->" << cnt << endl;
	}

	cout << cnt << endl;



	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
use std::ops::Bound::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<i64>();
    if n == 1 {
        println!("{}", 1);
        return;
    }
    let n = 2 * n;
    let mut ans = std::i64::MAX;
    for i in 1..n + 1 {
        if i * i > n {
            break;
        }
        if n % i == 0 {
            let r = [0, n / i - 1];
            let m = [i, n / i];
            if m[0] != 1 && m[1] != 1 {
                let x = crt(&r, &m);
                if let Some((x, y)) = x {
                    ans = min(ans, x);
                }
            }
            let r = [i - 1, 0];
            if m[0] != 1 && m[1] != 1 {
                let m = [i, n / i];
                let x = crt(&r, &m);
                if let Some((x, y)) = x {
                    ans = min(ans, x);
                }
            }
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn inv_gcd(a: i64, b: i64) -> (i64, i64) {
    let a = a.rem_euclid(b);
    if a == 0 {
        return (b, 0);
    }
    let mut s = b;
    let mut t = a;
    let mut m0 = 0;
    let mut m1 = 1;

    while t != 0 {
        let u = s / t;
        s -= t * u;
        m0 -= m1 * u;
        std::mem::swap(&mut s, &mut t);
        std::mem::swap(&mut m0, &mut m1);
    }
    if m0 < 0 {
        m0 += b / s;
    }
    (s, m0)
}

// return y (mod z)
pub fn crt(r: &[i64], m: &[i64]) -> Option<(i64, i64)> {
    assert_eq!(r.len(), m.len());
    // Contracts: 0 <= r0 < m0
    let (mut r0, mut m0) = (0, 1);
    for (&(mut ri), &(mut mi)) in r.iter().zip(m.iter()) {
        assert!(1 < mi);
        ri = ri.rem_euclid(mi);
        if m0 < mi {
            std::mem::swap(&mut r0, &mut ri);
            std::mem::swap(&mut m0, &mut mi);
        }
        if m0 % mi == 0 {
            if r0 % mi != ri {
                return None;
            }
            continue;
        }
        let (g, im) = inv_gcd(m0, mi);
        let u1 = mi / g;
        // |ri - r0| < (m0 + mi) <= lcm(m0, mi)
        if (ri - r0) % g != 0 {
            return None;
        }
        let x = (ri - r0) / g % u1 * im % u1;

        r0 += x * m0;
        m0 *= u1; // -> lcm(m0, mi)
        if r0 < 0 {
            r0 += m0
        };
    }

    Some((r0, m0))
}


Measured memory_bytes: 2156
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#define N 2010
#define M 2000001
#define ls i << 1
#define rs i << 1 | 1
#define inf 0x3f3f3f3f
#define inc(i) (++ (i))
#define dec(i) (-- (i))
// #define mid ((l + r) >> 1)
#define int long long
#define XRZ 998244353
#define debug() puts("XRZ TXDY");
#define n_ ((n >> 1) + 1)
#define mem(i, x) memset(i, x, sizeof(i));
#define Next(i, u) for(register int i = head[u]; i ; i = e[i].nxt)
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout);
#define Rep(i, a, b) for(register int i = (a) , i##Limit = (b) ; i <= i##Limit ; inc(i))
#define Dep(i, a, b) for(register int i = (a) , i##Limit = (b) ; i >= i##Limit ; dec(i))
// const int dx[10] = {1, -1, 0, 0};
// const int dy[10] = {0, 0, 1, -1};
using namespace std;
inline int read() {
    register int x = 0, f = 1; register char c = getchar();
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
void work() {}
signed main(void){
	int H,W;
	H=read(),W=read();
	int ans=H*W/2;
	if(H*W%2){
		++ans;
	}
	if(H==1||W==1){
		printf("1");
		return 0;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n,m,s[100000],x,y,r[100001],fa[1000001],ans;
ll find(ll x){
    if(fa[x]==x)return x;
    return fa[x]=find(fa[x]);
}
void uni(ll x,ll y){
    x=find(x);
    y=find(y);
    if(x==y)return ;
    if(r[x]<r[y])fa[x]=y;
    else fa[y]=x;
    if(r[x]==r[y])r[x]++;
}
int main(void){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        fa[i+1]=i+1;
        cin>>s[i];
    }
    for(int i=0;i<m;i++){
        cin>>x>>y;
        uni(x,y);
    }
    for(int i=0;i<n;i++){
        if(find(i+1)==find(fa[s[i]]))ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string st1,st2;
    cin>>st1>>st2;
    int len=st2.size();
    for(int i=0;i<len;i++)
        if(st1[i]!=st2[len-i-1])
    {
        puts("NO");
        return 0;
    }
    puts("YES");
    return 0;
}


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

int n, q, cnt[202020];
vector<vector<int>> graph(202020, vector<int>(0));

void dfs(int a, int pa){
  cerr << a << endl;
  cnt[a] += cnt[pa];
  
  for(int x : graph.at(a)){
    if(x == pa) continue;
    dfs(x, a);
  }
  return;
}

int main(){
  cin >> n >> q;
  rep(i, n + 1) cnt[i] = 0;
  rep(i, n - 1){
    int a, b;
    cin >> a >> b;
    graph.at(a).push_back(b);
    graph.at(b).push_back(a);
  }
  rep(i, q){
    int p, x;
    cin >> p >> x;
    cnt[p] += x;
  }
  
  dfs(1, 0);
  
  rep(i, n - 1) cout << cnt[i + 1] << " ";
  cout << cnt[n] << endl;
  return 0;
}


Measured memory_bytes: 23552
N, M = list(map(int, input().split()))
correct = 0
incorrect = 0
Q = [0] * N
num_WA = [0] * N
for i in range(M):
    s, t = input().split()
    s = int(s)

    if t == 'AC':
        if Q[s-1] == 1:
            continue
        else:
            Q[s-1] = 1
            correct += 1
            incorrect += num_WA[s-1]
    else:
        num_WA[s-1] += 1
print(correct, incorrect)


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

const ll N  = 100000;

ll n;
vector<ll> a(3 * N + 5, 0);
vector<ll> front(3 * N + 5, 0);
vector<ll> back(3 * N + 5, 0);
priority_queue <ll> max_heap;
priority_queue<ll, vector<ll>, greater<ll> > min_heap;

int main()
{
  cin >> n;
  
  for (ll i = 1; i <= 3 * n; i++) {
    cin >> a[i];
  }
  
  //front
  for (ll i = 1; i <= 3 * n; i++) {
    min_heap.push(a[i]);
    front[i] += front[i - 1] + a[i];
    
    if (i > n) {
      front[i] -= min_heap.top();
      min_heap.pop();
    }
  }
  
  for (ll i = 3 * n; i >= 1; i--) {
    max_heap.push(a[i]);
    
    back[i] += back[i + 1] + a[i];
    
    if (i <= 2 * n) {
      back[i] -= max_heap.top();
      max_heap.pop();
    }
  }
  
  ll ans = front[n] - back[n + 1];
  for (ll i = n + 1; i <= 2 * n; i++) {
    ans = max(ans, front[i] - back[i + 1]);
  }

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

Measured memory_bytes: 9588
import java.io.*;

 class Main
{
   public static void main(String[] args) throws IOException
   {

    BufferedReader br =
     new BufferedReader(new InputStreamReader(System.in));

   String str = br.readLine();
   int x = Integer.parseInt(str);

   System.out.println( (int)Math.pow(x,3) );
   }
}

Measured memory_bytes: 24332
#include <iostream>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <vector>

class interval {
public:
  int id;
  int begin;
  int end;
  constexpr interval() : id(0), begin(0), end(0) {}
  constexpr interval(const int id, const int begin, const int end) : id(id), begin(begin), end(end) {}
  constexpr int next_position(const int current_position) const {
    return current_position < this->begin ? this->begin : this->end < current_position ? this->end : current_position;
  }
};

int main() {
  int n;
  std::cin >> n;
  std::vector<interval> intervals_order_by_begin_desc(n);
  std::vector<interval> intervals_order_by_end_asc(n);
  for (int i = 0; i < n; ++i) {
    int l, r;
    std::cin >> l >> r;
    intervals_order_by_begin_desc[i] = interval(i, l, r);
    intervals_order_by_end_asc[i] = interval(i, l, r);
  }
  std::sort(intervals_order_by_begin_desc.begin(), intervals_order_by_begin_desc.end(), [](const interval& x, const interval& y){ return x.begin > y.begin; });
  std::sort(intervals_order_by_end_asc.begin(), intervals_order_by_end_asc.end(), [](const interval& x, const interval& y){ return x.end < y.end; });
  const auto calc_distance = [&](const int toggle){
    std::vector<bool> used_intervals(n, false);
    int begins_cursor = 0;
    int ends_cursor = 0;
    int current_position = 0;
    std::uint64_t distance = 0;
    for (int i = 0; i < n; ++i) {
      const interval current_interval = [&](){
        if (i % 2 == toggle) {
          for (; used_intervals[intervals_order_by_begin_desc[begins_cursor].id]; ++begins_cursor);
          return intervals_order_by_begin_desc[begins_cursor];
        } else {
          for (; used_intervals[intervals_order_by_end_asc[ends_cursor].id]; ++ends_cursor);
          return intervals_order_by_end_asc[ends_cursor];
        }
      }();
      const int old_position = current_position;
      current_position = current_interval.next_position(current_position);
      distance += std::abs(current_position - old_position);
      used_intervals[current_interval.id] = true;
#ifdef DEBUG
      std::cout << distance << ": " << old_position << " -> " << current_position << " ([" << current_interval.begin << ", " << current_interval.end << "])" << std::endl;
#endif
    }
    distance += std::abs(current_position);
#ifdef DEBUG
    std::cout << distance << ": " << current_position << " -> " << 0 << " ([0, 0])" << std::endl;
    std::cout << std::endl;
#endif
    return distance;
  };
  std::cout << std::max(calc_distance(0), calc_distance(1)) << std::endl;
  return 0;
}

Measured memory_bytes: 2688