akhauriyash/Code-Regression huggingface dataset:
use std::str::FromStr;
use std::fmt::Debug;
use std::collections::HashMap;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn get_max_key_value(map: &HashMap<u32, u32>) -> (u32, u32){
    let mut max = (0, 0);
    for (key, value) in map{
        if max.1 < *value{
            max = (*key, *value);
        }
    }
    max
}

fn main(){
    let n: u32 = read_as_vec()[0];
    let series: Vec<u32> = read_as_vec();

    let mut even = HashMap::new();
    let mut odd  = HashMap::new();

    for i in 0..series.len(){
        if i%2 == 0{
            *even.entry(series[i]).or_insert(0) += 1;
        }else{
            *odd.entry(series[i]).or_insert(0) += 1;            
        }
    }
    /*
    for elem in series.iter().step_by(2){
        *even.entry(*elem).or_insert(0) += 1;
    }

    for elem in series.iter().skip(1).step_by(2){
        *odd.entry(*elem).or_insert(0) += 1;
    }
    */
    let even_max = get_max_key_value(&even);
    let odd_max = get_max_key_value(&odd);
    if even_max.0 != odd_max.0{
        println!("{}", series.len() as u32 - even_max.1 - odd_max.1);
    }else{
        even.remove(&even_max.0);
        odd.remove(&odd_max.0);

        let even_2nd_max = get_max_key_value(&even);
        let odd_2nd_max = get_max_key_value(&odd);
        if even_2nd_max.1 > odd_2nd_max.1{
            println!("{}", series.len() as u32 - odd_max.1 - even_2nd_max.1);
        }else{
            println!("{}", series.len() as u32 - even_max.1 - odd_2nd_max.1);
        }
    }
}


Measured memory_bytes: 10492
#pragma optimize("", off)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:36777216")
#include <bits/stdc++.h>

#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define all(v) v.begin(),v.end()
#define pb push_back
#define sz(i) (int)(i.size())
#define setto(n) cout << fixed << setprecision(n)
#define fi first
#define se second
#define ld long double
#define inf LONG_MAX
#define pii pair<int, int>
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
const int mod = 1000000007;
using namespace std;

#define meta __FUNCTION__<<" : "<<__LINE__<<" "
#define tr1(x) cerr<<meta<<"| "<<#x<<" : "<<x<<" | "<<endl
#define tr2(x,y) cerr<<meta<<"| "<<#x<<" : "<<x<<" | "<<" "<<#y<<" : "<<y<<" | "<<endl
#define tr3(x,y,z) cerr<<meta<<"| "<<#x<<" : "<<x<<" | "<<" "<<#y<<" : "<<y<<" | "<<" "<<#z<<" : "<<z<<" | "<<endl
#define tr4(w,x,y,z) cerr<<meta<<"| "<<#w<<" : "<<w<<" | "<<" "<<#x<<" : " <<x<<" | "<<" "<<#y<<" : "<<y<<" | "<<" "<<#z<<" : "<<z<<" | "<<endl
#define tr5(v,w,x,y,z) cerr<<meta<<"| "<<#v<<" : "<<v<<" | "<<" "<<#w<<" : "<<w<<" | "<<" "<<#x<<" : "<<x<<" | "<<" "<<#y<<" : "<<y<<" | "<<" "<<#z<<" : "<<z<<" | "<<endl
#define tr6(u,v,w,x,y,z) cerr<<meta<<#u<<" : "<<u<<" | "<<" "<<#v<<" : "<<v<<" | "<<" "<<#w<<" : "<<w<<" | "<<" "<<#x<<" : "<<x<<" | "<<" "<<#y<<" : "<<y<<" | "<<" "<<#z<<" : "<<z<<" | "<<endl

template<class T> void smin(T& a, T val) {if (a > val) a = val;}
template<class T> void smax(T& a, T val) {if (a < val) a = val;}
template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
//Check N size twiceeeeeeeeeeeeeeeeee, and verify it

const int N = 2*1e5 + 10;

int n, T;
int main(){_
	cin>>n>>T;

	int ma = 1e9;
	for (int i = 0; i < n; ++i)
	{
		int x, y;
		cin>>x>>y;
		if(y <= T){
			smin(ma, x);
		}
	}

	if(ma == 1e9){
		cout<<"TLE";
	}
	else{
		cout<<ma;
	}

	return 0;
}

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

int main(void) {

  long n,m;
  scanf("%ld %ld", &n, &m);
  long x[n],y[m];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &x[i]);
  }
  for (long i = 0; i < m; i++) {
    scanf("%ld", &y[i]);
  }
  long mod = pow(10,9)+7;
  long x_len[n-1],y_len[m-1];
  for (long i = 0; i < n-1; i++) {
    x_len[i] = x[i+1]-x[i];
    x_len[i] %= mod;
  }
  for (long i = 0; i < m-1; i++) {
    y_len[i] = y[i+1]-y[i];
    y_len[i] %= mod;
  }
  long x_k[n-1],y_k[m-1];
  x_k[0] = n-1;
  for (long i = 1; i < n/2; i++) {
    x_k[i] = x_k[i-1]+(n-1)-i*2;
    x_k[i] %= mod;
  }
  for (long i = n/2; i < n-1; i++) {
    x_k[i] = x_k[n-2-i];
  }
  y_k[0] = m-1;
  for (long i = 1; i < m/2; i++) {
    y_k[i] = y_k[i-1]+(m-1)-i*2;
    y_k[i] %= mod;
  }
  for (long i = m/2; i < m-1; i++) {
    y_k[i] = y_k[m-2-i];
  }
  long x_sum = 0, y_sum = 0;
  for (long i = 0; i < n-1; i++) {
    x_sum += x_len[i]*x_k[i];
    x_sum %= mod;
  }
  for (long i = 0; i < m-1; i++) {
    y_sum += y_len[i]*y_k[i];
    y_sum %= mod;
  }
  long ans = x_sum*y_sum;
  ans %= mod;
  printf("%ld\n", ans);

  return 0;
}

