akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> S(M), C(M);
  for (int i = 0; i < M; i++) {
    cin >> S.at(i) >> C.at(i);
  }
  
  vector<int> X(N, -1);
  for (int i = 0; i < M; i++) {
    if (X.at(S.at(i) - 1) == -1) {
      X.at(S.at(i) - 1) = C.at(i);
    }
    else if (X.at(S.at(i) - 1) != C.at(i)) {
      X.at(S.at(i) - 1) = -100;
    }
  }
  
  int K = 0;
  for (int i = 0; i < N; i++) {
    K += X.at(i);
  }
  if (K < -50) {
    cout << -1 << endl;
  }
  else if (N != 1 && X.at(0) == 0) {
    cout << -1 << endl;
  }
  else {
    if (N == 1 && X.at(0) == -1) cout << 0 << endl;
    else if (N == 1) cout << X.at(0) << endl;
    else if (N == 2 && X.at(0) == -1) cout << 10 + X.at(1) << endl;
    else if (N == 2 && X.at(1) != -1) cout << X.at(0) * 10 + X.at(1) << endl;
    else if (N == 2) cout << X.at(0) * 10 << endl;
    else {
      if (X.at(0) == -1) X.at(0) = 1;
      if (X.at(1) == -1) X.at(1) = 0;
      if (X.at(2) == -1) X.at(2) = 0;
      cout << 100 * X.at(0) + 10 * X.at(1) + X.at(2) << endl;
    }
  }
    
}


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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

ll dp[105][8];

int main()
{
    int h,w,k; cin >> h >> w >> k;
    dp[0][0] = 1;
    int m[8] = {1,2,3,5,8,13,21,34};
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(j == 0){
                dp[i+1][j] = dp[i][1] * m[max(0,w-3)] + dp[i][j] * m[max(w-2,0)];
            }else if(j == w-1){
                dp[i+1][j] = dp[i][w-2] * m[max(0,w-3)] + dp[i][j] * m[max(w-2,0)];
            }else{
                dp[i+1][j] = dp[i][j-1] * m[max(j-2,0)] * m[max(w-2-j,0)] + dp[i][j+1] * m[j-1] * m[max(0,w-j-3)] + dp[i][j] * m[j-1] * m[w-j-2]; 
            }
            dp[i+1][j] %= mod;
        }
    }
    cout << dp[h][k-1];
}


Measured memory_bytes: 256
import numpy as np
from itertools import chain,combinations
def powerset(iterable):
    "powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)"
    s = list(iterable)
    return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))

H, W, K = map(int, input().split())
c = []
for h in range(H):
    c.append(list(map(str, input())))
c = np.array(c)


h_list = [i for i in range(H)]
w_list = [i for i in range(W)]

h_comb_list = list(powerset(h_list))
w_comb_list = list(powerset(w_list))
#h_comb_list.remove(())
#w_comb_list.remove(())

comb_list = []
x = 0
for h_temp in h_comb_list:
    for w_temp in w_comb_list:
        if -1 in h_temp and -1 in w_temp:
                x += 1
        else:
            comb_list.append({'h':h_temp, 'w':w_temp})
ans = 0
for comb in comb_list:
    h_r = comb['h']
    w_r = comb['w']
    h_temp = [i for i in range(H)]
    w_temp = [i for i in range(W)]
    #print(h_r, w_r)
    if len(h_r) > 0:
        for h in h_r:
            h_temp.remove(h)
    if len(w_r) > 0:
        for w in w_r:
            w_temp.remove(w)
    #print(h_temp, w_temp)
    if np.sum(c[h_temp, :][:, w_temp] == '#') == K:
        #print(h_r, w_r)
        #print(c[h_temp, :][:, w_temp])
        ans += 1
print(ans)

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

struct Edge {
    int from;
    int to;
    int weight;
    Edge(int f, int t, int w) : from(f), to(t), weight(w) {};
};

using Graph = vector<Edge>;

int main() {
    int N, M;
    cin >> N >> M;

    bool circle[N];
    long long cost[N];
    rep(i, N) cost[i] = -1e+13, circle[i] = false;
    cost[0] = 0;

    Graph G;
    rep(i, M) {
        int from, to, weight; 
        cin >> from >> to >> weight;
        from--, to--;
        G.push_back(Edge(from, to, weight));
    }    

    rep(i, N) {
        for (auto v : G) cost[v.to] = max(cost[v.to], cost[v.from] + (long long) v.weight);
    }

    for (auto v : G) {
        if (cost[v.to] < cost[v.from] + (long long) v.weight) circle[v.to] = true;
        if (circle[v.from] == true) circle[v.to] = true;
    }


    if (circle[N-1]) cout << "inf" << endl;
    else cout << cost[N-1] << endl;

    return 0;
}



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

