akhauriyash/Code-Regression huggingface dataset:
/*
* @author:  codancer
* @createTime:  2020-08-31, 23:21:52
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9+7;
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
#define deb(x) cerr<<#x<<" = "<<(x)<<"\n"
typedef vector<int> VI;
typedef vector<ll> VII;
typedef pair<int,int> pii;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll Rand(ll B) {
	return (ull)rng() % B;
}
const int N = 1e6+100;
int cnt[N];
int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,0,n-1) scanf("%d",&a[i]);
	rep(i,0,n-1){
		int x=a[i];
		for(int j=2;j*j<=x;j++){
			if(x%j==0){
				cnt[j]++;
				while(x%j==0) x/=j;
			}
		}
		if(x!=1) cnt[x]++;
	}
	//rep(i,2,10) cout<<i<<' '<<cnt[i]<<endl;
	int ans=a[0];
	bool finds=0;
	rep(i,0,n-1){
		vector<int> fac;
		int x=a[i];
		for(int j=2;j*j<=x;j++){
			if(x%j==0){
				if(cnt[j]>=2){
					finds=1;
					break;
				}
				while(x%j==0) x/=j;
			}
		}
		if(x!=1) if(cnt[x]>=2) finds=1;
		if(finds) break;
	}
	rep(i,0,n-1) ans=__gcd(ans,a[i]);
	if(!finds){
		puts("pairwise coprime");return 0;
	}
	if(ans==1){
		puts("setwise coprime");
		return 0;
	}
	puts("not coprime");
	return 0;
}

Measured memory_bytes: 11116
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define INF 1000000009
#define INFL 1000000000000000018
#define mod 1000000007
#define pb push_back
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<int, vector<int>, greater<int> >PQG;

int n, a[200005], sum[200005], ans = INFL;
PA L[200005], R[200005];

signed main()
{
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(i == 0){
            sum[i] = a[i];
        }
        else{
            sum[i] = sum[i - 1] + a[i];
        }
    }
    int l = 0;
    for(int i = 1; i < n - 2; i++){
        int suml = sum[l];
        int sumr = sum[i] - sum[l];
        while(abs(sumr - suml) > abs((sumr - a[l + 1]) - (suml + a[l + 1])) && i - (l + 1) > 0){
            l++;
            suml = sum[l];
            sumr = sum[i] - sum[l];
        }
        //cout << suml << " " << sumr << endl;
        L[i].first = suml;
        L[i].second = sumr;
    }
    int r = n - 2;
    for(int i = n - 3; i >= 1; i--){
        int sumr = sum[n - 1] - sum[r];
        int suml = sum[r] - sum[i];
        while(abs(suml - sumr) > abs((sumr + a[r]) - (suml - a[r])) && (r - 1) - i > 0){
            r--;
            sumr = sum[n - 1] - sum[r];
            suml = sum[r] - sum[i];
        }
        //cout << suml << " " << sumr << endl;
        R[i].first = suml;
        R[i].second = sumr;
    }
    int mx, mn;
    for(int i = 1; i < n - 2; i++){
        mx = max(L[i].first, max(L[i].second, max(R[i].first, R[i].second)));
        mn = min(L[i].first, min(L[i].second, min(R[i].first, R[i].second)));
        ans = min(ans, abs(mx - mn));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define pb(x) push_back(x)
#define int long long

int n, m;

signed main(void){
	cin >> n >> m;
	cout << (n-1)*(m-1) << endl;

	return 0;
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a=in();
    cout<<3*a*a<<endl;
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#include <algorithm>
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define l long
#define mm(arr) memset(arr, 0, sizeof(arr))
#define scanArray(a,n) for(int i = 0; i < n; i++){cin >> a[i]}
using namespace std;
int main(){
    FAST
    int n; cin >> n;
    ll sum=0;
    for(int i=1; i<=n; i++){
        if(i%3!=0 && i%5 != 0){
            sum+=i;
        }
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 3560
using System;
using System.Linq;

class Test {
	static void Main(string[] args) {
      int N =　int.Parse(System.Console.ReadLine());
      var L = System.Console.ReadLine()
    	.Split(' ')
    	.Select(s => int.Parse(s))
    	.ToArray();
      int cnt = 0;
      for(int i = 0; i < N - 2; i++){
        for(int j = i+1; j < N - 1; j++){
          for(int k = j+1; k < N; k++){
            if(L[i] != L[j] && L[j] != L[k] && L[k] != L[i]){
              if(L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j]){
                cnt++;
              }
            }
          }
        }
        
      }
      Console.WriteLine(cnt);
	}
}

Measured memory_bytes: 18952
#include <bits/stdc++.h>
using namespace std;
using ll=int_fast64_t;
using P=pair<int,int>;
const ll INF=1<<30;
const ll LINF=1LL<<60;
const double EPS=1e-11;
int main(){
    int d;cin>>d;
    if(d==25){
        cout<<"Christmas"<<endl;
    }else if(d==24){
        cout<<"Christmas Eve"<<endl;
    }else if(d==23){
        cout<<"Christmas Eve Eve"<<endl;
    }else{
        cout<<"Christmas Eve Eve Eve"<<endl;
    }
}

Measured memory_bytes: 256
s = gets.chomp
k = gets.to_i

counts = []
pre = nil
cnt = 1
s.chars.each do |c|
  if pre == nil
    pre = c
  elsif pre == c
    cnt += 1
  else
    counts << cnt
    pre = c
    cnt = 1
  end
end
counts << cnt

ans = 0
if counts.size == 1
  ans = counts[0] * k / 2
elsif s[0] == s[-1]
  counts[1..-2].each { |t| ans += t / 2}
  ans *= k
  ans += (counts[0] + counts[-1]) / 2 * (k - 1)
  ans += counts[0] / 2
  ans += counts[-1] / 2
else
  counts.each { |t| ans += t / 2 }
  ans = ans * k
end
puts ans

Measured memory_bytes: 1788
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7)


int main(void) {
	string x;
	cin >> x;
	ll ans = 1000000;
	for (int i = 0;i <= x.length() - 3;i++) {
		ll a = x[i] - '0';
		ll b = x[i + 1] - '0';
		ll c = x[i + 2] - '0';
		ll num = 100 * a + 10 * b + c;
		ans = min(ans, abs(num - 753));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define forn(i,a,b) for(long long i=a;i<=b;i++)
#define fork(i,a,b,k) for(long long i=a;i<=b;i+=k)
int n;
double p[3000],dp[3005][3005];
using namespace std;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>p[i];
	dp[0][0]=1.0;
	for(int i=1;i<=n;i++){
		dp[i][0]=dp[i-1][0]*(1-p[i]);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i>=j)dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
		}
	}
	double ans=0.0;
	for(int i=(n+1)/2;i<=n;i++)ans+=dp[n][i];
	cout<<fixed<<setprecision(10)<<ans;
}

Measured memory_bytes: 69120
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    vector<bool> dp1(10, false);
    vector<bool> dp2(100, false);
    vector<bool> dp3(1000, false);

    for (char c : s) {
        int k = c - '0';
        rep(i, 100)
        {
            if (dp2[i]) {
                dp3[i * 10 + k] = true;
            }
        }
        rep(i, 10)
        {
            if (dp1[i]) {
                dp2[i * 10 + k] = true;
            }
        }
        dp1[k] = true;
    }

    int cnt = 0;
    rep(i, 1000)
    {
        if (dp3[i]) {
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int N; cin >> N;
    vector<int> V(N);
    rep (i, N)
    {
        cin >> V[i];
    }
    vector<int> C(N);
    rep (i, N)
    {
        cin >> C[i];
    }

    int sum = 0;
    rep (i, N)
    {
        if (V[i] - C[i] <= 0)
        {
            continue;
        }
        sum += V[i] - C[i];
    }

    cout << sum << endl;

    return 0;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

typedef unsigned long long LL;

LL N;
vector<LL> D;

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

	LL A, B, C;
	cin >> A >> B >> C;

	if( (A % 2) == 0 || (B % 2) == 0 || (C % 2) == 0){
		printf("0\n");
	}
	else{
		LL ans = min(A*B, min(B*C, C*A));
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3784
k = int(raw_input())

n = 50
a = [n - 1 + k // n] * n
j = 0
s = 0
c = 0
for i in xrange(k % n):
    a[j] += n + 1
    s += 1
    c += 1
    if c == 15:
        j += 1
        c = 0
for i in xrange(n):
    a[i] -= s
print n
print " ".join(str(x) for x in a)


Measured memory_bytes: 2568
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;
int W, H;
int s[1010][1010] = { 0 };

int score(int i, int j) {
	if ((i + j) % 2 == 0)return (s[i + 1][W] - s[i + 1][j]) - s[i + 1][j];
	return s[i + 1][j] - (s[i + 1][W] - s[i + 1][j]);
}

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

	int dp[1010][1010];
	cin >> W >> H;
	eFOR(i,1, H) {
		eFOR(j,1, W) {
			cin >> s[i][j];
			s[i][j] += s[i][j - 1];
		}
	}
	
	for (int i = H; i >= 0; i--) {
		for (int j = W; j >= 0; j--) {
			if (i == H)dp[i][j] = 0;
			else if (j == W)dp[i][j] = score(i, j) - dp[i + 1][j];
			else dp[i][j] = max(-dp[i][j + 1], score(i, j) - dp[i + 1][j]);
		}
	}
	cout << abs(dp[0][0]) << endl;


	return 0;
}




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

int main(void){
	string s, t;
	cin >> s >> t;
	map<char, char> t_map;
	map<char, char> s_map;


	bool f = true;
	for(int i=0; i<s.size(); i++){
		if(!t_map.count(t[i])){
			t_map[t[i]] = s[i];
		}else{
			if(t_map[t[i]] != s[i]){
				f = false;
				break;
			}
		}
	}
	for(int i=0; i<s.size(); i++){
		if(!s_map.count(s[i])){
			s_map[s[i]] = t[i];
		}else{
			if(s_map[s[i]] != t[i]){
				f = false;
				break;
			}
		}
	}

	if(f) puts("Yes");
	else puts("No");
	
	return 0;
}


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

using namespace std;

#define MAX_N 30
int dp[MAX_N + 1];
bool checked[MAX_N + 1];
//??\???

int count(int n) {

  if ( n == 1 ) return 1;
  if ( n == 2 ) return 2;
  if ( n == 3 ) return 4;

  if(checked[n] == true){
    return dp[n];
  } else {
    checked[n] = true;
    return dp[n] = count(n-1) + count(n-2) + count(n-3);
  }

}

int main() {

  ios::sync_with_stdio(false);

  int n, years;
  while(cin >> n) {
    if (n==0) break;
    int c = count(n);
    years = ( c / 3650 ) + (c % 3650 == 0 ? 0 : 1);
    cout << years << endl;
  }

  return 0;
}

Measured memory_bytes: 3076
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

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

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

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

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

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

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

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

fn main() {
  input! {
    n: usize, m: usize,
    sc: [(usize, usize); m]
  }
  
  for x in 0..10i32.pow(n as u32) {
    let t: String = x.to_string();
    if
      t.len() == n &&
      sc.iter().all(|&(s, c)| t.chars().nth(s - 1) == std::char::from_digit(c as u32, 10)) {
        println!("{}", x);
        return;
    }
  }
  
  println!("-1");
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll N = 200005;

namespace Modop {
    ll modAdd(ll a, ll b) {
        return (a + b) % MOD;
    }
    
    ll modSub(ll a, ll b) {
        return (((a - b) % MOD) + MOD) % MOD;
    }
    
    ll modMul(ll a, ll b) {
        return ((a % MOD) * (b % MOD)) % MOD;
    }

    ll modExp(ll base, ll power) {
        if (power == 0) {
            return 1;
        } else {
            ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
            if (power % 2 == 1) cur = cur * base;
            cur = cur % MOD;
            return cur;
        }
    }
    
    ll modInv(ll a) {
        return modExp(a, MOD - 2);
    }
    
    ll modDiv(ll a, ll b) {
        return modMul(a, modInv(b));
    }
}

using namespace Modop;

int n;
ll ans = 1;

bitset<N> last;
ll prob[N], pos[N];

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;
    vector<int> a;
    for (int i = 0; i < n; i++) {
        int ci; cin >> ci;
        if (!i || ci != a[a.size() - 1])
            a.push_back(ci);
    }

    for (int i = 1; i < N; ++i) prob[i] = 1;
    n = a.size();
    pos[n] = 1;

    last.set();
    bool pair = false;
    for (int i = n - 1; i >= 0; --i) {
        if (last[a[i]]) {
            prob[a[i]] = pos[i + 1];
            pos[i] = pos[i + 1];
            last[a[i]] = 0;
        } else {
            ans = modAdd(ans, prob[a[i]]);
            // cout << i << ' ' << prob[a[i]] << '\n';
            prob[a[i]] = modAdd(prob[a[i]], pos[i + 1]);
            pos[i] = prob[a[i]];
    
            // if (!pair) {
                // pos[i] = 2;
                // pair = true;
            // } else pos[i] = pos[i + 1];
        }
    }

    // for (int i = 0; i < n; i++) {
        // cout << i << ' ' << pos[i] << ' ' << prob[a[i]] << '\n';
    // }
    cout << ans;
}


Measured memory_bytes: 7164
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  cin.tie(nullptr), ios::sync_with_stdio(false);

  int a, b;
  cin >> a >> b;
  if (a == 1) a = 100;
  if (b == 1) b = 100;

  cout <<
    (a == b ? "Draw" :
     a < b ? "Bob" : "Alice") << LF;

  return 0;
}



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

using namespace std;

int main() {
  string x; cin >> x;
  string d1 = "", d2 = "";
  for(int i = 0; i < 2; i++) d1 += x[i];
  for(int i = 2; i < 4; i++) d2 += x[i];
  int p = stoi(d1), q = stoi(d2);
  if(p <= 12 and q <= 12 and p >= 1 and q >= 1) {
    puts("AMBIGUOUS");
  }
  else if((p > 12 and (q == 0 or q > 12)) or (q > 12 and (p == 0 or p > 12)) or (p == 0 and q == 0)) {
    puts("NA");
  }
  else if(p <= 12 and p >= 1) {
    puts("MMYY");
  }
  else if(q <= 12 and q >= 1) {
    puts("YYMM");
  }
}

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

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

  if (s[0] == s[1] && s[1] == s[2]) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 764
import java.util.*;

class IntQue{
    final int MAX=100000;
    int[] q;
    int head,tail;
    IntQue(){
        q=new int[MAX];
        head=0;tail=0;
    }
    boolean isEmpty(){
        return head==tail;
    }
    void enqueue(int time){
        q[tail]=time;
        if(tail+1==MAX) tail=0;
        else tail++;
    }
    int dequeue(){
        int t=q[head];
        if(head+1==MAX) head=0;
        else head++;
        return t;
    }
}
class StringQue{
    final int MAX=100000;
    String[] q;
    int head,tail;
    StringQue(){
        q=new String[MAX];
        head=0;tail=0;
    }
    boolean isEmpty(){
        return head==tail;
    }
    void enqueue(String name){
        q[tail]=name;
        if(tail+1==MAX) tail=0;
        else tail++;
    }
    String dequeue(){
        String t=q[head];
        if(head+1==MAX) head=0;
        else head++;
        return t;
    }
}
public class Main {
    private static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        IntQue iq=new IntQue();
        StringQue sq=new StringQue();
        int n=sc.nextInt();
        int qms=sc.nextInt();
        for(int i=0;i<n;i++){
            sq.enqueue(sc.next());
            iq.enqueue(sc.nextInt());
        }
        int total=0;
        while(!(iq.isEmpty())){
            String name=sq.dequeue();
            int time=iq.dequeue();
            if(time>qms){
                total=total+qms;
                sq.enqueue(name);
                iq.enqueue(time-qms);
            }else{
                total=total+time;
                System.out.printf("%s %d\n",name,total);
            }
        }
    }
}

Measured memory_bytes: 103120
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

void solve()
{	
	string s;
	cin >> s;
	string t = "";
	rep(i, sz(s)) if(i % 2 == 0) t += s[i];
	cout << t;
}


 
 
int main()
{
 //	freopen("sparse.in", "r", stdin);
	//freopen("sparse.out", "w", stdout);
	   Red;
  	//int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#include <map>
#include <numeric>
#include <stack>
#include <queue>
#include <functional>
#include <stdio.h>
#define ll long long
#define pl pair<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define vvvb vector<vector<vector<bool> > >
#define rep(i,a) for(ll i = 0;i<a;++i)
#define rep1(i,a) for(ll i = 1;i<a;++i)
#define rrep(i,a) for(ll i = a;i>=0;--i)
#define mod 1000000007
#define inf 10010010010
using namespace std;


int main(){
	ll n; cin >> n;
	vl seki(n,0);
	cout << 0 << endl;
	string s;
	cin >> s;
	if (s[0] == 'M') seki[0] = -1;
	else if(s[0] == 'F') seki[0] = 1;
	else return 0;
	rep1(i, n) seki[i] = -seki[i - 1];
	ll left = 1, right = n - 1;
	rep(i, 19){
		ll now = (left + right) / 2;
		cout << now << endl;
		cin >> s;
		if ((s[0] == 'M' && seki[now] != -1) || (s[0] == 'F' && seki[now] != 1)){
			right = now - 1;
		}
		else if (s[0] == 'M' || s[0] == 'F'){
			left = now + 1;
		}
		else return 0;
	}
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    ll n; cin >> n;

    ll V = n * (n+1) * (n+2) / 6;
    ll E = 0;
    
    rep(i, n-1){
        ll u, v;
        cin >> u >> v;
        if(u > v) swap(u, v);
        E += u * (n - v + 1); 
    }
    
    cout << V - E << endl;
    return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3540
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, k, ans = 0;
	cin >> num >> k;
	while (num > 0) {
		num /= k;
		ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
ans = 0
# 000 - 999 まで全探索
for i in range(1000):
    t = str(i).zfill(3)

    # 1桁目が存在するか
    if t[0] in S:
        t1 = S.index(t[0])
        # 2桁目を1桁目のidx + 1から探す
        if t[1] in S[t1 + 1:]:
            # 1桁目のidx + 2桁目のidx + 1 桁目から3文字目を探す
            t2 = t1 + S[t1 + 1:].index(t[1]) + 1
            if t[2] in S[t2 + 1:]:
                ans += 1

print(ans)

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

int main() {
  int64_t N;
  cin >> N;
  vector<int64_t> p(N);
  for(int i=0;i<N;i++)
    cin >> p.at(i);
  
  int64_t x=0;
  for(int i=0;i<N-1;i++){
    if( (int64_t)p.at(i) > (int64_t)p.at(i+1) ){
      x += (int64_t)p.at(i) - (int64_t)p.at(i+1);
      p.at(i+1) =  p.at(i) ;
    }
  }
  cout << x <<endl;
  
}

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

#define INF 1E18



int main(){
    ll n;
    cin >> n;
    ll w[n];
    rep(i,n) cin >> w[i];

    ll ans = INF;
    rep2(t,1,n-1){
        ll s1 = 0;
        ll s2 = 0;
        rep(i,t+1) s1 += w[i];
        rep2(i,t+1,n) s2 += w[i];
        ans = min(ans, abs(s1 - s2));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
H=list(map(int,input().split()))
dp=[0]*(n+1)
dp[0]=0; dp[1]=abs(H[1]-H[0])
for i in range(2,n):
  dp[i]=min(dp[i-1]+abs(H[i]-H[i-1]), \
    dp[i-2] + abs (H[i]-H[i-2]))
print(dp[n-1])

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

int main () {
    int N;
    cin >> N;
    int a[N];
    int count = N;
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }

    for (int i = 0; i < N - 1; i++) {
        for (int j = N - 1; j > i; j--) {
            if (a[i] == a[j]) {
                count--;
                break;
            }
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k - 1] = (char)(s[k - 1] + 'a' - 'A');
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
    using namespace std; 
    using namespace std::chrono; 
    #define ll long long int 
     
    int main() 
    { 
    	//freopen("input.txt","r",stdin);
    	//freopen("output.txt","w",stdout);
    	
    	ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        ll n,m,k;
        cin>>n>>m>>k;
        if(n==m&&n!=k||m==k&&m!=n||n==k&&n!=m)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    	return 0; 
    } 
     


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}
int lcm(int a, int b) {return a * b / gcd(a, b); }
long long bpow(long long a, long long b, long long m) 
{
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("in.txt","r",stdin);
  freopen("out.txt","w",stdout);
  #endif
}
template<typename P> struct Cmp
{
    bool operator()(const P &p1, const P &p2)
    {
        return (p1.ss < p2.ss); 
    }
};


int main() 
{ 
    fast_io
    go();
    int n;cin>>n;
    vi v(n);
    int c=0;
    int arr[1000001]={0},is[1000001]={0};
    int maxx=INT_MIN;
    for(int i=0;i<n;i++)
    {
      cin>>v[i];
      maxx=max(maxx,v[i]);
      arr[v[i]]++;
      if(arr[v[i]]>=2)
        is[v[i]]=1;
    }
    //sort(v.begin(),v.end());
    for(int i=0;i<n;i++)
    {
      for(int j=2*v[i];j<=maxx;j+=v[i])
        is[j]=1;
    }
    for(int i=0;i<n;i++)
    {
     if(is[v[i]]==0)
      c++;
    }
    cout << c <<"\n";
} 























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

int main(){
  int n,m; ll b=0;
  priority_queue<ll> p;
  cin >>n >>m;
  for(int i=0;i<n;i++){
    int s;
    cin >> s;
    p.push(s);
  }
  for(int i=0;i<m;i++){
    p.push(p.top()/2);
    p.pop();
  }
  for(int i=0;i<n;i++){
    b+=p.top();
    p.pop();
  }
  cout << b << endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 10000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;
   // #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
    //#endif
   	ll int n;
   	cin>>n;
   	ll int len=1;
   ll int 	k=n,z,i,tot;
   
  vector<ll int> v;
   	
   	while(k!=0)
   	{
   		k--;
   		z=k%26;
   		v.PB(z);
   		k=k/26;
   	}

   	for(i=v.size()-1;i>=0;i--)
   	{
   		
   		//if(v[i]==25)
   	//		cout<<"z";
   	//	else
   		{	
   			cout<<(char)(v[i]+96+1);
   		}
   	}
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

ll ncm(ll n, ll m){
    ll ret = 1;
    rep(i, m){
        ret *= n - i;
        ret /= i + 1;
    }
    return ret;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    vll v(n);
    rep(i, n){
        cin >> v[i];
    }
    sort(v.rbegin(), v.rend());
    long double ans = 0.0;
    rep(i, a){
        ans += v[i];
    }
    ll cnt = 0;
    ll cntbef = 0;
    rep(i, n){
        if(v[i] > v[a-1]) cntbef++;
        if(v[i] == v[a-1]) cnt++;
    }
    ll ans2 = 0;
    if(!cntbef){
        for(ll i = a; i <= min(b, cnt); i++){
            ans2 += ncm(cnt, i);
        }
    }else{
        ans2 += ncm(cnt, a-cntbef);
    }
    ans /= a;
    cout << fixed << setprecision(15) << ans << endl;
    cout << ans2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int data, i, b, f, r, v, rooms[4][3][10] = {};
	scanf("%d", &data);
	for (i = 0; i < data; i++) {
		scanf("%d %d %d %d", &b, &f, &r, &v);
		rooms[b - 1][f - 1][r - 1] += v;
	}
	for (b = 0; b < 4; b++) {
		if (b != 0) {
			printf("####################\n");
		}
		for (f = 0; f < 3; f++) {
			for (r = 0; r < 10; r++) {
				printf(" %d", rooms[b][f][r]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int ll;
typedef vector<int > vecint;
typedef vector<bool > vecbool;
typedef vector<string > vecstr;
typedef vector<vector<int > > vec2int;
typedef vector<vector<bool > > vec2bool;
int dx[4] {-1,+1, 0, 0};
int dy[4] { 0, 0,-1,+1};
int main()
{
  int h, w, n;
  cin >> h >>w>>n;
  int a = max(h, w);
  cout << n/a + (n % a != 0) << endl;

}


Measured memory_bytes: 256
program XXOR
  implicit none
  integer :: n, m, i, j
  integer(8) :: k, a(100000) = 0_8, x = 0_8, f = 0_8
  read(*,*) n, k
  read(*,*) a(1:n)
  do i = 40, 0, -1
    m = 0
    do j = 1, n
      if (btest(a(j),i)) m = m+1
    end do
    if (m < n-m) x = ibset(x,i)
    if (x > k) x = ibclr(x,i)
  end do
  do i = 1, n
    f = f+xor(x,a(i))
  end do
  write(*,'(i0)') f
end program XXOR

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

int main(){
	int n, a;
	int count = 0;
	unordered_set<int> s;
	cin >> n;
	for(int i= 0; i <n ; i++){
		cin >> a;
		if(s.count(a)){
			s.erase(a);
			count--;
		} else {
			s.insert(a);
			count++;
		}
	}
	cout << count;
}



Measured memory_bytes: 4388
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(long long)(n); i++)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const ll inf = 1020304050607080910;
const ll mod = 1000000007;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x,ll y){if(x>y)swap(x, y);while(x!=0){y%=x;swap(x, y);}return y;}
ll mpow(ll x,ll r){if(r==0)return 1;if(r%2==1){return x*mpow(x,r-1)%mod;}else{ll aa=mpow(x,r/2);return aa*aa%mod;}}

int main(){
	string t; cin >> t;
	rep(i, t.size()){
		if(t[i] == '?') t[i] = 'D';
	}
	rep(i, t.size()) cout << t[i];
	cout << endl;
	return 0;
}


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

int main() {  
	int n,k,count=0;
  	cin >>n>>k;
  	int w[n];
  	for(int i=0;i<n;i++){
    cin >>w[i];
    }
  	int flag,memo;
  long long int left=0,right=1000000000,mid;
  	
  while(right-left>1){
    mid=(right+left)/2;
  	count=0;flag=0,memo=0;
  	for(int i=0;i<n;i++){
    	if(w[i]>mid){flag=1;}//まず無理
      	else{
        	if((memo+w[i])<=mid){
            	memo+=w[i];
            }
          	else{
            	memo=0;count++;memo+=w[i];
            }
        }	
    }
  	if(flag==1||count>=k){
     	left=mid;
    }
  	else{
    	right=mid;
    }   
  }
  cout <<right<<endl;
}


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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string n;
    cin >> n;
    int ans = 0;
    REP(i, 4) if (n[i] == '2') ans++;
    cout << ans << ln;
    return 0;
}


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

using namespace std;

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

        int a, b;

        cin >> a >> b;

        int sum = a + b;
        int sub = a - b;
        int mult = a * b;

        cout << max(max(sum, sub), mult) << endl;
        return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

    int n;
    cin>>n;

    int a[1000000];
    int b[1000000];

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

    // ans=a[0];
    int count=0;
    int tmp=0;

    bool flag=false;
    for(int i=0;i<n;i++){

        if(a[tmp]!=2){
            tmp=a[tmp]-1;
            count++;
        }else{
            cout<<count+1<<endl;
            flag=true;
            return 0;
        }
        
    
    }

    if(!false){
        cout<<-1<<endl;
    }


}

Measured memory_bytes: 2560
S = str(input())
K = int(input())

if len(S) == 1:
  print(S)
  exit()

if set(S[:K]) == set(['1']):
  print(1)
  exit()
else:
  for idx in range(K):
    if S[idx] != '1':
      print(S[idx])
      exit()


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

int main() {
  int N; cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; ++i) cin >> s[i];

  int M = 2 * N - 1;
  vector<string> table(M);
  for (int i = 0; i < M; ++i) {
    for (int j = 0; j < M; ++j) {
      table[i] += s[(i + 1) % N][j % N];
    }
  }

  int ans = 0;
  for (int h = 0; h < N; ++h) {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        if (table[h + i][j] != table[h + j][i]) i = j = N;
        if (i == N - 1 && j == N - 1) ans += N - h;
      }
    }
  }
  for (int w = 1; w < N; ++w) {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        if (table[i][w + j] != table[j][w + i]) i = j = N;
        if (i == N - 1 && j == N - 1) ans += N - w;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
 
//dp[i][j][k],i桁数,j:0を用いた数、k:最大かどうか?
bool vis[120][4][2];
lli dp[120][4][2];
string s;
 
lli calc(lli now,lli leftK,int maxFlag){
	if(vis[now][leftK][maxFlag])return dp[now][leftK][maxFlag];
	vis[now][leftK][maxFlag] = true;
	if(leftK==0){return dp[now][leftK][maxFlag]=1;
	}
	if(now>=s.size())return dp[now][leftK][maxFlag]=0;
	lli rtn=0;

	//maxフラグが立っている。
	if(maxFlag){
		//0をここで使う場合
		if(s.at(now)=='0')rtn += calc(now+1,leftK,1);
		else rtn += calc(now+1,leftK,0);
 
		//0以外を使う
		//さらにmaxをそのまま継続する場合
		if(s.at(now)!='0'){
			rtn += calc(now+1,leftK-1,1);
			rtn += (s.at(now)-'1')*calc(now+1,leftK-1,0);
		}
 
		//maxは継続させない場合
		//if(s.at(now)!=0)rtn += (s.at(now)-'1')*calc(now+1,leftK-1,0);
	}
	else{//maxを継続せずに9倍させる。
		//0を使う場合,leftKはそのままにする。
		rtn += calc(now+1,leftK,0);
		//0以外を使う場合,leftKを減らす
		rtn += 9 * calc(now+1,leftK-1,0);
	}
 
 	if(DEBUG)cout<<"now="<<now<<"leftK="<<leftK<<"maxFlag="<<maxFlag<<" rtn ="<<rtn<<endl;
	return dp[now][leftK][maxFlag] = rtn;
}
 
signed main(){
 
	lli k;
 
	cin>>s>>k;
 
 	calc(0,k,1);
 	if(dp[0][k][1]<0)cout<<0<<endl;
	else cout<<calc(0,k,1)<<endl;
 
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int answer;
int s[30005];
int snum=2; 
int scout=1;
int main()
{
    int n;
    cin>>n;
   
    if(n==3){
    	cout<<2<<" "<<5<<" "<<63;
	}else{
		s[2]=1;s[3]=1;
		int i3;
		if((n-3)%2!=0) i3=n-3;
		else i3=n-4;
		for(int i=3;i<=min(9999,i3*2+1);i+=2){
			s[3*i]=1;
			snum+=1;
		}
		for(int i=2;i<=n-snum;i++){
			s[2*i]=1;
			scout+=i;
		}
		for(int i=n-snum+1;i<=n-snum+3;i++){
			if(i%3==(3-scout%3)%3) s[i*2]=1;
		}
		for(int i=1;i<=30000;i++){
			if(s[i]==1) cout<<i<<" ";
		}
	}

    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int a, b, c;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if (a + b == 1 || a + b + c == 0){
		printf("Close\n");
	}
	else if (a + b == 2 || c == 1){
		printf("Open\n");
	}
	
	return (0);
}

Measured memory_bytes: 584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		int ans = String.valueOf(N).length();
		for (long A = 1; A * A <= N; A++) {
			if (N % A != 0) {
				continue;
			}
			long B = N / A;
			int tmp = Math.max(String.valueOf(A).length(), String.valueOf(B).length());
			if (ans > tmp) {
				ans = tmp;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

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

int main() {
	int N, K;
	int h[100000];
	int count = 0;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> h[i];
		if (h[i] >= K)count++;
	}
	cout << count << endl;
}


Measured memory_bytes: 640
function Scanner(input) {
	var self = this;
	self.itemNo = 0;
	self.orgStr = input;
	self.splitedStrs = (function(target) {
		var result = [];
		var target = target.replace(/[\n \t]+/g, " ");
		var strs = target.split(" ");
		for (var i = 0, len = strs.length; i < len; i++) {
			result.push(strs[i]);
		}
		return result;
	}(input));

	self.next = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? result : null;
	}

	self.nextInt = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? parseInt(result) : null;
	}

	self.nextBigDecimal = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? parseFloat(result) : null;
	}
	
	self.nextByte = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? new Int8Array(result) : null;
	}

}

function Main(sc) {

	var N = sc.nextInt();
	var M = sc.nextInt();
	var anss = [];
	
	if (N == M * 2 + 1) {
		for (var i = 0; i < M; i++) {
			var ans = (Math.floor(N / 2) - i) + " " + (Math.floor(N / 2) + i + 1);
			anss.push(ans);
		}
	} else {
		for (var i = 0; i < M; i++) {
			var start = 0;
			var skip = 0;
			if (i % 2 == 0) {
				start = parseInt(i / 2) + 1;
				skip = M - i;
			} else {
				start = parseInt(i / 2) + parseInt(N / 2) + 1;
				skip = M - i;
			}
			var ans = start + " " + (start + skip);
			anss.push(ans);
		}
	}
	
	console.log(anss.join("\n"));
}
Main(new Scanner(require("fs").readFileSync("/dev/stdin", "utf8")));
// Main(new Scanner("33"));

// var str1 = sc.next(); // Stringで取得
// var int1 = sc.nextInt(); // intで取得
// var bd1 = sc.nextBigDecimal(); // BigDecimalで取得
// var byte1 = sc.nextByte(); // byteで取得
// for (var i = 0; i < 1000000000; i++) var toDelay = "aaa"; // 1000msくらいの遅延


Measured memory_bytes: 47852
h,w = [int(i) for i in input().split()]

def solve(h,w):
    ans = min(h,w)
    for i in range(1,h):
        p1 = w*i
        p2 = (h-i)*(w//2)
        p3 = h*w-p1-p2
        ans = min(ans, max(p1,p2,p3)-min(p1,p2,p3))
    return ans 

ans = min(solve(h,w), solve(w,h))
if h*w % 3 == 0:
    ans = 0

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
// #define DEBUG

using namespace std;

const int N = 1e3+7;
const int M = 2e3+7;

int n, m, k;
int u[M], v[M], fir[N], nex[M], last[N], res[N], dis[N], vis[N];

inline void dijiskra(int s, int t, int del)
{
    priority_queue<pair<int, int>> q;
    memset(dis, 0x3f, sizeof(int)*(n+3));
    dis[s] = 0;
    vis[s] = 1;
    last[s] = 0;
    q.push({0, s});
    while (q.size()) {
        auto cur = q.top(); q.pop();
        int w = -cur.first, uu = cur.second;
        --vis[uu];
        if (dis[uu] < w) continue;
        for (int i = fir[uu], vv; i; i = nex[i]) {
            if (i == del) continue;
            vv = v[i];
            if (w+1 < dis[vv]) {
                ++vis[vv];
                dis[vv] = w+1;
                last[vv] = uu;
                q.push({-dis[vv], vv});
            }
        }
    }
#ifdef DEBUG
    cout << s << " " << t << endl;
    for (int i = 1; i <= n; ++i) {
        cout << dis[i] << " ";
    }
    cout << endl;
#endif
    if (dis[t]+1 < k) {
        k = dis[t]+1;
        for (int i = t, id = 1; i; i = last[i], ++id) {
            res[id] = i;
        }
    }
}

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
        cin >> u[i] >> v[i];
        nex[i] = fir[u[i]];
        fir[u[i]] = i;
    }
    k = n+1;
    for (int i = 1; i <= m; ++i) {
        dijiskra(v[i], u[i], i);
    }
    if (k == n+1) {
        cout << -1 << endl;
        return 0;
    }
    cout << k << endl;
    for (int i = 1; i <= k; ++i) {
        cout << res[i] << endl;
    }
    return 0;
}


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

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

	int ans=0;
	bool end = false;
	while(1)
	{
		rep(i,n)
		{
			if(a[i]%2 != 0) end=true;
		}
		if(end) break;
		rep(i,n)
			a[i] /= 2;
		ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<string>
#include<queue>
#include<iomanip>
#include<bitset>
#include<math.h>
#include<stack>
#include<set>
using namespace std;
#define int long long
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int> q(a);
	vector<int> w(b);
	vector<int> e(c);
	for (int i = 0; i < a; i++) {
		cin >> q[i];
	}
	for (int j = 0; j < b; j++) {
		cin >> w[j];
	}
	for (int i = 0; i < c; i++) {
		cin >> e[i];
	}
	sort(q.begin(), q.end());
	reverse(q.begin(), q.end());

	sort(w.begin(), w.end());
	reverse(w.begin(), w.end());

	sort(e.begin(), e.end());
	reverse(e.begin(), e.end());
	multiset<int> ne;
	for (int i = 0; i < x; i++) {
		ne.insert(q[i]);
	}
	for (int i = 0; i < y; i++) {
		ne.insert(w[i]);
	}
	for (int i = 0; i < c; i++) {
		if (*ne.begin() < e[i]) {
			ne.erase(ne.begin());
			ne.insert(e[i]);
		}
	}
	int sum = 0;
	for (auto it = ne.begin(); it != ne.end(); it++) {
		sum += *it;
	}
	cout << sum;
}
	

Measured memory_bytes: 14036