akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main() {
    int n;
    string s;
    cin>>n>>s;
    int total_e=0, total_w=0, left_e=0, left_w=0;
    for(int i=0; i<n; i++) {
        if(s[i] == 'E')
            total_e++;
        else
            total_w++;
    }
    int ans = n, right_e, right_w;
    for(int i=0; i<n; i++) {
        if(s[i] == 'E')
            left_e++;
        right_e = total_e - left_e;
        right_w = total_w - left_w;

        if(left_w + right_e < ans) {
            ans = left_w + right_e;
        }
        if(s[i] == 'W')
            left_w++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 900
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
int main(){
  while(1){
    int n,a,b,c,x;
    cin>>n>>a>>b>>c>>x;
    if(n==0) return 0;
    int cnt=0;
    queue<int> que;
    for(int i=0;i<n;i++){
      int a;
      cin>>a;
      que.push(a);
    }
    while(!que.empty()&&cnt<=10001){
      if(x==que.front()){
        que.pop();
      }
      x=(a*x+b)%c;
      cnt++;
    }
    cout<<(cnt>10001?-1:cnt-1)<<endl;
  }
}



Measured memory_bytes: 3100
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

x = readInt()

for i in range(int(x//105),int(x//100)+2):
	t = x-100*i
	if 0<=t and t<=5*i:
		print(1)
		exit()
print(0)

Measured memory_bytes: 9352
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
	int H,W; cin>>H>>W;
	vector<vector<int>> c(10,vector<int>(10));
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			cin>>c[i][j];
		}
	}
	vector<int> cost(10,-1);
	cost[1]=0;
	int k=0,min_cost=999999999;
	for(int i=0;i<10;i++){
		if(i==1)continue;
		if(min_cost>c[i][1]){
			min_cost=c[i][1];
			k=i;
		}
	}
	cost[k]=min_cost;
	int last=k;
	int rem=7;
	//cout<<k<<endl;
	while(rem>=0){
		min_cost=10000000;
		for(int i=0;i<10;i++){
			if(i==1 or cost[i]!=-1)continue;
			if(min_cost>c[i][1]){
				k=i;
				min_cost=c[i][1];
			}
			for(int j=0;j<10;j++){
				if(j==1 or cost[j]==-1)continue;
				if(min_cost>c[i][j]+cost[j]){
					k=i;
					min_cost=c[i][j]+cost[j];
				}
			}
		}
		cost[k]=min_cost;
		if(cost[k]<cost[last])last=k;
		rem--;
	//	cout<<k<<endl;
	}
	//for(int i=0;i<10;i++)cout<<i<<":"<<cost[i]<<endl;
	int ans=0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
				int a; cin>>a;
				if(a!=-1)ans+=cost[a];
		}
	}
	cout<<ans<<endl;


}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()