Measured memory_bytes: 6420
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <vector>

using namespace std;

int h, w, m;
unordered_map<int, unordered_set<int>> row, col;

int main() {
    cin >> h >> w >> m;
    for (int k = 0; k < m; k++) {
        int i, j; cin >> i >> j;
        row[i].insert(j);
        col[j].insert(i);
    }
    unordered_set<int> rows_needed, cols_needed;
    size_t mx1 = 0;
    for (auto it : row) {
        mx1 = max(mx1, it.second.size());
    }
    for (auto it : row) {
        if (it.second.size() == mx1) {
            rows_needed.insert(it.first);
        }
    }
    size_t mx2 = 0;
    for (auto it : col) {
        mx2 = max(mx2, it.second.size());
    }
    for (auto it : col) {
        if (it.second.size() == mx2) {
            cols_needed.insert(it.first);
        }
    }

    for (auto it : rows_needed) {
        for (auto to_check : cols_needed) {
            if (row[it].find(to_check) == row[it].end()) {
                cout << mx1 + mx2 << endl;
                return 0;
            }
        }
    }

    cout << mx1 + mx2 - 1 << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, k, r, s, p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  deque<char> S;
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    int T = 0;
    if (t[i] == 'r')
      S.push_back('p'), T = p;
    else if (t[i] == 's')
      S.push_back('r'), T = r;
    else if (t[i] == 'p')
      S.push_back('s'), T = s;

    if (i - k >= 0 && S[i - k] == S.back())
      S.pop_back(), S.push_back(' '), T = 0;
    ans += T;
  }

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


Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	cout << a[0] << b[0] << c[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  string s;
  cin >> n >> s;

  array<vector<int>, 10> pos;
  for (int i = 0; i < s.size(); i++) {
    pos[s[i] - '0'].push_back(i);
  }

  long long ans = 0;
  for (int i = 0; i <= 999; i++) {
    stringstream ss;
    ss << setfill('0') << right << setw(3) << i;

    // num_sを作れるかどうか
    auto num_s = ss.str();
    int cur = -1;
    bool found = true;
    for (int i = 0; i < num_s.size(); i++) {
      auto &ch_pos = pos[num_s[i] - '0'];
      auto it = upper_bound(ch_pos.begin(), ch_pos.end(), cur);
      if (it == ch_pos.end()) {
        found = false;
        break;
      }

      cur = *it;
    }

    if (found) {
      ans++;
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
#define eb emplace_back
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

ll n, m;
ll a[100'005];
ll memo[100005];

ll dfs(int i){
    if (i == 0) return 1;
    if (i < 0) return 0;
    if (memo[i] != -1) return memo[i];
    if (i == 1){
        if (a[i] == 1) return memo[i] = 0;
        else return memo[i] = 1;
    }

    ll res = 0;
    if (a[i] == 1 || (a[i-1] == 1 && a[i-2] == 1)){
        return memo[i] = 0;
    }else{
        if (a[i-2] == 1){
            res = dfs(i - 1) % MOD;
        }else if (a[i-1] == 1){
            res = dfs(i - 2) % MOD;
        }else{
            res = (dfs(i - 1) + dfs(i - 2)) % MOD;
        }
    }
    return memo[i] = res;
}

int main()
{
    ciosup;
    cin >> n >> m;
    REP(i,m){
        int b;
        cin >> b;
        a[b] = 1;
    }
    REP(i,n+1) memo[i] = -1;
    dfs(n);
    cout << memo[n] << endl;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 2005;

vector<int> G[MAX_N];
int K;

void dfs1(int u,int p,int k,int& res)
{
    if(k > K/2){
        res++;
    }
    rep(i,G[u].size()){
        if(G[u][i] != p){
            dfs1(G[u][i],u,k+1,res);
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n >> K;
    vector<P> ed(n-1);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        ed[i] = P(a-1,b-1);
        G[a-1].pb(b-1),G[b-1].pb(a-1);
    }
    int mn = INF;
    if(K % 2 == 0){
        rep(i,n){
            int res = 0;
            dfs1(i,-1,0,res);
            mn = min(res,mn);
        }
    }else{
        rep(i,n-1){
            int res = 0;
            dfs1(ed[i].fi,ed[i].se,0,res);
            dfs1(ed[i].se,ed[i].fi,0,res);
            mn = min(mn,res);
        }
    }
    cout << mn << endl;
    return 0;
}


Measured memory_bytes: 512
import math
K = int(input())
ans = 0
for i in range(1, K + 1):
    ans += i
    for j in range(i + 1, K + 1):
        ans += math.gcd(i, j) * 6
        for k in range(j + 1, K + 1):
            ans += math.gcd(i, math.gcd(j, k)) * 6
print(ans)

Measured memory_bytes: 9192
var
a:array[0..2,0..105] of longint;
n,i:integer;
begin
readln(n);
a[1,0]:=0;
a[2,0]:=0;
for i:=1 to n do read(a[1,i]);
readln;
for i:=1 to n do read(a[2,i]);
for i:=1 to n do a[1,i]:=a[1,i]+a[1,i-1];
for i:=1 to n do
  if a[1,i]>a[2,i-1] then a[2,i]:=a[2,i]+a[1,i]
                     else a[2,i]:=a[2,i]+a[2,i-1];
writeln(a[2,n]);
end.

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

int64_t time(int64_t x, map<int64_t,int64_t> &mp){
	if( !mp.count(x) ) mp[x] = 2*time(x/2, mp)+1;
	return mp.at(x);
}

int main() {
	int64_t h;
	cin >> h;
	map<int64_t,int64_t> t;
	t[1]=1;
	cout << time( h,t ) << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String A = sc.next();

		if (Character.isUpperCase(A.charAt( 0 ))) {
			System.out.println('A');
		} else {
			System.out.println('a');
		}


	}

}


Measured memory_bytes: 26964
#include<bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int L[510],f[510][510][510];
int fact[510],ifact[510],pw[510][510];
int C(int n,int m){return 1ll*fact[n]*ifact[m]%mod*ifact[n-m]%mod;}
int Fill(int n,int m){if(m<0)return!n;if(!n||!m)return!n&&!m;if(n<m)return 0;return C(n-1,m-1);}
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int n=gi(),X=gi();
	for(int i=1;i<=n;++i)++L[gi()];
	fact[0]=1;for(int i=1;i<=X;++i)fact[i]=1ll*fact[i-1]*i%mod;
	ifact[X]=pow(fact[X],mod-2);for(int i=X;i;--i)ifact[i-1]=1ll*ifact[i]*i%mod;
	f[X][0][0]=1;
	for(int i=0;i<=X;++i){
		pw[i][0]=1;
		for(int j=1;j<=n;++j)pw[i][j]=1ll*pw[i][j-1]*i%mod;
	}
	for(int i=X;i;--i)
		for(int j=0;j<=X;++j)
			for(int k=0;k<=X;++k)
				if(f[i][j][k])
					for(int c=0,nj=j,nk=k;nj<=X&&nk<=X;++c,nj+=i,nk++)
						inc(f[i-1][nj][nk],1ll*f[i][j][k]*ifact[c]%mod*pw[nj-nk*(i-1)][L[i]]%mod);
	int ans=0;
	for(int j=X,M=1;~j;--j,M=mod-M)
		for(int k=X;~k;--k)
			if(f[0][j][k])
				for(int o=0;o<=X-j;++o)
					inc(ans,1ll*f[0][j][k]*M%mod*Fill(o,k-1)%mod*(X-j-o+1)%mod*fact[k]%mod);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 510208
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()

int SieveOfEratosthenes(int n,int k)
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        // If prime[p] is not changed, then it is a prime
        if (prime[p] == true)
        {
            // Update all multiples of p greater than or
            // equal to the square of it
            // numbers which are multiple of p and are
            // less than p^2 are already been marked.
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for(int i=2;i<(N);i++)
    {
        if(prime[i] && i>=k)
        {
            cout<<i<<endl;
            return 0;
        }
    }
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   SieveOfEratosthenes(N,n);
}


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

MaxCount = 0
L = []
for i in range(1, N + 1):
    v = i
    count = 0
    while True:
        if (i % 2 == 1):
            break
        elif(i % 2 == 0):
            i = i // 2
            count += 1
    MaxCount = max(MaxCount, count)
    L.append((v, count))

for v in L:
    if (v[1] == MaxCount):
        print(v[0])
        break


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#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 REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

bool check(int n, int k, int e) {
  if (n < k) {
    return false;
  }
  int ma, mi;
  if (n == k) {
    ma = k;
    mi = k;
  } else {
    ma = k - 1;
    mi = max(0, 2 * k - n);
  }
  return mi <= e && e <= ma;
}

int main(void){
  int n;
  cin >> n;
  VI a(n);
  int ma = 0, mi = 1e8;
  REP(i, 0, n) {
    cin >> a[i];
    ma = max(ma, a[i]);
    mi = min(mi, a[i]);
  }
  bool ok;
  if (ma - mi >= 2) {
    ok = false;
  }
  else if (ma == mi) {
    ok = check(n, ma, 0) || check(n, ma + 1, n);
  } else {
    int e = 0;
    REP(i, 0, n) {
      if (a[i] != ma) {
	e += 1;
      }
    }
    ok = check(n, ma, e);
  }
  cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
using namespace std;
bool d[33554432];
char k[128];


int c(char str[12]){
	int ans = str[0];
	for(int i = 1;i < strlen(str);i++){
		ans <<= 2;
		ans += k[str[i]];
	}
	return ans;
}

int main(){
	k['A'] = 0;k['C'] = 1;k['G'] = 2;k['T'] = 3;
	int n;scanf("%d", &n);
	char s[7], str[12];
	for(int i = 0;i < n;i++){
		scanf("%s %s", s, str);
		if(s[0] == 'i')d[c(str)] = true;
		else puts(d[c(str)] ? "yes" : "no");
	}
	return 0;
}

Measured memory_bytes: 4036
import java.util.*

fun main(args: Array<String>) {
//    val reader = System.`in`.bufferedReader()
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
//    val input = reader.readLine()
//    val stringTokenizer = StringTokenizer(input)
    val array = IntArray(n) {
//        Integer.parseInt(stringTokenizer.nextToken())
        sc.nextInt()
    }
    val strBuilder = StringBuilder(array.size * 2)
    array.cSort().forEach {
        strBuilder.append(it).append(" ")
    }
    println(strBuilder.deleteCharAt(strBuilder.lastIndex))
}

fun IntArray.cSort(): IntArray {
    val countArray = IntArray((this.max() ?: 0) + 1)
    countArray.fill(0)
    for (i in this) {
        countArray[i]++
    }
    for (i in 1 until countArray.size) {
        countArray[i] += countArray[i - 1]
    }
    val ansArray = IntArray(this.size)
    for (i in ansArray.size-1 downTo 0) {
        ansArray[countArray[this[i]] - 1] = this[i]
        countArray[this[i]]--
    }
    return ansArray
}


Measured memory_bytes: 511740
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

int main(){
    ll N, H; cin >> N >> H;
    vector<ll> A, B;
    A = B = vector<ll>(N,0);
    rep(i,N){
        cin >> A[i] >> B[i];
    }

    // aの最大値を算出
    ll max_a = 0;
    rep(i,N){
        max_a = max(max_a, A[i]);
    }
    
    // bの降順でソート
    sort(B.begin(), B.end(), greater<ll>());
    
    ll ans = INF;
    rep(i,N){
        H -= B[i];
        ll a_count = 0;
        if (H > 0){
            a_count = (H+(max_a-1))/ max_a;
        }
        ans = min(ans, a_count+i+1);
    }

    cout << ans << endl;

}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

using Int = long long;
using Event = pair<Int, pair<Int, Int>>;

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

    vector<Event> E;
    for (int i = 0; i < N; i++) {
        Int s, t, x;
        cin >> s >> t >> x;

        E.push_back({s - x, {-1, x}});
        E.push_back({t - x, {0, x}});
    }
    for (int i = 0; i < Q; i++) {
        Int d;
        cin >> d;

        E.push_back({d, {1, i}});
    }
    sort(E.begin(), E.end());

    vector<Int> res(Q);
    multiset<Int> S;
    for (auto e : E) {
        Int x = e.first;
        Int t = e.second.first;
        Int v = e.second.second;

        switch (t) {
        case -1:
            S.insert(v);
            break;
        case 0:
            S.erase(S.lower_bound(v));
            break;
        case 1:
            res[v] = (S.empty() ? -1 : *(S.begin()));
            break;

        default:
            break;
        }
    }

    for (auto r : res) {
        cout << r << '\n';
    }
}


Measured memory_bytes: 27620
#include <algorithm>　　　 //STL 通用算法
#include <bitset>　　　　　//STL 位集容器
#include <cctype>         //字符处理
#include <cerrno> 　　　　 //定义错误码
#include <cfloat>　　　　 //浮点数处理
#include <ciso646>         //对应各种运算符的宏
#include <climits> 　　　　//定义各种数据类型最值的常量
#include <clocale> 　　　　//定义本地化函数
#include <cmath> 　　　　　//定义数学函数
#include <complex>　　　　 //复数类
#include <csignal>         //信号机制支持
#include <csetjmp>         //异常处理支持
#include <cstdarg>         //不定参数列表支持
#include <cstddef>         //常用常量
#include <cstdio> 　　　　 //定义输入／输出函数
#include <cstdlib> 　　　　//定义杂项函数及内存分配函数
#include <cstring> 　　　　//字符串处理
#include <ctime> 　　　　　//定义关于时间的函数
#include <cwchar> 　　　　 //宽字符处理及输入／输出
#include <cwctype> 　　　　//宽字符分类
#include <deque>　　　　　 //STL 双端队列容器
#include <exception>　　　 //异常处理类
#include <fstream> 　　　 //文件输入／输出
#include <functional>　　　//STL 定义运算函数（代替运算符）
#include <limits> 　　　　 //定义各种数据类型最值常量
#include <list>　　　　　　//STL 线性列表容器
#include <locale>         //本地化特定信息
#include <map>　　　　　　 //STL 映射容器
#include <memory>         //STL通过分配器进行的内存分配
#include<new>            //动态内存分配
#include <numeric>         //STL常用的数字操作
#include <iomanip> 　　　 //参数化输入／输出
#include <ios>　　　　　　 //基本输入／输出支持
#include <iosfwd>　　　　　//输入／输出系统使用的前置声明
#include <iostream> 　　　//数据流输入／输出
#include <istream>　　　　 //基本输入流
#include <iterator>        //STL迭代器
#include <ostream>　　　　 //基本输出流
#include <queue>　　　　　 //STL 队列容器
#include <set>　　　　　　 //STL 集合容器
#include <sstream>　　　　 //基于字符串的流
#include <stack>　　　　　 //STL 堆栈容器
#include <stdexcept>　　　 //标准异常类
#include <streambuf>　　　 //底层输入／输出支持
#include <string>　　　　　//字符串类
#include <typeinfo>        //运行期间类型信息
#include <utility>　　　　 //STL 通用模板类
#include <valarray>        //对包含值的数组的操作
#include <vector>　　　　　//STL 动态数组容器
using namespace std;
int main(){
	string str;
	cin>>str;
	int n=str.length();
	int num=0,ans=0;
	for (int i=0; i<=n; i++){
		if (str[i]=='R') num++;
			else{
				ans=max(ans,num);
				num=0;
			}
	}
	printf("%d\n",ans);
}

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

using namespace std;

int n,W;
long long int w[103];
long long int v[103];
long long f[103][100003];

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

    cin>>n>>W;
    for(int i = 1;i<= n; i++)
    {
        cin>>w[i]>>v[i];
    }
    f[0][0] = 0;
    for(int i = 1;i<= n ; i++)
    {
        for(int j = 1; j <=W ; j++)
        {
            if(j >= w[i]) f[i][j] = max(f[i - 1][j - w[i] ] + v[i], f[i-1][j] );
            else f[i][j] = f[i-1][j];
        }
    }
    cout<<f[n][W];
    return 0;
}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
using lint = long long;
using pi = pair<lint, lint>;
const int MAXN = 1000005;
const int MAXT = 2100000;

int query(int x, int y){
	cout << "? " << x << " " << y << endl;
	char c; cin >> c;
	return c == 'Y';
}

int main(){
	int a, b;
	cin >> a >> b;
	if(a <= b){
		puts("Impossible");
		return 0;
	}
	int cur = 0;
	int ret = 0;
	for(int i=0; i<a+b; i++){
		if(ret == 0){
			cur = i;
		}
		int q = query(i, cur);
		if(q == 0){
			if(ret == 0){
				continue;
			}
			ret--;
		}
		else ret++;
	}
	string dap;
	for(int i=0; i<a+b; i++){
		dap.push_back(query(cur, i) + '0');
	}
	cout << "! " << dap << endl;
}



Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

int main()
{
    int h,w;
    cin>>h>>w;
    char a[h+1][w+1];
    char b[h+1][w+1];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
            b[i][j]='.';
        }
    }
    int k=0;
    int aaa=0,bbb=0;
    for(int i=0;i<h+w+10;i++){
        if(aaa==h-1&&bbb==w-1){
            break;
        }

        if(a[aaa+1][bbb]=='#'){
            aaa++;
            b[aaa][bbb]='#';
            continue;
        }
        if(a[aaa][bbb+1]=='#'){
            bbb++;
            b[aaa][bbb]='#';
            continue;
        }
        break;
    }
    b[0][0]='#';

    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]!=b[i][j]){
                k++;
            }
        }
    }

    //cout<<k<<endl;

    if(k==0){
        cout<<"Possible"<<endl;
    }
    else{
        cout<<"Impossible"<<endl;
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    int n,k;
    cin >> n >> k;
    vector<int> c(n);
    rep(i, 0, n){
        cin>>c[i];
    }
    sort(c.begin(), c.end());
    int ans = 1000000001;
    rep(i, 0, n-k+1){
        ans = min(c[i+k-1]-c[i], ans);
    }
    
    cout << ans << endl;
    return 0;
}

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