int main()
{
	int A, B;
	int count = 0;

	cin >> A >> B;
	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) cout << "Possible" << endl;

	else cout <<"Impossible" << endl;
    return 0;
}


Measured memory_bytes: 256
use std::collections::*;

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 main() {
    let n: usize = read();
    if n == 3 || n == 5 || n == 7 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int k,n;
  cin>>k>>n;
	int a[200000];
  for(int i=0;i<n;i++){
  	cin>>a[i];
  }
  int diff=-1;
  for(int i=0;i<n-1;i++){
  	diff=max(diff,a[i+1]-a[i]);
  }
  diff=max(diff,(k-a[n-1]+a[0]));
  cout<<k-diff<<endl;
	return 0;
}

Measured memory_bytes: 1024
//Hanafuda Shuffle
#include <iostream>
#include <algorithm>
using namespace std;
int N, R, p, c;
int main() {
  while (cin >> N >> R && N>0) { //1??????????????????
    int A[N];
    for (int i=0; i<N; ++i) { //??±????????\???
      A[i] = N-i;
    }
    for (int i=0; i<R; ++i) { //?????£?????????
      cin >> p >> c;
      rotate(A, A+p-1, A+p+c-1);
    }
    cout << A[0] << endl;
  }
}

Measured memory_bytes: 1184
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

int main(){
	int  n;
	int tmp;
	int res;
	scanf("%d\n", &n);
	tmp = n / 100;
	tmp += tmp * 100 + tmp * 10;
	if(n <= tmp) res = tmp;
	else res = tmp + 111;
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 128
n = gets.to_i
a = gets.split.map(&:to_i)

b = 0
ans = 0
i = 0
n.times do |j|
    while b & a[j] != 0
        ans += j - i
        b -= a[i]
        i += 1
    end

    b += a[j]
end

x = n - i
p ans + x * (x + 1) / 2

Measured memory_bytes: 15364
#include <bits/stdc++.h>
using namespace std;
 
int main(void) 
{
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;

    string S1="";
  
  
    int same=0,diff=0;
    for(int i=0; i<N-1; i++)
    {
        if(S[i]==S[i+1]) same++;
        if(S[i]!=S[i+1]) diff++;
    }
    //cout << same << " " << diff << endl;

    int ans = 0;
    cout << same + min(K*2,diff) << endl;

    return 0;
}


Measured memory_bytes: 512
n,k=map(int,input().split())
a=list(map(int,input().split()))
roop=[]
roop_set=set([])

a.insert(0, 0)
s=1
for i in range(k):
    s=a[s]
    if(s not in roop_set):
        roop.append(s)
        roop_set.add(s)
    else:
        s_first=roop.index(s)
        roop=roop[s_first:]
        k-=(s_first+1)
#        print(k,roop,s_first)
        print(roop[k%len(roop)])
        break
else:
#    print(roop,k)
    print(roop[k-1])

Measured memory_bytes: 32276
import Foundation

func main() {
let inputString = readLine()!
var split: [Int] = inputString.components(separatedBy: " ").map{Int(String($0))!}
split.sort()
if (split[0]%2==0||split[1]%2==0||split[2]%2==0) {
  print(0)
  return
}
print(split[0]*split[1])
}

main()

Measured memory_bytes: 14256
//https://beta.atcoder.jp/contests/dwacon5th-prelims/tasks/dwacon5th_prelims_a
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int a[112];
int main(){
    int n;
    cin>>n;
    int ave=0;
    for(int i:range(n)){
        cin>>a[i];
        ave+=a[i];
        a[i]*=n;
    }
    pair<int,int> ret={(int)1e9,0};
    for(int i:range(n)){
        chmin(ret,{abs(a[i]-ave),i});
    }
    cout<<ret.second<<endl;
    return 0;
}

Measured memory_bytes: 892
#include <stdio.h>

int main(){
        int N,a,b,i,count=0;
        scanf("%d",&N);
        for(a=0;a<=9;a++){
                for(b=0;b<=9;b++){
                        for(i=1;i<=9;i++){
                                if(1000*a+100*a+10*a+b==N||1000*b+100*a+10*a+a==N){
                                        count++;
                                        printf("Yes\n");
                                        break;
                                }
                        }
                }
        }
        if(count==0){
                printf("No\n");
        }
        return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    set<char>d;
    for(int i=0;i<s.size();i++)
    {        d.insert(s[i]);
    }
    if(d.size()==2)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
    int K;
    char S[150];
    scanf("%d%s",&K,&S);
    if(strlen(S)<=K)
    {
        printf("%s\n",S);
    }
    else
    {
        for(int i=0;i<K;i++)
        {
            printf("%c",S[i]);
        }
        printf("...\n");
    }
}

Measured memory_bytes: 1600
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



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

    map<ll,ll> l,r;
    rep(i,0,n){
	ll a;
	cin >> a;
	l[i+a+1]++;
	r[i+1-a]++;
    }

    ll ans = 0;
    rep(i,0,200005){
	ans += l[i] * r[i];
    }
    P(ans);
    return  0;
}


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

