akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define all(x) x.begin(), x.end()
using pii = pair<int, int>;
using ll = long long;
const int INF = 1e9;
int dp[101][1010];
struct Edge {
    int to, cost;
};
int N, M, C;
// vector<Edge> G[101], rev[101];
int d[101];

int rec(int i, int j, vector<vector<Edge>>& G) {
    // cerr << i << " " << j << endl;
    if (dp[i][j] < INF) return dp[i][j];
    if (i == N - 1) return dp[i][j] = 0;
    if (j == 0) {
        return dp[i][j] = d[i];
    } else {
        int res = INF;
        for (auto e : G[i]) {
            if (d[e.to] >= d[i]) continue;
            res = min(res, rec(e.to, j, G) + e.cost);
            res = min(res, rec(e.to, j - 1, G));
        }
        return dp[i][j] = res;
    }
    return dp[i][j] = INF - 1;
}
void dijkstra(int s, vector<vector<Edge>>& G) {
    priority_queue<pii, vector<pii>, greater<pii>> que;
    fill(d, d + N, INF);
    d[s] = 0;
    que.push(pii(0, s));
    while (!que.empty()) {
        pii p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++) {
            Edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(pii(d[e.to], e.to));
            }
        }
    }
}
bool solve() {
    cin >> N >> M >> C;
    if (N == 0) return false;
    REP(i, N) REP(j, M + 1) dp[i][j] = 1e9;
    dp[N - 1][0] = 0;
    vector<vector<Edge>> G(N), rev(N);
    REP(i, M) {
        int u, v, c;
        cin >> u >> v >> c;
        u--, v--;
        G[u].push_back({v, c});
        rev[v].push_back({u, c});
    }
    // cerr << "dijkstra" << endl;
    dijkstra(N - 1, rev);
    ////cerr << "dijkstra done" << endl;
    using arr3 = array<int, 3>;
    priority_queue<arr3, vector<arr3>, greater<arr3>> que;
    que.push({0, N - 1, 0});
    while (!que.empty()) {
        arr3 arr = que.top();
        que.pop();

        int res = arr[0], pos = arr[1], k = arr[2];
        // cerr << pos << " " << k << " " << res << endl;
        // if (res >= dp[pos][k]) continue;
        dp[pos][k] = min(dp[pos][k], res);
        for (auto e : rev[pos]) {
            int nxt = e.to;
            if (dp[nxt][k] > dp[pos][k] + e.cost) {
                dp[nxt][k] = dp[pos][k] + e.cost;
                que.push({dp[nxt][k], nxt, k});
            }
            if (dp[nxt][k + 1] > dp[pos][k]) {
                dp[nxt][k + 1] = dp[pos][k];
                que.push({dp[nxt][k + 1], nxt, k + 1});
            }
        }
    }
    // cerr << "done" << endl;
    REP(i, M + 1) {
        if (dp[0][i] <= C) {
            cout << i << endl;
            return true;
        }
    }
    return true;
}

signed main() {
    while (solve())
        ;
}



Measured memory_bytes: 9144
package main

import (
	"fmt"
)