int main(void){
	int l,m,n;

	while(cin>>l && l){
		int ans,sum = 0;
		bool flg = true;

		for(int i=0;i<12;i++){
			cin>>m>>n;
			sum += m - n;

			if(flg && sum >= l){
				flg = false;
				ans = i + 1;
			}
		}

		if(flg){
			cout<<"NA\n";
		}
		else{
			cout<<ans<<endl;
		}
	}

	return 0;
}

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

N=int(input())
import math
ij=[N,N]
n=math.floor(math.sqrt(N))

for itemp in range(n):
    i=itemp+1
    if N%i==0:
        if sum(ij)>i+N/i:
            ij=[i,N/i]
print(int(sum(ij)-2))

Measured memory_bytes: 40556
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
    }
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
            fn parse(s: &str) -> ($($t),*) {
                let mut tokens = s.split_whitespace();
                let t = ($($t::parse(tokens.next().unwrap())),*);
                t
            }
        }
    }
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

fn bound_check(x: i32, y: i32, width: i32, height: i32) -> bool {
    if x < 0 || y < 0 || x >= width || y >= height {
        return false;
    } else {
        return true;
    }
}

// ===

static DX: &'static [i32] = &[0, 1, 0, -1];
static DY: &'static [i32] = &[-1, 0, 1, 0];

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_B&lang=jp