int main()
{
    std::ios::sync_with_stdio(false);
    lld t = 1;
    // cin >> t;
    while(t--) {
        lld a;
        cin >> a;
        string s;
        cin >> s;
        if(a < 3200) {
            cout << "red\n";
        } else {
            cout << s << "\n";
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	int now = 0;
	int t = 1;
	rep(i, n) {
		if (a[i] == t) {
			now++;
			t++;
		}
	}
	if(t!=1)cout << n - now << endl;
	else cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) printf("Case #%d: ",i);
using namespace std;
typedef long long int ll;
typedef complex<double> com;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;

ll gcd(ll a, ll b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

int main(){
	int n; cin >> n;
	ll ans=1;
	rep(i, 0, n) {
		ll p; cin >> p;
		ans *= p / gcd(ans, p);
	}
	printf("%lld", ans);
	return 0;
}

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

int main(){
    int n;
    while(cin >> n, n != 0){
        vector<string> v;
        for(int i=0;i<n;++i){
            string s;
            cin >> s;
            string t = "";
            t.push_back(s[0]);
            for(int j=0;j<s.size()-1;++j){
                if(s[j] == 'a' || s[j] == 'i' || s[j] == 'u' || s[j] == 'e' || s[j] == 'o'){
                    t.push_back(s[j+1]);
                }
            }
            v.push_back(t);
        }

        bool ng = true;
        for(int k=1;k<=50;++k){
            set<string> st;
            for(auto e : v){
                st.insert(e.substr(0, min(k, (int)e.size())));
            }
            if(st.size() == n){
                ng = false;
                cout << k << endl;
                break;
            }
        }

        if(ng)cout << -1 << endl;
    }

    return 0;
}



Measured memory_bytes: 3168
in_all = list(map(int, input().split()))
 
total = 0
for n in range(1, in_all[0]+1):
    tmp = str(n)
    all = 0
    for t in tmp:
        all += int(t)
    if all>=in_all[1] and all<=in_all[2]:
        total += n
 
print(total)

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

int main() {
  int N;
  cin>>N;
  vector<int> vec(2001);
  
vec.at(1)=0;
vec.at(2)=0;
vec.at(3)=1;
vec.at(4)=1;
vec.at(5)=1;

  for (int i = 6; i <= N; i++){
        vec.at(i)++;

    for(int j = 3; i-j>=3; j++){
       vec.at(i)=(vec.at(i)+vec.at(i-j))%MOD;
     }

  }
  cout<<vec.at(N)<<endl;
}

Measured memory_bytes: 3648
/*
	Auther:_Destiny
	time:2020.5.10
*/
#include <bits/stdc++.h>
#define ll long long
#define N 200010
#define M 1010

using namespace std;
ll n, k, a[N], last[N];

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

	last[1] = 1;ll now = 1;
	while (k) {
		if (last[a[now]]) {
			ll len = last[now] + 1 - last[a[now]];
			k %= len;
			if (!k) break;
			k--;now = a[now];
			while (k > 0) {
				now = a[now];
				k--;
			}
		}
		if (!k) break;
		last[a[now]] = last[now] + 1;
		now = a[now]; 
		k--;
	}
	cout << now << "\n";
}

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

using namespace std;

int N;
int A[20];
int X[20][20];
int Y[20][20];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    for (int j = 0; j < A[i]; j++) {
      cin >> X[i][j] >> Y[i][j];
    }
  }

  int ans = 0;
  for (int i = 0; i < (1 << N); i++) {
    bitset<15> bits(i);
    bool ok = true;
    for (int j = 0; j < N; j++) {
      if (!bits.test(j)) continue;
      for (int k = 0; k < A[j]; k++) {
        if ((bits[X[j][k] - 1] ^ Y[j][k]) == 1) ok = false;
      }
    }
    if (ok) ans = max(ans, (int)bits.count());
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
// ABC116_B
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    ll S;
    cin >> S;
    
    // calculation
    if (S == 4 || S == 2 || S == 1) {
        cout << 4 << "\n";
    } else {
        // 始めて４が出た時
        ll idx = 1, now = S;
        while (true) {
            if (now%2 == 0) {
                now /= 2;
                idx++;
            } else {
                now = 3*now + 1;
                idx++;
            }
            
            if (now == 4) break;
        }
        
        cout << idx + 3 << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define forn(i, n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()

void solve (int n)
{
    vi a(n);
    ll sum = 0;
    forn (i, n)
    {
        cin >> a[i];
        sum += a[i];
    }

    vi df(n);
    forn (i, n)
        df[i] = a[(i + 1) % n] - a[i];

    ll c2 = (ll)n * (ll)(n + 1) / 2LL;
    if (sum % c2 != 0)
    {
        cout << "NO" << endl;
        return;
    }

    ll iters = sum / c2;
    forn (i, n)
    {
        ll cur = df[i] - iters;
        // was df[i], subtracted 1 iters times
        // want 0 by adding n * something
        cur = -cur;

        if (cur < 0 || cur % n != 0)
        {
            cout << "NO" << endl;
            return;
        }
    }

    cout << "YES" << endl;
}

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

    int n;
    while (cin >> n)
        solve(n);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  long long k;cin>>k;
  long long n=s.size();
  for(int i=0;i<min(n,k);i++){
    if(s[i]!='1'){
      cout<<s[i]<<endl;
      return 0;
    }
  }
  cout<<1<<endl;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "cabacc", "abc" ].solve == 1 );
	assert( [ "codeforces", "atcoder" ].solve == 6 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	input.popFront;
	auto t = input.front.to!( dchar[] );
	
	auto ans = long.max;
	foreach( i; 0L .. s.length.signed - t.length.signed + 1 )
	{
		auto d = 0L;
		foreach( sc, tc; lockstep( s[ i .. i + t.length ], t ) )
		{
			d += ( sc != tc );
		}
		ans = min( ans, d );
	}
	return ans;
}


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

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

    if (a >= 3200) {
        cout << s;
    } else if (a < 3200) {
        cout << "red";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;
const int MAX = 100'000;

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

  int mfe = 0, mfo = 0;
  vector<int> e(MAX, 0), o(MAX, 0);
  rep(i,0,n-1) {
    int v;
    cin >> v;
    if (i % 2 == 0) {
      e[v]++;
      if (e[mfe] < e[v]) mfe = v;
    } else {
      o[v]++;
      if (o[mfo] < o[v]) mfo = v;
    }
  }

  sort(e.begin(), e.end(), greater<int>());
  sort(o.begin(), o.end(), greater<int>());

  int e_size = (n + 1) / 2;
  int o_size = n / 2;
  if (mfe != mfo || e[0] != o[0])
    cout << e_size - e[0] + o_size - o[0] << endl;
  else
  {
    int ans1 = e_size - e[0] + o_size - o[1];
    int ans2 = e_size - e[1] + o_size - o[0];
    cout << min(ans1, ans2) << endl;
  }

  return 0;
}


Measured memory_bytes: 4028
import java.util.*
import javax.security.auth.login.AccountLockedException

class Feed(val x:Int){
    private val mCats: Stack<Cats> = Stack()
    var count:Int = 0
        private set
    val cats:Iterable<Cats> = mCats
    fun addCats(cats:Iterable<Cats>):Unit {
        mCats.addAll(cats)
        count += cats.sumBy { it.size }
    }
    fun addCats(cats:Cats):Unit {
        mCats.add(cats)
        count += cats.size
    }
}
class Cats(val x:Int, val size:Int)
fun allocationCats(left:Feed, cats:Iterable<Cats>, right:Feed):Unit {
    val mid = right.x + left.x
    left.addCats(cats.filter{it.x * 2 <= mid})
    right.addCats(cats.filter{it.x * 2 > mid})
}
fun main(args:Array<String>):Unit {
    while(true){
        val (n,m) = readLine()!!.trim().split(' ').map(String::toInt)
        if (n == 0 && m == 0) return
        val cats = Array(n){
            val (x, _, c) = readLine()!!.trim().split(' ').map(String::toInt)
            Cats(x, c)
        }
        val feeds = LinkedList<Feed>()
        repeat(m){feeds.addLast(Feed(readLine()!!.trim().toInt()))}
        feeds.sortBy(Feed::x)
        val feedArray = feeds.toTypedArray()
        feedArray[0].addCats(cats.filter{it.x < feedArray[0].x})
        for (i in 1 until m) {
            allocationCats(feedArray[i - 1], cats.filter{it.x in feedArray[i - 1].x until feedArray[i].x}, feedArray[i])
        }
        feedArray.last().addCats(cats.filter{feedArray.last().x <= it.x})
        var minMax = Int.MAX_VALUE
        repeat(m - 2){
            val max = feeds.maxBy(Feed::count)!!
            if (minMax > max.count) minMax = max.count
            val idx = feeds.indexOf(max)
            feeds.removeAt(idx)
            if (idx == feeds.size)
                feeds[idx - 1].addCats(max.cats)
            else if (idx == 0)
                feeds[0].addCats(max.cats)
            else
                allocationCats(feeds[idx - 1], max.cats, feeds[idx])
        }
        if (minMax > feeds.maxBy(Feed::count)!!.count) minMax = feeds.maxBy(Feed::count)!!.count
        println(minMax)
    }
}


Measured memory_bytes: 83944
#include<iostream>
#include<algorithm>
#include<string.h>
#include<utility>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n=0;
	cin >> n;
	int ar[n];
	for(int i=0;i<n;i++){
		cin >> ar[i];
	}
	int dcp[n];
	for(int i=0;i<n;i++){
		dcp[i]=-1;
	}
	dcp[0]=0;
	dcp[1]=abs(ar[0]-ar[1]);
	for(int i=2;i<n;i++){
		dcp[i]=min(abs(ar[i]-ar[i-1])+dcp[i-1],dcp[i-2]+abs(ar[i]-ar[i-2]));
	}
	int ans=0;
	ans=dcp[n-1];
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

def judge(x):
    for i in range(x+1):
        if i<=N and x-i<=M and accA[i]+accB[x-i]<=K:
            return True
    
    return False

def binary_search():
    l, r = 0, N+M
    
    while l<=r:
        m = (l+r)//2
        
        if judge(m):
            l = m+1
        else:
            r = m-1
    
    return r

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
accA = [0]

for Ai in A:
    accA.append(accA[-1]+Ai)

accB = [0]

for Bi in B:
    accB.append(accB[-1]+Bi)

print(binary_search())

Measured memory_bytes: 132608
using System;
using System.Collections.Generic;
class Program
{
 
    static void Main()
    {
      string K = Console.ReadLine();
      string S = Console.ReadLine();
      int Ka = int.Parse(K);
      int Sa = S.Length;
      
      if(Ka>=Sa)
      {
        Console.WriteLine(S);
      }
      else if(Ka<Sa)
      {
        Console.WriteLine(S.Substring(0,Ka)+"...");
      }
 
      
 
    }
}

Measured memory_bytes: 27500
#include <cstdio>
#include <iostream>

using namespace std;

int qr(){int ret=0,f=1;char ch=getchar();while(!isdigit(ch))f=ch=='-'?-1:1,ch=getchar();while(isdigit(ch))ret=ret*10+ch-'0',ch=getchar();return ret*f;}
#define Rint register int
#define il inline

int k,x;

int main(){
    k = qr(),x = qr();
    int L = -1000000;
    int R = 1000000;
    for(int i = max(L,x-k+1);i<=min(R,x+k-1);i++)
        printf("%d ",i);
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
MOD=1000000007
x=list(map(int,input().split()))
y=list(map(int,input().split()))
sx=0
sy=0
for i in range(1,n):
  sx += (x[i]-x[i-1]) * i * (n-i)
  sx %= MOD
for i in range(1,m):
  sy += (y[i]-y[i-1]) * i * (m-i)
  sy %= MOD
print(sx*sy%MOD)

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

#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int lli;
typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    int m_count = 0;
    int min_positive = INT_MAX;
    int num;
    lli total = 0;
    REP(i, n) {
        cin >> num;
        if (num < 0) {
            m_count++;
            num = -num;
        }
        min_positive = min(min_positive, num);
        total += num;
    }
    if (m_count % 2 == 1)
        cout << total - min_positive * 2 << endl;
    else
        cout << total << endl;
}


Measured memory_bytes: 256
s = gets.to_s.chomp.bytes

h = Hash.new(0)
h[0] = 1

cur = 0
p10 = 1

ans = 0
s.reverse_each do |c|
  cur = ( cur + ( c - 48 ) * p10 ) % 2019
  ans += h[cur]
  h[cur] += 1
  p10 *= 10
  p10 %= 2019 if p10 >= 2019
end

puts ans

Measured memory_bytes: 16384
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<double, int>pdi;
#define SIZE 202000
class unionfind
{
public:
	int par[SIZE];
	int ran[SIZE];
	int ren[SIZE];
	int root[SIZE];
	void init()
	{
		for (int i = 0; i<SIZE; i++)
		{
			par[i] = i;
			ran[i] = 0;
			ren[i] = 1;
			root[i] = i;
		}
	}
	int find(int a)
	{
		if (a == par[a])return a;
		else return par[a] = find(par[a]);
	}
	void unite(int a, int b)
	{
		a = find(a);
		b = find(b);
		if (a == b)return;
		root[a] = root[b] = min(root[a], root[b]);
		if (ran[a]>ran[b])
		{
			par[b] = a;
			ren[a] += ren[b];
		}
		else
		{
			par[a] = b;
			ren[b] += ren[a];
		}
		if (ran[a] == ran[b])ran[b]++;
	}
};
unionfind uf;
int par[202020];
int dat[202020];
ll n0[202020], n1[202020];
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 1; i < num; i++)scanf("%d", &par[i]), par[i]--;
	for (int i = 0; i < num; i++)scanf("%d", &dat[i]);
	set<pdi>se;
	for (int i = 0; i < num; i++)se.insert(make_pair(dat[i], i)), n0[i] = dat[i] == 0, n1[i] = dat[i] == 1;
	uf.init();
	ll ans = 0;
	for (;;)
	{
		if (se.empty())break;
		pdi z = *se.begin();
		se.erase(se.begin());
		int v = z.second;
		if (v == 0)continue;
		int x = uf.root[uf.find(par[v])];
		se.erase(make_pair(double(n1[x]) / double(n0[x] + n1[x]), x));
		ans += n1[x] * n0[v];
		//printf("%d %d\n", x + 1, v + 1);
		uf.unite(v, x);
		n0[x] += n0[v], n1[x] += n1[v];
		se.insert(make_pair(double(n1[x]) / double(n0[x] + n1[x]), x));
		//for (int i = 0; i < num; i++)printf("%lld %lld  ", n0[i], n1[i]); printf("\n");
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 20736
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		double[] p=new double[n];
		for (int i=0;i<n;++i)
			p[i]=in.nextDouble();
		double[][] dp=new double[n+1][n+1];
		dp[0][0]=1;
		for (int i=0;i<=n;++i)
			for (int j=0;j<=n;++j) {
				if (i+j>=n) break;
				int t=i+j;
				dp[i+1][j]+=dp[i][j]*p[t];
				dp[i][j+1]+=dp[i][j]*(1-p[t]);
			}
		double res=0;
		for (int i=n/2+1;i<=n;++i)
			res+=dp[i][n-i];
		System.out.printf("%.12f\n",res);
	}
}