func main() {
	var r, g, b int
	fmt.Scan(&r, &g, &b)
	rgb := r*100 + g*10 + b
	if rgb%4 == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


Measured memory_bytes: 512
import itertools,collections
def main():
    n,m=map(int, input().split())
    pos = []
    checkp = []
    for i in range(n):
        a,b=map(int, input().split())
        pos.append((a,b))
    for i in range(m):
        c,d = map(int, input().split())
        checkp.append((c,d))

    res = []
    for i in range(n):
        shortes = 10000000000
        index = 1000
        for j in range(m):
            if(shortes>abs(pos[i][0]-checkp[j][0]) + abs(pos[i][1]-checkp[j][1])):
                shortes=abs(pos[i][0]-checkp[j][0]) + abs(pos[i][1]-checkp[j][1])
                index = j

        res.append(index+1)
    for i in res:
        print(i)

if __name__ == '__main__':
    main()


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

const int maxn=2e5+10;
const int mod=998244353;
char c[maxn];
ll a[maxn],sum[maxn],tot,f[maxn],b[maxn];
int n;
ll poww(ll x,ll k) {
	ll ans=1;
	while(k) {
		if(k&1) ans=ans*x%mod;x=x*x%mod;k>>=1; 
	}return ans;
}
bool check(int x) {
	int now=1,f=0;
	for(int i=1;i<=n;++i) {
		if(((c[now]-'0')^f)>(c[i]-'0')) return 0;
		else if(((c[now]-'0')^f)<(c[i]-'0')) return 1;
		else {
			now++;
			if(now>x) now=1,f^=1;
		}
	}
	return 1;
}
int get(int x) { 
	if((n/x)%2) {
		if(check(x))
		return sum[x]+1;
		else return sum[x];
	}
	return 0;
} 
ll ans;
int main()
{
	scanf("%d",&n);
	scanf("%s",c+1);
	for(int i=1;i<=n;++i) {
		tot=tot*2%mod;
		if(c[i]=='1') tot=tot+1;
		sum[i]=tot; 
	//	cout<<sum[i]<<"*\n";
	}
	tot=tot%mod;
	for(int i=1;i<=sqrt(n);++i) {
		if(n%i==0) f[i]=get(i);
		if(i*i!=n&&(n%(n/i)==0)) f[n/i]=get(n/i);
	}
	//cout<<get(n/2)<<"\n";
	//for(int i=1;i<=n;++i) cout<<f[i]<<"*\n";
	for(int i=1;i<=n;++i) {
		for(int j=i+i;j<=n;j+=i) f[j]=(f[j]-f[i]+mod)%mod;
	}
	for(int i=1;i<=n;++i) {
		if(n%i==0) {
			ans=(ans+f[i]*2*i%mod)%mod;
		}
	}
	cout<<ans<<"\n";
	return 0;
}
/*
5
00100
*/

Measured memory_bytes: 5120
#include <iostream>
#include <climits>

int main()
{
    int h,n;
    std::cin>>h>>n;
    int a[1001], b[1001], dp[10001]={0};
    for (int i=0; i<n; i++) std::cin>>a[i]>>b[i];
    for (int i=1; i<=h; i++) dp[i]=INT_MAX;
    for (int i=1; i<=h; i++)
        for (int j=0; j<n; j++)
    {
        if (i>=a[j])
            dp[i]=std::min(dp[i],dp[i-a[j]]+b[j]);
        else dp[i]=std::min(dp[i],dp[0]+b[j]);
    }
    std::cout<<dp[h];
    return 0;
}


Measured memory_bytes: 3692
n, m = gets.chomp.split.map(&:to_i)
ans = 0
x = []

n.times do |hoge|
    i = gets.chomp.split.map(&:to_i)
    x [hoge] = i
end
x =  x.sort {|a,b| a[0] <=> b[0]}
n.times do |hoge|
    if m < x[hoge][1]
        ans += x[hoge][0] * m
        break
    else
        ans += x[hoge][0] * x[hoge][1]
        m -= x[hoge][1]
    end
end
puts ans




Measured memory_bytes: 11128
#include<iostream>
#include<string>
using namespace std;
int main(){
	int h,w;
	string c[100];
	cin>>h>>w;
	for(int i=0;i<h;i++){
		cin>>c[i];
	}
	for(int i=0;i<h;i++){
		cout<<c[i]<<endl;
		cout<<c[i]<<endl;
	}
	return 0;
}

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

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,m;
    cin >> n >> m;
    vector<int> v(m);
    for (int i=0;i<m;i++)
    {
        cin >> v[i];
        n-=v[i];
    }
    n=max(n,-1);
    cout << n;
}



Measured memory_bytes: 3672
group = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]

x, y = gets.split.map(&:to_i)

x_belongs_group = group.find { |array| array.include?(x) }

if x_belongs_group.include?(y)
  puts 'Yes'
else
  puts 'No'
end


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

#define REP(i,m,n) for(int i=(int)m; i < (int) n; ++i)
#define rep(i,n) REP(i,0,n)

int H, W;
vector<vector<int> > field;

void dfs(int h, int w) {
    field[h][w] = 0;
    for(int i = -1; i <= 1; i++) {
        for(int j = -1; j <= 1; j++) {
            int nh = h+i;
            int nw = w+j;
            
            if(nh < 0 || nw < 0 || nh >= H || nw >= W) continue;
            if(field[nh][nw] == 0) continue;
            dfs(nh, nw);
        }
    }
}

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

    while(cin >> W >> H) {
        if(H == 0 && W == 0) break;
        field.assign(H, vector<int> (W, 0));
        rep(i, H) rep(j, W) cin >> field[i][j];
        int ans = 0;
        rep(i, H) rep(j, W) {
            if(field[i][j] == 0) continue;
            dfs(i, j);
            ans++;
        }

        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 3380
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <queue>
typedef long long ll;
#define rep(i,n) for(int i = 0;i<n;++i)
#define repc(bit,k,n) for (int bit = (1<<k)-1;bit < (1<<n); bit = next_combination(bit))
#define repi(itr,vec) for(auto itr = vec.begin();itr!=vec.end();++itr)
using namespace std;
using Graph = vector<vector<int> >;

/* next combination
 * usage:repc(bit,k,n)
 * */
inline int next_combination(int sub) {
  int x = sub & -sub, y = sub + x;
  return (((sub & ~y) / x) >> 1) | y;
}

/* uniq
 * usage:uniq(vec)
 * */
void uniq(vector<int> &vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return;
}

/* BinaryIndexedTree
 * usage:update and sum of 1~N
 * */
int N;
int bit[1000010];
void add(int a, int w) {
  for (int x = a; x <= N; x += x & -x) bit[x] += w;
}
int sum(int a) {
  int ret = 0;
  for (int x = a; x > 0; x -= x & -x) ret += bit[x];
  return ret;
}

/* DP
 * usage: chmin(dp[i],dp[i-1]+v);
 * */
const ll INF = 1LL << 60;
ll dp[100010];

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;
}
int main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
  int n;cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  ll ans = 0;
  rep(i,n-1){
    if(a[i]>a[i+1]){
      ans+=a[i]-a[i+1];
      a[i+1]=a[i];
    }
  }
  cout<<ans<<'\n';

        return 0;
}