// ナップザック問題　index以降のものを価値weight以下でとって最大の物を返す
fn search(
    ws: &Vec<i32>, vs: &Vec<i32>, dp: &mut Vec<Vec<i32>>,
    index: usize, weight: usize
) -> i32 {
    if index == ws.len() { return 0; }
    else if dp[index][weight] != -1 { return dp[index][weight]; }
    else if ws[index] > weight as i32 { return search(ws, vs, dp, index + 1, weight); }
    else {
        let a1 = search(ws, vs, dp, index + 1, weight);
        let a2 = search(ws, vs, dp, index + 1, weight - ws[index] as usize) + vs[index];
        let ret = max(a1, a2);
        dp[index][weight] = ret;
        return ret;
    }
}

fn main() {
    let (n, w): (usize, usize) = read();
    let mut vs: Vec<i32> = vec![0; n];
    let mut ws: Vec<i32> = vec![0; n];
    for i in 0..n { 
        let (v, w) = read();
        vs[i] = v; ws[i] = w;
    }

    let mut dp: Vec<Vec<i32>> = vec![vec![-1; 10010]; 110];

    println!("{}", search(&ws, &vs, &mut dp, 0, w));
}



Measured memory_bytes: 9020
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define head(xs) *(xs).begin()
#define last(xs) *(xs).rbegin()
#define append emplace_back
#define findge lower_bound
#define findgt upper_bound
const i64 MOD = 1000000007;
const f64 EPS = 1e-10;