Measured memory_bytes: 123472
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int a, b, c;
    cin >> a >> b >> c ;
    
    //*
    if( ( a * 100 + b * 10 + c ) % 4 == 0 ){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    //*/
    
    //cout << a.at(0) - 'a' + 'A' << b.at(0) - 'a' + 'A' << c.at(0) - 'a' + 'A' << endl;

    return 0; 
}


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

int main(void){
  int a,b;
  cin >> a >> b;
  if(a == 1 && b != 1){
    cout << "Alice" << '\n';
  }
  else if(a != 1 && b == 1){
    cout << "Bob" << '\n';
  }
  else if(a == 1 && b == 1){
    cout << "Draw" << '\n';
  }
  else{
    if(a > b){
      cout << "Alice" << '\n';
    }
    else if(a < b){
      cout << "Bob" << '\n';
    }
    else{
      cout << "Draw" << '\n';
    }
  }
}


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

using namespace std;

int main()
{
	int a, b;
	string s;
	cin >> a >> b >> s;
	bool r = s[a] == '-';
	for (int i = 0; i < s.length(); i++)
		if (i != a)
			r = r&&isdigit(s[i]);
	cout << (r ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

        int s = sc.nextInt();
        Map<Integer,Integer> list = new HashMap<Integer,Integer>();
        int n = 1;
        while(true){
            list.put(s, s);
            n++;
            if(s % 2 == 0){
                s /= 2;
            }else{
                s = s * 3 + 1;
            }
            if(list.containsKey(s)){
                System.out.println(n);
                break;
            }
        }
    }
}