int main() {
    ll N,M,C; scanf("%lld%lld%lld",&N,&M,&C);
    ll B[25];
    rep(i,M) scanf("%lld",&B[i]);
    ll A[25][25];
    rep(i,N){
        rep(j,M) scanf("%lld",&A[i][j]);
    }
    ll ans=0;
    rep(i,N){
        ll temp=C;
        rep(j,M){
            temp+= A[i][j]*B[j];
        }
        if (temp > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
    long int n,m,a[1000],sum=0,count;
    cin >> n >> m;
    for(int i=0 ; i<n ; i++)
    {
        cin >> a[i];
        sum+=a[i];
    }
    count=0;
    for(int j=0 ; j<n ; j++)
    {
        if((a[j]*4*m)>=sum)
        {
            count++;
        }
    }
    if(count>=m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int, input().split()))
max=a[0]
dai=0
for i in range(n):
    #print(f"{i}回目")
    if max>a[i]:
        dai+=max-a[i]
       
    else:
        max=a[i]
    #print(max,dai)
print(dai)

Measured memory_bytes: 32128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
int main(){
    int N, T; cin >> N >> T;
    int A[N]; rep(i,N) cin >> A[i];

    long int r[N-1]; rep(i,N-1) r[i] = A[i+1] - A[i];
    vector<long int> dp(N,-10e9);
    long int mx = -10e9; int cnt = 1; int tmp = 0;
    rep(i,N-1) dp[i+1] = max(r[i], dp[i]+r[i]);
    for(int i=1; i<N; i++){
      	//cout << dp[i] << " " << mx << endl;
        if(dp[i] > mx){
            mx = dp[i];
            cnt = 1;
        }
        else if(dp[i] == mx) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 2176
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

void solve(){
	ll n;
	cin>>n;
	ll A[n+1] = {0};
	rep(i,2,n+1){
		ll x;
		cin>>x;
		A[x]++;
	}
	rep(i,1,n+1)	cout<<A[i]<<endl;
	return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll no;
	// cin>>no;
	no = 1;
	while(no--){
		solve();
	}
    return 0;
}

Measured memory_bytes: 5176
#include<bits/stdc++.h>
using namespace std;
#define ll         long long int
#define co         cout
#define ci         cin
#define sf1(n)     scanf("%lld",&n)
#define sf2(n,m)   scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p);
#define pf1(n)     printf("%lld\n",n);
#define mem(a,b)   memset(a,b,sizeof(a))
#define en         cout<<endl;
#define pb         push_back
#define gcd(n,m)   __gcd(n,m)
#define lcm(n,m)   ((n)/__gcd(n,m))*(m)
#define fi         first
#define se         second
#define coy        cout<< "YES"<<endl;
#define con        cout<< "NO"<<endl;
#define f(a,b)     for(ll i=a;i<b;i++)
#define all(x)     (x).begin(),(x).end()
#define allr(x)    (x).rbegin(),(x).rend()
#define pi         pair<ll,ll>
#define br         break;
#define i64        long long
#define PI         2*acos(0.0)

int main()
{
    ll t,n,g,k,m,mx=0,mn=1e9,c,res,c1,x,y,w,z,c2;
    ll l,r,d;
    ci>>l>>r>>d;
    x=l/d;
    x=x*d;
    c=0;
    if(x<l) x+=d;
    for(ll i=x;i<=r;i+=d) c++;
    co<<c;
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;


int main(int argc, char const *argv[]) {
    long long int n, k;
    cin >> n >> k;
    vector<long long int> A(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    long long int dp[41][2];
    for (int i = 0; i <= 40; i++) {
        long long int d = k >> (40 - i);
        k -= d << (40 - i);
        
        if (i == 0) {
            // assert d == 0;
            dp[i][0] = -1LL;
            dp[i][1] = 0LL;
            continue;
            // cout << d << ": " << dp[i][0] << ", " << dp[i][1] << endl;
        }
        long long int sum_i = 0;
        for (int j = 0; j < n; j++) {
            auto a = A[j];
            long long int d_a = a >> (40 - i);
            sum_i += d_a;
            A[j] -= d_a << (40 - i);
        }
        // small -> small
        if (dp[i-1][0] != -1) {
            auto temp = max(sum_i, n - sum_i) << (40 - i);
            dp[i][0] = dp[i-1][0] + temp;
        } else {
            dp[i][0] = -1;
        }
        if (d == 1) {
            // exact -> small by choosing 0
            auto temp = sum_i << (40 - i);
            dp[i][0] = max(dp[i][0], dp[i-1][1] + temp);
            // exact -> exact by choosing 1
            temp = (n - sum_i) << (40 - i);
            dp[i][1] = dp[i-1][1] + temp;
        } else {
            // exact -> exact by choosing 0
            auto temp = sum_i << (40 - i);
            dp[i][1] = dp[i-1][1] + temp;
        }
        // cout << d << ": " << dp[i][0] << ", " << dp[i][1] << endl;
    }
    cout << max(dp[40][0], dp[40][1]) << endl;
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
time_list = list(map(int,input().split()))
m = int(input())
drink_list = [list(map(int,input().split())) for _ in range(m)]
sum_time = sum(time_list)

for d in drink_list:
    effect_index = d[0] - 1
    effect_time = d[1]
    print(sum_time - time_list[effect_index] + effect_time)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    int x[n];
    rep(i, 0, n) cin >> x[i];
    int s[n];
    rep(i, 0, n) s[i] = x[i];

    sort(s, s + n);
    
    int center = (n - 1) / 2;
    rep(i, 0, n)
    {
        if (x[i] <= s[center])
            cout << s[center + 1] << endl;
        else
            cout << s[center] << endl;
    }


    return 0;
}

Measured memory_bytes: 3712
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    auto solve = [](ll x, ll a, ll b) {
        return (x - (x / a) - (x / b) + (x / LCM(a, b)));
    };
    cout << solve(B, C, D) - solve(A - 1, C, D) << endl;
    return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : ATcoder.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {


	int a,b;

	cin>>a>>b;

	if((a+b)<24){
		cout<<a+b<<endl;
	}
	if((a+b)==24){
		cout<<"0"<<endl;
	}
	if((a+b)>24){
		cout<<a+b-24<<endl;
	}

	return 0;
}



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

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

    int k;
    string s;

    cin >> k >> s;

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

    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

const int MAX_V=1e9;
int main(){
    int n,k,s;
    cin>>n>>k>>s;
    if(s==MAX_V){
        for(int i=0;i<k;i++) cout<<s<<" ";
        for(int i=0;i<n-k;i++) cout<<1<<" ";
    }
    else{
        for(int i=0;i<k;i++) cout<<s<<" ";
        for(int i=0;i<n-k;i++) cout<<MAX_V<<" ";

    }
    
    return 0;
}


Measured memory_bytes: 1280
def solve():
    n = int(input())
    a = list(int(input()) for _ in range(n))
    ranking = sorted(a)[::-1]
    first = ranking[0]
    second = ranking[1]
    first_idx = a.index(first)
    for idx in range(n):
        if idx == first_idx:
            print(second)
        else:
            print(first)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 14148
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
 
}
  







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

int main(void){
 
 char a;
 cin >> a;
 
 if(a == 'A'){
     cout << 'T' <<endl;
 }
 else if(a == 'T'){
     cout << 'A' <<endl;
 }
 else if(a == 'G'){
     cout << 'C' <<endl;
 }
 else{
     cout << 'G' << endl;
 }
}

Measured memory_bytes: 3584
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(INF)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

struct Node{
	set<int> son;
	set<int> con;
	int tag;
	int ans;
	Node(){
		son.clear();
		tag=0;
	}
}; vector<Node> tree;

void build(int n){
	for(auto &i:tree[n].con){
		tree[i].con.erase(n);
		build(i);
		tree[n].son.emplace(i);
	}
}

void go(int now,int n){
	now+=tree[n].tag;
	tree[n].ans=now;
	for(auto &i:tree[n].son){
		go(now,i);
	}
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,q; cin>>n>>q;
	tree.resize(n);
	int s,t;
	For(i,0,n-2){
		cin>>s>>t;
		s--; t--;
		tree[s].con.emplace(t);
		tree[t].con.emplace(s);
	}
	build(0);
	int x,p;
	while(q--){
		cin>>p>>x;
		p--;
		tree[p].tag+=x;
	}
	go(0,0);
	For(i,0,n-1){
		cout<<tree[i].ans<<" \n"[i==n-1];
	}
	return 0;
}




























Measured memory_bytes: 61824
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！
def count(li):
    black = 0
    for i in range(h):
        for j in range(w):
            if li[i][j] == "#":
                ans += 1
    return black
        
h,w,k = MI()
c = [list(input()) for _ in range(h)]
ans = 0
for bit in range(1<<h):
    for bit2 in range(1<<w):
        black = 0
        for i in range(h):
            for j in range(w):
                if ((bit >> i) & 1) == 0 and ((bit2 >> j) & 1) == 0:
                    if c[i][j] == "#":
                        black += 1
        if black == k:
            ans += 1
print(ans)
            

Measured memory_bytes: 9992
// ~/SolverToBe/Developers/Corvus
// ~/sudo apt-get verdict Accpeted

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
#include <limits.h>
#include <math.h>
#include <string.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <functional>
#include <assert.h>
#include <complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int N = 100005, M = 505;
const ll MOD = 1e9 + 7;
const double eps = 1e-9;
const double PI = acos(-1.0);

int n;

int main() {
	scanf("%d", &n);
	int a = n % 100;
	int b = n / 100;
	if ((a >= 1 && a <= 12) && (b >= 1 && b <= 12)) puts("AMBIGUOUS");
	else if (a >= 1 && a <= 12) puts("YYMM");
	else if (b >= 1 && b <= 12) puts("MMYY");
	else puts("NA");
	return 0;
}

Measured memory_bytes: 256
n,m,x=map(x->parse(Int,x),split(readline()))

function chgBinum(num) #numをString型の配列で返す
    num=string(num,base=2)
    ai=split(num,"")
    b=fill("0",n)
    for i=1:length(ai)
        b[i]=ai[length(ai)+1-i]
    end
    return b
end

function checknowA(nowA) #nowAのすべての要素がxを超えたか
    for i=1:m
        if nowA[i] < x
            return false
        end
    end
    return true
end

function main()
    c=Array{Int}(undef,n)
    a=Array{Int}(undef,n,m)
    #a[i,j]=理解度
    for i=1:n#cとaの受取
        data=map(x->parse(Int,x),split(readline()))
        for j=1:m+1
            if j==1
                c[i]=data[j]
            else
                a[i,j-1]=data[j]
            end
        end
    end
    ans= n*10^5+1
    for bit=1:(1<<length(c)-1) #bit全探索
        combination=chgBinum(bit)
        nowA=zeros(Int,m)
        nowPrice=0
        for i=1:n #組み合わせごとに条件を満たすか            
            if combination[i] == "1" #参考書iを買うか？
                for j=1:m #理解度の更新
                    nowA[j] += a[i,j] 
                end
                nowPrice += c[i]
            end
        end
        if checknowA(nowA) && nowPrice < ans
            ans=nowPrice
        end
    end
    if ans != n*10^5+1
        println(ans) #成功
    else
        println(-1) #失敗
    end
end 
main()

Measured memory_bytes: 209404
import random

mod=998244353
N,X=input().split()
N=int(N)
A=[]
for i in range(N):
    A.append(int(input(),2))
A.sort()

a=A[-1]
M=max(len(X)-1,a.bit_length()-1)
base=[]
n=a.bit_length()-1
for i in range(M-n,-1,-1):
    base.append(a<<i)

for i in range(0,N-1):
    a=A[i]
    for j in range(M):
        for b in base:
            a=min(a,a^b)
        if a==0:
            break
        else:
            base.append(a)
            a=a<<1

data=[0]*(M+1)
data2=[0]*(M+1)
for b in base:
    data[b.bit_length()-1]=b
    data2[b.bit_length()-1]=1

for i in range(1,M+1):
    data2[i]+=data2[i-1]

data2=[0]+data2

#print(data)
#print(data2)

x=0
ans=0
n=len(X)-1
for i in range(len(X)):
    if X[i]=="1":
        if x>>(n-i)&1==1:
            if data[n-i]:
                ans+=pow(2,data2[n-i],mod)
                ans%=mod
        else:
            ans+=pow(2,data2[n-i],mod)
            ans%=mod
            if data[n-i]:
                x=x^data[n-i]
            else:
                break
    else:
        if x>>(n-i)&1==1:
            if data[n-i]:
                x=x^data[n-i]
            else:
                break
        else:
            continue
else:
    ans+=1
    ans%=mod
print(ans)


Measured memory_bytes: 85808
import sys
 
N=int(input())
 
if N==1:
  print(1)
  sys.exit()

Flag=0
nCnt=1
Tmp=2
while Flag==0:
  TmpN = N /Tmp
  if TmpN >= 2:
    Tmp *= 2
    nCnt +=1
  else:
    Flag=1

A = 2 ** (nCnt)
print(A)

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

int main(){
  string O,E;
  cin >> O >> E;
  for(int i=0;i<E.size();i++){
    cout << O.at(i) << E.at(i);
  }
  if(O.size()!=E.size()){
    cout << O.back();
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException
import java.io.InputStream
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val (n, m) = sc.nextInts(2)
    val a = sc.nextIntArray(m).sorted()
    println(if (m <= n) 0 else (0 until m - 1).map { a[it + 1] - a[it] }.sorted().subList(0, m - n).sum())
}

class Scanner(private val `in`: InputStream) {
    private val buffer = ByteArray(1024)
    private var ptr = 0
    private var buflen = 0

    companion object {
        private fun isPrintableChar(b: Byte): Boolean = b in 33..126
        private fun isNumericChar(b: Byte): Boolean = b in 48..57
        private fun digit(b: Byte): Int = b - 48
    }

    fun hasNextByte(): Boolean {
        if (ptr < buflen) return true
        ptr = 0
        try {
            buflen = `in`.read(buffer)
        } catch (e: IOException) {
            e.printStackTrace()
        }
        return 0 < buflen
    }

    private fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1

    private fun skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++
    }

    fun hasNext(): Boolean {
        skipUnprintable()
        return hasNextByte()
    }

    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        return buildString {
            var b = readByte()
            while (isPrintableChar(b)) {
                appendCodePoint(b.toInt())
                b = readByte()
            }
        }
    }

    fun nextInt(): Int {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0
        var b = readByte()
        val minus = b.toChar() == '-'
        if (minus) b = readByte()
        if (!isNumericChar(b)) throw NumberFormatException()
        do {
            n *= 10
            n += digit(b)
            b = readByte()
        } while (isNumericChar(b))
        return if (minus) -n else n
    }

    fun nextInts(n: Int): Array<Int> = Array(n) { nextInt() }

    fun nextIntArray(n: Int): IntArray = IntArray(n) { nextInt() }

    fun nextIntArrays(n: Int, m: Int): Array<IntArray> {
        val arrays = Array(m) { IntArray(n) }
        repeat(n) { i -> repeat(m) { j -> arrays[j][i] = nextInt() } }
        return arrays
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var b = readByte()
        val minus = b.toChar() == '-'
        if (minus) b = readByte()
        if (!isNumericChar(b)) throw NumberFormatException()
        do {
            n *= 10
            n += digit(b)
            b = readByte()
        } while (isNumericChar(b))
        return if (minus) -n else n
    }

    fun nextLongs(n: Int): Array<Long> = Array(n) { nextLong() }

    fun nextLongArray(n: Int): LongArray = LongArray(n) { nextLong() }

    fun nextLongArrays(n: Int, m: Int): Array<LongArray> {
        val arrays = Array(m) { LongArray(n) }
        repeat(n) { i -> repeat(m) { j -> arrays[j][i] = nextLong() } }
        return arrays
    }

}

Measured memory_bytes: 39948
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using Graph = vector<vector<int>>;
bool seen[100010];
ll dp[100010][2];

void rec(const Graph &g, int i) {
    seen[i] = true;
    dp[i][0] = 1;
    dp[i][1] = 1;
    for (auto j: g[i]) {
        if (seen[j]) continue;
        rec(g, j);
        dp[i][0] *= dp[j][0] + dp[j][1];
        dp[i][0] %= MOD;
        dp[i][1] *= dp[j][0];
        dp[i][1] %= MOD;
    }
}

int main() {
    int n; cin >> n;
    Graph g(n);
    rep(i, n-1) {
        int x, y; cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    rec(g, 0);
    cout << (dp[0][0] + dp[0][1]) % MOD << endl;
}


Measured memory_bytes: 12928
import itertools
n,m,x=map(int,input().split())
c=[0]*n
a=[[0 for i in range(m)] for j in range(n)]
current_skill=[0]*m
INF=9999999
min_money=INF


for  i in range(n):
    tmp=list(map(int,input().split()))
    c[i]=tmp[0]
    a[i]=tmp[1:]

current_money=0

for i in range(1 << n):
    bug=[]
    for j in range(n):
        if (i>>j) &1:
            bug.append(j)
    current_skill=[0]*m
    current_money=0
    for chosen_set_num in bug:
        current_money+=c[chosen_set_num]
        for each_book_num in range(m):
            current_skill[each_book_num]+=a[chosen_set_num][each_book_num]
            

        if all(status >=x for status in current_skill ):
            min_money=min(min_money,current_money)
            continue
if min_money==INF:
    min_money=-1
print(min_money)


Measured memory_bytes: 9196
#include<iostream>
#include<utility>
#define INF 1 << 30
using namespace std;

int color_count[3][33];
int D[33][33];

int main() {
    int N, C, color, min_sum = INF;
    cin >> N >> C;
    for (int i = 0; i < 3; i++) {
        for (int j = 1; j <= 30; j++) {
            color_count[i][j] = 0;
        }
    }
    for (int i = 1; i <= C; i++) {
        for (int j = 1; j <= C; j++) {
            cin >> D[i][j];
        }
    }
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            cin >> color;
            color_count[(i + j) % 3][color]++;
        }
    }
    for (int i = 1; i <= C; i++) {
        for (int j = 1; j <= C; j++) {
            if (i != j) {
                for (int k = 1; k <= C; k++) {
                    if (i != k && j != k) {
                        int sum_D = 0;
                        for (int l = 1; l <= C; l++) sum_D += color_count[0][l] * D[l][i];
                        for (int l = 1; l <= C; l++) sum_D += color_count[1][l] * D[l][j];
                        for (int l = 1; l <= C; l++) sum_D += color_count[2][l] * D[l][k];
                        if (min_sum > sum_D) min_sum = sum_D;
                    }
                }
            }
        }
    }
    cout << min_sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
 
using namespace std;


	
int main()
{ 
	string arr [200000];
	for(int i=0;i<200000;i++)arr[i]=999999;
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>arr[i];
	sort(arr,arr+n);
	int cnt=1;
	for(int i=1;i<n;i++)
		if(arr[i]!=arr[i-1])cnt++;
	cout<<cnt<<endl;
	return 0;
}
	
	


Measured memory_bytes: 9880
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main() {
    set<string> st;
    string s; int k;    cin >> s >> k;
    int l = s.length();

    for (int i = 0; i < l; i++) {
        for (int j = 1; j <= 5; j++) {
            if (i + j - 1 < l)
                st.insert(s.substr(i, j));
        }
    }

    set<string>::iterator ite = st.begin();
    int i = 1;
    while (i++ < k)
        ite++;
    
    cout << *ite << endl;
    return 0;
}

Measured memory_bytes: 4780
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H, W;
		while (true) {
			H = sc.nextInt();
			W = sc.nextInt();
			if (H == 0 && W == 0)
				break;
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if (i % 2 == 0 && j % 2 != 0) {
						System.out.print(".");
					} else if (i % 2 != 0 && j % 2 == 0) {
						System.out.print(".");
					} else {
						System.out.print("#");
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 33612
#include <iostream>

int main()
{
    int N;
    long long A[100000];
    std::cin >> N;

    bool zero = false;
    int minus = 0;
    for (int i = 0; i < N; ++i)
    {
        std::cin >> A[i];
        if (A[i] == 0)
        {
            zero = true;
        }
        else if (A[i] < 0)
        {
            minus++;
        }
    }

    long long ans = 0;
    if (zero || (minus % 2) == 0)
    {
        for (int i = 0; i < N; ++i)
        {
            if (A[i] < 0)
            {
                ans += A[i] * -1;
            }
            else
            {
                ans += A[i];
            }
        }
    }
    else
    {
        long long min = 1e9 + 1;
        for (int i = 0; i < N; ++i)
        {
            int a = A[i];
            if (a < 0)
            {
                a *= -1;
            }

            ans += a;
            if (a < min)
            {
                min = a;
            }
        }

        ans -= min * 2;
    }

    std::cout << ans << std::endl;

    return 0;
}


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

int main(){
const int INF=10000000;
int a,b,c,ans;
while(cin>>a>>b){
ans=1;
a+=b;
for(int i=0;i<INF;i++){
c=a%10;
a-=c;
if(a==0){break;}
if(a!=0){
ans++;
a/=10;}}
cout<<ans<<endl;}}

Measured memory_bytes: 1160
<?php
class Line {
    protected $lineData;
    protected $pointer;
    public function __construct(array $line)
    {
        $this->lineData = $line;
        $this->pointer = 0;
        $this->count = count($line);
    }

    public function next()
    {
        if ($this->count > $this->pointer) {
            return $this->lineData[$this->pointer++];
        }
        return false;
    }
}

class IOW {
    /**
     * @return Line
     */
    public static function nl()
    {
        $str = trim(fgets(STDIN));
        return new Line(explode(' ', $str));
    }

    public static function out($data)
    {
        print_r ($data . PHP_EOL);
    }
}

$line = IOW::nl();
$r = $line->next();
$d = $line->next();
$x = $line->next();

for ($i = 1; $i <= 10; $i++) {
    $x = $r * $x - $d;
    IOW::out(($x));
}


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

using namespace std;
using ll = long long;
using coord = pair<int, int>;

int dw[4] = {1, 0, -1, 0};
int dh[4] = {0, 1, 0, -1};

int main() {
    int H, W;
    cin >> H >> W;

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

    queue<coord> que;
    vector<vector<int>> dist(H, vector<int>(W, -1));
    que.emplace(0, 0);
    dist[0][0] = 1;
    while (!que.empty()) {
        int h = que.front().first;
        int w = que.front().second;
        que.pop();
        for (int i = 0; i < 4; i++) {
            int h_tmp = h - dh[i];
            int w_tmp = w - dw[i];
            if (h_tmp < 0 || h_tmp >= H || w_tmp < 0 || w_tmp >= W) continue;
            if (s[h_tmp][w_tmp] == '#') continue;
            if (dist[h_tmp][w_tmp] != -1) continue;
            que.emplace(h_tmp, w_tmp);
            dist[h_tmp][w_tmp] = dist[h][w] + 1;
        }
    }

    int white = 0, black = 0;
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            if (s[h][w] == '.') {
                white++;
            } else {
                black++;
            }
            // cout << dist[h][w] << " ";
        }
        // cout << endl;
    }

    int output;
    output = white - dist[H - 1][W - 1];
    if (dist[H - 1][W - 1] == -1) {
        output = -1;
    }
    cout << output << endl;

    return 0;
}


Measured memory_bytes: 3612
#!/usr/bin/env python3
import sys
import heapq



def main():
    N, M = map(int, input().split())

    # day日目に選択可能になる選択肢をまとめて管理しておく。
    jobs = [[] for _ in range(M + 1)]
    for _ in range(N):
        a, b = map(int, input().split())
        if a > M:
            continue
        jobs[a].append(b)

    heap = []
    salary = 0

    # M日目から遡っていく。
    for day in range(1, M + 1):
        # 選択可能になる選択肢をエンキュー(取り出す時に最大値が欲しいのでマイナスにする。)
        for i in jobs[day]:
            heapq.heappush(heap, -i)
        # ヒープが空でなければ最も良い選択肢を取得、マイナスを戻す。
        if len(heap) > 0:
            salary += abs(heapq.heappop(heap))

    print(salary)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 18376
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;

int a[110];

int main(){
    int N,c=0,minj;
    cin>>N;
    for(int i=0;i<N;i++) cin>>a[i];
    for(int i=0;i<=N-1;i++){
        minj=i;
        for(int j=i;j<=N-1;j++){
            if(a[j]<a[minj]){
                minj=j;
            }
        }
        swap(a[i],a[minj]);
        if(i!=minj) c++;
    }
    for(int i=0;i<N;i++){
        if(i==N-1) cout<<a[i]<<endl;
        else cout<<a[i]<<" ";
    }
    cout<<c<<endl;
    return 0;
}



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

int main(){
    int N; cin >> N;
    vector<int> A(N);
    int cnt =0;

    rep(i,N){
        cin >> A[i];
        if(A[i]%2 == 1){
            cnt++;
        }
    }

    if(cnt%2 == 1){
        cout << "NO" << endl;
    }

    else{
        cout << "YES" << endl;
    }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)


int main() {
    int M, T, P, R;
    while (cin >> M && M) {
        cin >> T >> P >> R;
        if (R == 0) {
            cout << T;
            rep3(i, 1, T) {
                cout << "=" << T - i;
            }
            cout << endl;
            continue;
        }
        set<int> s[T]; //解いた問題
        int time[T]; fill_n(time, T, 0);
        vector<pair<pii, pii> > v(R);
        rep(i, R) {
            //チーム、問題、時間、yes or no
            cin >> v[i].S.F >> v[i].F.F >> v[i].F.S >> v[i].S.S;
            //0indexed
            v[i].F.F--;
            v[i].S.S *= -1; //0が一番下に来ないと!!!
        }
        sort(all(v));
        //cout << endl; rep(i, R) out(v[i].F.F + 1 << " " << v[i].F.S << " " << v[i].S.F << " " << v[i].S.S);
        
        
        
        int pena = 0;
        if (v[0].S.S == 0) {
            s[v[0].F.F].insert(v[0].F.S);
            time[v[0].F.F] = v[0].S.F;
        } else {
            pena += 20;
        }
        rep3(i, 1, R) {
            if (!(v[i].F.F == v[i - 1].F.F && v[i].F.S == v[i - 1].F.S)) {
                pena = 0;
            }
            if (v[i].S.S == 0) {
                time[v[i].F.F] += pena + v[i].S.F;
                s[v[i].F.F].insert(v[i].F.S);
                pena = 0;
            } else {
                pena += 20;
            }
        }
        
        
        
        vector<pair<int, pii> > solve;
        rep(i, T) {
            solve.eb(SZ(s[i]), pii(-time[i], i + 1));
        }
        sort(all(solve));
        reverse(all(solve));
        //cout << endl; rep(i, T) out(solve[i].F << " " << solve[i].S.F << " " << solve[i].S.S + 1);
        cout << solve[0].S.S;
        rep3(i, 1, T) {
            if (solve[i].F == solve[i - 1].F && solve[i].S.F == solve[i - 1].S.F) {
                cout << "=" << solve[i].S.S;
            } else {
                cout << "," << solve[i].S.S;
            }
        }
        cout << endl;
    }
}





Measured memory_bytes: 3132
//b.c B-Five Dishes
#include<stdio.h>
#include<stdbool.h>

void swap(int *a,int i,int j){
    int x = a[i];
    a[i] = a[j];
    a[j] = x;
}

void bsort(int *a,int n){
    bool flag = true;
    while(flag){
        flag  = false;
        for(int i=0;i<n-1;++i){
            int x1 = a[i]%10;
            int x2 = a[i+1]%10;
            if(x1==0){
                x1 += 10;
            }
            if(x2==0){
                x2 += 10;
            }
            if(x1<x2){
                swap(a,i,i+1);
                flag = true;
            }
        }
    }
}

int main(void){
    int buf[5];
    for(int i=0;i<5;++i){
        scanf("%d",buf+i);
    }

    
    bsort(buf,5);
    
    int ans = 0;
    for(int i=0;i<5;++i){
        int y = buf[i]%10;
        if(y!=0 && i!=4){
            ans += buf[i] + 10 -y;
        }else{
            ans += buf[i];
        }
        
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
A = []
for i in range(3):
	A.append([int(i) for i in input().split(" ")]);

N = int(input())
called = []
for i in range(N):
 	called.append(int(input()))

import numpy as np
np_card = np.array(A, dtype=np.int32)

def checked_card(card, numbers):
    tmp_card = np.full((3, 3), False)
    for number in numbers:
        tmp_card = np.logical_or(tmp_card, card == int(number))
    return tmp_card

def bingo_or_not(booled_card):
    if booled_card[0][0] and booled_card[0][1] and booled_card[0][2]:
        return "Yes" 
    if booled_card[1][0] and booled_card[1][1] and booled_card[1][2]:
        return "Yes" 
    if booled_card[2][0] and booled_card[2][1] and booled_card[2][2]:
        return "Yes" 
    if booled_card[0][0] and booled_card[1][0] and booled_card[2][0]:
        return "Yes" 
    if booled_card[0][1] and booled_card[1][1] and booled_card[2][1]:
        return "Yes" 
    if booled_card[0][2] and booled_card[1][2] and booled_card[2][2]:
        return "Yes" 
    if booled_card[0][0] and booled_card[1][1] and booled_card[2][2]:
        return "Yes" 
    if booled_card[0][2] and booled_card[1][1] and booled_card[2][0]:
        return "Yes" 
    return "No"

print(bingo_or_not(checked_card(np_card, called)))


Measured memory_bytes: 14280
use std::collections::HashSet;
use std::io;

fn read_lines() -> Vec<i32> {
    let mut line = String::new();
    let mut inputs = Vec::<i32>::new();
    io::stdin().read_line(&mut line).unwrap();
    let n_num = line.trim().parse::<i32>().unwrap();
    line.clear();
    for _ in 0..n_num {
        io::stdin().read_line(&mut line).unwrap();
        let line_num = line.trim().parse::<i32>().unwrap();
        inputs.push(line_num);
        line.clear();
    }
    inputs
}

fn solve(inputs: Vec<i32>) -> i32 {
    let mut past_set = HashSet::new();
    let mut curr_i = inputs[0];
    let mut count = 1;
    for _ in 0..(inputs.len()) {
        if curr_i == 2 {
            return count;
        }
        let next_i = inputs[(curr_i - 1) as usize];
        past_set.insert(curr_i);
        if past_set.contains(&next_i) {
            return -1;
        }
        curr_i = next_i;
        count += 1;
    }
    -1
}

fn main() {
    let inputs = read_lines();
    let res = solve(inputs);
    println!("{}", res);
}


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

int main() {
  int n;
  cin >> n;
  int sum = 0;
  int temp = n;
  while (temp != 0) {
    sum += temp % 10;
    temp /= 10;
  }
  cout << (n % sum == 0 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int tt;
     int a,w,t,r;
    cin>>tt;
    a=w=t=r=0;
    while(tt--){


       string c;
       cin>>c;
       if(c=="AC"){
            a++;
       }
       else if(c=="WA"){
            w++;
       }
       else if(c=="TLE")
       {
           t++;
       }
       else{
        r++;
       }
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",a,w,t,r);
}


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

int main(void){
    char s[4096], p[4096], str[4096];
    
    cin >> s >> p;
    strcpy(str, s);
    strcat(s, str);
    if(strstr(s, p) == NULL) cout << "No" << endl;
    else cout << "Yes" <<endl;
    return 0;
}



Measured memory_bytes: 3104
#include <iostream>

using namespace std;

int main(void)
{
    int W, H, x, y, r;
    bool point = false;
    
    cin >> W >> H >> x >> y >> r;
    if (x + r <= W && x - r >= 0) {
        if (y + r <= H && y - r >= 0) {
            point = true;
        }
    }
    switch (point) {
        case true:
            cout << "Yes" << endl;
            break;
        case false:
            cout << "No" << endl;
            break;
    }
    
    return 0;
}


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

int main() {
  int i,n;
  cin >> n;
  vector<int64_t> l(n+1,2);
  
    l.at(1)=1;
  
  if(n>=2){
    for(i=2;i<=n;i++){
      l.at(i)=l.at(i-1)+l.at(i-2);
      //cout << l.at(i) << endl;
    }
  }
    cout << l.at(n) << endl;
}

Measured memory_bytes: 256
// http://algorithms.blog55.fc2.com/blog-entry-66.html

#include <iostream>
using namespace std;
#include <stdio.h>
#include <string.h>

#define MAX 100

int SIZE;
int R[MAX + 2];
int C[MAX+1][MAX+1]; // cost table
int B[MAX+1][MAX+1]; // best table

void compute(){
	int i=0,j,k;
	memset(C,99,sizeof(C));
    
    for (i = 0; i < SIZE; i++ ) C[i][i] = 0;
    
    for (j = 1; j < SIZE; j++ ){
        for (i = 0; i < SIZE - j; i++ ){
            for (k = i; k < i + j; k++ ){
                // C[i][i+j] = min( C[i][i+j], 
                //                  C[i][k-1] + C[k][i+j] + R[i]*R[k]*R[i+j+1]);
                int cost = C[i][k] + C[k+1][i+j] + R[i]*R[k+1]*R[i+j+1];
                if ( cost < C[i][i+j] ){
                    C[i][i+j] =  cost;
                    B[i][i+j] = k;
                }
                
            }
        }
    }
}

void order( int i, int j ){
    if ( i == j ) cout << "M" << i;
    else{
        cout << "(";
        order( i, B[i][j]-1 ); order(B[i][j], j);
        cout << ")";
    }
}

void input(){
    cin >> SIZE;
	int z,i=0;
    for (; i < SIZE; i++ ) cin >> R[i]>>z;
	R[i]=z;
	//SIZE++;
}

void output(){
    cout <<  C[0][SIZE-1] << endl;
    //order(1, SIZE);
    //cout << endl;
}

main(){
    input();
    compute();
    output();
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
int main()
{
    int k;
    char s[10010];
    cin>>k;
    scanf("%s",s);
    int n=strlen(s);
    if(n<=k) printf("%s",s);
    else {
        for(int i=0;i<k;i++){
            printf("%c",s[i]);
        }
        printf("...");
    }
    return 0;
}


Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) x&(-x)
const int N = 100005;
int n, a[N], c[2*N], s[N];
int query(int x){
    int ans = 0;
    for(int i = x; i; i -= lowbit(i)) ans += c[i];
    return ans;
}
void add(int x){
    for(int i = x; i < 2*N; i += lowbit(i)) c[i] += 1;
}
bool check(int x){
    for(int i = 1; i < 2*N; ++i) c[i] = 0;
    for(int i = 1; i <= n; ++i){
        s[i] = s[i-1] + (a[i] >= x ? 1 : -1);
    }
    long long sum = 0;
    for(int i = 0; i <= n; ++i){
        sum += query(s[i] + N);
        add(s[i] + N);
    }
    return sum >= 1ll*n*n/4;
}
int main(){
    int l = 0, r = 0, ans;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i){
        scanf("%d", a+i);
        r = max(a[i], r);
    }
    for(int i = 1; i <= 32; ++i){
        int mid = (l + r) >> 1;
        if(check(mid)){
            l = mid + 1;
            ans = mid;
        }else r = mid - 1;
    }
    printf("%d\n", ans);
    return 0;
}


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

long long func(long long A, long long B){
    long long cA = A, cB = B;
    int a[100], b[100];
    int i = 0, j, k;
    long long ans = 0;
    while(cB != 0){
       i++;
       b[i] = cB % 2;
       cB = cB / 2;
    }
    k = i;// ketasuu
    int c[k];
    i = 0;
    while(cA != 0){
       i++;
       a[i] = cA % 2;
       cA = cA / 2;
    }
    for(j = i + 1;j <= k; j++){
        a[j] = 0;
    }
    if(a[1] == 0 && b[1] == 1 ){
        if((B - A - 1) % 4 == 0) return 1;
        else return 0;
    }else if(a[1] == 0 && b[1] == 0){
        if((B - A) % 4 == 0){
            return B;
        }else{
            return B + 1;
        }
    }else if(a[1] == 1 && b[1] == 1){
        if((B - A) % 4 == 0){
            return A;
        }else{
            return A - 1;
        }
    }else{
        if((B - A - 1) % 4 == 0){
            for(i = 1; i <= k; i++ ){
                if(a[i] + b[i] == 1) c[i] = 1;
                else c[i] = 0;
                if(c[i]) ans += pow(2, i - 1);
            }
            return ans;
        }else{
            for(i = 1; i <= k; i++ ){
                if(a[i] + b[i] == 1) c[i] = 1;
                else c[i] = 0;
                if(c[i]) ans += pow(2, i - 1);
            }
            if(ans % 2 == 0) return ans + 1;
            else return ans - 1;
        }
    }
    return 0;
}

int main(){
    long long A, B;
    cin >> A >> B;
    if(A == B) cout << A << endl;
    else cout << func(A, B) << endl;

    return 0;
}

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

int main()
{
	int n;
	cin>>n;
	long long minn=100000000;
	for(int i=1;i<=n/2;++i)
	{
		int temp1=i;
		int temp2=n-i;
		long long sum=0;
		while(temp1)
		{
			sum+=temp1%10;
			temp1/=10;
		}
		while(temp2)
		{
			sum+=temp2%10;
			temp2/=10;
		}
		if(sum<minn)
			minn=sum;
	}
	cout<<minn<<endl;
	return 0;
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
const int mod = 1e9+7;
ll qpow(ll a,ll b){ll res=1;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b)cout<<"safe"<<endl;
    else cout<<"unsafe"<<endl;
    return 0;
}


Measured memory_bytes: 3636