akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

int main() {
	int N, K;

	cin >> N >> K;

	if (N > K) {
		if (N%K == 0) {
			cout << "0" << endl;
		}
		else { cout << "1" << endl; 
		}
	}

	else if (N < K) {
		cout << "1" << endl;
	}
	else { cout << "0" << endl; }

	return 0;
}

Measured memory_bytes: 256
def resolve():
	n = int(input())
	ws = [input() for _ in range(n)]
	cnt = []
	for w in ws:
		if w in cnt:
			print('No')
			return
		if len(cnt) and cnt[-1][-1] != w[0]:
			print('No')
			return
		cnt.append(w)
	print('Yes')
resolve()

Measured memory_bytes: 38384
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
	char s[101];
	gets(s);
	int i,l=strlen(s);
	bool b=false;
	for(i=0;i<l;i++)
		if(s[i]=='C')
		{
			b=true;
			break;
		}
	if(b)
		for(b=false;i<l;i++)
			if(s[i]=='F')
			{
				b=true;
				break;
			}
	printf(b?"Yes":"No");
	return 0;
}


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

using namespace std;

int main()
{
    string s;
    cin>>s;
    string t;
    cin>>t;
    int tt=0;
      for(int i=0;i<s.size();i++)
      {
          if(s[i]!=t[i])
          {
              cout<<"No"<<endl;
              return 0;
          }
      }

          cout<<"Yes"<<endl;
}


Measured memory_bytes: 3588
c = gets.to_i
temp = "a"
ac = 0
wa = 0
tle = 0
re = 0
c.times do
  temp = gets.to_s
  if temp == "AC\n"
    ac = ac + 1
  elsif temp == "WA\n"
    wa = wa + 1
  elsif temp == "RE\n"
    re = re + 1
  else
    tle = tle + 1
  end
end
puts "AC x " + ac.to_s
puts "WA x " + wa.to_s
puts "TLE x "+tle.to_s
puts "RE x " + re.to_s


Measured memory_bytes: 14272
k,f =map(int,input().split())
a = list(map(int,input().split()))
a.append(0)
a.sort()
t = a[-1]
s = sum(a[:-1])
if 1 == f:
    print(t-1)
elif t<=s:
    print(0)
else:
    print(t-s-1)


Measured memory_bytes: 3060
N, M = gets.split.map(&:to_i)

a = Array.new(N, 0)
b = Array.new(N, 0)
c = Array.new(N, 0)

M.times do |i|
  ta, tb, tc = gets.split.map(&:to_i)
  a[i] = ta
  b[i] = tb
  c[i] = -tc
end

dist = Array.new(N) { Float::INFINITY }
dist[0] = 0

(N-1).times do
  M.times do |i|
    next if dist[a[i] - 1] == Float::INFINITY
    if dist[b[i] - 1] > dist[a[i] - 1] + c[i]
       dist[b[i] - 1] = dist[a[i] - 1] + c[i]
    end
  end
end

ans = dist[N - 1]
negative = Array.new(N, false)

N.times do
  M.times do |i|
    next if dist[a[i] - 1] == Float::INFINITY
    if dist[b[i] - 1] > dist[a[i] - 1] + c[i]
       dist[b[i] - 1] = dist[a[i] - 1] + c[i]
       negative[b[i] - 1] = true
    end

    if negative[a[i] - 1] == true
       negative[b[i] - 1] = true
    end
  end
end

if negative[N - 1]
  puts('inf')
else
  p(-ans)
end

Measured memory_bytes: 3836
# AOJ 0611: Silk Road
# Python3 2018.7.4 bal4u

import sys
from sys import stdin
input = stdin.readline

INF = 0x7fffffff
n, m = map(int, input().split())
d = [int(input()) for i in range(n)]
c = [int(input()) for i in range(m)]
dp = [[INF for j in range(n+1)] for i in range(m+1)]
dp[0][0] = 0
for i in range(m):
	dp[i+1] = dp[i][0:n+1]
	for j in range(n):
		if dp[i][j] != INF:
			dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j]+c[i]*d[j])
print(dp[m][n])


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define DUP(x, y) (((x) + (y) - 1) / (y))

using ll = std::int64_t;
using vint = std::vector<int>;
using vll = std::vector<ll>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

void Main() {
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];

    sort(ALL(a));
    int ans = INF;

    rep(i, n - 1) {
        ans = min(ans, gcd(a[i], a[i + 1]));
    }
    cout << ans << endl;

}

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



Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =998244353;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    