Measured memory_bytes: 21972
// Problem : F - Knapsack for All Subsets
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 998244353;

int n, s, a[maxN];
ll dp[maxN];

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> s;
	REP(i, n) cin >> a[i];
	dp[0] = 1;
	REP(i, n) {
		FORD(j, s, 0) {
			dp[j] = 2 * dp[j];
			if (j - a[i] >= 0) dp[j] += dp[j - a[i]];
			dp[j] %= MOD;
		}
	}
	cout << dp[s] << endl;
	return 0;
}
 


Measured memory_bytes: 3688
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

A, B, K = nl()

seen = set()

for i in range(A, B+1):
    if i-A >= K:
        break
    seen.add(i)

count = 0
for i in range(B, A-1, -1):
    if count >= K:
        break
    seen.add(i)
    count += 1

for c in sorted(list(seen)):
    print(c)


Measured memory_bytes: 3064
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  int n, k;
  readf("%s %s\n", &n, &k);

  auto as = readln.chomp.split.to!(int[]);
  auto num = new int[](n+1);
  int[int] cnt;
  foreach (a; as) {
    num[a]++;
    cnt[a]++;
  }
  
  num = num.filter!(x=>x!=0).array;
  num.sort();

  int res;
  auto m  = cnt.keys.length;
  foreach (e; num) {
    if (m <= k) {
      break;
    } else {
      res += e;
      m--;
    }
  }

  res.writeln;
}