Measured memory_bytes: 4756
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

ll n,a,b;
ll v[100010];

bool check(ll mid)
{
	ll num = 0;
	REP(i,n)
	{
		ll tmp = b*mid;
		
		if((v[i] - tmp + a - 1) / a > 0)
		{
			num += (v[i] - tmp + a - 1) / a;
		}
	}
	
	return mid >= num;
}

int main()
{
	cin >> n>> a>> b;
	a -= b;
	
	
	REP(i,n)
	{
		cin >> v[i];
	}
	
	ll ub,tb;
	ub = 0;tb = 10000000000;
	
	while(tb - ub > 1)
	{
		ll mid = (ub+tb)/2;
				
		if(check(mid))tb = mid;
		else ub = mid;
	}
	
	cout << tb << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<fstream>
#include<sstream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<vector>
#include<cmath>
#include<ctime>
#include<locale>
using namespace std;
pair<long,long >a[100001];
int main()
{
    long n,k;
    memset(a,0,sizeof(a));
    cin>>n>>k;
    for(long i=0;i<n;i++)
    {
        scanf("%d%d",&a[i].first,&a[i].second);
    }
    sort(a,a+n);
    long x=0;
    for(long s=0;s<k;x++)
    {
        s=s+a[x].second;
    }
    cout<<a[x-1].first;
	return 0;
}


Measured memory_bytes: 1792
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007


signed main(){
    int S,W;
    cin>>S>>W;
    
    if(S<=W) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int h, w, n;
    cin >> h >> w >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    int panel[w];
    int num = 0, idx = 0;
    rep(i, h) {
        if (i % 2 == 0) {
            rep(j, w) {
                panel[j] = idx + 1;
                num++;
                if (num == a[idx]) {
                    idx++;
                    num = 0;
                }
            }
        } else {
            repr(j, w, 0) {
                panel[j] = idx + 1;
                num++;
                if (num == a[idx]) {
                    idx++;
                    num = 0;
                }
            }
        }

        rep(j, w) cout << panel[j] << ((j < w - 1) ? " " : "\n");
    }
    return 0;
}

Measured memory_bytes: 384
import numpy as np
from itertools import product

n = int(input())

c = np.zeros((10, 10), dtype=np.int)
for i in range(1, n+1):
    first = int(str(i)[0])
    last = int(str(i)[-1])
    c[first, last] += 1

res = 0
for i, k in product(range(10), repeat=2):
    res += c[i, k] * c[k, i]

print(res)


Measured memory_bytes: 14456
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    string s;
    cin>>s;
    
    map<char,int> mp;
    
    rep(i,s.size()){
        mp[s[i]]++;
    }
    
    if( mp['S']!=0 && mp['N']==0 ||
        mp['S']==0 && mp['N']!=0 ||
        mp['E']!=0 && mp['W']==0 ||
        mp['E']==0 && mp['W']!=0){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}

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

const int INF = 1e9 + 5;

int main() {

    int N;
    scanf("%d", &N);

    vector<int> dp(3);

    for (int day = 0; day < N; ++day) {
        vector<int> c(3);
        vector<int> new_dp(3, -INF);

        for (int i = 0; i < 3; ++i) scanf("%d", &c[i]);

        for (int i = 0; i < 3; ++i)
            for (int j = 0; j < 3; ++j) {
                if (i != j)
                    new_dp[j] = max(new_dp[j], dp[i] + c[j]);
            }

        dp = new_dp;
    }

    printf("%d\n", max(dp[0], max(dp[1], dp[2])));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;

int main() {
    int n;
    cin >> n;
    deque<int> que;
    for(int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        if((n - i) % 2)
            que.push_front(a);
        else
            que.push_back(a);
    }
    for(auto i : que)
        cout << i << " ";
    return 0;
}


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

using namespace std;

int n, m;
int arr[310][310];
bool chk[310];

int cnt[310];
pair<int,int> num() {
	int i, j, maxi = 0, t;
	for (i=0;i<n;i++) {
		for (j=0;j<m;j++) if (chk[arr[i][j]]) break;
		cnt[arr[i][j]]++;
		maxi = max(maxi,cnt[arr[i][j]]);
	}
	for (i=0;i<m;i++) if (maxi==cnt[i]) t=i;
	for (i=0;i<m;i++) cnt[i] = 0;
	return {t,maxi};
}

int main() {
	int i, j, res = 654;

	scanf("%d%d",&n,&m);
	for (i=0;i<n;i++) for (j=0;j<m;j++) {scanf("%d",&arr[i][j]);arr[i][j]--;}
	for (i=0;i<m;i++) chk[i] = 1;
	for (i=0;i<m;i++) {
		pair<int,int> tmp = num();
		chk[tmp.first] = 0; res = min(res,tmp.second);
	}
	printf("%d\n",res);

    return 0;
}


Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))

