akhauriyash/Code-Regression huggingface dataset:
S = str(input())

def checker(y, m, d):
    if y < 2019: return 'Heisei'
    if y > 2019: return 'Heisei'
    if m  in [1, 2, 3, 4]: return 'Heisei'
    
    return 'TBD'

y, m, d = map(int, S.split('/'))
print(checker(y, m, d))



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int n;
  cin >> n;
  vector<pair<string,int>> t(n);
  rep(i,n){
    int s;
    cin >> t[i].first >> s;
    t[i].second = 100 - s;
  }
  vector<pair<string,int>> l(n);
  l = t;
  sort(l.begin(), l.end());
  vector<int> ans(n);
  rep(i,n){
    rep(j,n){
      if(l[j] == t[i])ans[j] = i+1;
    }
  }
  rep(i,n)cout << ans[i] << endl;
}




Measured memory_bytes: 3612
import Control.Applicative

main :: IO ()
main = do
    a <- readLn
    b <- readLn
    c <- readLn
    d <- readLn
    e <- readLn
    k <- readLn
    putStrLn $ solve a b c d e k

solve :: Int -> Int -> Int -> Int -> Int -> Int -> String
solve a b c d e k = if b - a > k 
                    || c - a > k
                    || d - a > k
                    || e - a > k
                    || c - b > k 
                    || d - b > k
                    || e - b > k
                    || d - c > k
                    || e - c > k
                    || e - d > k
                    then ":("
                    else "Yay!"
                                 


Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std ;
int main()
{
	int n,t,i;
	cin>>n>>t;
	int c[n],q[n];
	for (i=0;i<n;i++)
		cin>>c[i]>>q[i];
	vector<int> p;
	for (i=0;i<n;i++)
	{
		if(q[i]<=t)
		p.push_back(c[i]);
	}
	if (p.size()==0)
		cout<<"TLE"<<endl;
	else
		cout<<*min_element(p.begin(),p.end())<<endl;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;



int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    vector<long> left(n);
    vector<long> right(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld%ld", &left[i], &right[i]);
    }
    sort(left.rbegin(), left.rend());
    sort(right.begin(), right.end());

    // left
    ll ans0=0, ans1=0;
    {
        long curr = 0;
        for(i=0; i<n; i++) {
            if(left[i]<=curr) break;
            ans0 += (left[i] - curr);
            curr = left[i];

            if(right[i]>=curr) break;
            ans0 += (curr - right[i]);
            curr = right[i];
        }
        ans0 += abs(curr);
        //printf("ans=%lld\n", ans0);
    }

    // right
    {
        long curr = 0;
        for(i=0; i<n; i++) {
            if(right[i]>=curr) break;
            ans1 += (curr - right[i]);
            curr = right[i];

            if(left[i]<=curr) break;
            ans1 += (left[i] - curr);
            curr = left[i];
        }
        ans1 += abs(curr);
        //printf("ans=%lld\n", ans1);
    }
    printf("%lld\n", MAX(ans0, ans1));

    return 0;
}



Measured memory_bytes: 1792
S = input()
alpha = lambda c:chr(c+96)
List = []
for i in range(len(S)):
  tmp = S[i]
  List.append(tmp)
for k in range(1,27):
  if(List.count(alpha(k)) <= 1):
    pass
  else:
    print("no")
    exit()
print("yes")


Measured memory_bytes: 2940
// ABC101A - Eating Symbols Easy

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

int main() {
	string S;
	cin >> S;

	int ans = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '+') {
			ans++;
		} else if (S[i] == '-') {
			ans--;
		}
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m , k;
  cin >> n >> m >> k;
  vector<long long> a(n), b(m);
  long long num = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    num += a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  int bindex = 0;
  long long bnum = 0;
  long long ans = 0;
  for (long long i = n; i >= 0; i--) {
    if (i!=0 && num > k) {
      num -= a[i-1];
      continue;
    }
    for (; bindex <= m;) {
      if (num + bnum <= k && ((bindex == m) || (num + bnum + b[bindex]> k))) {
        ans = max(ans, i + bindex);
        break;
      }
      bnum += b[bindex];
      bindex++;
    }
    num -= a[i-1];
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 6336
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;


public class Main {

  private static final Scanner in = new Scanner(System.in);
  private static final PrintWriter out = new PrintWriter(System.out);
  private static final Set<String> set = new TreeSet<>();

  private static long[] nextArray(int n) {
    long[] arr = new long[n];
    for (int i = 0; i < n; i++) {
      arr[i] = in.nextLong();
    }
    return arr;
  }

  public static void main(String[] args) {
    String s = in.next();
    int k = in.nextInt();
    solve(s, k);
    int i = 0;
    for (String string : set) {
      if (i == k - 1) {
        out.println(string);
      }
      i++;
    }
    out.flush();
    out.close();
  }

  private static void solve(String str, int k) {
    for (int i = 0; i < str.length(); i++) {
      for (int j = i + 1; j <= i + k && j <= str.length(); j++) {
        set.add(str.substring(i, j));
      }
    }
  }


}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N;
    cin >>N;

    string S;
    map<char,ll> mp;
    rep(i,N){
        cin >> S;
        mp[S[0]]++;
    }
    vector<ll> MARCH(5);
    MARCH[0]=mp['M'];
    MARCH[1]=mp['A'];
    MARCH[2]=mp['R'];
    MARCH[3]=mp['C'];
    MARCH[4]=mp['H'];
    //-----------------------------------
    ll ans=0;
    int PATT[10][3]={{0,1,2},{0,1,3},{0,1,4},{0,2,3},{0,2,4},
        {0,3,4},{1,2,3},{1,2,4},{1,3,4},{2,3,4}};
    rep(i,10){
        ans+=MARCH[PATT[i][0]]*MARCH[PATT[i][1]]*MARCH[PATT[i][2]];
        //cout<<ans<<endl;
    }

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=n-1;i>=0;i--){
        cout<<a[i];
        if(i)cout<<" ";
    }cout<<endl;
    return 0;
}


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