i64 n, t;
i64 a[200000];

i32 main()
{
    cin >> n >> t;
    times(n, i) {
        cin >> a[i];
    }
    i64 c = a[0];
    i64 ans = 0;
    range(1, n, i) {
        ans += min(a[i] - c, t);
        c = a[i];
    }
    cout << ans + t << endl;
    return 0;
}

Measured memory_bytes: 1792
import collections
N = int(input())
A = list(map(int, input().split()))
wlists = collections.Counter(A)
sum_num = 0
for i in wlists:
  sum_num += wlists[i] * (wlists[i] - 1) // 2
for i in range(N):
  num = sum_num - wlists[A[i]] * (wlists[A[i]] - 1) // 2
  if wlists[A[i]] > 1:
    num += (wlists[A[i]] - 1) * (wlists[A[i]] - 2) // 2
  print(num)

Measured memory_bytes: 26780
local ior = io.input()
local h, w = ior:read("*n", "*n", "*l")

local function getindex(i_h, i_w)
  return i_w + (i_h - 1) * w
end

local function createMap()
  local str = ""
  local map = {}
  for i_h = 1, h do
    str = ior:read()
    for i_w = 1, w do
      map[getindex(i_h, i_w)] = (str:sub(i_w, i_w) == "#")
    end
  end
  return map
