akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  char c; cin >> c;

  int x = c - 'A';
  if (x >= 0 && x < 26) cout << "A\n";
  else cout << "a\n";
  return 0;
}


Measured memory_bytes: 3612
s = input()
n = int(input())
c = 0
left_l = ['', '']
right_l = ['', '']
s_l = [s, s[::-1]]
for _ in range(n):
  lst = [i for i in input().split()]
  if lst[0] == '1':
    if c == 1:
      s_l[0], s_l[1] = s_l[1], s_l[0]
      #print(s)
    else:
      s_l = [right_l[1] + s_l[1] + left_l[1], left_l[0] + s_l[0] + right_l[0]]
      left_l[0], left_l[1] = '', ''
      right_l[0], right_l[1] = '', ''
      c = 1
      #print(s)
  elif lst[0] == '2':
    c = 0
    if lst[1] == '1':
      left_l[0] = lst[2] + left_l[0]
      left_l[1] = left_l[1] + lst[2]
    elif lst[1] == '2':
      right_l[0] = right_l[0] + lst[2]
      right_l[1] = lst[2] + right_l[1]
w = left_l[0] + s_l[0] + right_l[0]
print(w)


Measured memory_bytes: 11020
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;


int main()
{
    f_io;
    ll n;
    cin >> n;
    vector<ll> arr(n);
    foi(0,n)
        cin >> arr[i];
    ll ans=0;
    foi(0,n-2)
    {
        foj(i+1,n-1)
        {
            fok(j+1,n)
            {
                if(arr[i]!=arr[j] and arr[j]!=arr[k] and arr[i]!=arr[k])
                {
                    if(arr[i]+arr[j]>arr[k] and arr[i]+arr[k]>arr[j] and arr[k]+arr[j]>arr[i])
                        ans++;
                }
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>; // グラフ型

int main()
{
    int n,m,k; cin >> n >> m >> k;
    vector<int> a(n); rep(i, n) cin >> a[i];
    vector<int> b(m); rep(i, m) cin >> b[i];

    vector<ll> sa(n+1);
    rep(i,n){
        sa[i+1] = a[i] + sa[i];
    }
    vector<ll> sb(m+1);
    rep(i,m){
        sb[i+1] = b[i] + sb[i];
    }

    int ans = 0;

    rep(i,n+1){
        ll k2 = k - sa[i];
        if(k2 < 0) continue;
        auto c = upper_bound(sb.begin(), sb.end(), k2);
        int j = distance(sb.begin(), c);
        ans = max(ans, i+j-1);
    }

    cout << ans << endl;
}

/*
sb = 0,1,5,7,8,9
5 = 3
4 = 2
0 = 1
*/


/*
g++ b.cpp
./a.out

oj d https://atcoder.jp/contests/abc172/tasks/abc172_c
oj t
*/


Measured memory_bytes: 7976
#!/usr/bin/python
# -*- coding: utf-8 -*-
 
from collections import defaultdict
 
n=int(raw_input())
v=[int(x) for x in raw_input().split()]
 
a,b = defaultdict(lambda: 0), defaultdict(lambda: 0)
for i, val in enumerate(v):
	if i%2 == 1:
		a[val] += 1
	else:
		b[val] += 1
a[-1] = 0
b[-2] = 0
aa = sorted([(y,x) for x, y in a.iteritems()], reverse=True)
bb = sorted([(y,x) for x, y in b.iteritems()], reverse=True)
# print aa, bb
if aa[0][1] != bb[0][1]:
	print n - (aa[0][0] + bb[0][0])
else:
	print n - max((aa[0][0] + bb[1][0]), (aa[1][0] + bb[0][0]))

Measured memory_bytes: 56304
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

char s[1005][1005];
int dx[4] = {0,0,-1,1};
int dy[4] = {1,-1,0,0};
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int h,w;
    cin >> h >> w;
    queue<pair<int,int>> q;
    rep(i,h)rep(j,w){
        cin >> s[i][j];
        if(s[i][j]=='#')q.push({i,j});
    }
    int ans = 0;
    while(!q.empty()){
        queue<pair<int,int>> q2;
        ans ++ ;
        while(!q.empty()){
            auto x = q.front();q.pop();
            rep(i,4){
                int nx = x.first + dx[i];
                int ny = x.second+ dy[i];
                if(nx<0 || ny<0 || nx>=h || ny>=w)continue;
                if(s[nx][ny]=='.'){
                    s[nx][ny] = '#';
                    q2.push({nx,ny});
                }
            }
        }
        q = q2;
    }
    cout << ans - 1 << endl;
}

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

using namespace std;

int nc[100010];

struct shi{
	int p;
	int y;
	int num;

	bool operator<(const shi &in) const{
		return y<in.y;
	};
};

struct ids{
	int ida;
	int idb;
	int num;

	bool operator<(const ids &in) const{
		return num<in.num;
	};
};

int main(){

	vector<shi> s;
	vector<ids> ii;
	int n, m;

	for(int i=0;i<100010;i++) nc[i]=1;

	cin>> n >> m;

	s.resize(m);
	ii.resize(m);

	for(int i=0;i<m;i++){
		cin>> s[i].p >> s[i].y;
		s[i].num=i;
	}

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

	for(int i=0;i<m;i++){
		ii[i].ida=s[i].p;
		ii[i].idb=nc[s[i].p];
		nc[s[i].p]++;
		ii[i].num=s[i].num;
	}

	sort(ii.begin(), ii.end());

	for(int i=0;i<m;i++) printf("%06d%06d\n",ii[i].ida ,ii[i].idb);

}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    string s; cin >> s;
    stack<int> st;
    for(int i = 0; i < s.size(); ++i){
        if(st.empty()) {
            st.push(s[i] - '0');
            continue;
        }
        int c = st.top();
        int now = s[i] - '0';
        if(c ^ now) st.pop();
        else st.push(now);
    }
    cout << s.size() - st.size() << endl;
}

Measured memory_bytes: 768
N=int(input())
L=[0]*(10**4)
for i in range(1,101):
  for j in range(1,101):
    for k in range(1,101):
      if i**2+j**2+k**2+i*j+j*k+k*i<=10**4:
        L[(i**2+j**2+k**2+i*j+j*k+k*i)-1]+=1
for i in range(N):
  print(L[i])

Measured memory_bytes: 69052
a, b, c, x, y = [int(i) for i in input().split()]
#print(a, b, c, x, y)

ans=1000000000000
for k in range(0,100000+1):
  i=x-k
  if i<0:
    i=0
  j=y-k
  if j<0:
    j=0
  price=a*i+b*j+2*c*k
  if price < ans:
    ans = price
    
print(ans)

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

#define ll long long

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
    
   int a,b,c;
   
   cin>>a>>b>>c;
   
   if(a+b+c >= 22)
   cout<<"bust";
   else
   cout<<"win";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
 long int n,s=1,k;
	cin>>n>>k;
   long long int arr[n];
	for(int i=0;i<n;i++)
	cin>>arr[i];
	for(int i=k;i<n;i++)
	{
	    if(arr[i]>arr[i-k])
	    cout<<"Yes"<<endl;
	    else
	    cout<<"No"<<endl;
	}
	
}


Measured memory_bytes: 5112
import java.util.*;
import java.util.ArrayList;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		char[] array = input.toCharArray();
		List<Integer> nums = new ArrayList<>();
		char prevC = array[0];
		int cnt = 0;
		for(char c : array){
			if(c != prevC){
				nums.add(cnt);
				cnt = 0;
			}
			cnt++;
			prevC = c;
		}
		nums.add(cnt);

		int ans = 0;
		boolean add = false;
		for(int num : nums){
			if(add){
				ans++;
				num--;
			}
			ans += (int)(num/3) * 2;
			if(num%3 != 0) ans += 1;
			add = num%3 == 2 ? true : false;
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 30768
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S;
  for ( int i=0; i<N; i++){
    cin >> S;
    if (S == "Y"){
      break;}
  }
    if (S=="Y"){
      cout << "Four" << endl;}
    else{
      cout << "Three" << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	ll arr[5];
	REP(i,0,5) cin>>arr[i];
	REP(i,0,5){
		if(arr[i] == 0){
			cout<<i+1<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int dmax(int x,int y,int z){
  if(x>=y && x>=z){
    return x;
  }
  else if(y>=x && y>=z){
    return y;
  }
  else if(z>=x && z>=y){
    return z;
  }
}
int main() {
  int a,b;
  cin >> a>> b;
  int ans;
  ans =dmax(a+a-1,a+b,b+b-1);
  cout << ans << endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
lr_list = [list(map(int,input().split())) 
           for nesya in range(m)]
l = 0
r = n
for lr in lr_list:
  l = max(l,lr[0])
  r = min(r,lr[1])
if l > r:
  print(0)
else:
  print(r-l+1)

Measured memory_bytes: 27336
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        if(0 == n%m){
            System.out.println("0");
        }else{
            System.out.println("1");
        }
    }

}

Measured memory_bytes: 23892
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int AB = in.nextInt();
            int BC = in.nextInt();
            int CA = in.nextInt();
            System.out.println(AB * BC / 2);
        }
    }
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

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

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  int m;
  cin >> m;
  vector<int> b(m);
  rep(i,m) cin >> b[i];

  int ans = 1;
  rep(i,m) {
    if (!binary_search(a.begin(), a.end(), b[i])) ans = 0;
  }

  cout << ans << endl;

  return 0;
}



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

int main(){

  string s;

  cin >> s;
  int length = (int)(s.length());

  for(int i=0;i<=(length-1)/2;i++){
    if(s[i]!=s[length-1-i]){
      cout << "No" <<endl;
      return 0;
    }
  }

  for(int i=0;i<=(length-1)/2/2;i++){
    if(s[i]!=s[(length-1)/2-1-i]){
      cout << "No" <<endl;
      return 0;
    }
  }

  for(int i=0;i<=(length-1)/2/2;i++){
    if(s[(length+3)/2-1+i]!=s[length-1-i]){
      cout << "No" <<endl;
      return 0;
    }
  }


  cout << "Yes" <<endl;
  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i);

sum=0
deff = 0
for i in 0..a.length-2 do
	if a[i].to_i > a[i+1].to_i then
		deff = a[i].to_i - a[i+1].to_i
		sum += deff
		a[i+1] += deff
	end
end
puts sum


Measured memory_bytes: 30184
#include <iostream>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    int m = a;
    if (b > m) {
        m = b;
    }
    if (c > m) {
        m = c;
    }
    
    cout << a + b + c + m * 9 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(A)		(A).begin(),(A).end()
#define DUMP(A)    cout<<#A<<"="<<(A)<< endl
#define SIZE(A)    (int)((A).size())
using namespace std;
typedef long long ll;

int ret;
bool used[10];
int S;
int dat[11][1000];
void solve(int nsum,int at){
    if(at==11) return;
    else{
        if(nsum<1000) dat[at][nsum]++;
        for(int i=0;i<10;i++){
            if(!used[i]){
                used[i]=true;
                solve(nsum+i*(at+1),at+1);
                used[i]=false;
            }
        }
    }
}

int main(){
    for(int i=0;i<10;i++){
        for(int j=0;j<1000;j++){
            dat[i][j]=0;
        }
    }
    solve(0,0);
    int N,S;
    while(scanf("%d%d",&N,&S)!=-1){
        if(S>=1000) printf("0\n");
        else printf("%d\n",dat[N][S]);
    }
}

Measured memory_bytes: 792
package main

import (
	"bufio"
	"fmt"
	"os"
)

const Inf = 1001001001

func main() {
	N, M := ReadInt(), ReadInt()
	adjL := make([][]int, N)
	for i := 0; i < M; i++ {
		u, v := ReadInt()-1, ReadInt()-1
		adjL[u] = append(adjL[u], v)
	}
	S, T := ReadInt()-1, ReadInt()-1
	dist := make([][]int, N)
	for i := 0; i < N; i++ {
		dist[i] = make([]int, 3)
		for j := 0; j < 3; j++ {
			dist[i][j] = Inf
		}
	}
	dist[S][0] = 0
	q := make([][]int, 0)
	q = append(q, []int{S, 0})
	for len(q) > 0 {
		v, l := q[0][0], q[0][1]
		q = q[1:]
		nl := (l + 1) % 3
		for _, u := range adjL[v] {
			if u == T && nl == 0 {
				fmt.Println((dist[v][l] + 1) / 3)
				return
			}
			if dist[u][nl] == Inf {
				dist[u][nl] = dist[v][l] + 1
				q = append(q, []int{u, nl})
			}
		}
	}
	fmt.Println(-1)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 27700
N = input()
length = len(N)
N = int(N)

if length == 1:
  print(N)
elif length == 2:
  print(9)
elif length == 3:
  print(N-90)
elif length == 4:
  print(909)
elif length == 5:
  print(N-9090)
else:
  print(90909)

Measured memory_bytes: 3060
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        String S = sc.next().toUpperCase();
                        int ans = 0;
                        while (true) {
                                String T = sc.next();
                                if(T.equals("END_OF_TEXT"))break;

                                if (S.equals(T.toUpperCase())) {
                                        ans++;
                                }
                        }
                        System.out.println(ans);
                }
        }
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)