b = [0 for _ in range(n)]


def check(i, n):
    cnt = 0
    t = i
    while t <= n:
        cnt += b[t-1]
        t += i
    return cnt


for i in range(n-1, -1, -1):
    if (a[i] + check(i+1, n)) % 2 == 1:
        b[i] = 1

ans = []
cnt = 0
for i in range(n):
    if b[i] == 1:
        cnt += 1
        ans.append(i+1)
print(cnt)
l = [str(int(i)) for i in ans]
print(' '.join(l))


Measured memory_bytes: 23092
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
void dout() { cerr << '\n'; }
 
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}
 
#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
 
const int N = 2e5 + 123;
int n, a[N];
set <pii> st;
 
void add(int pos, int x) {
    if (pos < 1) {
        return;
    }
    if (!st.empty()) {
        if ((*prev(st.end())).fi == pos) {
            return;
        }
        if ((*prev(st.end())).se == x) {
            st.erase(prev(st.end()));
        }
    }
    st.insert({pos, x});
}
 
void debug() {
    cout << "st:\n";
    for (auto i : st) {
        cout << i.fi << ' ' << i.se << '\n';
    }
    cout << '\n';
}
 
bool check(int k) {
    st.clear();
    add(a[1], 0);
    pii last;
    for (int i = 2; i <= n; i++) {
        if (a[i - 1] < a[i]) {
            add(a[i], 0);
        }   else {
            last.fi = 0;
            while (!st.empty() && (*prev(st.end())).fi >= a[i]) {
                last = *prev(st.end());
                st.erase(prev(st.end()));
            }
            last.fi = a[i];
            add(last.fi, last.se);
            last = *prev(st.end());
            if (last.se == k - 1) {
                st.erase(prev(st.end()));
                if (st.empty()) {
                    return false;
                }
                last = *prev(st.end());
                st.erase(prev(st.end()));
                last.fi--;
                add(last.fi, last.se);
                last.fi++;
                last.se++;
                add(last.fi, last.se);
                last.fi = a[i];
                last.se = 0;
                add(last.fi, last.se);
            }   else {
                st.erase(prev(st.end()));
                last.fi--;
                add(last.fi, last.se);
                last.fi++;
                last.se++;
                add(last.fi, last.se);
            }
        }
    }
    return true;
}
 
int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
 
    cin >> n;
    if (n == 1) {
        cout << 1;
        return 0;
    }
    bool good = true;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if (i > 1 && a[i] <= a[i - 1]) {
            good = false;
        }
    }
    if (good) {
        cout << 1;
        return 0;
    }
    int l = 1, r = n;
    while (l < r - 1) {
        int mid = l + r >> 1;
        if (check(mid)) {
            r = mid;
        }   else {
            l = mid;
        }
    }
    cout << r;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	ll n, x, t;
	cin >> n >> x >> t;
	cout << (n + x - 1) / x * t << '\n';
}



Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
int x[100010];
int dat[500000];
bool used[100010];
void update(int i,int a,int b,int l,int r,int z){
	if(a<=l&&b>=r){
		dat[i]+=z;
		return ;
	}
	if(r<=a||b<=l) return ;
	update(i*2+1,a,b,l,(l+r)/2,z);
	update(i*2+2,a,b,(l+r)/2,r,z);
	dat[i]=max(dat[i*2+1],dat[i*2+2]);
}
int qe(int i,int a,int l,int r,int z){
	if(a<l&&r-l==1&&dat[i]>z&&!used[l]){
		used[l]=true;
		dat[i]=-1;
		return l;
	}
	if(r-l==1) return INF;
	if(dat[i*2+1]>z&&(r+l)/2>a+1){
		int bo=qe(i*2+1,a,l,(l+r)/2,z);
		if(bo==INF&&dat[i*2+2]>z)bo=qe(i*2+2,a,(l+r)/2,r,z);
		dat[i]=max(dat[i*2+1],dat[i*2+2]);
		return bo;
	}
	if(dat[i*2+2]>z){
		int bo=qe(i*2+2,a,(l+r)/2,r,z);
		dat[i]=max(dat[i*2+1],dat[i*2+2]);
		return bo;
	}
	return INF;
}
signed main(){
	int n,ans=0;
	cin>>n;
	f(i,n){
		cin>>x[i];
		update(0,i,i+1,0,n,x[i]);
	}
	f(i,n){
		if(!used[i]){
			used[i]=true;
			int z=qe(0,i,0,n,x[i]);
			while(z!=INF){
				z=qe(0,z,0,n,x[z]);
			}
			ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 4992
from collections import deque

n = int(input())

q = deque()

for _ in range(n):
	com = input()
	if com[0] == "i":
		q.appendleft(com[7:])
	elif len(com) == 11:
		q.popleft()
	elif len(com) == 10:
		q.pop()
	else:
		try:
			q.remove(com[7:])
		except:
			pass


print(*q)



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


int main(){
  long long int X;
  cin >> X;
  long long int money=100;
  long long int ans=0;
  while(money<X){
    money = money + money * 0.01;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
N = int(input())
*A, = map(int,input().split())

X = []
tmp = 0
for i in range(1,N,2):
    tmp += A[i]
X.append(sum(A)-2*(tmp))

for i in range(N-1):
    X.append(2*A[i]-X[i])

for num in X:
    print(num,end = " ")
print()


Measured memory_bytes: 14028
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

ll weight[100010],value[100010],dp[100010][102];

int main(){
    int n,total;
    scanf("%d %d",&n,&total);
    for(int i=1;i<=n;i++){
        scanf("%lld%lld",&weight[i],&value[i]);
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=total;j++){
            if(j-weight[i]>=0)
                dp[j][i]=max(dp[ j-weight[i] ][ i-1 ]+value[i],dp[j][i-1]);
            dp[j][i]=max(dp[j][i],dp[j][i-1]);
        }
    }
    /*
    for(int i=1;i<=n;i++){
        for(int j=1;j<=total;j++){
            cout<<dp[j][i]<<' ';
        }
        cout<<'\n';
    }*/
    printf("%lld",dp[total][n]);
    
    
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

using namespace std;

typedef long long ll;

ifstream fin ("spioni.in");
ofstream fout ("spioni.out");

#define f first
#define s second

int c;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  char ch;
  cin >> ch;
  cout << (char)(ch + 1);
  return 0;
}


Measured memory_bytes: 256
import numpy as np
import sys
input = sys.stdin.readline

MOD = 10 ** 9 + 7

n, m = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))

weight_n = np.array([(i + 1) * (n - i - 1) % MOD for i in range(n - 1)]).astype(np.int64)
weight_m = np.array([(i + 1) * (m - i - 1) % MOD for i in range(m - 1)]).astype(np.int64)

dxs = np.array([xs[i+1] - xs[i] for i in range(n-1)]).astype(np.int64)
dys = np.array([ys[i+1] - ys[i] for i in range(m-1)]).astype(np.int64)

t_x = np.sum(weight_n * dxs % MOD) % MOD
t_y = np.sum(weight_m * dys % MOD) % MOD

print(t_x * t_y % MOD)


Measured memory_bytes: 29644
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int z = scanner.nextInt();
        System.out.println(z + " " + x + " " + y);
        scanner.close();
    }
}


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

