akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;

const int mod = 1e9+7;



int32_t main(){
    FAST;

    string s;       cin >> s;
    int n = s.size();

    int ans = 0;

    for(auto ch : s){
        if(ch == 'A' or ch == 'T' or ch == 'G' or ch == 'C')
            ans = 1;
    }

    if(n == 1){
        if(s[0] != 'A' and s[0] != 'T' and s[0] != 'G' and s[0] != 'C'){
            cout << 0;
            exit(0);
        }else cout << 1;
        exit(0);
    }

    for(int x=0;x<n-1;x++){
        for(int y=x+1;y<n;y++){

            int len = y - x + 1;

            int has = 1;

            for(int i = x ; i <= y ; i++){
                if(s[i] != 'A' and s[i] != 'C' and s[i] != 'G' and s[i] != 'T')
                    {has = 0; break;}
            }

            if(has) {
                ans = max(ans , len);
                //cout << s.substr(x,len) << '\n';
            }

        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val count = mutableMapOf<String,Int>()
    val n = sc.nextInt()
    repeat(n) {
        val s = sc.next()
        count[s] = count.getOrElse(s, {0}) + 1
    }
    val m = sc.nextInt()
    repeat(m) {
        val s = sc.next()
        count[s] = count.getOrElse(s, {0}) - 1
    }

    println(Math.max(0, count.values.max()!!))
}

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

int main() {
    int m1, d1, m2, d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;
    if (m1 != m2) cout << 1 << endl; else cout << 0 << endl;
}


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

using ll = long long;
using ld = long double;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 200000;
std::vector<std::pair<int,int>> v;
std::map<std::pair<int,int>,int> mp;

int main() {
  int n;
  std::cin >> n;
  for(int i = 1;i <= n; i++) {
    ld init;
    std::cin >> init;
    ll number = llround(1000000000LL * init);
    std::pair<int,int> basic(0, 0);

    while(number % 2 == 0) {
      number /= 2;
      basic.first++;
    }
    while(number % 5 == 0) {
      number /= 5;
      basic.second++;
    }
    mp[basic]++;
    if(mp[basic] == 1)
      v.push_back(basic);
  }
  ll result = 0;

  for(int i = 0; i < v.size(); i++)
    for(int j = i; j < v.size(); j++)
      if(18 <= v[i].first + v[j].first && 18 <= v[i].second + v[j].second) {
        if(i == j)
          result += 1LL *  mp[v[i]] * (mp[v[i]] - 1) / 2;
        else
          result += 1LL * mp[v[i]] * mp[v[j]];
      }
  std::cout << result;
}


Measured memory_bytes: 3736
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;
import std.array;

int readInt(){
  return readln.chomp.to!int;
}

int[] readInts(){
  return readln.chomp.split.to!(int[]);
}

void main(){
  int s = readInt(), n;
  int[] dic;
  
  dic ~= s;
  for(n = 2; ; n++){
    if(s % 2 == 0){
      s /= 2;
    } else {
      s = 3 * s + 1;
    }
    
    if(dic.find(s).empty){
      dic ~= s;
    } else break;
  }
  
  writeln(n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end())
using namespace std;
using lint     = long long;
const lint MOD = 1e9 + 7;
const lint INF = 1e18;

template <class T>
vector<T> dividers(T n) {
  vector<T> ret;
  for (T x = 1; x * x <= n; x++) {
    if (n % x == 0) {
      ret.push_back(x);
      ret.push_back(n / x);
    }
  }
  return ret;
}

int main() {
  lint n, m;
  cin >> n >> m;
  vector<lint> v = dividers(m);

  lint ma = -1;
  for (auto x : v) {
    if (x * n <= m) { ma = max(ma, x); }
  }
  cout << ma << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    ll n;
    cin >> n;
    vector<double> x(n), y(n);
    repi(i, n, 0)
    {
        cin >> x[i];
    }
    repi(i, n, 0)
    {
        cin >> y[i];
    }
    double dist = 0;
    repi(i, n, 0)
    {
        dist += abs(x.at(i) - y.at(i));
    }
    cout << fixed << setprecision(10) << dist << endl;
    dist = 0;
    repi(i, n, 0)
    {
        dist += pow(abs(x.at(i) - y.at(i)), 2);
    }
    cout << fixed << setprecision(10) << sqrt(dist) << endl;
    dist = 0;
    repi(i, n, 0)
    {
        dist += pow(abs(x.at(i) - y.at(i)), 3);
    }
    cout << fixed << setprecision(10) << pow(dist,1./3) << endl;
    dist = 0;
    repi(i, n, 0)
    {
        dist = max(abs(x.at(i) - y.at(i)),dist);
    }
    cout << fixed << setprecision(10) << dist << endl;
    return 0;
}


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

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

	string s = "AKIHABARA";
	int flag = 0;
	int n = S.size();
	int j = 0;
	for( int i = 0; i < n; i++ ) {
		if( S[i] != s[j] ) {
			if( j >= s.size() || s[j] != 'A' ) {
				flag = 1;
				break;
			}
			else {
				j++;
				i--;
			}
		}
		else j++;
	}
	string ans = "YES";
	if( flag || j < s.size() - 1 ) ans = "NO";

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n;
	cin>>n;
	n*=9;
	int ans=0;
	if(n%7)
	{
		long long c=1;
		for(int i=0;i<=1000000;i++)
	{
	    c*=10;
		c%=n;
		ans++;
		if(c==1)break;
	}
	}
	else
	{
		n/=7;
		long long d=1;
	for(int i=0;i<=1000000;i++)
	{   d*=10;
		d%=n;
		ans++;
		if(d==1)break;
	}
	}
	if(ans>1000000)
	cout<<"-1"<<endl;
	else
	cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;

#define INF (1e9)
ll MOD = 1e9 + 7;

ll N, K;

int main() {
    cin >> N >> K;

    vi A(N);
    vi B(2001, 0);
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        B[A[i]]++;
        for (int j = 2000; j > A[i]; j--) {
            ans += B[j];
        }
    }

    ans *= K;
    ans %= MOD;

    vi C(2001, 0);
    for (int i = 2000; i > 0; i--) {
        C[i - 1] = C[i] + B[i];
    }

    ll tmp = K * (K - 1) / 2;
    tmp %= MOD;
    for (int i = 0; i < N; i++) {
        ans += tmp * C[A[i]];
        ans %= MOD;
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int a,b,c;cin>>a>>b>>c;
    if(a+b==c || b+c==a || c+a==b) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  double w,h,x,y;
  cin >> w >> h >> x >> y;
  cout << w*h/2 << " ";
  if (x*2 == w && y*2 == h){
    cout << 1 << endl;
  }
  else cout << 0 << endl;
}

Measured memory_bytes: 256
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect

while(True):
    after_string_list = []
    before_string_list = []
    convert_list = {}

    n = int(input())
    if n == 0:
        break

    for i in range(n):
        convert = list(input().split())
        convert_list[convert[0]] = convert[1]

    m = int(input())
    for i in range(m):
    	before_string_list.append(input().rstrip())

    for c in before_string_list:
    	if c in convert_list:
    		after_string_list.append(convert_list[c])
    	else:
    		after_string_list.append(c)
    print("".join(after_string_list))

Measured memory_bytes: 18588
N = int(input())
flag = 0
cou = N//4 +1

if N < 4:
    print("No")

else:
    for i in range(cou):
        N2 = N - 4*i

        if N2 < 0:
            break

        elif N2 % 7 == 0:
            print("Yes")
            flag = 1
            break

        else:
            continue 

    if flag == 0:
        print("No")
        

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)998244353;

int n;
string s;
vector<int> vec, vec2;
long long cnt[200009], ans;

bool fun(int len)
{
	for (int i = 0; i < n; i++) {
		char c = s[i%len];
		if ((i / len)%2) {
			if (c == '1') c = '0';
			else c = '1';
		}
		if (s[i] < c) return false;
		else if (s[i] > c) return true;
	}
	return true;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> s;
	for (int i = 1; i <= n; i += 2) {
		if (n%i == 0) vec.pb(i);
	}
	for (int i = 0; i < (int)vec.size(); i++) {
		int cur = n/vec[i];
		vec2.pb(cur);
		long long un = 1;
		for (int j = cur - 1; j >= 0; j--) {
			if (s[j] == '1') {
				cnt[cur] += un;
				cnt[cur] %= MOD;
			}
			un *= 2;
			un %= MOD;
		}
		if (fun(cur)) {
			cnt[cur] ++;
			cnt[cur] %= MOD;
		}
	}
	sort(vec2.begin(), vec2.end());
	for (int i = 0; i < (int)vec2.size(); i++) {
		int ti = vec2[i];
		for (int j = i + 1; j < (int)vec2.size(); j++) {
			int tj = vec2[j];
			if (tj % ti == 0) {
				cnt[tj] = cnt[tj] - cnt[ti] + MOD;
				cnt[tj] %= MOD;
			}
		}
		ans += cnt[ti]*ti*2;
		ans %= MOD;
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int mod = 1e9 + 7;
const int inf = 2e18;

signed main() {
    string S, T;
    cin >> S >> T;
    vector<vector<int>> dp(T.length() + 1, vector<int>(S.length() + 1, 0));
    for (int i = 1; i <= T.length(); i++) {
        for (int j = 1; j <= S.length(); j++) {
            if (T[i - 1] == S[j - 1]) {
                dp[i][j] = max(dp[i][j - 1], dp[i - 1][j - 1] + 1);
            } else {
                dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
            }
        }
    }
    string ans = "";
    int s = S.length();
    int t = T.length();
    while (s > 0 && t > 0) {
        if (dp[t][s] <= dp[t - 1][s]) {
            --t;
        } else if (dp[t][s] == dp[t][s - 1]) {
            --s;
        } else {
            --s;
            --t;
            ans += S[s];
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;

}



Measured memory_bytes: 70784
import bisect
N,K=map(int,input().split())
A=list(map(int,input().split()))
index=[0]
index.append(A[0]-1)
tt=[A[0]-1]
flag=0
count=0
for _ in range(1,K):
    t=index[-1]
    ttt=bisect.bisect_left(tt, A[t]-1)

    if len(tt) > ttt and tt[ttt]==A[t]-1:
        index.append(A[t]-1)
        flag=1
        break
    index.append(A[t]-1)
    bisect.insort(tt,A[t]-1)
if flag==0:
    print(index[-1]+1)
    exit()
#print("a")
#print(index)
check = index[-1]
for i,c in enumerate(index):
    if c==check:
        a_path=i
        break
K-=a_path
t=len(index)-1-a_path
print(index[a_path+K%t]+1)



Measured memory_bytes: 106248
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fir first
#define sec second
typedef long long ll;
////////////////////////////////////////////////////////////

vector<pair<int,int>> seikika( vector<int> &v ){
	map<int,int> mp;
	int num = 1;
	vector<pair<int,int>> r(100010);
	rep(i,0,v.size()){
		if( mp[v[i]] == 0 ){
			mp[v[i]] = num++;
			r[mp[v[i]]] = pair<int,int> (0, v[i] );
		}
		r[mp[v[i]]].fir++;
	}
	return r;
}

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

	vector<int> vg(n/2),vk(n/2);

	rep(i,0,n){
		if(i%2) cin >> vk[i/2];
		else cin >> vg[i/2];
	}

	/*
	cout << "vg:";
	rep(i,0,n/2) cout << vg[i] << " ";
	cout << endl;

	cout << "vk:";
	rep(i,0,n/2) cout << vk[i] << " ";
	cout << endl;
	*/
	vector<pair<int,int>> sk=seikika(vk);
	vector<pair<int,int>> sg=seikika(vg);

	vsort(sk); vsort(sg);
	reverse(sk.begin() , sk.end());
	reverse(sg.begin() , sg.end());

	/*
	rep(i,0,n/2) cout << "<"<<sg[i].fir<<","<<sg[i].sec<<">";
	cout << endl;
	rep(i,0,n/2) cout << "<"<<sk[i].fir<<","<<sk[i].sec<<">";
	cout << endl;
	*/
	if( sk[0].sec == sg[0].sec ){
		//cout << "swap" << endl;
		if( sk[1].fir < sg[1].fir ) swap(sg[0],sg[1]);
		else swap(sk[0],sk[1]);
	}

	int ck = 0 , cg = 0;
	for(int i = 1 ; sk[i].fir != 0 ; i++ ) ck += sk[i].fir;
	for(int i = 1 ; sg[i].fir != 0 ; i++ ) cg += sg[i].fir;

	cout << ck + cg << endl;

	ret 0;
}

Measured memory_bytes: 4608
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio{
  int it,len;
  char s[LEN + 5];
  fastio(){
    it = len = 0;
  }
  char get(){
    if(it < len) return s[it++];
    it = 0, len = fread(s,1,LEN,stdin);
    return len ? s[it++] : EOF;
  }
  bool notend(){
    char c;
    for(c = get();c == ' ' || c == '\n';c = get());
    if(it) it--;
    return c != EOF;
  }
  void put(char c){
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush(){
    fwrite(s,1,it,stdout);
  }
}buff,bufo;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll(){
  char c; ll res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char(){
  char c;
  for(c = buff.get();c == ' ' || c == '\n';c = buff.get());
  return c;
}
#define maxn 100005
typedef pair <int,int> P;
const int inf = 0x3f3f3f3f;
int n;
P arms[maxn]; // r,l.
int main(){
  n = getint();
  for(int i = 1;i <= n;i++){
    int x = getint(), l = getint();
    arms[i].first = x + l, arms[i].second = x - l;
  }
  sort(arms + 1,arms + n + 1);
  int ed = -inf, ans = 0;
  for(int i = 1;i <= n;i++){
    if(ed <= arms[i].second){
      ans++;
      ed = arms[i].first;
    }
  }
  putint(ans,'\n');
  bufo.flush();
  return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int N,K;
	cin>>N>>K;

	int LIM=(N-1)*(N-2)/2;
	if(LIM<K){
		cout<<-1<<endl;
		return 0;
	}

	vpint ans;
	rep(i,N-1)ans.eb(i,N-1);
	
	int num=LIM-K;
	for(int i=0;i<N-1;i++){
		for(int j=i+1;j<N-1;j++){
			if(num==0)break;
			ans.eb(i,j);
			num--;
		}
	}
	cout<<ans.size()<<endl;
	for(auto &pr:ans)cout<<pr.fi+1<<" "<<pr.se+1<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
    int N,L;
    cin>>N>>L;
    string S[N];
    for(int i=0;i<N;++i)cin>>S[i];

    sort(S,S+N);
        for(int i=0;i<N;++i)cout<<S[i];

    
}

Measured memory_bytes: 3116
function Main(input) {
  var r = 0;
  const s = input.toString();
  if (s[0] === '1') r++;
  if (s[1] === '1') r++;
  if (s[2] === '1') r++;
  console.log(r);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int N,K;
    cin>>N>>K;
    long long int arr[N];
    long long int sum = 0;
    for(int i = 0;i<N;i++){
        cin>>arr[i];
        sum+=arr[i];
    }
    sort(arr,arr+N);
    if(K>=N){
        cout<<0<<endl;
    }
    else {
        for(int i = N-K;i<N;i++){
            sum-=arr[i];
        }
        cout<<sum<<endl;
    }
}

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

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

	/*

	A
	001111B
	001111
	110000
	110000
	110000

	*/
	int H, W, A, B;
	scanf("%d %d %d %d", &H, &W, &A, &B);

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if ((i < B) ^ (j < A)) {
				cout << 1;
			} else {
				cout << 0;
			}
		}
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 1280
import java.util.*;

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

      int n = Integer.parseInt(sc.next());

      int[] a = new int[n];

      for(int i=0;i<n;i++){
        a[i] = Integer.parseInt(sc.next());
      }

      String ans = "No";

      Arrays.sort(a);

///////////////////////////////////////////////
if(a[n-1]==0){
  ans ="Yes";
}
///////////////////////////////////////////////

///////////////////////////////////////////////
if(n%3==0 && a[n/3-1]==0 && a[n/3]==a[n-1]){
  ans ="Yes";
}
///////////////////////////////////////////////

///////////////////////////////////////////////
int c = a[0]^a[n/3]^a[n-1];
if(n%3==0 && a[0]==a[n/3-1] && a[n/3]==a[2*n/3-1] && a[2*n/3]==a[n-1] && a[0]!=a[n/3] && a[n/3]!=a[n-1] & c==0){

    ans ="Yes";
}
///////////////////////////////////////////////


      System.out.println(ans);

    }
}


Measured memory_bytes: 46192
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<queue>
#define LL long long
using namespace std;
inline LL read( )
{
  LL sum=0;char c=getchar( );bool f=0;
  while(c<'0'||c>'9') {if(c=='-') f=1;c=getchar( );}
  while(c>='0'&&c<='9') {sum=sum*10+c-'0';c=getchar( );}
  if(f) return -sum;
  return sum;
}
LL n;int len;bool p[202];
int main( )
{
  n=read( )+1;
  while(n!=1)
    {
      if(n&1) n--,p[++len]=1;
      else n>>=1,p[++len]=0;
    }
  printf("%d\n",len<<1);
  int i;deque<int>q;
  for(i=len;i>=1;i--)
    p[i]?q.push_front(len-i+1):q.push_back(len-i+1);
  while(!q.empty( )) 
    printf("%d ",q.front( )),q.pop_front( );
  for(i=1;i<=len;i++) printf("%d ",i);
  return 0;
}
     

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;

int main(){
  int n,m; cin >> n >> m;
  string big[n];
  rep(i,n) cin >>  big[i];
  string small[m];
  rep(i,m) cin >> small[i];

  string ans = "No\n";

  rep(i,n-m+1){
    rep(j,n-m+1){
      bool frag = true;
      rep(k,m) rep(l,m){
        if(big[i+k][j+l] != small[k][l]) frag = false;
      }
      if(frag) ans = "Yes\n";
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
N = int(input())
X=list(map(int, input().split()))

sorted_X=sorted(X)
med1=sorted_X[N//2-1]
med2=sorted_X[N//2]
#print(med1, med2)
for i in range(N):
    if X[i]<=med1:
        print(med2)
    elif X[i]>=med2:
        print(med1)

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

#define null               ""
#define all(dat)           dat.begin(), dat.end()
#define over(msg)          cout << msg << endl, exit(0);
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

int n, a, b;

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> a >> b;
    cout << min(a, b) << ' ' << max(a + b - n, 0) << endl;
}


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

using namespace std;

#define int long long
#define PB push_back
#define MP make_pair
#define ALL(V) V.begin(), V.end()
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> pipi;

constexpr int INF = 1LL << 60;
constexpr int MOD = 1000000007;
constexpr int MAX_N = 105;
constexpr int dx[] = { 0, 1, 0, -1 };
constexpr int dy[] = { 1, 0, -1, 0 };

int n, d[MAX_N], a[MAX_N], mem[MAX_N][40330];
vector<vector<int>> perm;
map<vector<int>, int> dic;

int Solve(int i, int j) {
    if (i == n) return 0;
    if (mem[i][j] != -1) return mem[i][j];

    int res = 0, ai = 0;
    vector<int> cur = perm[j];
    int er = 0;
    for (int k = 0; k < cur.size(); ++k) {
        cur[k]--;
        if (cur[k] == 0) er = k;
    }
    for (int k = 0; k < er; ++k) {
        if (n < i + cur[k] || d[i + cur[k]] < cur[k]) continue;
        ai += a[i + cur[k]];
    }
    for (int k = er + 1; k < cur.size(); ++k) {
        if (d[i] < cur[k] || n < i + cur[k]) continue;
        ai += a[i];
    }
    cur.erase(cur.begin() + er);
    for (int k = 0; k <= 8; ++k) {
        vector<int> tmp = cur;
        tmp.insert(tmp.begin() + k - (er < k ? 1 : 0), 8);
        res = max(res, Solve(i + 1, dic[tmp]) + ai);
    }

    return mem[i][j] = res;
}

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

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

    vector<int> hoge(8);
    for (int i = 1; i <= 8; ++i) hoge[i - 1] = i;
    int idx = 0;
    do {
        perm.PB(hoge);
        dic[hoge] = idx++;
    } while (next_permutation(ALL(hoge)));

    memset(mem, -1, sizeof(mem));
    int ans = 0;
    for (int i = 0; i < idx; ++i) {
        ans = max(ans, Solve(1, i));
    }

    cout << ans << endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> hs(N);
  for (int i=0; i<N; i++)
    cin >> hs.at(i);
  sort(hs.begin(), hs.end());
  int minh=-1;
  for (int i=0; i<N-K+1; i++)
    if (minh==-1 || minh > hs.at(i+K-1)-hs.at(i))
      minh = hs.at(i+K-1)-hs.at(i);
  cout << minh << endl;
}

Measured memory_bytes: 640
// #include <bits/stdc++.h>
#include <map>
#include <set>
#include <ctime>
#include <cstring>
#include <queue>
#include <iostream>
#include <algorithm>
using namespace std;
 
#define mod 1000000007
#define INF 1000000000

#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define all(x) begin(x), end(x)
#define len(x) ((int)(x).size())
#define contains(a, x) (a.find(x) != end(a))
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define F(i,a,b) for(int i = (int)(a); i < (int)(b); ++i)
#define RF(i,a,b)for(int i = (int)(a); i >= (int)(b); --i)

using dbl = double;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvl = vector<long long>;
using pi = pair<int,int>;

#define fast() {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define log(x) cout << (x) << endl;



int n,m,a,b;
set<int> seen;
map<int,vi> graph;

int dfs(int v) {
	if (len(seen) == n)
		return 1;

	int res = 0;
	for (auto node: graph[v]) {
		if (contains(seen, node))
			continue;
		seen.emplace(node);
		res += dfs(node);
		seen.erase(node);
	}

	return res;
}

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

	rep (i, m) {
		cin>>a>>b;
		graph[a].eb(b);
		graph[b].eb(a);
	}

	seen.emplace(1);
	log(dfs(1));

	return 0;
}





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

typedef long long int ll;
set <ll> divi_n;
ll l;

void printDivisors(ll n,ll fl) 
{ 
    // Note that this loop runs till square root 
    for (ll i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
	        
        	if(fl == 0)
        	{
	           // If divisors are equal, print only one 
	            if (n/i == i) 
	                divi_n.insert(i); 
	  
	            else // Otherwise print both 
	            {
	            	divi_n.insert(i);
	            	divi_n.insert(n/i);

	            }
	        }
	        else
	        {
	        	if (n/i == i) 
	            {
	            	if(divi_n.find(i) == divi_n.end())
	            	{
	            		l++;
	            	}
	            }	  
	            else // Otherwise print both 
	            {
	            	if(divi_n.find(i) == divi_n.end())
	            	{
	            		l++;
	            	}
	            	if(divi_n.find(n/i) == divi_n.end())
	            	{
	            		l++;
	            	}
	            	

	            }

	        } 
        } 
    } 
} 



int main()
{
	ll i,j,k,m,n;

	cin >> n;

	if(n==2)
	{
		cout << 1 << '\n';
		return 0;
	}

	l = 0;

	printDivisors(n,0);
	printDivisors(n-1,1);
	// k = divi_n_1.size();


	// l = (k-j);

	set <ll>::iterator itr;

	for(itr = divi_n.begin();itr!=divi_n.end();itr++)
	{
		k = *itr;

		// cout << k << '\n';

		if(k==1)
		{
			continue;
		}

		j = n;

		while(j%k == 0)
			j = j/k;

		if(j%k==1)
			l++;
	}
	cout << l << '\n';
	// for(i=2;i<=sqrt(n);i++)
	// {
	// 	j = n;
	// 	m = 0;
	// 	while(j>0)
	// 	{
	// 		k = j%divi_n[i];
	// 		if(k != 1 && k != 0)
	// 		{
	// 			m = 1;
	// 			break;
	// 		}
	// 		j = j/divi[i];

	// 		// cout << k << '\n';

	// 	}

	// 	if(m == 0)
	// 	{
	// 		cout << i << '\n';
	// 		l++;
	// 	}
	// }
	// cout << l << '\n';




}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,abc;
  cin >> a;
  cin >> b;
  cin >> c;

  abc = c - (a - b);
 if(abc <= 0){
   cout << 0;
  }else{
    cout << abc;
  }
}

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

int main(void){
  int n, m;
  cin >> n >> m;
  vector<string> dataset; 
  dataset.resize(n, "");
  
  for(int i = 0; i < n; i++){
    cin >> dataset[i];
  }
  for(int i = 0; i < n; i++){
    int count = 0;
    for(int j = 0; j < m ; j++){
      if(dataset[i][j] == '.'){
        count++;
      }
    }
    if(count==m){
      for(int j = 0; j < m ; j++){
        dataset[i][j] = 'x';
      }
    }
  }
  for(int i = 0; i < m; i++){
    int count = 0;
    for(int j = 0; j < n ; j++){
      if(dataset[j][i] == '.' || dataset[j][i] == 'x'){
        count++;
      }
    }
    if(count==n){
      for(int j = 0; j < n ; j++){
        dataset[j][i] = 'x';
      }
    }
  }
  
  for(int i = 0; i < n; i++){
    int flag = 0;
    for(int j = 0; j < m ; j++){
      if(dataset[i][j] != 'x'){
        cout << dataset[i][j];
        flag = 1;
      }
    }
    if(flag == 1){
      cout << endl;
    }
  }
}

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

int main(){
	int N;
	cin>>N;
	vector<int>A(N);
	vector<int>sa;
	for(int i=0;i<N;++i){
		cin>>A[i];
		if(i==0)sa.push_back(A[0]);
		if(i!=0)sa.push_back(A[i]-A[i-1]);
	}
	sa.push_back(-A[N-1]);
	/*
	for(int i=0;i<N;++i){
		cout<<A[i]<<" ";
	}
	cout<<endl;
	for(int i=0;i<=N;++i){
		cout<<sa[i]<<" ";
	}
	cout<<endl;
	*/
	int trueans=0;
	for(int i=0;i<=N;++i){
		trueans+=abs(sa[i]);
	}
	vector<int>ans;
	for(int i=0;i<N;++i){
		ans.push_back(trueans-((abs(sa[i])+abs(sa[i+1]))-abs(sa[i]+sa[i+1])));
	}
	for(int i=0;i<N;++i){
		cout<<ans[i]<<endl;
	}
}


Measured memory_bytes: 2552
#include <iostream>

int main()
{
    int W, H, x, y, r;

    std::cin >> W >> H >> x >> y >> r;

    if( (x - r) >= 0 &&
        (y - r) >= 0 &&
        (x + r) <= W &&
        (y + r) <= H)
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }
    return 0;
}

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

using namespace std;

const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const int MAXN = 2e5+10;
const int INF = 0x3f3f3f3f;
struct Edge
{
    int v;
    int cost;
    Edge(int _v = 0, int _cost = 0) : v(_v), cost(_cost) {}
};
vector<Edge> E[MAXN];
void addEdge(int u, int v, int w)
{
    E[u].push_back(Edge(v, w));
}
bool vis[MAXN]; // 在队列标志
int cnt[MAXN]; // 每个点的⼊列队次数
int dist[MAXN];
bool SPFA(int start, int n)
{
    memset(vis, false, sizeof(vis));
    memset(dist, 0x3f, sizeof(dist));
    vis[start] = true;
    dist[start] = 0;
    queue<int> que;
    while (!que.empty())
    {
        que.pop();
    }
    que.push(start);
    memset(cnt, 0, sizeof(cnt));
    cnt[start] = 1;
    while (!que.empty())
    {
        int u = que.front();
        que.pop();
        vis[u] = false;
        for (int i = 0; i < E[u].size(); i++)
        {
            int v = E[u][i].v;
            if (dist[v] > dist[u] + E[u][i].cost)
            {
                dist[v] = dist[u] + E[u][i].cost;
                if (!vis[v])
                {
                    vis[v] = true;
                    que.push(v);
                    if (++cnt[v] > n)
                    {
                        return false; // cnt[i]为⼊队列次数，⽤来判定是否存在负环回路
                    }
                }
            }
        }
    }
    return true;
}


int main(){
    //freopen("input.txt","r",stdin);
    int k;
    cin>>k;
    int cnt=0;
    for(int i=1;i<k;i++){
        addEdge(i,(i+1)%k,1);
        addEdge(i,i*10%k,0);
        cnt+=2;
    }
    SPFA(1,cnt);
    cout<<dist[0]+1<<endl;
    return 0;
}

Measured memory_bytes: 9984
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n,mod=2019;
char c[200010];
map<int,int> M;
vector<pair<int,int> > ans;
int fpm(int x,int y){
	int sum=1;
	while(y){
		if(y&1)sum=1ll*sum*x%mod;
		x=1ll*x*x%mod;
		y>>=1;
	}
	return sum;
}
long long dp[200010];
int main(){
//	freopen("d.in","r",stdin);
//	freopen("d.out","w",stdout);
	scanf("%s",c+1);
	n=strlen(c+1);
	int num=0;
	M[0]=n+1;
	int last=n+1;
	for(register int i=n;i>=1;i--){
		(num=num+(c[i]-'0')*fpm(10,n-i))%=mod;
		if(M[num]){
			ans.push_back(make_pair(i,M[num]-1));
		}
		M[num]=i;
	}
	sort(ans.begin(),ans.end());
	long long anss=0;
	for(register int i=0;i<=n;i++)dp[i]=1;
	for(register int i=0;i<ans.size();i++){
		long long w=dp[ans[i].first-1];		
		dp[ans[i].second]+=w;
		anss+=w;
	}
	printf("%lld\n",anss);
	return 0;
}

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

/*-------------------Define Start-------------------*/
typedef bool BL;                        // 布尔类型
typedef char SB;                        // 有符号1字节,8位
typedef unsigned char UB;                // 无符号1字节,8位
typedef short SW;                        // 有符号短整型,16位
typedef unsigned short UW;                // 无符号短整型,16位
typedef long SDW;                        // 有符号整型,32位
typedef unsigned long UDW;               // 无符号整型,32位
typedef long long SLL;                    // 有符号长整型,64位
typedef unsigned long long ULL;            // 无符号长整型,64位
typedef char CH;                        // 单个字符
typedef float R32;                        // 单精度浮点数
typedef double R64;                        // 双精度浮点数

#define Rep(i, n) for (register SDW i = 0; i < (n); ++i)
#define For(i, s, t) for (register SDW i = (s); i <= (t); ++i)
#define rFor(i, t, s) for (register SDW i = (t); i >= (s); --i)
#define foreach(i, c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,0x7f,sizeof(a))
#define LOWBIT(x) ((x)&(-x))

#define MP make_pair
#define PB push_back
#define ft first
#define sd second
#define ALL(x) x.begin(),x.end()

#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl

#define lson l , mid , rt << 1 
#define rson mid + 1 , r , rt << 1 | 1

const ULL mod = 1e9 + 7;                //常用模数(可根据题目需要修改)
const ULL inf = 0x7fffffff;                //用来表示无限大
const ULL infLL = 0x7fffffffffffffffLL;    //用来表示无限大
/*-------------------Define End-------------------*/

const UDW maxN = 5e5 + 7;
SDW N, Q;
string S; 
SDW ans;

void output();

SDW st[maxN << 2];
    
inline void pushUp(SDW rt) {
    st[rt] = st[rt << 1] | st[rt << 1 | 1];
}

// 单点更新 
inline void update(SDW x, SDW y, SDW l, SDW r, SDW rt) {
    if(l >= r) {
        st[rt] = y;
        return;
    }
    SDW mid = (l + r) >> 1;
    if(x <= mid) update(x, y, lson);
    else update(x, y, rson);
    pushUp(rt);
}

// 区间查询 
inline SDW query(SDW L, SDW R, SDW l, SDW r, SDW rt) {
    if(L <= l && r <= R) return st[rt];
    SDW ret = 0;
    SDW mid = (l + r) >> 1;
    
    if(L <= mid) ret |= query(L, R, lson);
    if(R > mid) ret |= query(L, R, rson);
    return ret;
}

void input(){
	cin >> N >> S >> Q;
	S = "#" + S;
	For(i, 1, N) {
		update(i, (1 << (S[i] - 'a')), 1, N, 1);
	}
}

void solve(){
	SDW mode;
	
	Rep(i, Q) {
		cin >> mode;
		if(mode == 1) {
			SDW x;
			CH y;
			cin >> x >> y;
			update(x, (1 << (y - 'a')), 1, N, 1);
		}
		else if(mode == 2) {
			SDW x, y;
			cin >> x >> y;
			ans = query(x, y, 1, N, 1);
			ans = __builtin_popcount(ans);
			output();
		}
	}
}

void output(){
    cout << ans << endl;
}

int main() {
    input();
    solve();
    return 0;
}

Measured memory_bytes: 11160
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll W;
    cin >> W;

    vl weight;
    weight.pb(1);
    for(ll i = 6; i <= W; i *= 6) {
        weight.pb(i);
    }
    for(ll i = 9; i <= W; i *= 9) {
        weight.pb(i);
    }

    ll n = weight.size();

    vl dp(W+1, INF);  // 重さがjとなるときの価値の総和の最小値
    dp[0] = 0;
    rep(i, n) {
        for(ll j = weight[i]; j <= W; j++) {
            chmin(dp[j], dp[j - weight[i]] + 1);
        }
    }
    
    out(dp[W]);
    re0;
}

Measured memory_bytes: 1024
li=list(input())
a=int(li[0]+li[1])
b=int(li[2]+li[3])

if (a==0 or a>12) and 1<=b<=12:
    print('YYMM')
elif 1<=a<=12 and (b==0 or b>12):
    print('MMYY')
elif 1<=a<=12 and 1<=b<=12:
    print('AMBIGUOUS')
else:
    print('NA')


Measured memory_bytes: 3064
-- AtCoder My Practice
-- author: Leonardone @ NEETSDKASU
 
-- 解説読後
-- http://agc004.contest.atcoder.jp/data/agc/004/editorial.pdf

 
import Data.Array (listArray, accum, (!))
 
main = print . solve . map read . words =<< getContents
 
solve (n:x:a) = ans where
    sm = sum a
    aa = listArray (0, n - 1) a
    ans = f n sm aa
    f 1 r _  = r
    f c r ar = f (c - 1) r2 ar2 where
        ar2 = accum min aa [(i, ar ! (mod (i + n - 1) n)) | i <- [0 .. n - 1]]
        r2 = minimum [r, (n - c + 1) * x + sum ar2]


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

using namespace std;

int main()
{
    //freopen("cbarn.out", "w", stdout) ;
    //freopen("cbarn.in", "r", stdin) ;
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(0);
    long long a;
    cin>>a;
    long long s=ceil((double)sqrt(a));
    for(int i=s;i>0;i--)
    {
        if(a%i==0)
        {
            cout<<((i)+(a/i))-2;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
mod = 10**9 + 7
count = 0
for n in range(K, N+2):
  maxSum = (n*(N + N-n+1))//2
  minSum = (n*(n-1))//2
  count += maxSum - minSum + 1
  count %= mod

print(count)

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

int main(){
	int next[7][2] = {{1,3},{6,2},{4,5},{1,6},{5,3},{3,1},{6,6}};
	string s;
	while(cin >> s){
		if(s == "#") break;
		int pos = 0;
		for(int i = 0;i < s.length();i++){
			pos = next[pos][s[i] - '0'];
		}
		if(pos == 5) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3108
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int S = sc.nextInt();
		int W = sc.nextInt();



		if(S == W || S < W) {
			System.out.println("unsafe");
		}

		else {
			System.out.println("safe");
		}

		sc.close();
	}

}


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


using ll = long long;
const int Mod = 1e9+7;
const int L = 2e5+10;
int inv[L];


ll powmod(ll a, ll b, ll m) {
    ll c = 1;
    for (; b; b >>= 1, a = (ll)a * a % m) {
        if (b & 1) c = c * a % m;
    }
    return c;
}


void exgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0) {x = 1, y = 0; return;}
    exgcd(b, a % b, y, x);
    y -= a / b * x;
}


ll invmod(ll a, ll m) {
    ll x, y;
    exgcd(a, m, x, y);
    return (x % m + m) % m;
}


ll binomial(int n, int m)
{
    ll ans = 1;
    for (int i = 1; i <= m; i++) {
        //ans = ans * (n - i + 1) % Mod * invmod(i, Mod) % Mod;
        ans = ans * (n - i + 1) % Mod * inv[i] % Mod;
    }
    return ans;
}


int main()
{
    int n, a, b;
    cin >> n >> a >> b;

    inv[0] = inv[1] = 1;
    for (int i = 2; i <= b; i++) inv[i] = (Mod - Mod / i) * (ll)inv[Mod % i] % Mod;
    ll ans = (powmod(2, n, Mod) - 1 + Mod) % Mod;
    ans = ((ans - binomial(n, a) - binomial(n, b)) % Mod + Mod) % Mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{

    //freopen("input.txt", "r", stdin);


    string s;
    cin >> s;
    int n = (int)s.size();

    string t = "keyence";

    int cntS = 0;
    while(cntS < 7 && s[cntS] == t[cntS]) ++cntS;
    int cntE = 0;
    while(cntE < 7 && s[n - 1 - cntE] == t[6 - cntE]) ++cntE;
    
    if (cntS + cntE >= 7)
        cout << "YES";
    else
        cout << "NO";

}


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

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const int north = -1;
const int west = 1;
int pow2(int a, int b) {
	if (b == 0)return 1;

	int res = pow2(a*a, b / 2);
	if (b & 1)res *= a;
	return res;
}
int gcd(int x, int y) {

	return y == 0 ? x : gcd(y, x%y);
}
signed main() {
	string s;
	while (cin >> s, s != "#") {
		vector<int>v;
		rep(i, 0, s.size()) {
			if (s[i] == 'n')v.push_back(north);
			else if (s[i] == 'w')v.push_back(west);
		}
		int bo, shi;
		bo = pow2(2, v.size() - 1);
		shi = pow2(2, v.size() - 1)*(v.back() == north ? 0 : 90);
		dump(bo);
		dump(shi);
		rep(i, 0, v.size() - 1) {
			shi += pow2(2, i)*v[i] * 90;
		}
		int g = gcd(shi, bo);
		bo /= g;
		shi /= g;
		cout << shi;
		if (bo != 1)cout << '/' << bo;
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3028
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
using namespace std;

int main(void)
{
    int n,a,q;
    cin >> n >> a;
    q = n % 500;
    if(q > a){cout << "No" << endl;}
    else{cout << "Yes" << endl;}
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define MAX 100000
using namespace std;
int n,k;
long long T[MAX];
int check(long long p)
{
  int i = 0 ;
  for(int j = 0;j<k;j++)
  {
    long long s = 0;
    while (s+T[i] <= p)
    {
      s += T[i];
      i++;
      if(i == n) return n ;
    }
  }
  return i ;
}
int solve()
{
  int left = 0;
  int right = 100000*10000;
  int mid;
  while(right-left>1)
  {
    int mid = (right+left)/2;
    int v = check(mid);
    if(v>=n) right = mid;
    else left = mid;
  }
  return right;
}
int main ()
{
  cin>>n>>k;
  for(int i = 0;i<n;i++)
     cin>>T[i];
  long long ans = solve();
  cout<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 3800
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

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


int main(void) {

	int n;

	cin >> n;
	vector<string> s(n + 1);

	FOR(i, 1, n) {
		cin >> s[i];
	}

	FOR(i, 1, n) {
		
		int a = 0;
		int deep = 0;
		int nowdeep = 0;

		FOR(j, 0, s[i].size() - 1) {
			if (s[i][j] == '[') {
				deep++;
			}
			else {
				break;
			}
		}

		vector< priority_queue<int, vector<int>, greater<int> > > que(deep+1);

		bool flag = false;

		FOR(j, 0, s[i].size() - 1) {
			if (s[i][j] == '[') {
				nowdeep++;
				flag = false;
			}
			else if (s[i][j] >= '0'&&s[i][j] <= '9') {
				a *= 10;
				a += s[i][j] - '0';
				flag = false;
			}
			else if (s[i][j] == ']') {
				if (nowdeep == deep && flag == false) {
					que[nowdeep].push((a/2)+1);
					a = 0;
				}
				if (flag == true) {
					int size;
					int z = 0;
					size = que[nowdeep + 1].size();
					FOR(k, 1, (size) / 2 + 1) {
						z += que[nowdeep + 1].top();
						que[nowdeep + 1].pop();
						//cout << z << endl;
					}
					que[nowdeep].push(z);
					while (!que[nowdeep + 1].empty()) {
						que[nowdeep + 1].pop();
					}
				}

				nowdeep--;
				flag = true;
			}
		}

		cout << que[1].top() << endl;

	}

	
	return 0;
}


Measured memory_bytes: 3248
import Data.Char
import Data.List
import System.IO
import Control.Applicative
import Control.Monad
-- https://hoogle.haskell.org で関数検索

{- お客様の中でHaskellを書ける方はいらっしゃいますか？
    と、Haskellの例がなくて困っていたところを @tanakh さんに助けて頂きました。本当にありがとうございました。-}
main :: IO ()
main = do
    [a,b,c] <- getLine
    yesno (not.same3) [a,b,c]
 
same3 [a,b,c]
    | a==b && b==c = True
    | otherwise         = False       
       
diff3 [a,b,c] 
    | a==b = False
    | b==c = False
    | c==a = False
    | otherwise = True

yesno cond x 
    | cond x      = putStrLn "Yes"
    | otherwise = putStrLn "No"
{-

(+) 3 $ (*) 4 4
-> 19
pure (+) <*> (Just 1) <*> ( Just 3)
-> Just 4

main = do 
    [a,b] <- getIntegerList 
    print $ (a*(a-1)+b*(b-1)) `div` 2
    -- / じゃなくて'div' ！！！！！

main = do
    s <- getLine    
    samecoffee s

samecoffee [x,y,a,b,c,d] 
    | a==b && c==d = do putStrLn "Yes"
    | otherwise         = do putStrLn "No"
samecoffee s = do putStrLn ""
         
putStrLn $ (show c) ++ " " ++ (show a) ++ " " ++ (show b)


main :: IO ()
main = do
    -- 整数の入力
    a <- readLn
    -- スペース区切り整数の入力
    [b, c] <- getIntegerList

    --[b, c] <- map read . words <$> getLine
    -- 文字列の入力
    s <- getLine
    -- 出力
    putStrLn $ show (a + b + c) ++ " " ++ s
-}

-- レイアウト規則

fac 0 = 1
fac n = n * fac (n-1)

-- FileName   : 164a
-- CreatedDate: 2020-04-26 20:56:13

--------------------------------------------  https://atcoder.jp/contests/abc164/submissions/12342628

getIntList        = map (read :: String -> Int) . words <$> getLine
getIntegerList    = map (read :: String -> Integer) . words <$> getLine
getIntegerListN m = map (read :: String -> Integer) <$> replicateM m getLine


base :: Integer
base = 1000000007

plus :: Integer -> Integer -> Integer
plus a b = (a+b) `mod` base

times :: Integer -> Integer -> Integer
times a b = a * b `mod` base

minus :: Integer -> Integer -> Integer
minus a b
   | a < b     = a-b + base
   | otherwise = a-b

power :: Integer -> Integer -> Integer
power n k
   | k == 0         = 1
   | k `mod` 2 == 0 = power (times n n) (k`div`2)
   | otherwise      = times n $! power n (k-1)

inv :: Integer -> Integer
inv n = power n $ base - 2

binom :: Integer -> Integer -> Integer
binom n m
   | (n-m) < m = times (foldr times 1 [m+1..n]) $ inv $ foldr times 1 [1..n-m]
   | otherwise = times (foldr times 1 [n-m+1..n]) $ inv $ foldr times 1 [1..m]



















Measured memory_bytes: 380