string shuffle(string s, int h) {
    string head = s.substr(0, h);
    string tail = s.substr(h, s.size() - h);
    return tail + head;
}

int main() {
    string cards;
    int m, h;

    while (1) {
        cin >> cards;
        if (cards == "-") break;

        cin >> m;
        REP(i, m) {
            cin >> h;
            cards = shuffle(cards, h);
        }
        cout << cards << endl;
    }
}

Measured memory_bytes: 3144
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        double[] arr = new double[n];
        for (int i = 0; i < n; i++)
            arr[i] = scan.nextDouble();

        double[][] dp = new double[n + 1][n + 1];
        dp[0][0] = 1;
        for (int i = 1; i <= n; i++)
            dp[i][0] = dp[i - 1][0] * (1 - arr[i - 1]);
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                dp[i][j] = dp[i - 1][j - 1] * arr[i - 1] + dp[i - 1][j] * (1 - arr[i - 1]);
        double sum = 0;
        for (int j = (int) ((n + 1) / 2); j <= n; j++)
            sum += dp[n][j];
        System.out.println(sum);
    }
}

Measured memory_bytes: 122700
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>

using namespace std;

typedef long long int ll;

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

  string s, t;
  cin >> s;
  cin >> t;

  int n = s.size(), m = t.size();
  vector<vector<int> > dp(n+2, vector<int>(m+2));
  //for (int j = 0; j < m+2; j++) dp[0][j] = j;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      dp[i+1][j+1] = max(max(dp[i+1][j], dp[i][j+1]), dp[i][j] + (int)(s[i] == t[j]));
    }
  }

  int x = n-1, y = m-1;
  string ans;
  while (x >= 0 && y >= 0) {
    if (s[x] == t[y]) {
       ans += s[x];
       x--;
       y--;
     }
     else if (dp[x+1][y+1] == dp[x][y+1]) x--;
     else y--;
  }

  reverse(ans.begin(), ans.end());
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 35584
// "include" {{{
#include <deque>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
// }}}
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;


signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	string t = "2019/04/30";
	cout << ((s <= t) ? "Heisei\n" : "TBD\n");
	return 0;
}


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

using namespace std;

int N, M;
bool ok[100001];
int cnt[100001];

int main()
{
    scanf("%d%d", &N, &M);
    for(int i=1; i<=N; i++)
        cnt[i]=1;
    ok[1]=true;
    for(int i=0; i<M; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        cnt[a]--;
        cnt[b]++;
        if(ok[a])
            ok[b]=true;
        if(cnt[a]==0)
            ok[a]=false;
    }
    int ans=0;
    for(int i=1; i<=N; i++)
        ans+=ok[i];
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int main(){int a1;
while(cin>>a1){
int w[10],i=0;
	if(a1>=512){
	a1-=512;w[i]=512;i++;}
	if(a1>=256){
	a1-=256;w[i]=256;i++;}
	if(a1>=128){
	a1-=128;w[i]=128;i++;}
	if(a1>=64){
	a1-=64;w[i]=64;i++;}
	if(a1>=32){
	a1-=32;w[i]=32;i++;}
	if(a1>=16){
	a1-=16;w[i]=16;i++;}
	if(a1>=8){
	a1-=8;w[i]=8;i++;}
	if(a1>=4){
	a1-=4;w[i]=4;i++;}
	if(a1>=2){
	a1-=2;w[i]=2;i++;}
	if(a1==1){
	a1-=1;w[i]=1;i++;}
	for(int ii=0;ii<i-1;ii++){
	cout<<w[i-ii-1]<<" ";}
	cout<<w[0]<<endl;}
	return 0;}


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

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const int mod=1000000007;



ll inv(ll a){
	ll n=mod-2;
	ll res=1;
	while(n){
		if(n&1) res=(res*a)%mod;
		a=a*a%mod;
		n>>=1;
	}
	return res%mod;
}


ll dp[2010][2010];

int main(void){
	ll n,d,x;
	while(1){
		cin >> n >> d >> x;
		x--;
		
		if(n==0)
			break;
		
		dp[0][0]=1LL;

		for(int i=0;i<n;++i){
			for(int j=1;j<=n;++j){
				if(j-x-1>=0)
					dp[i+1][j]=(dp[i+1][j-1]+dp[i][j-1]-dp[i][j-x-1]+mod)%mod;
				else
					dp[i+1][j]=(dp[i+1][j-1]+dp[i][j-1])%mod;
			}
		}
		
		ll ans=0;
		ll com=1;
		for(ll i=1;i<=n;++i){
			ll dd=(d-(i-1)+mod)%mod;;
			com=com*dd%mod;
			com=com*inv(i)%mod;
			ans=(ans+com*dp[i][n]+mod)%mod;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 32564
from itertools import accumulate
n,q=list(map(int,input().split()))
s=input()
l=[0]*q
r=[0]*q
for i in range(q):
    l[i],r[i]=list(map(int,input().split()))
L=min(l)
R=max(r)
#前処理
A=[]
for i in range(L,R):
    if s[i-1]=="A"and s[i]=="C":
        A.append(1)
    else:
        A.append(0)
A.append(0)
s=[0]+A
S=list(accumulate(s))
#累積和
for i in range(q):
    print(S[r[i]-L]-S[l[i]-L])
    


        



Measured memory_bytes: 17508
D, G = map(int, input().split())
PC = [0]+[list(map(int,input().split())) for _ in range(D)]

def dfs(d, g):
    if(d == 0):
        return 1e9

    c = min(g//(100*d), PC[d][0])
    s = 100*d*c
    if c == PC[d][0]:
        s += PC[d][1]
    if s<g:
        c += dfs(d-1, g-s)
    return min(c, dfs(d-1,g))

print(dfs(D, G))

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x " = " << (x) << '\n';
#define P(x) cout << #x << '\n';    
#define int long long
typedef pair<int, int> pii;
const int mod = 1000000007;


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
	
	
	int h, n;
	cin >> h >> n;
	vector<int> a(n);
	for(int &x : a)
		cin >> x;
	int su = accumulate(a.begin(), a.end(), 0LL);
	cout << (su >= h ? "Yes" : "No") << '\n';
	
	return 0;
}






Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
int main(void){
    int n,a[1000]={0},b[1000]={0},c[1000]={0},cuta[1000],cutb[1000],cutc[1000],i,j,k,x,y[1000]={0},z;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        scanf("%d",&b[i]);
        scanf("%d",&c[i]);
    }
    for(j=0;j<n;j++){
        for(k=j+1;k<n;k++){
            if(a[j]==a[k]){
                cuta[j]=1;
                cuta[k]=1;
            }
        }
    }
    for(j=0;j<n;j++){
        for(k=j+1;k<n;k++){
            if(b[j]==b[k]){
                cutb[j]=1;
                cutb[k]=1;
            }
        }
    }
    for(j=0;j<n;j++){
        for(k=j+1;k<n;k++){
            if(c[j]==c[k]){
                cutc[j]=1;
                cutc[k]=1;
            }
        }
    }
    for(i=0;i<n;i++){
        if(cuta[i]==1)a[i]=0;
        if(cutb[i]==1)b[i]=0;
        if(cutc[i]==1)c[i]=0;
        z=a[i]+b[i]+c[i];
        printf("%d\n",z);
    }
    return 0;
}

Measured memory_bytes: 1212
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABCProblems
{
    class Program
    {
        static void Main(string[] args)
        {
            //空白ずつ取得
            string number = Console.ReadLine();
            string[] input = Console.ReadLine().Split(' ');
            int[] numList = new int[input.Length];

            bool isJudge = true;

            //整数配列
            for(int i = 0; i < int.Parse(number); i++)
            {
                numList[i] = int.Parse(input[i]);

                if(numList[i] % 2 == 0)
                {
                    if(!(numList[i] % 3 == 0 || numList[i] % 5 == 0))
                    {
                        isJudge = false;
                        break;
                    }
                }
            }

            if (isJudge)
            {
                Console.WriteLine("APPROVED");
            }
            else
            {
                Console.WriteLine("DENIED");
            }

        }
    }
}


Measured memory_bytes: 13140
//shahil_005
//Some basic pre-written functions might have been copied from www.geeksforgeeks.org or cp-algorithms.com//

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int N = 1e5 + 5;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

int32_t main()
{
    int n,r;
    cin >> n >>r;

    if(n< 10)
    {
        cout << r + 100*(10-n);
    }

    else
        cout << r;

    return 0;
}



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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pi;
typedef vector<int> vi;
void print_pair(pi a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}
template<int T1, int T2>
void print_2d(int a[T1][T2], int x, int y){
  For(i, x){
    For(j, y){
      cerr<<a[i][j]<<" ";
    }
    cerr<<endl;
  }
}

int a,b;

int main(){
  cin>>a>>b;
  if(a+b==15)cout<<"+"<<endl;
  else if(a*b==15)cout<<"*"<<endl;
  else cout<<"x"<<endl;
  return 0;
}



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

int main()
{
    int W, H, N;
    cin >> W >> H >> N;

    vector<vector<int>> c(H, vector<int>(W));

    for(int i=0; i<N; i++) {
        int x, y, a;
        cin >> x >> y >> a;

        if (a == 1) {
            for (int j=0; j<H; j++) {
                for (int k=0; k<x; k++) {
                    c.at(j).at(k)++;
                }
            }
        }
        else if (a == 2) {
            for (int j=0; j<H; j++) {
                for (int k=x; k<W; k++) {
                    c.at(j).at(k)++;
                }
            }
        }
        else if (a == 3) {
            for (int j=0; j<y; j++) {
                for (int k=0; k<W; k++) {
                    c.at(j).at(k)++;
                }
            }
        }
        else if (a == 4) {
            for (int j=y; j<H; j++) {
                for (int k=0; k<W; k++) {
                    c.at(j).at(k)++;
                }
            }
        }
    }
    int count = 0;
    for (int j=0; j<H; j++) {
        for (int k=0; k<W; k++) {
            if (!c.at(j).at(k)) {
                count ++;
            } 
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() 
{
	ll n;
	cin>>n;
	ll arr[n],i,arr2[n];
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	arr2[0]=0;
	arr2[1]=abs(arr[1]-arr[0]);
	for(i=2;i<n;i++)
	{
		arr2[i]=min(abs(arr[i]-arr[i-1])+arr2[i-1],abs(arr[i]-arr[i-2])+arr2[i-2]);
	}
	cout<<arr2[n-1];
	return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

inline bool only_number(char s[])
{
    int len=strlen(s);
    rep(i,len)
    {
        if(!('0'<=s[i]&&s[i]<='9')) return false;
    }
    return true;
}

int main()
{
    char f[]="Fizz", b[]="Buzz", fb[]="FizzBuzz";
    int m,n;
    char s[25];
    while(scanf(" %d %d", &m, &n),m)
    {
        list<int> player;
        rep(i,m) player.pb(i+1);

        auto itr=player.begin();
        bool only_one=false;
        for(int i=1; i<=n; ++i)
        {
            scanf(" %s", s);

            if(only_one) continue;

            bool valid=false;
            if(i%15==0)
            {
                if(strcmp(s,fb)==0) valid=true;
            }
            else if(i%3==0)
            {
                if(strcmp(s,f)==0) valid=true;
            }
            else if(i%5==0)
            {
                if(strcmp(s,b)==0) valid=true;
            }
            else
            {
                if(only_number(s) && atoi(s)==i) valid=true;
            }

            if(!valid) itr=player.erase(itr);
            else ++itr;

            if(itr==player.end()) itr=player.begin();

            if(!only_one && player.size()==1) only_one=true;
        }

        bool F=true;
        each(ITR,player)
        {
            if(!F) printf(" ");
            printf("%d", *ITR);
            F=false;
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007 
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
vector <int> adj[100001];
vector <vector <ll>> dp(100001,vector <ll> (2,1ll));
vector <bool> visited(100001);
void dfs(int u){
    visited[u]=true;
    ll w=1;//0
    ll bw=1;//1
    for(int v:adj[u]){
        if(visited[v]==false){
            dfs(v);
            w=(w*dp[v][1])%MOD;
            bw=(bw*(dp[v][1]+dp[v][0]))%MOD;
        }
    }
    dp[u][0]=(dp[u][0]*w)%MOD;
    dp[u][1]=(dp[u][1]*bw)%MOD;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        for(int i=1;i<n;i++){
            int u,v;
            cin>>u>>v;
            adj[u].push_back(v);
            adj[v].push_back(u);
        }
        dfs(1);
        cout<<((dp[1][0]+dp[1][1])%MOD)<<"\n";
    }
    return 0;
}

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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	int count = 0;
	for(int i=a;i<=b;i++){
		if(c % i == 0){
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3136
/*
 Sarthak Jain
*/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
int mod=1e9+7;
int min(int a,int b){
	return (a<b)?a:b;
}
int max(int a,int b){
	return (a>b)?a:b;
}
int fp(int a,int b){
	if(b==0) return 1;
	int x=fp(a,b/2);
	x=(x*x)%mod;
	if(b&1) x=(x*a)%mod;
	return x;
}


signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 int n,m,k,x;
 cin>>n>>m>>k;
 int s=0;
 int a[n+1];
 set<array<int,2>> st;

 for(int i=1;i<=n;i++)
 {
 	cin>>a[i];
 	s+=a[i];
 	st.insert({s,i});
 }

 s=0;
 int ans=0;
 auto it=st.upper_bound({k,0});

 if(it==st.end()||(*it)[0]>k){
 			if(it!=st.begin())
 			{
 				it--;
 				ans=max(ans,(*it)[1]);
 			}
 }
 else
 {
 	ans=max(ans,(*it)[1]);
 }
 	
 
// cout<<ans<<endl;
 for(int i=1;i<=m;i++)
 {
 	cin>>x;
 	s+=x;
 	if(s<=k)
 	{
 		auto it=st.upper_bound({k-s,0});
 		 if(it==st.end()||(*it)[0]>k-s){
 			if(it!=st.begin())
 			{
 				it--;
 				ans=max(ans,i+(*it)[1]);
 			}
 			else{
 				ans=max(ans,i);
 			}
 		}
 		else
 		{
 				ans=max(ans,i+(*it)[1]);
 		}
 	}
 }		
 cout<<ans;


}


Measured memory_bytes: 17688
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int a[53];
  for(i=1;i*i*i<151200;i++)
    a[i-1]=i*i*i;
  int b[95];
  b[0]=1;
  for(i=1;b[i-1]+(i+1)*(i+2)/2<151200;i++)
    b[i]=b[i-1]+(i+1)*(i+2)/2;
  bool c[151201];
  memset(c,0,151201);
  for(i=0;i<53;i++)
    c[a[i]]=1;
  for(i=0;i<95;i++)
    c[b[i]]=1;
  for(i=0;i<53;i++){
    for(j=0;j<95;j++){
      if(a[i]+b[j]<151201)
	c[a[i]+b[j]]=1;
    }
  }
  int n;
  while(cin>>n&&n){
    for(;c[n]==0;n--);
    cout<<n<<endl;
  }
  return 0;
}

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

using namespace std;
using ll = long long;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }

    int sum = 0;
    for (int i = 0; i < N; i++) {
        sum += 2*min(x[i], abs(x[i] - K));
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	peakCount, loadsCount := nextInt(), nextInt()
	var peaks = map[int]int{}
	var betterPeaks = map[int]bool{}
	for n := 1; n <= peakCount; n++ {
		height := nextInt()
		peaks[n] = height
		betterPeaks[n] = true
	}
	for m := 0; m < loadsCount; m++ {
		peakNoA, peakNoB := nextInt(), nextInt()
		if peaks[peakNoA] < peaks[peakNoB] {
			lowerPeasNo := peakNoA
			betterPeaks[lowerPeasNo] = false
		} else if peaks[peakNoB] < peaks[peakNoA] {
			lowerPeasNo := peakNoB
			betterPeaks[lowerPeasNo] = false
		} else {
			betterPeaks[peakNoA] = false
			betterPeaks[peakNoB] = false
		}
	}
	var betterPeakCount int
	for _, v := range betterPeaks {
		if v {
			betterPeakCount++
		}
	}
	fmt.Println(betterPeakCount)
}


Measured memory_bytes: 10816
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define mod 1000000007
#define inf 1000000007
#define ll long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 200010

template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}

int pow(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;b>>=1;
	}
	return ans;
}

ll g[51];
int a[55],b[55];
void cal(vi &v){
	rep(i,0,51)g[i]=1LL<<i;
	rep(i,1,51){
		per(k,0,SZ(v)){
			if(v[k]>i)break;
			g[i]|=g[i%v[k]];
		}
	}
}
int main(){
	//cout<<setprecision(9)<<fixed;
    int ca=0,T,m=0,k,i,j,n,K;
	scanf("%d",&n);
	rep(i,0,n)scanf("%d",&a[i]);
	rep(i,0,n)scanf("%d",&b[i]);
	rep(i,0,n)if(a[i]<b[i]){puts("-1");return 0;}
	rep(i,0,51)g[i]|=1LL<<i;
	rep(i,1,51){
		rep(j,1,i+1){
			k=i%j;
			g[i]|=g[k];
		}
	}
	rep(i,0,n)if(g[a[i]]>>b[i]&1);else {puts("-1");return 0;}
	K=51;
	vi ans,v;
	while(1){
		cal(ans);
		int ok=1;
		rep(i,0,n)if(g[a[i]]>>b[i]&1);else{ok=0;break;}
		if(ok)break;
		rep(k,1,K){
			v=ans;
			per(i,1,k+1)v.pb(i);
			cal(v);
			ok=1;
			rep(i,0,n)if(g[a[i]]>>b[i]&1);else{
				ok=0;break;
			}
			if(ok){
				K=k;
				ans.pb(K);break;
			}
		}
	}
	ll s=0;
	for(auto &x:ans)s+=1LL<<x;
	printf("%lld\n",s);
}


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

void print(const vector<int64_t> &a){
  size_t n = a.size();
  for(int i=0;i<n-1;i++){
    cout << a[i] << " ";
  }
  cout << a[n-1] << endl;
}

void insertionSort(vector<int64_t> &a){
  size_t n = a.size();
  for(int i=1;i<n;i++){
    int v = a[i];
    int j = i - 1;
    while(j>=0 && a[j] > v){
      a[j+1] = a[j];
      j--;
    }
    a[j+1]=v;
    print(a);
  }
}

int main(){
  int N;
  vector<int64_t> v;

  cin >> N;
  v.resize(N);
  for(int i=0;i<N;i++){
    cin >> v[i];
  }

  print(v);
  insertionSort(v);

  return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { 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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    string s;cin >> s;
    if(s[2]==s[3] and s[4]==s[5]){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    
    return 0;
}





Measured memory_bytes: 3628
k, a, b = map(int, input().split())
bis, jpn = 1, 0
if b-a < 2 or k <= a-1:
    print(k+1)
else:

    bis = a + max(b-a, 2) * int((k-a+1)/2) + (k-a+1)%2
        
    print(int(bis))






Measured memory_bytes: 2940
#include <bits/stdc++.h> 
#define pb push_back
#define M 100005
#define ll long long int
#define rep(i,n) for(int i=1;i<n;i++)
#define mp(a,b) make_pair(a,b)
#define gcd(a,b)    __gcd(a,b)
#define lcm(a,b) ((a)*((b)/gcd(a,b)))
using namespace std;
int main(){
	ll n;
	cin>>n;
	int i=sqrt(n);
	cout<<i*i<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    ll n=s.length();
    if((s[0]==s[n-1])&&((n&1)==0)){
        cout<<"First"<<endl;
    }
    else if((s[0]!=s[n-1])&&((n&1)==1)){
        cout<<"First"<<endl;
    }
    else{
        cout<<"Second"<<endl;
    }
    return 0;
}


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

int dx[] = {0, 1, 0,-1};	//上下左右進む方向
int dy[] = {-1,0, 1, 0};

// void dfs(int x, int y, int field[100][100]){
// 	if(field[x][y] == 0) return;	//行けなかったら終わり

// 	field[x][y] = 0;
// 	for(int k = 0; k < 4; k++){
// 		dfs(x + dx[k], y + dy[k], field);
// 	}
// }

//深さ優先探索
int dfs(int x, int y, int field[100][100]){	//引数は座標と今まで通ってきたフィールド
	int d = field[x][y];			//今の場所の距離
	for(int k = 0; k < 4; k++){		//上下左右進む
		int nextX = x + dx[k];		//次に進む方向
		int nextY = y + dy[k];
		if(field[nextX][nextY] == 1){	//もし次に進めたら
			field[nextX][nextY] = field[x][y]+1;	//行った印,スタートからの距離
			d = max(d, dfs(nextX, nextY, field));	//今の距離(今まで行った距離)と比較
			field[nextX][nextY] = 1;	//もとに戻しておく
		}
	}

	return d; //その位置から行けるスタートからの最大距離を返す
}

int main(){
	int m, n;
	while(cin >> m >> n, m != 0 && n != 0){
		/*入力*/
		int ice[100][100] = {{0}};			//与えられる配列(外壁あり)
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= m; j++){
				cin >> ice[i][j];
			}
		}

		/*計算*/
		int ans = 0;
		for(int i = 1; i <= m; i++){		//始めの位置
			for(int j = 1; j <= n; j++){
				if(ice[i][j] == 1){			//氷があったら
					ice[i][j] = 2;			//行った印,スタートからの距離(0,1が使われているから2)
					ans = max(ans, dfs(i, j, ice));	//調べ終わった距離と、その位置からの行ける最大距離を比べる
					ice[i][j] = 1;			//氷を戻しておく
				}
			}
		}

		/*出力*/
		cout << ans-1 << endl;	//2から始まっていたので-1する
	}
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int MOD = 1e9 + 7;

int f[26];
int32_t main() {
        int n;
        string s; cin >>n >>  s;
        for(char x: s) f[x - 'a']++;
        int ans = 1;
        for(int i = 0; i < 26; i++)
                ans = (ans * (f[i] + 1)) % MOD;
        cout << ((ans - 1) + MOD) % MOD << endl;
}


Measured memory_bytes: 512
#include<algorithm>
#include<vector>
#include<list>
#include<iostream>
#include<utility>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<iterator>
#include<map>
#include<limits>
#include<iomanip>
#include<ctime>
 
const int INF=2147483647;
 
using namespace std;

//long long minEqVal;


int main(){
   int a,b,c;
   cin>>a>>b>>c;
   
   
   bool ans=false;
   for(int i=0; i<b; i++){
       ans=ans||((i*a)%b == c);
   }
   cout<<(ans?"YES":"NO");
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define VECCIN(x) for(auto&youso_: (x) ) cin >>  youso_
#define VECCOUT(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << endl
template<class T>bool chmax(T &a, const T &b) { if (a<b) { 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 int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head

int main(){
    string s,t;
    vector<string> ans;
    int index=inf;
    cin >>s>>t;
    int ns=s.size();
    int nt=t.size();
    if (ns<nt){
        cout << "UNRESTORABLE" << endl;
        return 0;}

    for range(i,ns-nt+1){
        bool flug = true;

        for range(j,nt){
            if (s[i+j]!=t[j] && s[i+j]!='?') flug=false;}

        if (flug){
            // cout << s << endl;
            string tmp = s;
                for range(k,nt){
                    tmp[i+k]=t[k];}
                for range(k,ns) {
                    if (tmp[k]=='?') tmp[k]='a';}
                // cout <<  tmp << endl;
                ans.push_back(tmp);
        }
    }
    if (!ans.size()){
        cout <<"UNRESTORABLE" << endl;
        return 0;}
    string m=*min_element(all(ans));
    cout << m << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a1 = Integer.parseInt(in.next());
            int a2 = Integer.parseInt(in.next());
            int a3 = Integer.parseInt(in.next());
            int ans = 1000;

            ans = Math.min(ans, Math.abs(a1 - a2) + Math.abs(a2 - a3));
            ans = Math.min(ans, Math.abs(a1 - a3) + Math.abs(a3 - a2));
            ans = Math.min(ans, Math.abs(a2 - a1) + Math.abs(a1 - a3));
            ans = Math.min(ans, Math.abs(a2 - a3) + Math.abs(a3 - a1));
            ans = Math.min(ans, Math.abs(a3 - a1) + Math.abs(a1 - a2));
            ans = Math.min(ans, Math.abs(a3 - a2) + Math.abs(a2 - a1));

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 25172
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 2005
using namespace std;
int a,b,tot;
int d[maxn][maxn];
int dis[maxn][maxn];
int head[maxn],nex[maxn*maxn],to[maxn*maxn];
string val[maxn*maxn];
void add(int x,int y,string z)
{
	to[++tot]=y; val[tot]=z; nex[tot]=head[x]; head[x]=tot;
}
int main()
{
	memset(dis,0x3f,sizeof(dis));
	scanf("%d%d",&a,&b);
	for(int i=1;i<=a;i++)
		for(int j=1;j<=b;j++)
			scanf("%d",&d[i][j]);

	for(int i=1;i<=100;i++)
		add(i,i+1,"X");

	for(int i=102;i<=201;i++)
		add(i,i+1,"Y");
	
//	cerr<<"+2"<<endl;

	for(int i=0;i<=100;i++)
	{
		for(int j=0;j<=100;j++)
		{
			int temp=0;
			for(int k=1;k<=a;k++)
			{
				for(int o=1;o<=b;o++)
				{
					temp=max(temp,d[k][o]-k*i-o*j);
				}
			}
//			cerr<<"its "<<i<<" "<<j<<endl;	
			add(i+1,202-j,to_string(temp));

			for(int k=1;k<=a;k++)
			{
				for(int o=1;o<=b;o++)
				{
					dis[k][o]=min(dis[k][o],temp+i*k+o*j);
				}
			}
		}
	}

//	cerr<<"+1"<<endl;

	for(int i=1;i<=a;i++)
	{
		for(int j=1;j<=b;j++)
		if(dis[i][j]!=d[i][j])
		{
//			cerr<<d[i][j]<<' '<<dis[i][j]<<endl;
			return printf("Impossible\n"),0;
		}
	}

	printf("Possible\n");
	printf("%d %d\n",202,tot);	
	for(int i=1;i<=202;i++)
	{
		for(int j=head[i];j;j=nex[j])
		{
			cout<<i<<" "<<to[j]<<" "<<val[j]<<endl;
		}
	}
	printf("1 202\n");
}


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

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		//参加人数
		int N = scanner.nextInt();
		//日数
		int D = scanner.nextInt();
		//チョコレートの残り
		int X = scanner.nextInt();

		//A_iをarrayに入力
		int[] array = new int[N];
		for (int i = 0; i < N; i++) {
			array[i] = scanner.nextInt();
		}

		//食べたチョコレートの合計sum
		int sum = 0;
		for (int i = 0; i < N; i++) {
			int count = 0;
			//チョコレートを食べる日date
			List<Integer> date = new ArrayList<>();
			for (int j = 0; j < D; j++) {
				//j人目
				if (j * array[i] + 1 > D) {
					break;
				}
				date.add(j * array[i] + 1);
				//j人目の人がチョコレートを食べた日数の合計count
				count = date.size();
			}
			sum += count;
		}

		int chocolate = X + sum;
		System.out.println(chocolate);
	}

}

Measured memory_bytes: 21716