long long int solve()
{
	long long int d,t,s;
	cin>>d>>t>>s;
	if(t*s>=d)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

int main() 
{
	long long int q;
	q=1;
	while(q--)
	{
	    if(solve())
	    cout<<"Yes"<<endl;
	    else
	    cout<<"No"<<endl;
	}
    
}
 

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define IREP(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define MOD (1000 * 1000 * 1000 + 7)

typedef long long ll;

typedef pair<int, int> pint;

int main() {
    int a, b, t;
    cin >> a >> b >> t;
    int next = 0, cnt = -b, i = 1;
    while(next <= t){
        next += a * i;
        cnt += b;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
#include<iostream> 

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
	string s;
	rep(i, 3) {
		cin >> s;
		cout << s.at(0);
	}
	cout << "\n";
	
	return 0;
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in) ;
        int a = Integer.parseInt(sc.next()) ;
        int b = Integer.parseInt(sc.next()) ;
        if(a>b) System.out.println("safe");
        else System.out.println("unsafe");
    }
}


Measured memory_bytes: 35736
#include <cstdio>
#include <algorithm>

constexpr int MAX_X = 4, MAX_YN = 50;

int main(){
    while(true){
        int X, Y, Z;
        int roulette[MAX_X], jump[MAX_YN]{}, get_money[MAX_YN]{};
        float dp[MAX_YN + 1][100 * MAX_YN + 1]{1};
        scanf("%d%d%d", &X, &Y, &Z);
        if(!X){
            break;
        }
        for(int i = 0; i < X; ++i){
            scanf("%d", &roulette[i]);
        }
        for(int i = 0; i < Z; ++i){
            int n, e, a;
            scanf("%d%d%d", &n, &e, &a);
            switch(e){
                case 1:
                    jump[n] = a;
                    break;
                case 2:
                    get_money[n] = a;
                    break;
                case 3:
                    get_money[n] = -a;
                    break;
            }
        }
        for(int i = 0; i < Y; ++i){
            for(int j = 0; j <= 5000; ++j){
                if(dp[i][j] == 0){
                    continue;
                }
                for(int k = 0; k < X; ++k){
                    int ni, nj;
                    ni = std::min(i + roulette[k], Y);
                    nj = std::max(j + get_money[ni], 0);
                    ni = std::min(ni + jump[ni], Y);
                    dp[ni][nj] += dp[i][j] / X;
                }
            }
        }
        float ans = 0;
        for(int i = 0; i <= 5000; ++i){
            ans += dp[Y][i] * i;
        }
        printf("%d\n", (int)ans);
    }
    return 0;
}

Measured memory_bytes: 3580
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define VI vector<int>
#define VL vector<lint>
#define VB vector<bool>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVL vector<VL>
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define REPR(i, x, n) for(int i = n - 1 ; i >= x ; i--)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) REPR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    string s;
    cin >> s;
    int ans = 0;
    rep(i, s.size() - 1){
        if(s[i] != s[i+1]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
//----->|try=0; while(!success) try++;|<------
//----->|Belief Yourself,Respect Yourself|<----
//----->|Be Proud Of Yourself,You're Doing Your best|<-----
#include<bits/stdc++.h>
using namespace std;
#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search;
#define lower(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Lower value search;
#define max3(a,b,c) max(max(a,b),c)//maximum value find three value;
#define min3(a,b,c) min(min(a,b),c)//minimum value find three value;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, n) for(int i = 1; i <= n; ++i)
#define rep1(i,start,n) for(int i=start;i<n;++i)
#define PI acos(-1.0)//PI Calculation
#define LL long long
#define AND(a,b) ((a) & (b))
#define OR(a,b) ((a)|(b))
#define XOR(a,b) ((a) ^ (b))
#define MP make_pair
#define sqr(x) ((x)*(x))
#define sqrt(x) sqrt(1.0*(x))
#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define MX 1000005
#define MOD 1000000007
template<typename T> T POW(T b,T p)          //Pow calculation
 {
    T r=1;
    while(p) {
        if(p&1)r=(r*b);
        b=(b*b);
        p>>=1;
    }
    return r;
}

template<typename T> T BigMod(T b,T p,T m) //BigMod Calculation
{
    T r=1;
    while(p) {
        if(p&1)r=(r*b)%m;
        b=(b*b)%m;
        p>>=1;
    }
    return r;
}

//||--------------------------->||Main_Code_Start_From_Here||<---------------------------------||
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    int n,a,b,cnt,ar;
    while(cin>>n>>a>>b)
    {
        cnt=0;
        rep(i,n)
        {
            cin>>ar;
            if(ar<a) cnt++;
            if(ar>=b) cnt++;
        }
        cout<<cnt<<endl;
    }
}




Measured memory_bytes: 256
Public Class Compiler
    Shared Sub Main()
        Const c As Integer = 2019
        Dim input As String() = Console.ReadLine().Split(" ")
        Dim l As Integer = Integer.Parse(input(0))
        Dim r As Integer = Integer.Parse(input(1))
        Dim output As Integer = c
        If r - l < c Then
            For i As Integer = l To r
                For j As Integer = i + 1 To r
                    output = Math.Min(((i Mod c) * (j Mod c)) Mod c, output)
                Next
                If output = 0 Then Exit For
            Next
        End If
        output = output Mod c
        Console.WriteLine(output)
    End Sub
End Class

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

using namespace std;

const int maxn = 1e5 + 9;
long long result[maxn];

class dsu {
public:
	vector<int> parent, size;
	dsu(int n) : parent(n + 1), size(n + 1, 1) {
		for (int i = 0; i < n + 1; i++) {
			parent[i] = i;
		}
	}
	int find(int u) {
		if (u == parent[u]) return u;
		return parent[u] = find(parent[u]);
	}
	long long merge(int u, int v) {
		u = find(u); v = find(v);
		if (u == v) return -1LL;
		long long ret = size[u] * (size[u] - 1LL) * 1LL / 2LL + size[v] * (size[v] - 1LL) * 1LL / 2LL;
		parent[u] = v;
		size[v] += size[u];
		size[u] = 0;
		return ret;
	}
};

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> edges;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		edges.push_back(make_pair(a, b));
	}
	long long inf = n * (n - 1LL) * 1LL / 2LL, tmp = inf;
	dsu uf(n);
	for (int i = 0; i < m; i++) {
		result[m - i - 1] = tmp;
		pair<int, int> edge = edges[m - i - 1];
		long long d = uf.merge(edge.first, edge.second);
		if (d == -1LL) continue;
		tmp += d;
		int size = uf.size[uf.find(edge.first)];
		tmp -= size * (size - 1LL) * 1LL / 2LL;
	}
	for (int i = 0; i < m; i++) {
		cout << result[i] << '\n';
	}
	
	return 0;
}