end

local function uf_initialize(n)
  local parent = {}
  for i = 1, n do parent[i] = i end
  return parent
end

local function uf_findroot(idx, parent)
  while parent[idx] ~= idx do
    idx = parent[idx]
  end
  return idx
end

local map = createMap()
local parent = uf_initialize(h * w)

local function walk(src, dst)
  if map[src] ~= map[dst] then
    local sr, dr = uf_findroot(src, parent), uf_findroot(dst, parent)
    parent[src], parent[dst] = sr, dr
    if sr ~= dr then
      parent[dst], parent[dr] = sr, sr
    end
  end
end

for idx = 1, h * w do
  if w < idx then walk(idx, idx - w) end
  if idx <= (h - 1) * w then walk(idx, idx + w) end
  if 1 < w then
    if idx % w ~= 0 then walk(idx, idx + 1) end
    if idx % w ~= 1 then walk(idx, idx - 1) end
  end
end
local groups = {}
for idx = 1, h * w do
  local r = uf_findroot(idx, parent)
  if not groups[r] then
    local tmp = {0, 0}
    groups[r] = tmp
  end
  if map[idx] then
    groups[r][1] = groups[r][1] + 1
  else
    groups[r][2] = groups[r][2] + 1
  end
end
local ret = 0
for k, v in pairs(groups) do
  ret = ret + v[1] * v[2]
end
print(ret)


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

int main() {
  while(1) {
    int n;
    cin>>n;
    if(n==0) break;
    int dp[301] = {1};
    for(int i=1;i*i<=n;i++) 
      for(int j=i*i;j<=n;j++) dp[j] += dp[j-i*i];
    cout << dp[n] <<endl;
  }
return 0;
}

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

num_set = []
seven_count = 0

while seven_count * 7 < 100:
    total = 7 * seven_count
    while total <= 100:
        num_set.append(total)
        total += 4
    seven_count += 1

num_set = set(num_set)

if N in num_set:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
N,x = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
for i in range(N-1):
    tmpsum = A[i]+A[i+1]
    if tmpsum > x:
        need = tmpsum - x
        sub = min(A[i+1], need)
        A[i+1] -= sub
        ans += sub

if A[0] > x:
        need = A[0] - x
        sub = min(A[0], need)
        A[0] -= sub
        ans += sub

print(ans)

Measured memory_bytes: 14052
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
	int A = stdIn.nextInt();
	int B = stdIn.nextInt();
	if(A>0&&A<10&&B>0&&B<10){
	    System.out.println(A*B);
	}else{
	    System.out.println(-1);
	}
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 1; i < N; i++) A[i] += A[i - 1];

  ll ans = 1e15;
  for (int i = 1, j = 0, k = 2; i < N - 1; i++) {
    while (i - j >= 2 &&
           abs(A[i] - A[j] - A[j]) > abs(A[i] - A[j + 1] - A[j + 1]))
      j++;
    while (k < N - 2 && abs(A[N - 1] - A[k] - A[k] + A[i]) >
                            abs(A[N - 1] - A[k + 1] - A[k + 1] + A[i]))
      k++;
    ll m = min(A[j], min(A[i] - A[j], min(A[N - 1] - A[k], A[k] - A[i])));
    ll M = max(A[j], max(A[i] - A[j], max(A[N - 1] - A[k], A[k] - A[i])));
    ans = min(ans, M - m);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(void)
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if (a==1&&b==0&&c==0)
    {
        printf("Close\n");
    }
    else if (a==0&&b==1&&c==0)
    {
        printf("Close\n");
    }
    else if (a==a&&b==1&&c==0)
    {
        printf("Open\n");
    }
    else if (a==0&&b==0&&c==1)
    {
        printf("Open\n");
    }
    else if (a==0&&b==0&&c==0)
    {
        printf("Close\n");
    }
    return 0;
}