Measured memory_bytes: 27280
import java.util.Scanner;
class Main {
	public void rec() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(a * b +" "+ (a + b) * 2);
	}
	public static void main(String[] args) {
		new Main().rec();
	}
}

Measured memory_bytes: 17160
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
        
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

#初期化
# uf = UnionFind(n)
h,w = inpl()
s = [input() for _ in range(h)]
d = [(1,0),(-1,0),(0,1),(0,-1)]
uf = UnionFind(h*w+5)
def ind(i,j): return i*w+j
for y in range(h):
    for x in range(w):
        for dy,dx in d:
            ny = y+dy
            nx = x+dx
            if 0 <= ny < h and 0 <= nx < w and s[ny][nx] != s[y][x]:
                uf.union(ind(y,x), ind(ny,nx))
# print(uf.parents)f
res = 0
cnt = [[0,0] for _ in range(h*w)]
for i in range(h*w):
    ind = uf.find(i)
    color = 0 if s[i//w][i%w] == '.' else 1
    cnt[ind][color] += 1
for i in range(h*w):
    res += cnt[i][0] * cnt[i][1]
print(res)

Measured memory_bytes: 106300
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  string s,t;
  cin>>s>>t;
  s="S"+s;
  t="T"+t;
  int N=s.size();
  int M=t.size();
  int dp[N][M];
  REP(i,N)dp[i][0]=0;
  REP(i,M)dp[0][i]=0;
  FOR(i,1,N)FOR(j,1,M){
    if(s[i]==t[j]){
      dp[i][j]=dp[i-1][j-1]+1;
    }else{
      dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
  }
  string ans="";
  int si=N-1;
  int ti=M-1;
  while(si*ti!=0){
    if(s[si]==t[ti]){
      ans=s[si]+ans;
      si--;
      ti--;
    }else if(dp[si][ti]==dp[si-1][ti])si--;
    else ti--;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 35456
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: String
    }
    let result = if (*s).cmp("2019/04/31") == std::cmp::Ordering::Greater {
        "TBD"
    } else {
        "Heisei"
    };
    println!("{}", result);
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    for(int i = 0; i < h; i++) {
      String s = "";
      if(i < b) {
        for(int j = 0; j < a; j++) {
          s += "0";
        }
        for(int j = 0; j < w - a; j++) {
          s += "1";
        }
      } else {
        for(int j = 0; j < a; j++) {
          s += "1";
        }
        for(int j = 0; j < w - a; j++) {
          s += "0";
        }
      }
      System.out.println(s);
    }
  }
}