Measured memory_bytes: 3700
//default
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
typedef pair<int, int> P_i;
typedef pair<double,double> P_d;
#define rep(i,n) for(int i=0;i<(n);++i)
#define alrep(i,j,n) for(int i=0;i<(n);++i)for(int j=i+1;j<(n);++j)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
int ans=0;
#define answer cout << ans << endl;
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; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;

unordered_map<string,int> mp;

signed main(){
  int N;
  cin >> N;
  rep(i,N){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  for(auto p:mp){
    ans+=p.second*(p.second-1)/2;
  }
  answer
  return 0;
}


Measured memory_bytes: 10660
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n;
    vector<int>v;
    v.push_back(0);
    for(int i=0;i<n;i++)
    {
        cin>>m;
        v.push_back(m);
    }
    int dp[n+1];
  
    for(int i=1;i<=n;i++)
    dp[i]=100000;
    dp[1]=0;
    dp[2]=abs(v[2]-v[1]);
    for(int i=3;i<=n;i++)
        dp[i]=min(dp[i-2]+abs(v[i]-v[i-2]),dp[i-1]+abs(v[i]-v[i-1]));
      
    cout<<dp[n];
        
    
}

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> C(H, vector<char>(W));
    rep(i, H) {
        rep(j, W) {
            cin >> C.at(i).at(j);
        }
    }

    rep(i, H) {
        rep(j, W) {
            cout << C.at(i).at(j);
        }
        cout << endl;
        rep(j, W) {
            cout << C.at(i).at(j);
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long
#define INF 1000000001

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string n;cin>>n;
  if(n[0]=='9' || n[1]=='9'){
    P("Yes");
  }else{
    P("No");
  }
  return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  ervb
//
//  Created by Kanak Gautam on 21/04/20.
//  Copyright © 2020 Kanak Gautam. All rights reserved.
//
 
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#define pb push_back
#define mk make_pair
#define endl "\n"
#define mod 1000000007
using namespace std;
typedef long long int lli;
typedef long double ld;
priority_queue <lli, vector<lli>, greater<lli> > ti;
vector <lli> p[500005],g[500005],f(500005,0),b(500005,0),a(500005,0),ans(500005,0);
map <pair<lli,lli>,lli> mp;
set<pair<lli, lli> > s;
set<lli> st;
map<lli,lli> np,v;
queue<lli> qy;
lli n,q;
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
lli bpow(lli a, lli b) {
    lli res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res%mod;
}
lli fact(lli i)
{
    f[0]=1;
    for(lli k=1;k<=i;k++)
    {
        (f[k]=f[k-1]*k)%=mod;
    }
    return f[i];
}
lli isprime(lli n)
{
    if(n==1)
        return 0;
    for(lli i=2;i<=sqrt(n);i++)
        if(n%i==0)
            return 0;
    return 1;
}
bool cmp(lli i,lli j)
{
    return p[i].size()<p[j].size();
}
/*void sieve()
{
    for(lli i=2;i<=5000000;i++)
    {
        if(b[i]==0)
        {
        for(lli j=2;i*j<=5000000;j++)
        {
            b[i*j]=1;
        }
        }
    }
}*/
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    lli n;cin>>n;
    vector<lli> a(n);
    set<lli> s;
    for(lli i=0;i<n;i++)
    {
        cin>>a[i];
        s.insert(a[i]);
    }
    lli ans=0;
    for(lli i=0;i<n;i++)
    {
        for(lli j=i+1;j<n;j++)
        {
            if(a[i]!=a[j])
            {
            for(lli k=j+1;k<n;k++)
            {
                if(a[k]<a[i]+a[j] && a[k]>abs(a[i]-a[j]) && a[k]!=a[j] && a[k]!=a[i])
                    ans++;
            }
            }
        }
    }
    cout<<ans<<endl;
}


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

int main() {
  unsigned long n, d, count = 0;
  cin >> n >> d;
  long x[n], y[n];
  for (unsigned long i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    if (sqrt(x[i]*x[i] + y[i]*y[i]) <= d) count++;
  }
  
  cout << count;
  
  return 0;
}

Measured memory_bytes: 6764
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int h = Integer.parseInt(sc.next());
		int a = Integer.parseInt(sc.next());
		int count = 0;
		for(int i=0; h>0; i++){
			h -= a;
			count++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 35652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println((b - a - 1) % 2 == 1 ? "Alice" : "Borys");
	}
}


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