Measured memory_bytes: 2592
def main():
    n=int(input())
    MOD=10**9+7
    memo = [{} for i in range(n+1)]

    def ok(l4):
        for i in range(4):
            t=list(l4)
            if i>=1:
                t[i],t[i-1]=t[i-1],t[i]
            if ''.join(t).count('AGC')>=1:
                return False
        return True

    def dfs(cur,l3):
        if l3 in memo[cur]:
            return memo[cur][l3]
        if cur==n:
            return 1
        ret=0
        for c in 'ACGT':
            if ok(l3+c):
                ret=(ret+dfs(cur+1,l3[1:]+c))%MOD
        memo[cur][l3]=ret
        return ret
    
    print(dfs(0,'TTT'))

if __name__ == '__main__':
    main()

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

A, B, C, D, E, F = map(int, input().split())

water = []
for i in range(0, F+1, A*100):
    for j in range(0, F+1, B*100):
        if i + j <= F:
            water.append(i + j)
water = sorted(list(set(water)), reverse=True)
# 0はあとで割る時に困るので外す
water.pop(len(water)-1)

suger = []
for i in range(0, F+1, C):
    for j in range(0, F+1, D):
        if i + j <= F:
            suger.append(i + j)
suger = sorted(list(set(suger)))

# 合計の初期値に水を入れておく(これは0でもいい気がするんだけど…)
ans_ws = water[0]
ans_s = 0
node = 0
# 水は多い方、砂糖は少ない方から見ていく
for i in range(len(water)):
    for j in range(len(suger)):
        # 合計量チェック
        if water[i] + suger[j] > F:
            break
        # 溶ける量チェック
        if suger[j] / (water[i] + suger[j]) <= E / (E + 100):
            # 最大濃度更新なら答えを更新
            if suger[j] / (water[i] + suger[j]) > node:
                node = suger[j] / (water[i] + suger[j])
                ans_ws = water[i] + suger[j]
                ans_s = suger[j]
print(str(ans_ws) + " " + str(ans_s))

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

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

    int ans = 0;
    rep(i, n){
        int sum = 0;
        rep(j, m){
            cin >> a;
            sum += a * B[j];
        }
        sum += c;
        if (sum > 0) ans++;
    }
    cout << ans << endl;
}

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

_, x = raw_input().split(' ')
x = long(x)
aa = raw_input().split(' ')

ret = long(0)
last = 0
for i, a in enumerate(aa):
    a = long(a)
    if i == 0:
       last = min(a, x)
       ret += a - last
    else:   
       last = min(a, x - last)
       ret += a - last

print ret

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

ll p_map[1000];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin>>n;
    if(n==0 || n==1 || n%2==1){
        cout<<0<<endl;
        return 0;
    }
    ll ans = 0;
    for(ll i=10; i<=n; i*=5){
        ans += (n/i);
    }
    cout<<ans<<endl;
    return 0;


}

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

int main() {
  int A,B;
  cin>>A>>B;
  vector<int> ans(max(A,B),min(A,B));
  for(int i=0; i<max(A,B); i++){
    cout<<ans.at(i);
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define N 15
typedef long long LL;

char a[N];
LL c[N], s[N] = {0}, x;

int main()
{	
	int i, l, j;
	
	scanf("%s", a);
	l = strlen(a);
	c[l] = 1, s[l] = 0;
	i = l - 1;
	c[i] = 1, s[i] = (LL)a[i] - 48;
	for(i--; i >= 0; i--){
		for(j = i, x = 0; j < l; j++){
			x = x * 10 + (LL)a[j] - 48;
			s[i] += x * c[j + 1] + s[j + 1];
		}
		c[i] = c[i + 1] << 1;
	}
	printf("%lld\n", s[0]);
		
	return 0;
}

Measured memory_bytes: 128
big = 10**18
n = int(input())
things = list(map(int, input().split()))
result = 1
good = True
if 0 in things:
	print(0)
else:
	for x in things:
		result *= x
		if result > big:
			print(-1)
			good = False
			break
	if good:
		print(result)

Measured memory_bytes: 21704
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

int W, H;
vector<vector<char>> s;
vector<vector<int>> cost;

int bfs() {
	int dx[] = { 0,1,0,-1 };
	int dy[] = { 1, 0, -1, 0 };
	queue<pair<int, int>>que;
	que.push(make_pair(0, 0));
	cost[0][0] = 0;

	while (!que.empty()) {
		pair<int, int>p = que.front();
		que.pop();
		if (p == make_pair(H - 1, W - 1)) {
			return cost[p.first][p.second];
		}
		for (int i = 0; i < 4; i++){
			int ny = p.first + dy[i];
			int nx = p.second + dx[i];
			if (nx < 0 || ny < 0 || nx >= W || ny >= H) {
				continue;
			}
			if (s[ny][nx] == '#') {
				continue;
			}
			if (cost[ny][nx] != -1) {
				continue;
			}
			cost[ny][nx] = cost[p.first][p.second] + 1;
			que.push(make_pair(ny, nx));
		}
	}
	return -1;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> H >> W;
	s = vector<vector<char>>(H, vector<char>(W));
	int white = 0;
	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++) {
			cin >> s[i][j];
			if (s[i][j] == '.') {
				white++;
			}
		}
	}
	cost = vector<vector<int>>(H, vector<int>(W, -1));
	int min_cost = bfs();
	if (min_cost == -1) {
		cout << -1 << endl;
	}
	else {
		cout << white - (min_cost + 1) << endl;
	}

	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s; cin>>s;
	vector<bool>v(26,false);
	for(auto&i:s)v.at(i-'a')=true;
	int i=0;
	while(i<26&&v.at(i))++i;
	if(i==v.size())cout<<"None"s;
	else cout<<(char)('a'+i);
	cout<<"\n"s;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for( int i=a; i<b; i++ )
#define REP(i,n) rep(i,0,n)
using lli = long long int;
using ulli = unsigned long long int;
typedef pair<lli,lli> P;

struct edge{ int u, v, cost; };
struct DirectedGraph
{
  int vertex_num;
  int edge_num;
  vector<edge> edge_list;
  vector< vector<int> > adj_list;
};

void displayVector(vector<lli> v)
{
	lli n = v.size();
	REP(i,n){
		cout << v[i] << " " ;
	}
	cout << endl;
}



int main(){
	int n, m; cin >> n >> m;
	vector<int> p(m);
	vector<lli> y(m) ;
	vector< vector<lli> > id_list(n);

	REP(i, m){ 
		cin >> p[i] >> y[i]; 
		id_list[p[i]-1].push_back(y[i]);
	}

	REP(i, n){
		if( id_list[i].size() != 0 ){
			sort( id_list[i].begin(), id_list[i].end() );
		}
	}

	REP(i, m){
		lli out = 1000000 * lli( p[i] ) + distance(id_list[p[i]-1].begin(), lower_bound( id_list[p[i]-1].begin() , id_list[p[i]-1].end(), y[i]) ) + 1;
		cout << setfill('0') << right << std::setw(12) << out << endl;
	}

  return 0;
}

Measured memory_bytes: 8192
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static String contest = sc.next();

    public static void main(String[] args) {
        if (contest.equals("ABC")){
            System.out.println("ARC");
        } else {
            System.out.println("ABC");
        }
    }
}