Measured memory_bytes: 346044
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0;i<N;i++) {
      cin >> A.at(i);
  }
  
  int count=0;
  int ans =0;
  bool limit = false;
  
  while(limit == false) {
      
  for(int i=0;i<N;i++) {
      if(A.at(i) % 2 ==0) {
          count++;
          A.at(i) /= 2;
      }
      
  else {
      limit = true;
      break;
  }
  }
  ans++;
  }
  cout << ans-1 << endl;
}


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

#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> vc(m);
    rep(i, m)
    {
        cin >> vc[i].first >> vc[i].second;
    }

    rep(x, 1000)
    {
        int keta = 1;
        int nx = x / 10;
        vector<int> d;
        d.push_back(x % 10);
        while (nx)
        {
            keta++;
            d.push_back(nx % 10);
            nx /= 10;
        }
        reverse(d.begin(), d.end());
        if (keta != n)continue;
        bool ok = true;
        rep(i, m)
        {
            if (d[vc[i].first-1] != vc[i].second)ok = false;
        }
        if (ok)
        {
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>

using namespace std;
 
const double eps=1e-10;

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


int main()
{
	int n,m,a;
	while(cin>>n>>m>>a,n){
	
		map<int,vector<int> > amida;
		for(int i=0;i<m;i++){
			int h,p,q;
			cin>>h>>p>>q;

			amida[h].push_back(p);
			amida[h].push_back(q);
		}

		for(auto it=amida.rbegin();it!=amida.rend();it++){
			for(int i=0;i<(*it).second.size();i+=2){
				if((*it).second[i]==a){
					a=(*it).second[i+1];
					break;
				}
				if((*it).second[i+1]==a){
					a=(*it).second[i];
					break;
				}

			}
		}

		cout<<a<<endl;
	}
	return 0;
}

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

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    int c=abs(x-a);
    int d=abs(x-b);
    if(c<d)cout << 'A' << endl;
    else cout << 'B' << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i++)
#define pb push_back
#define eb emplace_back
#define vec vector

typedef uint8_t   i8;
typedef uint16_t  i16;
typedef int       i32;
typedef long long i64;

template<class T> bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template<class T> bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<class T> T gcd(T m, T n) {
  if (n == 0) return m;
  return gcd(n, m % n);
}

template<class T> T lcm(T m, T n) {
  return m * n / gcd(m, n);
}

const i64 inf = 1LL << 60;
const i32 mod = 1e9 + 7;

using namespace std;

/* Input variables. */
i32 k, x;

/* Solve! */
void solve() {
  if (k * 500 >= x) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

int main() {
  /* Input handling. */
  cin >> k >> x;

  solve();
  return 0;
}

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

int keta(int n) {
    int res;
    for(int i = 0; i < 100; i++) {
        n = n / 10;

        if(n == 0) {
            res = i + 1;
            break;
        }
    }
    return res;
}

int main() {
    int n;
  int wa=0,ac=0,re=0,tle=0;
  cin>>n;
  rep(i,n){
string s;
cin>>s;
    
if(s=="AC") ac++;
else if(s=="WA") wa++;
else if(s=="RE") re++;
else if(s=="TLE") tle++;

  }
  cout<<"AC x "<<ac<<endl;
  cout<<"WA x "<<wa<<endl;
  cout<<"TLE x "<<tle<<endl;
  cout<<"RE x "<<re<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string s;
  cin >> s;
  if(s[0]=='7'||s[1]=='7'||s[2]=='7') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n;
	cin >> n;
	vi a(n), b(n), c(n);

	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	rep(i, n)cin >> c[i];

	sort(all(a));
	sort(all(b));
	sort(all(c));

	ll ans = 0;

	rep(i, n) {

		int cent = b[i];
		ll pt = 1;

		pt *= lower_bound(all(a), cent) - a.begin();
		pt *= n - (upper_bound(all(c), cent) - c.begin());
		ans += pt;

	}

	cout << ans << endl;

}

Measured memory_bytes: 1408