using namespace std;

int main()
{
    int n,h,w;
    cin >> n >> h >>w ;
    int ans=0;
    for (int i=0;i<n;i++)
    {
        int x,y;
        cin >> x >> y;
        ans+=((x/h)*(y/w))>0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for _ in range(M)]

good = [1]*N

for ab in AB:
    if H[ab[0] - 1] < H[ab[1] - 1]:
        good[ab[0] - 1] = 0
    elif H[ab[0] - 1] > H[ab[1] - 1]:
        good[ab[1] - 1] = 0
    elif H[ab[0] - 1] == H[ab[1] - 1]:
        good[ab[0] - 1] = 0
        good[ab[1] - 1] = 0

print(sum(good))

Measured memory_bytes: 27336
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)

	nums := scanNums(n)

	bottom := 0.0
	for _, num := range nums {
		bottom += 1.0 / float64(num)
	}

	fmt.Println(1.0 / bottom)
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}


Measured memory_bytes: 512
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

struct question {
  point: u32,
  stock: u32,
  c_point: u32,
}

fn main() {
  let d = read::<u32>();
  let g = read::<u32>();
  let mut qs = vec![];
  let mut answers = vec![];

  for i in 0..d {
    let p = read::<u32>();
    let c = read::<u32>();
    qs.push(question {
      point: (i + 1) * 100,
      stock: p,
      c_point: c,
    })
  }

  let two: u32 = 2;
  for i in 0..two.pow(d) {
    let result: String = format!("{:0>keta$b}", i, keta = d as usize);

    let r_char: Vec<char> = result.chars().collect();

    let yes_r: Vec<&question> = qs
      .iter()
      .filter(|x| r_char[((x.point / 100) - 1) as usize] == '1')
      .collect();
    let no_r: Vec<&question> = qs
      .iter()
      .filter(|x| r_char[((x.point / 100) - 1) as usize] != '1')
      .collect();

    let mut b_p: u32 = yes_r.iter().map(|x| (x.point * x.stock) + x.c_point).sum();
    let mut cost: u32 = yes_r.iter().map(|x| x.stock).sum();

    let mut no_r_cp = no_r.clone();

    if b_p >= g {
      answers.push(cost)
    } else {
      no_r_cp.sort_by_key(|x| x.point);
      let max_q: &question = match no_r_cp.last() {
        Some(s) => s,
        None => continue,
      };
      for _ in 1..max_q.stock {
        b_p += max_q.point;
        cost += 1;

        if b_p >= g {
          answers.push(cost)
        }
      }
    }
  }

  println!("{:?}", answers.iter().min().unwrap());
}