int main(){
  string S, T;
  cin >> S >> T;
  int L=S.size();
  int M=T.size();
  int p=-1;
  for(int i=0; i<L-M+1 ; i++){
    int k=1;
    for(int j=0; j<M; j++){
      if(S.at(L-1-j-i)!='?' && S.at(L-1-j-i)!=T.at(M-1-j)){
        k=0;
        break;
      }
    }
    if(k==1){
      p=i;
      break;
    }
  }
  string Ans=S;
  if(p==-1){
    cout << "UNRESTORABLE" << endl;
  }
  else{
    for(int i=0; i<L; i++){
      if(L-p-M<=i && i<=L-p-1){
        Ans.at(i)=T.at(i-(L-p-M));
      }
      else if(Ans.at(i)=='?'){
        Ans.at(i)='a';
      }
    }
    cout << Ans << endl;
  }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N, max1=0, max2=0, x, m;
	cin >> N;
	REP(i, 0, N){
		cin >> m;
		if(m > max1){
			max2 = max1;
			max1 = m;
			x = i;
		}
		else if(m > max2) max2 = m;
	}
	REP(i, 0, N) cout << (i==x?max2:max1) << "\n";

}


Measured memory_bytes: 1664
import heapq

def main():
    l = list()

    while True:
        com, *para = input().split()

        if com == "insert":
            heapq.heappush(l, -int(para[0]))
        elif com == "extract":
            print(-heapq.heappop(l))
        elif com == "end":
            break

main()


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

const long long INF = 1LL<<60;
int N, v;
long long W;
long long w;

long long dp[110][100100];