Measured memory_bytes: 35596
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int[] NM = ReadInts();
            int[] h = ReadInts();
            long[] cost = new long[NM[0]];
            for(int i = 1; i < NM[0]; i++)
            {
                    long minm = long.MaxValue;
                for(int j = Max(0,i-NM[1]); j < i; j++)
                {
                  //  Write(i+" "+j);
                    minm = Min(cost[j]+Abs(h[j]-h[i]),minm);
                }
                cost[i] = minm;
            }
            Write(cost.Last());



        }

        
        private static void Write<T>(IEnumerable<T> target,string sep=" ") { Console.WriteLine(string.Join(sep,target)); }
        private static void Write<T>(T str) { Console.WriteLine(str); }
        private static string[] ReadStrings() { return Console.ReadLine().Split(' '); }
        private static int ReadInt() { return int.Parse(Console.ReadLine()); }
        private static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        private  static int[] ReadInts() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        private static double[] ReadDoubles() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        
    }

}

Measured memory_bytes: 20576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
deque<char> d;
int main()
{
    ios::sync_with_stdio(false);
    cout.tie(NULL);
    string s;  cin>>s;
    for(int i=0;i<s.length();i++)
        d.push_back(s[i]);
    int n;     cin>>n;
    bool flag=1;
    while(n--)
    {
        int t;  cin>>t;
        if(t==1)
        {
            flag=!flag;
        }
        else
        {
            int c; cin>>c;
            char s1;  cin>>s1;
            if(c==1)
            {
                if(flag)
                {
                    d.push_front(s1);
                    //s=s1+s;
                }
                else
                {
                    d.push_back(s1);
                    //s=s+s1;
                }
            }
            else
            {
                if(!flag)
                {
                    d.push_front(s1);
                    //s=s1+s;
                }
                else
                {
                    d.push_back(s1);
                    //s=s+s1;
                }
            }
        }
    }
    if(flag)
    {
        while(!d.empty())
        {
            cout<<d.front();
            d.pop_front();
        }
    }
    else
    {
        while(!d.empty())
        {
            cout<<d.back();
            d.pop_back();
        }
    }
    return 0;
}


Measured memory_bytes: 976
#include<iostream>

using namespace std;

int main(){

  int n, q;
  int data[101];

  while(cin >> n >> q){

    if(n == 0 && q == 0) break;

    for(int i = 0; i < 101; i++) data[i] = 0;

    for(int i = 0; i < n; i++){
      int num;
      cin >> num;
      for(int j = 0; j < num; j++){
	int in;
	cin >> in;
	data[in]++;
      }
    }
    int max = 0;
    int maxnum = 0;

    for(int i = 100; i > 0; i--){
      if(data[i] >= q && max <= data[i]){
	maxnum = i;
	max = data[i];
      }
    }

    cout << maxnum << endl;
  }

  return 0;
}

Measured memory_bytes: 0
// Created by Tanuj Jain
#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 pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int nax=1e5+10;
//This is like a 2d vector 
vector<int>edges[nax];
//find the max distance from ecah vertex this acts our dp array 
int dist[nax];
//visited array
bool visited[nax];

int dfs(int a)
{
	//if the vertex is visited then return thr max distance 
	if(visited[a])
		return dist[a];

	//mark a as visited 
	visited[a]=true;
	//visit the edges of each vertex 
	int ans=0;
	for(int b: edges[a])
	{
		//find the max distance from each child node and update the answer
			ans=max(ans,dfs(b)+1);
	}
	return dist[a]=ans;

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

	//#ifndef ONLINE_JUDGE
	//freopen("inputf.in","r",stdin);
	//freopen("outputf.in","w",stdout);
	//#endif

	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		edges[a].pb(b);
	}
	//run dfs from each edge and fill the distance value
	int ans=0;
	for(int i=1;i<=n;i++)
			ans=max(ans,dfs(i));
	//find the answer
	cout<<ans;
}

Measured memory_bytes: 8320