//解説AC
lint dp[3100][3100];
  int main(){
    lint n,s;
    cin>>n>>s;
    lint a[n];
    rep(i,n)cin>>a[i];
    dp[0][0]=1;
    rep(i,n){
        rep(j,3010){
            dp[i+1][j]+=dp[i][j]*2;
             dp[i+1][j]%=MOD;
            if(j-a[i]>=0)dp[i+1][j]+=dp[i][j-a[i]];
            dp[i+1][j]%=MOD;
        }
    }
    cout<<dp[n][s]<<endl;
  }
 
  
      
      
    
 
  
          
  

Measured memory_bytes: 76320
### coding: UTF-8
import sys

amount = 0

# 安い店から買える最大数分買う。ほしい個数を超えてる場合はほしい個数だけ
[n, m] = map(lambda x: long(x), sys.stdin.readline().split(" "))
for row in sorted([sys.stdin.readline() for _ in range(n)], key=lambda x: long(x.split(" ")[0])):
    [ai, bi] = map(lambda x: long(x), row.strip().split(" "))
    x = bi if m >= bi else m
    amount += ai * x
    m -= x
    if m == 0:
        break

print amount


Measured memory_bytes: 18776
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;
const ll INF = 1061109567;
const double EPS = 1e-10;

int main(){
    ll N,Y;
    cin>>N>>Y;
    int z;

    for(int i=0;i<N+1;i++){
        for(int j=0;j<N+1;j++){
            if(i+j<=N){
                z=N-i-j;
                if((ll)(i*10000+j*5000+z*1000)==Y){
                    cout<<i<<" "<<j<<" "<<z<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}

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

const int maxn = 1e5+3,M=1e9+7;
long long a[3];
int n;
long long dp[maxn][3];

int main() {
    ios::sync_with_stdio(0);
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>a[0]>>a[1]>>a[2];
        for(int u=0;u<3;u++) {
            for(int v=0;v<3;v++) {
                if(u==v) continue;
                dp[i][u] = max(dp[i][u],dp[i-1][v]+a[u]);
            }
        }
    }
    long long ans = max(dp[n][0],dp[n][1]);
    ans = max(ans,dp[n][2]);
    cout<<ans<<endl;
    return 0;
}




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

int main() {
  string s;
  cin >> s ;
  if((s.at(0) == s.at(1))&&(s.at(1) == s.at(2))){
      cout << "No" << endl;
    }
  else {
      cout << "Yes" << endl;
  }
}

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

typedef long long ll;
#define OO 1e9
using namespace std;

int main(){
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  string s, t;
  cin >> s >> t;
  int n = s.size(), m = t.size();
  int LCS[n + 1][m + 1];
  for(int i = 0;i <= n;i++)
    LCS[i][0] = 0;
  for(int i = 0;i <= m;i++)
    LCS[0][i] = 0;
  for(int i = 1;i <= n;i++){
    for(int j = 1;j <= m;j++){
      LCS[i][j] = max(LCS[i - 1][j], LCS[i][j - 1]);
      if(s[i - 1] == t[j - 1])
        LCS[i][j] = max(LCS[i][j], LCS[i - 1][j - 1] + 1);
    }
  }
  int curi, curj;
  curi = n;
  curj = m;
  string res;
  for(int i = 0;i < LCS[n][m];i++){
    while(LCS[curi][curj] != LCS[curi - 1][curj - 1] + 1 || s[curi - 1] != t[curj - 1]){
      if(LCS[curi][curj] == LCS[curi - 1][curj])
        curi--;
      else if(LCS[curi][curj] == LCS[curi][curj - 1])
        curj--;
      else
        assert(false);
    }
    assert(s[curi - 1] == t[curj - 1]);
    res += s[curi - 1];
    curi--;
    curj--;
  }
  reverse(res.begin(), res.end());
  cout << res;
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using product = pair<ll,ll>;
using graph = vector<vector<ll>>;
using vll = vector<ll>;
 
template <class type> void printVector(vector<type> vec){
    stringstream ss;
    for(ll i=0;i<vec.size();i++)
    {
        ss<<vec[i]<<" ";
        if(i!=vec.size()-1)ss<<" ";
    }
    cout<<ss.str()<<endl;
}

void solve(){
    ll N,M;
    cin>>N>>M;
    vll A(N,0);
    priority_queue<ll> que;
    for(ll i=0;i<N;i++){
        ll a;cin>>a;que.push(a);
    }
    for(ll i=0;i<M;i++)
    {
        ll discounted=que.top()/2;
        que.pop();
        que.push(discounted);
    }
    ll res = 0;
    for(ll i=0;i<N;i++)
    {
        res+=que.top();
        que.pop();
    }
    cout<<res;
}
 
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 5100
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<cmath>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  1000007
#define md 1000000007ll
///////////////////////////
///////////////////////////

int main(){
    int n, m;
    I2(n, m);
    int x = max(n, m);
    for(int i= 1; ; i++){
        int x = (i * (i + 1))/2;
        int y = (( i + 1) * ( i+ 2))/2;
        int k = x- n;
        int k1 = y - m;
        if(k >= 0 &&k == k1){
            cout<<k<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
struct pr{
	int dam;bool is_throw;
	bool operator<(const pr&oth)const{return dam<oth.dam;}
};
int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,h; cin>>n>>h;
	vector<pr>v(n+n);
	for(int i=0;i<n+n;++i){
		cin>>v.at(i).dam;
		v.at(i).is_throw=i&1;
	}
	sort(v.rbegin(),v.rend());
	int ans=0;
	for(int i=0;h>0&&i<n+n;++i){
		if(v.at(i).is_throw){
			h-=v.at(i).dam;
			++ans;
		}
		else{
			ans+=(h+v.at(i).dam-1)/v.at(i).dam;
			h=0;
		}
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 4796
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

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

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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int main() {
	string s; cin>>s;
	int n=s.length();

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

	for(int i=0; i<(n-1)/4; i++) {
		if(s.at(i)!=s.at((n-1)/2-1-i)) {
			cout<<"No"<<endl;
			return 0;
		}
	}

	for(int i=0; i<(n-1)/4; i++) {
		if(s.at((n+3)/2-1+i)!=s.at(n-1-i)) {
			cout<<"No"<<endl;
			return 0;
		}
	}

	cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <limits.h>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin>>n;
    
    int w;
    cin>>w;
    
    vector<vector<ll>> count;
    
    vector<ll> v(w+1,0);
    count.push_back(v);
    for(int i =1; i<=n; i++){
        vector<ll> add(w+1);
        count.push_back(add);
    }
    
    
    int id = 1;
    for(int it=0;it<n; it++ ){
        int wei,val;
        cin>>wei>>val;
        for(int i=0; i<=w;i++){
            if(i<wei)
                count[id][i] = count[id-1][i];
            else
                count[id][i] = max(count[id-1][i],val+count[id-1][i-wei]);
        }
        id++;
    }
    
    cout<<count[n][w]<<endl;
    
    return 0;
}

Measured memory_bytes: 80752
from collections import deque

def bfs(s):
    status[s] = VISITING
    signs[s] = 0
    Q.append(s)
    while len(Q) > 0:
        u = Q.popleft()
        for v in rooms[u]:
            if status[v] == NOT_VISITED:
                status[v] = VISITING
                signs[v] = u
                Q.append(v)
        status[u] = VISITED


n, m = map(int, input().split())
rooms = [[] for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    rooms[a-1].append(b-1)
    rooms[b-1].append(a-1)

INFTY = float('inf')
signs = [INFTY] * n

NOT_VISITED = 0
VISITING = 1
VISITED = 2
status = [NOT_VISITED] * n
Q = deque()

bfs(0)
ok = True

for sign in signs:
    if sign == INFTY:
        ok = False

if ok:
    print('Yes')
    signs = signs[1:]
    for sign in signs:
        print(sign + 1)

Measured memory_bytes: 35376
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        String S = sc.next();

        if(S.charAt(5) =='0' && S.charAt(6) =='1'){
	        System.out.println("Heisei");
	    }else if(S.charAt(5) =='0' && S.charAt(6) =='2'){
	        System.out.println("Heisei");
	    }else if(S.charAt(5) =='0' && S.charAt(6) =='3'){
	        System.out.println("Heisei");
	    }else if(S.charAt(5) =='0' && S.charAt(6) =='4'){
	        System.out.println("Heisei");
	    }else{
	        System.out.println("TBD");	        
	    }
	}
}


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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    int k, n;
    cin >> k >> n;
    vector<int> A(n);
    REP(i, n) cin >> A[i];
    int m = k - A[n-1] + A[0];
    for(int i=1; i<n; i++) {
        m = max(m, A[i] - A[i-1]);
    }
    OUT(k - m);
    return 0;
}


Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define mp make_pair

using namespace std;

typedef long long int64;
typedef vector<int> vi;
typedef pair<int, int> ii;

int BUBEN = 60;

class Task {
 public:
  void solveOne(istream &in, ostream &out) {
    int n;
    in >> n;
    vector<vector<int>> a(2 * BUBEN, vector<int>(2 * BUBEN));
    for (int i = 0; i < n; ++i) {
      string s;
      in >> s;
      if (s.find('.') == string::npos) {
        s += ".0";
      }
      int pos = s.find('.');
      string ps = s.substr(0, pos) + s.substr(pos + 1);
      int64 p = 0;
      for (int i = 0; i < ps.size(); ++i) {
        p = p * 10 + (ps[i] - '0');
      }
      int64 q = 1;
      for (int i = pos + 1; i < s.size(); ++i) {
        q *= 10;
      }
      int p2 = 0;
      while (p % 2 == 0) {
        p /= 2;
        ++p2;
      }
      int p5 = 0;
      while (p % 5 == 0) {
        p /= 5;
        ++p5;
      }
      int q2 = 0;
      while (q % 2 == 0) {
        q /= 2;
        ++q2;
      }
      int q5 = 0;
      while (q % 5 == 0) {
        q /= 5;
        ++q5;
      }
      ++a[p2 - q2 + BUBEN][p5 - q5 + BUBEN];
    }
    int64 res = 0;
    for (int i = 0; i < a.size(); ++i) {
      for (int j = 0; j < a.size(); ++j) {
        if (a[i][j] == 0) continue;
        for (int ii = 0; ii < a.size(); ++ii) {
          for (int jj = 0; jj < a.size(); ++jj) {
            if (a[ii][jj] == 0) continue;
            if (i + ii >= 2 * BUBEN && j + jj >= 2 * BUBEN) {
              res += a[i][j] * (int64) a[ii][jj];
            }
          }
        }
        if (i >= BUBEN && j >= BUBEN)
          res -= a[i][j];
      }
    }
    assert(res % 2 == 0);
    res /= 2;
    out << res << "\n";
  }

  void solve(std::istream &in, std::ostream &out) {
    int nt = 1;
    for (int it = 0; it < nt; ++it) {
      solveOne(in, out);
    }
  }
};


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  Task solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

int digits_sum(int num) {
  string s = to_string(num);
  int keta = s.size();

  int sum = 0;
  for (int i = 0; i < keta; i++) {
    sum += s[i] - '0';
  }

  return sum;
}

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

  int n;
  cin >> n;

  int ans = INF;
  for (int a = 1; a < n; a++) {
    int b = n - a;

    int sum = digits_sum(a) + digits_sum(b);

    ans = min(sum, ans);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int main() {
    string s;
    cin >> s;
    if(s == "AAA" || s == "BBB") cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
import math
import numpy as np
Q = int(input())
LR = []
for _ in range(Q):
    LR.append(list(map(int, input().split())))

rmax = max(r for l, r in LR)
primes = np.ones(1 + rmax, int)
for i in range(2, 1 + int(math.sqrt(rmax))):
    if primes[i]:
        primes[2*i::i] = 0
primes[:2] = 0
# like 2017
for i in range(rmax, 0, -2):
    if primes[i] and not primes[(i + 1) // 2]:
        primes[i] = 0
primes[2] = 0
acc = np.cumsum(primes)
for l, r in LR:
    ans = acc[r] - acc[l - 1]
    print(ans)

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

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

#define pb(x) push_back(x)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define INF 2123456789
#define IINF 9123456789123456789

void use_cio() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}
// template <typename... Args>
// void dbg(Args... args) {
//     ((cout << args << " "), ...);
//     cout << endl;
// }
//--------------------------------------------------//
string s;
ll k;
int main() {
    use_cio();
    cin >> s >> k;
    int pv = 0;
    while (s[pv] == '1') pv++;
    if (s[0] != '1') pv = -1;
    if (pv == -1)
        cout << s[0];
    else {
        if (pv < k)
            cout << s[pv];
        else
            cout << 1;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>

int main()
{
	int n;
	scanf("%d", &n);
	long long x[100];
	for (int i = 0; i < n; ++i)
	{
		scanf("%lld", x + i);
	}
	long long ans = 1e18;
	for (long long i = 1; i <= 100; ++i)
	{
		long long cost = 0;
		for (int j = 0; j < n; ++j)
		{
			long long dist = std::abs(x[j] - i);
			cost += dist * dist;
		}
		if (cost < ans)
		{
			ans = cost;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
//void inputer();
int W, H, x, y;


int main() { 
	cin >> W >> H >> x >> y;
	cout << 0.5 * W * H << " ";
	if (x == 0.5 * W && y == 0.5 * H) {
		cout << 1;
	}
	else {
		cout << 0;
	}


	return 0;
}

Measured memory_bytes: 256
a, b = gets.chomp.split.map(&:to_i)

array = []
a.times do
  string = gets
  array << string.chomp.split.map(&:to_i)
end
array = array.sort

i = 0
sum = 0
sum_to = 0
while sum < b
  sum = sum + array[i][1]
  sum_to = sum_to + (array[i][0] * array[i][1])
  i += 1
end
n = sum - b

p sum_to - (n * array[i - 1][0])




Measured memory_bytes: 11128
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define sz(a) (int)a.size() 
#define all(a) a.begin(),a.end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  
#define mt make_tuple 

#define int long long 

const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;

typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}


void solve() {
	int k ; cin >> k;
	string s; cin >> s;

	if(sz(s)<=k) cout << s ;
	else {
		rep(i,0,k) cout << s[i]; cout << "..." ;
	}
}	

int32_t main() {
  

    fast; 
	int t=1;
	// cin>>t;
	rep(i,0,t) {
		solve() ;
	}

	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>

using namespace std;
typedef unsigned long long uLL;
const uLL eps = 1e18;
const uLL N =  1e5+9;
uLL A[N];
int main()
{

   int n;
   cin>>n;
   uLL ans = 1;
   int zero = 0;
   for(int i=0;i<n;i++)
   {
       cin>>A[i];
    if(A[i]==0) zero++;

   }
    if(zero>0)
    {
        printf("0\n");
        return 0;
    }
    for(int i=0;i<n;i++)
    {
        if(A[i]<=eps/ans) ans*=A[i];
        else
        {
            printf("-1\n");
            return 0;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4384
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int a, b;
  cin >> a >> b;
  for(int i= 1; i<=10000; i++){
    if (int(i*0.08) == a and int(i*0.1)==b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
# AOJ 1059 Mysterious Onslaught
# Python3 2018.7.7 bal4u

def calc(b):
	if b == 0: return 0;
	if memo[b] >= 0: return memo[b]
	f = False
	for r1 in range(n):
		for c1 in range(n):
			if b & (1<<(5*r1+c1)):
				f, rr, cc = True, r1, c1
				break
		if f: break
	if not f:
		memo[b] = 0
		return 0

	ans = 25;
	for r2 in range(rr, n):
		for c2 in range(cc, n):
			k = b ^ arr[rr][cc][r2][c2]
			ans = min(ans, calc(k)+1)
	memo[b] = ans
	return ans

memo = [-1]*(1<<25)
arr = [[[[0 for c2 in range(5)] for r2 in range(5)] \
		    for c1 in range(5)] for r1 in range(5)]
for r1 in range(5):
	for c1 in range(5):
		for r2 in range(r1, 5):
			for c2 in range(c1, 5):
				for r in range(r1, r2+1):
					for c in range(c1, c2+1):
						arr[r1][c1][r2][c2] |= (1<<(r*5+c))

while True:
	n = int(input())
	if n == 0: break
	a = [list(map(int, input().split())) for i in range(n)]
	b = 0;
	for r in range(n):
		for c in range(n):
			if a[r][c]: b |= 1 << (5*r+c)
	print("myon"*calc(b))


Measured memory_bytes: 267744
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String former = s.substring(0,2);
    String latter = s.substring(2,4);
    int formerInt = Integer.parseInt(former);
    int latterInt = Integer.parseInt(latter);
    
    if(formerInt == 0){
      if(latterInt == 0 || latterInt > 12){
        System.out.println("NA");
      } else {
        System.out.println("YYMM");
      }
    }
    
    if(formerInt >0 && formerInt <= 12){
      if(latterInt == 0 || latterInt > 12){
        System.out.println("MMYY");
      }else{
        System.out.println("AMBIGUOUS");
      }
    }
    
    if(formerInt >12){
      if(0<latterInt && latterInt<=12){
        System.out.println("YYMM");
      }else{
        System.out.println("NA");
      }
    }
  }
}

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


int main() {
    int N;
    cin >> N;
    int V[100], C[100];
    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }
    int ans = 0;

    for (int i = 0; i < N; i++) {
        int diff = V[i] - C[i];
        if (diff > 0)
            ans += diff;
    }
    cout << ans << '\n';

}


Measured memory_bytes: 256
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i
n %= 10 # =
if n == 3
  puts 'bon'
elsif [0,1,6,8].include? n
  puts 'pon'
else
  puts 'hon'
end



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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

vs field;
int w,h;
int dfs(int y, int x)
{
  int cnt=1;
  field[y][x]='#';
  rep(i,4)
  {
    int nx=x+dx[i], ny=y+dy[i];
    if(nx<w&&0<=nx&&ny<h&&0<=ny&&field[ny][nx]=='.')
    {
      cnt+=dfs(ny,nx);
    }
  }
  return cnt;
}

signed main() 
{
  while(cin>>w>>h, w||h)
  {
    field.clear(); //初期化！！
    string s;
    rep(i,h) 
    {
      cin>>s;
      field.pb(s);
    }
    int x,y;
    rep(i,h) rep(j,w)
    {
      if(field[i][j]=='@')
      {
        y=i,x=j;
      }
    }
    print(dfs(y,x));
  }

  return 0;
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define mod  998244353
#define line cout<<"-------------------------->"<<endl
#define bar "--->"
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll  mx=100009;
ll  nxt[mx][2];
ll  node=1;
ll  n,l ;
void add(string str)
{
    ll  now=0;
    for(ll  i=0;i<str.size();i++)
    {
        bool c=str[i]-'0';
        if(nxt[now][c]==false) nxt[now][c]=node++;
        now=nxt[now][c];
    }
}
vector<ll > v;
void dfs(ll  s, ll  lv)
{

    if(nxt[s][0]==0 and  nxt[s][1]==0) return ;
    else if(nxt[s][0] and nxt[s][1])
    {

        dfs(nxt[s][0],lv+1);
        dfs(nxt[s][1],lv+1);
    }
    else if(nxt[s][0])
    {
        v.pb(l-lv);
        dfs(nxt[s][0],lv+1);
    }
    else
    {

        v.pb(l-lv);
        dfs(nxt[s][1],lv+1);
    }
}
int   main()
{
    cin>>n>>l;
    for(ll  i=0;i<n;i++)
    {
        string str;
        cin>>str;
        add(str);
    }
    dfs(0,0);
    ll  xr=0 ;
    for(auto x: v)
    {

        ll  cnt=1;
        while(x%2==0)
        {
            cnt*=2;
            x/=2;
        }
        xr^=cnt;
    }
    if(xr==0) cout<<"Bob"<<endl;
    else cout<<"Alice"<<endl;

}



Measured memory_bytes: 7440
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define _rep(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ll long long
#define N 100005
inline bool up(int&x,const int y){return x<y?x=y,1:0;}
inline bool down(int&x,const int y){return x>y?x=y,1:0;}
int n,a[N],cntb,cntc;
typedef std::pair<int,int> pii;
pii b[N],c[N];
std::unordered_map<int,int> odd,even;
int main(){
	std::ios::sync_with_stdio(0);
	std::cin.tie(0),std::cout.tie(0);
	std::cin>>n;
	rep(i,1,n){
		std::cin>>a[i];
		if(i&1) ++odd[a[i]];
		else ++even[a[i]];
	}
	for(auto i:odd) b[++cntb]={i.second,i.first};
	for(auto i:even) c[++cntc]={i.second,i.first};
	std::sort(b+1,b+cntb+1,std::greater<pii>());
	std::sort(c+1,c+cntc+1,std::greater<pii>());
	int mx=0;
	rep(i,1,2) rep(j,1,2){
		if(b[i].second!=c[j].second){
			up(mx,b[i].first+c[j].first);
		}
	}
	std::cout<<n-mx<<'\n';
	return 0;
}

Measured memory_bytes: 8492
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int X,A,B; cin>>X>>A>>B;
	ote(X-(A+(X-A)/B*B));
}


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

def nextNum(n):
  if n % 2 ==0:
    return n //2
  else:
    return 3 * n + 1

sList=[]
S = int(input())
sList.append(S)
num=nextNum(S)

while( num not in sList):
  sList.append(num)
  num=nextNum(num)
  
print(len(sList)+1)





Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e5;

int N,M;
int a[1250],b[1250];
bool G[50][50];

//頂点vから始めて到達できるものにフラグ立て
bool vis[50];
void dfs(int v){
	vis[v]=true;
	rep(u,N)if(G[v][u]&&!vis[u]) dfs(u);
  	return;
}

int main(){
	cin>>N>>M;
	rep(i,M){
		cin>>a[i]>>b[i];
        a[i]--;
      	b[i]--;
		G[a[i]][b[i]]=G[b[i]][a[i]]=true;
	}
	int bridge=0;
	rep(i,M){
		G[a[i]][b[i]]=false;
        rep(j,N) vis[j]=false;
		dfs(a[i]);
		if(!vis[b[i]]) bridge++;
		G[a[i]][b[i]]=true;
	}
	cout<<bridge;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

//Making Sugoroku
public class Main{
	
	boolean[] e = new boolean[252], reach = new boolean[252];
	@SuppressWarnings("unchecked")
	Set<Integer>[] next = new Set[252], rv = new Set[252];
	int max, n;
	
	void f(int v){
		if(e[v])return;
		e[v] = true;
		for(int x:rv[v])f(x);
	}
	
	void g(int v){
		if(reach[v])return;
		reach[v] = true;
		for(int x:next[v])g(x);
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(int i=0;i<252;i++){
			next[i] = new HashSet<Integer>();
			rv[i] = new HashSet<Integer>();
		}
		for(;;){
			max = sc.nextInt();
			if(max==0)break;
			n = sc.nextInt();
			int[] d = new int[n+2];
			for(int i=1;i<=n;i++)d[i]=sc.nextInt();
			for(int i=0;i<n+2;i++){
				next[i].clear();
				rv[i].clear();
			}
			for(int i=0;i<n+1;i++)for(int m=1;m<=max;m++){
				int nx = Math.min(i+m, n+1);
				nx = Math.max(0, Math.min(nx+d[nx], n+1));
				next[i].add(nx);
				rv[nx].add(i);
			}
			Arrays.fill(e, false);
			Arrays.fill(reach, false);
			f(n+1);
			g(0);
			boolean OK = true;
			for(int i=0;i<n+2;i++)if(reach[i] && !e[i])OK = false;
			System.out.println(OK?"OK":"NG");
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 55756
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()
 
ll modPow(ll a, ll n,ll p) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1,p)) % p;
  ll t = modPow(a, n / 2,p);
  return (t * t) % p;
}

int main(){
  ll N,x=0,s=0,t=0;
  string X;
  cin >> N >> X;
  vector<ll> f(N);
  rep(i,N){
    if(i==0) f.at(i)=0;
    else{
      bitset<20> s(i);
      f.at(i)=f.at(i%s.count())+1;
    }
  }
  rep(i,N){
    if(X.at(i)=='1') x++;
  }
  rep(i,N){
    if(X.at(i)=='1'){
      t+=modPow(2,N-1-i,x+1);
      t%=x+1;
      if(x>1){
        s+=modPow(2,N-1-i,x-1);
        s%=x-1;
      }
    }
  }
  rep(i,N){
    if(x==1&&X.at(i)=='1'){
      cout << 0 << endl;
    }else if(X.at(i)=='1'){
      ll S=s;
      S+=x-1;
      S-=modPow(2,N-1-i,x-1);
      S%=x-1;
      cout << f.at(S)+1 << endl;
    }else{
      ll T=t;
      T+=modPow(2,N-1-i,x+1);
      T%=x+1;
      cout << f.at(T)+1 << endl;
    }
  }
    
}

Measured memory_bytes: 5240
#include<stdio.h>

void judge(int w,int h,int x,int y,int r){
	if(x>w){
		printf("No\n");
	}
	else if(y>h){
		printf("No\n");
	}
	else if(r*2>h){
		printf("No\n");
	}
	else if(x+r>w){
		printf("No\n");
	}
	else if(y+r>h){
		printf("No\n");
	}
	else if(x<0 ||y<0){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
}

int main(void){
	int w,h,x,y,r;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	judge(w,h,x,y,r);
	return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
#define inf 9000000000000000000LL
using namespace std;

int ar[22][22];
lli dp[2097155];

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


    int n;
    cin >> n;


    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            cin >> ar[i][j];
        }
    }

    dp[0] = 1;
    for(int mask=0; mask<(1<<n)-1; mask++)
    {
        int a = __builtin_popcount(mask);

        for(int i=0;i<n;i++)
        {
            if(ar[a][i] && !(mask & (1<<i)))
            {
                int mask2 = mask|(1<<i);
                dp[mask2] += dp[mask];
                dp[mask2] %= mod;
            }
        }
    }
    cout << dp[(1<<n)-1] << endl;
    return 0;

}



Measured memory_bytes: 20036
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define print_array(ary, size) cout << ary[0]; rep1(i, 1, size - 1) cout << ' ' << ary[i]; cout << endl;
typedef long long ll;
typedef unsigned long long ull;

int n;
int A[2000000];
int B[2000000];
int C[10001] = { 0 };

void CountingSort(int* A, int* B, int k)
{
	rep(i, k) C[i] = 0;
	rep(i, n) C[A[i]]++;
	rep(i, k - 1) C[i + 1] += C[i];
	rrep(i, n) {
		B[C[A[i]] - 1] = A[i];
		C[A[i]]--;
	}
}

int main()
{
	cin >> n;
	rep(i, n) cin >> A[i];
	CountingSort(A, B, 10001);
	print_array(B, n);

	return 0;
}


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

int main() {
  int n; cin >>n;
  long long saisho;
  cin >>saisho;
  long long sum=0;
  for(int i=1;i<n;i++){
    int a;
    cin>>a;
    sum+=a;
  }
  if(saisho%2==sum%2){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int n,d,x;;
    cin>>n>>d>>x;
    vector<int>v(n);
    rep(i,n)cin>>v[i];
    int ans=0;
    rep(k,n){
        int cnt=1;
        for(int i=1;i<=d;i++){
            if(i==1)ans++;
            else if((i-1)==cnt*v[k]){
                ans++;
                cnt++;
            }
        }
    }
    cout<<ans+x<<endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
c = 0
for i in range(n - 1):
    j = a[i:].index(min(a[i:])) + i
    if i != j:
        a[i], a[j] = a[j], a[i]
        c += 1
print(" ".join(map(str, a)))
print(c)


Measured memory_bytes: 5600
import math

n = int(input().strip())
x_y = [[0] * 2] * n

for i in range(n):
    x_y[i] = list(map(int, input().split()))

den = math.factorial(n)
mol = 0

for i in range(n):
    for j in range(n):
        if (i == j):
            next
        else:
            mol += math.factorial(n - 1) * ((x_y[i][0] - x_y[j][0]) ** 2 + (x_y[i][1] - x_y[j][1]) ** 2) ** (1 / 2)

print(mol / den)


Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;

using ll = long long;

int main()
{
    ll a, b;
    cin >> a >> b;
    cout << a*b << endl;
    return 0;
}

Measured memory_bytes: 3160
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18


int main(){
   int N;
   long long x;
   cin >> N >> x;
   vector<long long> a(N);
   long long sum = 0;
   rep(i,N){
       cin >> a[i];
       sum += a[i];
   }
   sort(a.begin(),a.end());
   int ans = 0;
   if(x > sum) ans = N-1;
   else{
       int i = 0;
       while(x >= a[i]){
           ans++;
           x = x-a[i];
           i++;
           if(i == N) break;
       }
   }
   cout << ans << endl;
} 

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

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

    vector<ll> A(N), B(N), C(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    for (int i = 0; i < N; i++) cin >> C[i];

    sort(A.begin(), A.end());//小さい順に
    sort(C.begin(), C.end());

    ll cnt = 0;
    rep(i, N) {
        int a = upper_bound(A.begin(), A.end(), B[i] - 1) - A.begin();
        int c = lower_bound(C.begin(), C.end(), B[i] + 1) - C.begin();
        cnt += (N - c) * (a);
    }
    cout << cnt << endl;
}


Measured memory_bytes: 2560
def challenge(X, numlist, vec):
  while True:
    try:
      numlist.index(X)
    except:
      return(X)
    if vec:
      X -= 1
    else:
      X += 1

list1 = input().split()
X = int(list1[0])
N = int(list1[1])
  
if N == 0:
  print(X)
else:
  list2 = input().split()
  numlist = []
  for i in list2:
    numlist.append(int(i))

  num1 = challenge(X, numlist,True)
  num2 = challenge(X, numlist,False)
  wk1 = abs(X - num1)
  wk2 = abs(X - num2)
  if wk1 > wk2:
    print(num2)
  else:
    print(num1)


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

int main(){
  int n;
  string A;
  cin>>n;
  for (int i=0;i<n;i++){
    cin>>A;
    if(A=="Y"){
      cout<<"Four"<<endl;
      break;
      }
    if(i==n-1)
      cout<<"Three"<<endl;
    }
  }
      

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

MOD = int(1e9+7)

tokens = ['A','C','G','T']

suffixes = []
for suffix_1 in tokens:
    for suffix_2 in tokens:
        for suffix_3 in tokens:
            suffixes.append(suffix_1+suffix_2+suffix_3)

dp = [[0 for _ in suffixes] for _ in range(N+1)]

reverse_index = {}
for i,s in enumerate(suffixes):
    reverse_index[s] = i

def pprint(dp):
    N = len(dp)
    M = len(dp[0])

    for i in dp:
        st = ""
        for j in i:
            st += str(j)
            st += " "
        print(st)

for i,s in enumerate(suffixes):
    if not s in ['AGC', 'ACG', 'GAC']:
        dp[3][i]  = 1

valid_str_4 = set()

def swap(s, i ,j):
    s_new = list(s)
    s_new[i], s_new[j] = s[j], s[i]
    return ''.join(s_new)

def valid(str4):
    if 'AGC' in str4:
        return False
    for i in range(3):
        s_new = swap(str4, i, i+1)
        if 'AGC' in s_new:
            return False
    return True

for s in suffixes:
    for c in tokens:
        ss = s+c
        if valid(ss):
            valid_str_4.add(ss)

for n in range(4, N+1):
    for s in suffixes:
        for c in tokens:
            ss = s+c
            if ss in valid_str_4:
                dp[n][reverse_index[ss[1:]]] += dp[n-1][reverse_index[s]]

print(sum(dp[N]) % MOD)



Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int h,w;
int n;
pair<int,int>d[300005];
set<int>x;
set<int>y;
int hang[300005],cot[300005];
int check(int xmax,int ymax){
    for(int i=1;i<=h;i++)if(xmax==hang[i])x.insert(i);
    for(int i=1;i<=w;i++)if(ymax==cot[i])y.insert(i);
    long long cnt=0;
    for(int i=1;i<=n;i++){
        if(x.find(d[i].first)!=x.end() && y.find(d[i].second)!=y.end()){
            cnt++;
        }
    }
    return (cnt==1LL*x.size()*y.size());
}
int main(){
    cin>>h>>w>>n;
    for(int i=1;i<=n;i++){
        cin>>d[i].first>>d[i].second;
        hang[d[i].first]++;
        cot[d[i].second]++;
    }
    int xmax=0,ymax=0;
    for(int i=1;i<=h;i++)xmax=max(hang[i],xmax);
    for(int i=1;i<=w;i++)ymax=max(cot[i],ymax);
    cout<<xmax+ymax-check(xmax,ymax);
}


Measured memory_bytes: 36424