Measured memory_bytes: 4352
h, w = gets.split.map(&:to_i)
a = (1..h).map { gets.chomp }
count = -> i, j, c {
    (i..j).map {|k| w - a[k].count(c)}.inject(:+)
}
p (1..h-1).to_a.combination(2).map {|b, r|
    count[0, b-1, ?W] + count[b, r-1, ?B] + count[r, h-1, ?R]
}.min


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

int main() {
    string s;
    cin >> s;
    if (s.size() == 2) cout << s << endl;
    else {
        reverse(s.begin(), s.end());
        cout << s << endl;
    }
}


Measured memory_bytes: 256
a = int(input())
b = input().split()
x = []
for i in b:
    x.append(int(i))

count = 0

for i in x:
    if i % 2 != 0:
        count += 1

z = divmod(count,2)


if z[1] == 1:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 14108
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    int ans = 0;
    for(int i = 0; i < 1000000000; i++){
        for(int j = 0; j < N; j++){
            if(A[j]%2 == 0) A[j] /= 2;
            else{
                cout << ans << endl;
                return 0;
            }
        }
        ans++;
    }
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
box = list(map(int, input().split()))
box = np.array(box)
count=0
while(True):
  if any([i % 2 != 0 for i in box]):
    break
  elif all([i % 2 == 0 for i in box]):
    box /= 2
    count +=1
print(count)

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}


vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0 || vis[x] > (num+1))
      dfs2(x, curr, num+1);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != 0) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}
// Combination
ll modcomb(ll n, ll r)
{
  if(n < r) return 0;
  ll res = fact(n);
  (res *= ppow(fact(r), M-2)) %= M;
  (res *= ppow(fact(n-r), M-2)) %= M;
  return res;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find
// Find()
int parent[N], ran[N];
int find(int x)
{
    if(parent[x]==x)return x;
    else return parent[x]=find(parent[x]);
}
// Union()
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;

    if(ran[x]<ran[y])
        parent[x]=y;
    else{
        parent[y]=x;
        if(ran[x]==ran[y])ran[x]++;
    }
}

// Main Code

int main()
{
  int n,m;
  cin>>n>>m;
  cout<<((n-1)*(m-1))<<endl;
  return 0;
}


Measured memory_bytes: 14080
def k(S):
    N = len(S)
    n = N // 2
    #print(n, N)
    for i in range(n):
        #print(S[i], S[N-1-i])
        if S[i] != S[N-1-i]:
            return False
    return True

def main():
    S = input()
    N = len(S)
    n = N // 2

    o = (N + 3) // 2
    if k(S) and k(S[:n]) and k(S[o-1:]):
        print("Yes")
    else:
        print("No")


    return 0


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(a, b, c) for(int a = (b); a <= (c); ++ a)
#define per(a, b, c) for(int a = (b); a >= (c); -- a)
using namespace std;
template <class T> void rd(T &x){
  x = 0; int f = 1; char ch = getchar();
  while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); }
  while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  x *= f;
}

typedef pair <int, int> pii;
const int maxn = 55;
int n;
int a[maxn];
int mx, mi, pos_mx, pos_mi;
pii st[maxn];
int top;

int main(){
  rd(n);
  rep(i, 1, n){
	rd(a[i]);
	if(a[i] < 0){
	  if(a[i] < mi) mi = a[i], pos_mi = i;
	}
	else if(a[i] > mx) mx = a[i], pos_mx = i;
  }
  if(mx > -mi){
	rep(i, 1, n) if(a[i] < 0){
	  st[++ top] = pii(pos_mx, i);
	}
	rep(i, 2, n) st[++ top] = pii(i - 1, i);
  }
  else{
	rep(i, 1, n) if(a[i] > 0){
	  st[++ top] = pii(pos_mi, i);
	}
	per(i, n, 2) st[++ top] = pii(i, i - 1);
  }
  printf("%d\n", top);
  rep(i, 1, top) printf("%d %d\n", st[i].first, st[i].second);
  return 0;
}


Measured memory_bytes: 256