int main() {
    cin >> N >> W;
    for (int i=0; i<100100; i++) dp[0][i] = INF;
    dp[0][0] = 0;

    for (int i=1; i<=N; i++) {
        cin >> w >> v;
        for (int j=0; j<100100; ++j) {
            if (j < v) dp[i][j] = dp[i-1][j];
            else dp[i][j] = min(dp[i-1][j-v]+w, dp[i-1][j]);
        }
    }

    long long ans = 0;
    for (int i=100099; i>=0; --i) {
        if (dp[N][i] <= W) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 80128
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void A();

int main()
{
	A();
	fflush(stdout);
	return 0;
}
void dbg(std::vector<std::vector<int>>& flag) {
	for (auto it = flag.begin(); it != flag.end(); it++) {
		for (auto it2 = it->begin(); it2 != it->end(); it2++) {
			if (*it2 == (int)MOD_NUM) printf("F");
			else if (*it2 == -1) printf("W");
			else printf("%d", *it2);
		}
		putchar('\n');
	}
}
static void A()
{
	int H, W;
	get(H, W);

	int sh, sw;
	get(sh, sw); sh--; sw--;

	int gh, gw;
	get(gh, gw); gh--; gw--;

	std::vector<std::string> grid(H);
	for (int h = 0; h < H; h++) {
		get(grid[h]);
	}

	std::vector<std::vector<int>> flag(H, std::vector<int>(W, (int)MOD_NUM));
	std::deque<std::pair<int, int>> deq;
	int warp = 0;
	flag[sh][sw] = warp;
	deq.emplace_front(sh, sw);

	int dh[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
	int dw[] = { 0, 1, 0, -1, 1, -1, -1, 1 };
	while (!deq.empty()) {
		std::pair<int, int> pos = deq.front(); deq.pop_front();
		warp = flag[pos.first][pos.second];

		if (pos.first == gh && pos.second == gw) {
			printf("%d\n", warp);
			//dbg(flag);
			return;
		}

		for (int i = 0; i < 8; i++) {
			int nh = pos.first + dh[i];
			int nw = pos.second + dw[i];

			if ((nh >= 0) && (nh < H) && (nw >= 0) && (nw < W)) {
				if (i < 4) {
					if (grid[nh][nw] == '.' && flag[nh][nw] > warp) {
						deq.emplace_front(nh, nw);
						flag[nh][nw] = warp;
					}
				}
				if (flag[nh][nw] > warp) {
					if (grid[nh][nw] == '#') {
						flag[nh][nw] = -1;
					}
					else {
						flag[nh][nw] = warp + 1;
						deq.emplace_back(nh, nw);
					}
					for (int j = 0; j < 8; j++) {
						int nnh = nh + dh[j];
						int nnw = nw + dw[j];

						if ((nnh >= 0) && (nnh < H) && (nnw >= 0) && (nnw < W)) {
							if (grid[nnh][nnw] == '.' && flag[nnh][nnw] > (warp + 1)) {
								deq.emplace_back(nnh, nnw);
								flag[nnh][nnw] = warp + 1;
							}
						}
					}
				}
			}
		}
	}
//	dbg(flag);
	printf("-1\n");
}


Measured memory_bytes: 9596
#include <stdio.h>
#include <string.h>
//prototype
int main(void);

int main(void){
  char number_str[1000];
  int digit_count;
  int sum = 0;
  int num = 0;
  int i;

  while (1) {
    scanf("%s", &number_str);

    //exit condition
    if (number_str[0] == '0') {
      break;
    }

    digit_count = strlen(number_str);

    for (i = 0; i < digit_count; i++) {
      num = number_str[i] - '0';
      sum += num;
    }

    printf("%d\n", sum);
    sum = 0;
  }

  return 0;
}



Measured memory_bytes: 2028
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define F first
#define S second
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define ET cout << "\n"
#define DB(a,s,e) {for(int i=s;i<e;i++) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll dp[3005][3005],arr[3005];

int main()
{jizz
	ll n;
	cin >> n;
	for(int i=1;i<=n;++i)
		cin >> arr[i],dp[i][i]=arr[i],arr[i]+=arr[i-1];
	for(int i=1;i<n;++i)
		for(int j=1;j+i<=n;++j)
			dp[j][j+i]=arr[j+i]-arr[j-1]-min(dp[j+1][j+i],dp[j][j+i-1]);
	cout << 2*dp[1][n]-arr[n] << "\n";
}

Measured memory_bytes: 70016
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long 
int n;
ll k;
ll a[100005];
vector<ll> ys;
bool prime(int a)
{
	int cnt=0;
	for(int i=1;i<=a;i++)
	{
		if(a%i==0)cnt++;
	}
	if(cnt==2)return 1;
	else return 0;
}
int main()
{
	cin>>n;
	cin>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==k){
			cout<<"POSSIBLE";
			return 0;
		}
	}
	int cnt=0;
	sort(a,a+n);
	if(k>a[n-1]){
		cout<<"IMPOSSIBLE";
		return 0;
	}
	for(int i=1;i<=sqrt(a[0]);i++){
		if(a[0]%i==0){
			ys.push_back(i);
		}
	}
	int len=ys.size();
	for(int i=0;i<len;i++){
		ys.push_back(a[0]/ys[i]);
	}
	for(int i=0;i<ys.size();i++){
		if(ys[i]==1){
			ys[i]=1e9+7;
			break;
		}
	}
	for(int i=0;i<ys.size();i++){
		cnt=0;
		for(int j=0;j<n;j++){
			if((a[j]%ys[i])!=0){
				break;
			}
			else cnt++;
		}
		if(cnt==n){
			if(k%ys[i]!=0){
				cout<<"IMPOSSIBLE";
				return 0;
			}
		}
	}
	cout<<"POSSIBLE";
    return 0;
}

Measured memory_bytes: 1024
use std::io;
use std::io::BufRead;

fn main() {
    let mut sc = Scanner::new(std::io::stdin());
    let n: usize = sc.next().unwrap();
    let p: usize = sc.next().unwrap();
    let mut n0: u64 = 1;
    let mut n1: u64 = 0;
    for _ in 0..n {
        let i: usize = sc.next().unwrap();
        if i % 2 == 0 {
            n0 *= 2;
            n1 *= 2;
        } else {
            let tmp = n1 + n0;
            n0 = tmp;
            n1 = tmp;
        }
    }
    println!("{}", if p == 0 { n0 } else { n1 });
}

/// Scanner
///
/// # Example
/// ```
/// use contest::io::scanner;
/// let mut sc = scanner::Scanner::new("1 2 \n\n \r\t \n 3.5".as_bytes());
/// assert_eq!("1".to_string(), sc.next::<String>().unwrap());
/// assert_eq!(2, sc.next().unwrap());
/// assert_eq!(3.5, sc.next().unwrap());
/// assert_eq!(None, sc.next::<i32>());
/// ```

pub struct Scanner<R: io::Read> {
    br: io::BufReader<R>,
    // Read tokens are stored in reversed order per line.
    buf: Vec<String>,
}

impl<R: io::Read> Scanner<R> {
    pub fn new(r: R) -> Scanner<R> {
        Scanner {
            br: io::BufReader::new(r),
            buf: vec![],
        }
    }
    #[inline]
    pub fn next<T>(&mut self) -> Option<T>
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        self.next_string().map(|s| s.parse::<T>().expect("Parse failed: "))
    }
    fn next_string(&mut self) -> Option<String> {
        self.buf.pop().or_else(|| match self.update() {
            true => self.next_string(),
            false => None,
        })
    }
    #[inline]
    fn update(&mut self) -> bool {
        let mut s = String::new();
        let res = self.br.read_line(&mut s);
        match res.expect("I/O error.") {
            0 => false,
            _ => {
                self.buf = s.split_whitespace().map(|x| x.to_string()).rev().collect();
                true
            }
        }
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define Sheryang main
const int maxn=1e6+7;
typedef unsigned long long ll;
const int mod=1e9+7;
int read(){int c = getchar(),Nig = 1,x = 0;while(!isdigit(c))c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
#define read read()

struct node{
    int x,y;
}p[3];

int cmp(node a,node b){
    return a.x<b.x;
}

int Sheryang()
{
    int n=read;

    int ans=0;
    for(int i=1;i<=n;i++){
        int x=read;
        if(x&1){
            ans^=(n-i+1);
        }
    }

    if(!ans) printf("second\n");
    else printf("first\n");

    return 0;
}


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

int main() {
  int a, b, ans1 = 0, n = 0;
  double ans2 = 0;
  char c;
  while (cin >> a >> c >> b) {
    ans1 += a * b, ans2 += b, ++n;
  }
  ans2 = round(ans2 / n);
  cout << ans1 << endl << ans2 << endl;
}



Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<vector<ll>> cnt(10, vector<ll>(10, 0));
    reps(i, 1, n + 1) {
        string s = to_string(i);
        ll st = s[0] - '0';
        ll en = s[len(s) - 1] - '0';
        cnt[st][en]++;
    }
    ll ans = 0;
    reps(st, 1, 10) {
        rep(en, 10) {
            ans += cnt[st][en] * cnt[en][st];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int a, b, c, cnt;
    int tmp[3] = {};
    scanf("%d %d %d", &a, &b, &c);
    
    if (a % 2 == 0 && b % 2 == 0 && c % 2 == 0 &&a == b && b == c && c == a) {
        printf("-1\n");
        return 0;
    }

    cnt = 0;

    for (cnt; a%2==0&&b%2==0&&c%2==0; cnt++) {
        tmp[0] = (a+b)/2;
        tmp[1] = (b+c)/2;
        tmp[2] = (c+a)/2;
        a=tmp[0];b=tmp[1];c=tmp[2];
    }

    printf("%d\n", cnt);
    return 0;
}

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

int main(void) {
	int *powder_m;
	int powder_x;
	int donut_n;
	int num = 0;
	int min, i;

	scanf("%d %d", &donut_n, &powder_x);

	if((powder_m = (int *)malloc(sizeof(int) * donut_n)) == NULL){
		return -1;
	}

	for(i = 0; i < donut_n; i++){
		scanf("%d", &powder_m[i]);

		num++;
		if(min > powder_m[i] || i == 0){
			min = powder_m[i];
		}
		powder_x -= powder_m[i];
	}

	num += powder_x / min;

	printf("%d", num);

	return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}

	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	long long ans = 1;
	for (int i = 0; i < n; i++) {
		if (a[i] > 1000000000000000000/ans) {
			cout << -1 << endl;
			return 0;
		}
		else ans *= a[i];
	} 
	cout << ans << endl;
}

Measured memory_bytes: 3964
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;

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

	int a,b;

	cin >> a >> b;

	cout << (((a*b) % 2==0) ? "Even" : "Odd" ) << endl;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
int main() {
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());
    if(t > s)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void)
{
  char s1[11],s2[11],s3[11];
  scanf("%s%s%s",s1,s2,s3);
  printf("%c%c%c\n",s1[0]-32,s2[0]-32,s3[0]-32);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pii pair<int , int>
#define mpi make_pair
#define F first
#define S second
#define pb push_back
#define fl(i , n) for(int i = 0;i<n;i++)


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

    ll ans = (ll)n*(n-1);
    ans /= 2;

    cout<<ans<<endl;



    

	return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define ASSERT(expr...) assert((expr))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
using ll = long long;

constexpr i64 INF = 1010000000000000017LL;

constexpr i64 MOD = 1000000007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

ll mod_pow(ll x, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        return mod_pow(x * x % MOD, n / 2) % MOD;
    } else {
        return x * mod_pow(x, (n - 1)) % MOD;
    }
}

ll mod_pow_r(ll x, ll n) {
    if (x == 0) return 0;
    if (n == 0) return 1;

    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n /= 2;
    }
    return ret;
}

ll factorial(ll n) {
    ll ret = 1;
    REP(i, n) {
        ret *= (i + 1);
        ret %= MOD;
    }
    return ret;
}

ll combination(ll n, ll r) {
    if (n < 0 || n < r || r < 0) return 0;
    ll fn = factorial(n);
    ll fr = factorial(r);
    ll fn_r = factorial(n-r);

    ll d = (mod_pow(fr, MOD - 2) * mod_pow(fn_r, MOD - 2)) % MOD;
    ll u = fn % MOD;
    return u * d % MOD;
}

ll n, k;

void solve() {
    cin >> n >> k;
    ll rem = n % k;
    cout << min(rem, abs(rem - k));
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1);





int main() 
{
  ll H,K,W; cin>>H>>W>>K;
  ll sum=0;
  vector<ll> yoko(H,0);
  vector<ll> tate(W,0);
  vector<string> grid(H);
  rep(i,H)
  {
    cin>>grid.at(i);
    rep(j,W)
    {
      if(grid.at(i).at(j)=='#') 
      {
        yoko.at(i)++;
        tate.at(j)++;
        sum++;
      }
    }
  }
  //cout<<sum<<endl;
  /*
  rep(i,H)
  {
    if(i!=0) cout<<" ";
    cout<<yoko.at(i);
  }
  cout<<endl;
  rep(i,W)
  {
    if(i!=0) cout<<" ";
    cout<<tate.at(i);
  }
  cout<<endl;
  */
  
  
  ll ans=0;
  rep(i,1<<H)
  {
    rep(j,1<<W)
    {
      bitset<6> i2(i);
      bitset<6> j2(j);
      ll sum2=sum;
      vector<int> yoko2(0);
      vector<int> tate2(0);
      rep(k,H)
      {
        if(i2.test(k)) {yoko2.push_back(k);}
       
      }
      rep(k,W)
      {
        if(j2.test(k)) {tate2.push_back(k);}
        
      }
      /*
      rep(i,yoko2.size())
      {
        if(i!=0) {cout<<" ";}
        cout<<yoko2.at(i);
      }
      cout<<";"<<endl;
      rep(i,tate2.size())
      {
        if(i!=0) {cout<<" ";}
        cout<<tate2.at(i);
      }
      cout<<";"<<endl;
      */
      for(auto hoge:yoko2)
      {
        sum2-=yoko.at(hoge);
      }
      for(auto hoge:tate2)
      {
        sum2-=tate.at(hoge);
      }
      
      for(auto k:yoko2)
      {
        for(auto l:tate2)
        {
          if(grid.at(k).at(l)=='#')
          {
            sum2++;
          }
        }
      }
      
      if(sum2==K) {ans++;}
    }
  }  
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(auto i = (a); i != (b); ++i)
#define REP(i,n) rep(i,0,n)
#define all(v) (v).begin(), (v).end()

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

ll gcd(ll a, ll b) {while (b) a %= b,swap(a,b);return a;}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll N, M;
	cin >> N >> M;
	string S, T;
	cin >> S >> T;

	ll g = gcd(N, M);

	for (ll i = 0; i < N; i += N / g) {
		ll j = i * M / N;
		if (S[i] != T[j]) {
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld\n", N/g*M);

	/* for (ll i = 0; i < N; i++) cerr << i << " -> " << i * M / g << endl;
	for (ll i = 0; i < M; i++) cerr << i << " -> " << i * N / g << endl;
	*/

	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(){
	int i;
	char c[1201];
	gets(c);
	for (i=0;i<1201;i++){
		if (c[i]>='a'&&c[i]<='z')
			c[i]=c[i]-32;
		else if (c[i]>='A'&&c[i]<='Z')
			c[i]=c[i]+32;
	}
	printf("%s\n",c);
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
typedef vector<int64_t> vi;

int64_t gcd(int64_t a, int64_t b){
    if (b > a) return gcd(b, a);

    if(a % b == 0){
        return b;
    } else {
        return gcd(b, a % b);
    }
}

int main(){
  int N; vi A(100010);
  cin >> N;
  for(int i=0; i<N; i++) cin >> A[i];

  int64_t ans = gcd(A[0], A[1]);
  for(int i=0; i<N; i++) ans = gcd(ans, A[i]);

  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
    private static int solve(Scanner scanner) {
        String[] line = scanner.nextLine().split(" ");
        int X = Integer.parseInt(line[0]);
        int t = Integer.parseInt(line[1]);
        int ret = X - t;

        return ret > 0 ? ret : 0;
    }

    public static void main(String[] args) {
//        tests();

        Scanner scanner = new Scanner(System.in);
        System.out.println(solve(scanner));
    }

    private static String ex1 = "100 17";
    private static String ex2 = "48 58";
    private static String ex3 = "1000000000 1000000000";

    private static void tests() {
        System.out.println(solve(new Scanner(testCaseToInputStream(ex1))));
        System.out.println(solve(new Scanner(testCaseToInputStream(ex2))));
        System.out.println(solve(new Scanner(testCaseToInputStream(ex3))));
    }

    private static ByteArrayInputStream testCaseToInputStream(String ex) {
        try {
            return new ByteArrayInputStream(ex.getBytes("utf-8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            throw new RuntimeException();
        }
    }
}

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

using namespace std;

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

    int n;
    cin>>n;

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

    int m;
    cin>>m;

    vector<int> B(m);
    for(int i=0;i<m;i++) cin>>B[i];

    int i,j;
    for(i=0,j=0;i<n&&j<m;i++)
    {
        j+=A[i]==B[j];
    }

    cout<<(j==m)<<endl;

    return 0;
}



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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int N, M; cin >> N >> M;
  vector<map<int, int>> g(N);
  rep(i, M) {
    int a, b; cin >> a >> b;
    g[a-1][b-1] = g[b-1][a-1] = 1;
  }
  vector<int> ns(N); iota(ns.begin(), ns.end(), 0);
  int count = 0;
  do {
    if (ns[0] != 0) continue;
    bool ok = 1;
    rep(i, N - 1) {
      if (!g[ns[i]][ns[i + 1]]) {
        ok = 0;
      }
    }
    count += ok;
  } while (next_permutation(ns.begin(), ns.end()));
  cout << count << "\n";
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,29)-1;


int main() {
  ll K, A, B; cin >> K >> A >> B;
  ll result = 0;
  if (B-A<=2) result = K+1;
  else {
    if (A>=K) result = K+1;
    else {
      ll count = K-(A-1);
      result = A + (B-A)*(count/2)+(count%2);
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
n,t = map(int,input().split())
c = []
for _ in range(n):
    c1,t1 = map(int,input().split())
    if t1 <= t:
        c.append(c1)
if len(c) == 0:
    print("TLE")
else:
    c.sort(key=int)
    print(c[0])

Measured memory_bytes: 9120
#include<iostream>
#include<math.h>
#include<cstdio>
using namespace std;
const double PI=atan(1.0)*4;
struct Point
{
    double x,y;
    Point (){}
    Point (double x,double y):x(x),y(y){}
};
void Koch(int n,Point a,Point b)
{
    if(n==0)return ;
    Point s,u,t;
    s.x=(2*a.x+b.x)/3;
    s.y=(2*a.y+b.y)/3;
    t.x=(a.x+2*b.x)/3;
    t.y=(a.y+2*b.y)/3;
    double th=PI/3;
    u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
    u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
    Koch(n-1,a,s);
    printf("%.8f %.8f\n",s.x,s.y);
    Koch(n-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    Koch(n-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    Koch(n-1,t,b);
}
int main()
{
    int n;
    cin>>n;
    Point a(0,0),b(100,0);
    printf("%.8f %.8f\n",a.x,a.y);
    Koch(n,a,b);
    printf("%.8f %.8f\n",b.x,b.y);

    return 0;
}



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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

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

using ll = long long;

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

int dp[1001][1 << 12];

int main() {
    int n, m, a[1000], b, c[1000] = {}, t;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b;
        while (b--) {
            cin >> t;
            c[i] += (1 << (t - 1));
        }
    }
    fill(dp[0], dp[m + 1], INF);
    dp[0][0] = 0;
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < (1 << n); ++j) {
            if (dp[i][j] == INF)
                continue;
            chmin(dp[i + 1][j], dp[i][j]);
            chmin(dp[i + 1][j | c[i]], dp[i][j] + a[i]);
        }
    }
    cout << (dp[m][(1 << n) - 1] == INF ? -1 : dp[m][(1 << n) - 1]) << endl;

    return 0;
}

Measured memory_bytes: 19564
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d>0?i<n:i>n;i+=d)
#define foreach(a,A) for(auto &a:A)
#define endl "\n"
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

void solve(){
    ll n; cin >> n;
    if(n == 1){
        cout << 'a' << endl;
        return;
    }

    vector<string> res{"a"};
    rep(_, n - 1){
        vector<string> next;
        foreach(T, res){
            char c = *max_element(T.begin(), T.end());
            for(char i = 'a'; i <= c + 1; i++){
                next.push_back(T + i);
            }
        }
        swap(res, next);
    }

    sort(res.begin(), res.end());
    foreach(S, res){
        cout << S << endl;
    }
}

Measured memory_bytes: 10956
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	static ArrayList<Integer> G = new ArrayList<>();
	static int cnt;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int num[] = new int[n];
		for(int i=0; i<n; i++) {
			num[i] = sc.nextInt();
		}
		shellSort(num,n);
		System.out.println(G.size());
		for (int i = 0; i < G.size(); i++) {
			if (i == G.size() - 1) {
				System.out.print(G.get(i));
			} else {
				System.out.print(G.get(i) + " ");
			}
		}

		System.out.println();

		System.out.println(cnt);

		for (int i = 0; i < n; i++) {
			System.out.println(num[i]);
		}


	}

        static void shellSort(int[] num, int n) {
		for (int h = 1; ;) {
			if (h > n) break;
			G.add(0, h);
			h = 3 * h + 1;
		}

		for (int i = 0; i < G.size(); i++) {
			insertionSort(num, n, G.get(i));
		}
	}

	static void insertionSort(int[] num, int n, int g) {
		for (int i = g; i < n; i++) {
			int key = num[i];
			int j = i - g;
			while (j >= 0 && num[j] > key) {
				num[j + g] = num[j];
				j -= g;
				cnt++;
			}
			num[j + g] = key;
		}
	}

}




Measured memory_bytes: 298448
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
using namespace std;
int main(void){
    int n, x[200020], y[200020];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        y[i] = x[i];
    }
    sort(x, x + n);
    for (int i = 0; i < n; i++) {
        if (y[i] > x[n / 2 - 1]) cout << x[n / 2 - 1] << endl;
        else cout << x[n / 2] << endl;
    }
    return 0;
}


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

int main() {
  int n,m;
  cin >> n;
  vector<string> vn(n);
  rep(i,n){
    cin >> vn[i];
  }
  cin >> m;
  vector<string> vm(m);
  rep(i,m){
    cin >> vm[i];
  }
  
  int ans=0;
  rep(i,n){
    int count=0;
    rep(j,n){
      if(vn[i]==vn[j]){
        count++;
      }
    }
    rep(j,m){
      if(vn[i]==vm[j]){
        count--;
      }
    }
    if(count>ans){
      ans=count;
    }
  }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int N, max = 0, max_i = 0, sum_l = 0;
    cin >> N;
    int L[N];
    for (int i = 0; i < N; i++) {
        cin >> L[i];
        if (L[i] > max) {
            max = L[i];
            max_i = i;
        }
    }
    for (int i = 0; i < N; i++) {
        if (i == max_i) {
            continue;
        }
        sum_l += L[i];
    }
    if (max < sum_l) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
mod = 1000000007
l = input().split()
m = int(l[0])
n = int(l[1])


def power(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x % mod
    elif y % 2 == 0:
        return power(x, y/2)**2 % mod
    else:
        return power(x, int(y/2))**2 * x % mod


ans = power(m, n)
print(ans)


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

int main() {

  string s;
  cin >> s;
  int p_a, p_z;
  int N=s.size();
  for(int i = 0; i < N; i++) {
    if(s[i] == 'A') {
      p_a = i;
      break;
    }
  }
  for(int i = N -1; i >= 0; i--) {
    if(s[i] == 'Z'){
      p_z =i;
      break;
    }
  }
  cout <<p_z -p_a + 1;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 100000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double PI = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;


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

	ll a, b, c, n = 0;
	string s;
	cin >> a >> s >> b;
	if (s == "+")
		cout << a + b << endl;
	else
		cout << a - b << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n = int(input())
s = input()

ok = 0
ng = n//2+1

while ng-ok>1:
    mid = (ok+ng)//2

    d = {}
    isOk = False
    for l in range(n-mid+1):
        ss = s[l:l+mid]
        if ss not in d:
            d[ss] = l
        else:
            l2 = d[ss]
            if l2+mid<=l:
                isOk = True
                break

    if isOk:
        ok = mid
    else:
        ng = mid

print(ok)


Measured memory_bytes: 9456
#include <iostream>
int A = 0, B = 0;

int main(void){
    std::cin >> A >> B;
    A = (A == 1) ? 14 : A;
    B = (B == 1) ? 14 : B;

    if(A == B){
        std::cout << "Draw" << std::endl;
    }else if(A > B){
        std::cout << "Alice" << std::endl;
    }else{
        std::cout << "Bob" << std::endl;
    }
}

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

int main(void){
    int n, a[100100], cnt=0;
    cin >> n;
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    for(int i=0;i<n;++i){
        if(i<n-1){
            if(a[i]==(i+1)){
                swap(a[i], a[i+1]);
                ++cnt;
            }
        }else{
            if(a[i]==(i+1)){
                swap(a[i],a[i-1]);
                ++cnt;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
import sys

s = sys.stdin.readline().strip()
n = len(s)
def check(s):

    left = 0
    right = len(s) - 1 
    while left < right:
        if s[left] != s[right]:
            return False
        left += 1
        right -= 1
    return True
if check(s) and check(s[:(n-1)//2]) and check(s[(n+3)//2-1:]):
    print("Yes")
else:
    print("No")

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

using namespace std;

int checkeven(string a) {
	for (int i = 0; i < a.size()/2; i++) {
		if (a[i] != a[a.size()/2+i]) { return 1; }
	}
	return 0;
}

int main() {

	string s;
	cin >> s;

	while (true) {
		s.pop_back();
		s.pop_back();
		if (checkeven(s) == 0) {
			cout << s.size() << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
	int ans=0;
	int len;
	
	char str[101];
	while(~scanf("%s",str)){
		len=strlen(str);
		if(len==1){
			ans++;
		}else {
			int i=0;
			while(str[i]==str[len-i-1]){
				i++;
				if(i==len/2){
					ans++;
					break;
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 536
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    for(int i=0;i<=10000;i++){
    int x,y;
    cin>>x>>y;
    if(x==0&&y==0){
        break;
    }else if(x>y){
        cout<<y<<" "<<x<<endl;
        
    }else{
        cout<<x<<" "<<y<<endl;
    }
    }
}



Measured memory_bytes: 2992
#include <stdio.h>

int main(){
    int h,a;
    
    scanf("%d %d",&h,&a);
    
    if(h%a==0){
        printf("%d\n",h/a);
    }
    
    else{
        printf("%d\n",(h/a)+1);
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> void re(T& x) { cin >> x; }
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  




void solve(){
	int n , k; 
	re(n,k);
	int cnt = 0 ;
	while(n){
		cnt++	;
		n/=k;
	}
	cout << cnt << endl; 
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3636
// Try AtCoder
// author: Leonardone @ NEETSDKASU
package main

import (
	"fmt"
	"strings"
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	fmt.Println(strings.Repeat("#", w+2))
	for i := 0; i < h; i++ {
		var a string
		fmt.Scan(&a)
		fmt.Println("#" + a + "#")
	}
	fmt.Println(strings.Repeat("#", w+2))
}


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

void flag_set(int n, vector<int> &ope){
    for(int i = 0; i < 3; i++){
        if(n & (1 << i)){
            ope.push_back(1);
        }else{
            ope.push_back(-1);
        }
    }
}

int main(){

    int N, M;
    cin >> N >> M;
    vector<long long> x(N), y(N), z(N);
    for(int i = 0; i < N; i++) cin >> x[i] >> y[i] >> z[i];

    long long ans = 0;
    for(int i = 0; i < 8; i++){
        vector<long long> cake(N);
        vector<int> ope;
        flag_set(i, ope);
        for(int i = 0; i < N; i++) cake[i] = (ope[0] * x[i]) + (ope[1] * y[i]) + (ope[2] * z[i]);
        sort(cake.rbegin(), cake.rend());
        long long sum = 0;
        for(int i = 0; i < M; i++) sum += cake[i];
        ans = max(ans, sum);
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int MAX = 2e5 + 20;
int pic[MAX];
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n;i++)
        cin >> pic[i];
    long long ans = 0;
    int maxx = pic[1];
    for (int i = 2; i <= n;i++)
    {
        if (pic[i] > maxx)
            maxx = pic[i];
        else
            ans += maxx - pic[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3976
#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 h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	ll v1 = h1*60 + m1;
	ll v2 = h2*60 + m2;
	cout<<v2 - v1 - k<<endl;
	return 0;
}




Measured memory_bytes: 3636
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i, s, n) for (int i = s; i < n; i++)
#define repe(i, s, n) for(int i = s;i<=n;i++)

int main() {
	ll n; cin >> n;
	string s;
	ll c[5] = {};
	rep(i, 0, n) {
		cin >> s;
		switch (s[0]) {
		case 'M':c[0]++; break;
		case 'A':c[1]++; break;
		case 'R':c[2]++; break;
		case 'C':c[3]++; break;
		case 'H':c[4]++; break;
		default:break;
		}
	}
	ll ans = 0;
	rep(i, 0, 5)rep(j, i + 1, 5) rep(k, j + 1, 5) 	ans += c[i] * c[j] * c[k];
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256