akhauriyash/Code-Regression huggingface dataset:
N = int(input())
F = []
for _ in range(N):
    F.append(sum([int(f)<<i for i, f in enumerate(input().split())]))

P = [list(map(int, input().split())) for _ in range(N)]
B = []
for d in range(1,1024):
    b = 0
    for f, p in zip(F,P):
        c = 0
        ovlp = d&f
        while ovlp:
            if ovlp&1: c+=1
            ovlp>>=1
        b+=p[c]
    B.append(b)

print(max(B))

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

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

    vector<double> v;

    for(int i=0; i<n; i++)
    {
        double x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    

    double ans = v[0];
    for(int i=1; i<n; i++)
    {
        ans = (ans + v[i]) / 2;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
const int MAX_D = 10100;
const int MAX_K = 100;
const int MOD = 1e9+7;

template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a/b; a -= t*b; swap(a, b); u -= t*v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if (e%2 == 0) { p = (p*p)%mod; e /= 2; }
            else { a = (a*p)%mod; e--; }
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

using mint = ModInt<MOD>;

int main() {
    string S;
    int K;
    cin >> S >> K;
    int N = S.length();
    
    mint dp[MAX_D][2][MAX_K] = {0};
    dp[0][0][0] = 1;
    
    for (int i = 0; i < N; i++) {
        const int D = S[i] - '0';
        for (int flag = 0; flag < 2; flag++) {
            for (int k = 0; k < MAX_K; k++) {
                for (int d = 0; d <= (flag ? 9 : D); d++) {
                    dp[i+1][flag || (d<D)][(k+d)%K] += dp[i][flag][k];
                }
            }
        }
    }
    
    cout << (dp[N][0][0] + dp[N][1][0])-1 << endl;
    return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;

#define fbo find_by_order
#define ook order_of_key
#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// void initiate_random() { mt19937_64 rng(std::chrono::system_clock::now().time_since_epoch().count()); }

// /mnt/c/Users/vince/Desktop/POST-IOI/Codeforces/Regular/670


vector<int> idxes[200003];
int A[200003];
int cntA[200003];
int cntB[200003];
int ans[200003];
priority_queue<ii> pq;

int main()
{
	// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);

	int n; scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &A[i]);
		cntA[A[i]]++;
	}
	for(int i = 0; i < n; i++)
	{
		int x; scanf("%d", &x);
		cntB[x]++;
	}
	set<ii> st;
	for(int i = 1; i <= n; i++)
	{
		if(cntB[i])
			st.insert({cntB[i]+cntA[i], i});
	}
	for(int i = 0; i < n; i++)
	{
		if(st.rbegin()->fi > (n-i))
		{
			printf("No\n");
			return 0;
		}

		auto it = (--st.end());
		if(it->se == A[i]) it--;
		int x = it->se;
		st.erase(it);

		it = st.find({cntA[A[i]]+cntB[A[i]], A[i]});
		if(it != st.end()) st.erase(it);

		ans[i] = x;
		cntB[x]--;
		cntA[A[i]]--;

		if(it != st.end()) st.insert({cntB[A[i]]+cntA[A[i]], A[i]});
		if(cntB[x]) st.insert({cntB[x]+cntA[x], x});

		// printf("%d %d\n", x, A[i]);
		// for(auto x : st) printf("%d|%d ", x.fi, x.se);
		// 	printf("\n");

	}
	printf("Yes\n");
	for(int i = 0; i < n; i++)
		printf("%d%c", ans[i], (i == n-1)? '\n' : ' ');
}

Measured memory_bytes: 20800
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  lint n, b = 0, tmp = 0, s = 0;
  cin >> n;
  v1i v(n), d(n);
  rep(i, n){
    cin >> v[i];
    tmp += abs(v[i] - i - 1);
    d[i] = v[i] - i - 1;
  }
  sort(d.begin(), d.end());
  b = d[n/2];
  rep(i, n) s += abs(v[i]-i-1-b);
  cout << s << endl;
  return 0;
}

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

using namespace std;

const int N = 110;

string s;

int main()
{
    cin >> s;

    int res = 0;
    for(int i = 0; i < s.size() / 2; i++)
        if(s[i] != s[s.size() - i - 1])
            res++;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int i,n ,m = 100000,x;
	scanf ("%d",&n);
		for(i = 1; i <= n; i++){
		m = m *1.05;
		x = m % 1000;
		if (x != 0){
			m = m - x + 1000;
		}
		}
		printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 592
/** By @ZhakudaMagzhan **/

/*
# pragma comment(linker, "/stack:20000000")
# pragma GCC optimize("Ofast,no-stack-protector")	
# pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") // */

# include <bits/stdc++.h>

# define fi first
# define se second

# define y1   WENAO
# define endl "\n"
# define ioi  exit(0)  /* 2019 */

# define mp make_pair
# define pp pop_back	
# define pb push_back

# define ub upper_bound
# define lb lower_bound

# define sz(x)   (int)x.size()
# define all(x)  x.begin(), x.end()
# define bit(x)  __builtin_popcountll(x)
# define CLOCK   clock()/(double)CLOCKS_PER_SEC
# define uniq(x) x.resize(unique(all(x))-x.begin())

/*
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
# include <ext/pb_ds/detail/standard_policies.hpp>

using namespace __gnu_pbds;

typedef tree < int, null_type, less < int >, rb_tree_tag,
tree_order_statistics_node_update > ordered_set; // find_by_order(), order_of_key(). */

using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

typedef pair <ll, ll> pll;
typedef pair <int,int> pii;

typedef vector <ll>  vll;
typedef vector <int> vi;
typedef vector <pii> vpii;


const int inf = (int) 2e9, mod = (int) 1e9 + 7;
const ll linf = (ll) 2e18;

/*
int mult (int x, int y) { return ((ll)x * y) % mod; } 
int sub  (int x, int y) { x -= y; if (x < 0) return x + mod; return x; } 
int add  (int x, int y) { x += y; if (x >= mod) return x - mod; return x; } //*/

const int maxn = (int) 1e5 + 666, maxn2 = (int) 1e6 + 666;

int pref[maxn], pref2[maxn];

int main () {
	#define FN "" // zverskii raper		
	#ifdef GOLD
		freopen (FN".in", "r", stdin);
		freopen (FN".out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
	/*unsigned int FOR; asm("rdtsc" : "=A"(FOR)); srand(FOR); // */	
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++ i) {
		int a;
		cin >> a;
		pref[i] = pref[i-1] + a;
	}	
	for (int i = 1; i <= n; ++ i) {
		int b;
		cin >> b;
		pref2[i] = pref2[i-1] + b;
	}

	int mx = -inf;
	for (int i = 1; i <= n; ++ i) {
		mx = max (mx, (pref[i]) + (pref2[n] - pref2[i-1]));
	}
	cout << mx;
	return 0;
}


/* Jocelyn Flores */
	

Measured memory_bytes: 256
// ------------------------------------
// Date:2018/ 3/ 3
// Problem:AOJ DPL fd 1_F.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

// dp[num][weight]
//int dp[101][1010101010]; // 10^(2*9) Byte
int main()
{
  int N, W;
  // dp[num][value]
  int dp[101][10101];
  int v[101];
  int w[101];
  scanf("%d %d", &N, &W);
  REP(n, N + 1) {
    REP(v, 100*N + 1) {
      dp[n][v] = 1e9 + 1;
    }
  }
  memset(v, 11, sizeof(v));
  memset(v, 11, sizeof(w));
  REP(num, N) {
    scanf("%d %d", &v[num], &w[num]);
  }
  
  dp[0][0] = 0;
  REP(num, N) {
    REP(value, 100*N + 1) {
      if (value < v[num]) {
        dp[num + 1][value] = dp[num][value];
      } else {
        dp[num + 1][value] = min(dp[num][value],
                                 dp[num][value - v[num]] + w[num]);
      }
    }
  }
  
  int ans = 0;
  REP(value, 100*N + 1) {
    //printf("dp[N][%d] = %d\n", value, dp[N][value]);
    if (dp[N][value] <= W) {
      ans = max(ans, value);
    }
  }
  printf("%d\n", ans);
  return 0;
}



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

int main(){
    int n, i, buf, c=0, t=0;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> buf;
        if(buf == i+1){
            c++;
        }else{
            if(c == 1){
                t++;
            }else if(c > 1){
                t += (c+1)/2;
            }
            c = 0;
        }
    }
    if(c == 1){
        t++;
    }else if(c > 1){
        t += (c+1)/2;
    }
    cout << t;
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())

    dic = {}
    for _ in range(n):
        command = input().split(" ")
        value = command[1]
        if command[0] == 'insert':
            if value not in dic:
                dic[value] = 0
        elif command[0] == 'find':
            if value in dic:
                print('yes')
            else:
                print('no')
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 33116
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#define maxn 1005
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = getchar();c < '0' || c > '9';c = getchar()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return res * sig;
}
int h,w,dis[maxn][maxn];
char grid[maxn][maxn];
queue <P> que;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,1,0,-1};
int main(){
  h = getint(), w = getint();
  for(int i = 1;i <= h;i++){
    scanf("%s",grid[i] + 1);
  }
  memset(dis,0x3f,sizeof(dis));
  for(int i = 1;i <= h;i++){
    for(int j = 1;j <= w;j++){
      if(grid[i][j] == '#'){
        que.push(mp(i,j));
        dis[i][j] = 0;
      }
    }
  }
  while(!que.empty()){
    P p = que.front(); que.pop();
    int x = p.first, y = p.second;
    for(int i = 0;i < 4;i++){
      int cx = x + dx[i], cy = y + dy[i];
      if(cx > 0 && cx <= h && cy > 0 && cy <= w && dis[cx][cy] > dis[x][y] + 1){
        dis[cx][cy] = dis[x][y] + 1;
        que.push(mp(cx,cy));
      }
    }
  }
  int ans = 0;
  for(int i = 1;i <= h;i++){
    for(int j = 1;j <= w;j++){
      ans = max(ans,dis[i][j]);
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 13328
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        while(a > 0 && c > 0){
            c -= b;
            a -= d;
        }

        if(c <= 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

        
        
        

        






    }
}

Measured memory_bytes: 35784
n = int(input())
a = list(map(int,input().split()))
plan = abs(a[-1]) + abs(a[0])
for i in range(1,n):
    plan += abs(a[i] - a[i-1])

for i in range(n):
    if i > 0 and i < n-1:
        ans = plan -abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i+1] - a[i-1])
        
    elif i == 0:
        ans = plan - abs(a[i]) -abs(a[i + 1] - a[i]) + abs(a[i + 1])
        
    else:
        ans = plan -abs(a[i] - a[i - 1]) - abs(a[-1]) + abs(a[-2])
    
    print(ans)

Measured memory_bytes: 14048
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 205, M = 1e5 + 5, MOD = 1e9 + 7;
ll dp[N][M];
int a[N];

ll bp(ll a, ll p) {
    ll r = 1;
    while (p > 0) {
        if (p & 1) {
            r = r * a % MOD;
        }
        a = a * a % MOD;
        p >>= 1;
    }
    return r;
}

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

    int n, m;
    cin >> n >> m;

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

    sort(a, a + n);
    reverse(a, a + n);

    dp[0][m] = 1;

    for (int i = 0; i < n; i++) {
        ll x = bp(n - i, MOD - 2),
            y = (1 - x + MOD) % MOD;
        for (int j = 0; j <= m; j++) {
            if (j < a[i]) {
                dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
            }
            else {
                dp[i + 1][j % a[i]] = (dp[i + 1][j % a[i]] + dp[i][j] * x) % MOD;
                dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * y) % MOD;
            }
        }
    }

    ll ans = 0;

    for (int i = 0; i <= m; i++) {
        ans = (ans + dp[n][i] * i) % MOD;
    }

    for (int i = 1; i <= n; i++) {
        ans = ans * i % MOD;
    }

    cout << ans << "\n";

    return 0;
}

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

int main(){
  char c;

  cin >> c;

    if(c == 'a' || c == 'i' || c == 'u' || 
       c == 'e' || c == 'o'){
         cout << "vowel" << endl;
     }
   else {
         cout << "consonant" << endl;
      }

return 0;
}

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

int main(){
    ll n;
    cin >> n;
    ll ans = n;
    rep(i, 0, n+1){
        ll c = 0;
        ll t = i;
        while(t > 0){
            c += t%6;
            t /= 6;
        }
        t = n-i;
        while(t > 0){
            c += t%9;
            t /= 9;
        }
        ans = min(ans, c);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int abs(int a){return (a < 0)? -a : a;}
int main(){
   int N;
   scanf("%d",&N);
   
   int t_prev=0, x_prev=0, y_prev=0;
   int t_cur =0, x_cur =0, y_cur =0;
   
   while(N--){
        scanf("%d %d %d",&t_cur,&x_cur,&y_cur);
        int min_dist = abs(x_cur-x_prev) + abs(y_cur - y_prev);
        if((t_cur-t_prev) < min_dist || ((t_cur-t_prev)-min_dist)%2 != 0){
            puts("No"); return 0;
        }
        t_prev=t_cur; x_prev=x_cur; y_prev=y_cur;
   }
   puts("Yes");
}

Measured memory_bytes: 128
<?php
$n = intval(fgets(STDIN));
$s = intval(fgets(STDIN));

function f($b, $n){
    if($n < $b)return $n;
    return f($b, intdiv($n, $b)) + $n % $b;
}
if($n == $s){
    echo $n+1,"\n";exit;
}
for($i = 2, $I = sqrt($n); $i <= $I; $i++){
    if(f($i, $n) == $s){
        echo $i,"\n";exit;
    }
}
$minB = 10**18;
for($p = 1, $P = sqrt($n); $p <= $P; $p++){
    $q = $s - $p;
    if(($n-$q) % $p != 0)continue;
    $b = ($n-$q)/$p;
    if($b >= 2 && f($b, $n) == $s){
        $minB = min($minB, $b);
    }
}
if($minB == 10**18){
    echo -1,"\n";
}else{
    printf("%d\n", $minB);
}

Measured memory_bytes: 4728
import math,cmath
e=1e-6
def f(m):
  c=1j*math.acos(a/2)
  p1=cmath.exp(b+c)+p
  p2=cmath.exp(b-c)+p
  s1,s2=2,2
  for p3 in X:
    if p3 in[p,p0]:continue
    if abs(p3-p1)<1+e:s1+=1
    if abs(p3-p2)<1+e:s2+=1
  return max(m,s1,s2)

while 1:
  n=input()
  if n==0:break
  N=range(n)
  X=[]
  for i in N:
    x,y=map(float,input())
    X+=[x+1j*y]
  m=1
  for i in N:
    p=X[i]
    for p0 in X[i+1:]:
      a,b=cmath.polar(p0-p)
      b*=1j
      if a<=2:m=f(m)
  print m

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	int r, g, b, k;
	cin >> r >> g >> b >> k;

	int cnt = 0;
	while (r >= g) {
		cnt++;
		g *= 2;
	}
	while (g >= b) {
		cnt++;
		b *= 2;
	}
	if (cnt <= k)cout << "Yes" << endl;
	else cout << "No" << endl;


}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    map<ll,ll> mp;
    rep(i,n){
        ll a;cin>>a;
        mp[a]++;
    }
    ll now=0;
    for(auto& p:mp){
        ll it=p.first,m=p.second;
        //cout<<it<<" "<<m<<endl;
        if(it>m)continue;
        now+=it;
    }
    ll res=n-now;
    cout<<res<<endl;
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  string S;
  cin>>S;
  sort(ALL(S));
  string ans="None";
  rep(i,0,26){
    char X='a'+i;
    rep(j,0,S.size()){
      if(S[j]==X)
        break;
      if(S[j]>X){
        ans=X;
        goto K;
        }
      }
    }
  if(ans=="None"&&S[S.size()-1]!='z')
    ans=S[S.size()-1]+1;
  K:
  cout<<ans;
  }


Measured memory_bytes: 512
def solve():
    N, M, *X = map(int, open(0).read().split())
    
    X.sort()
    dx = [0 for _ in range(M - 1)]
    for i in range(1, M):
        dx[i - 1] = X[i] - X[i - 1]
    
    dx.sort()
    ans = 0
    for i in range(M - N):
        ans += dx[i]
    print(ans)


if __name__ == '__main__':
    solve()


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

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll block = N /(A + B);
  ll amari = N % (A + B);
  cout << A*block + min(A, amari) << endl;
}

  

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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

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

   string s;
   cin>>s;

   if(s[0] != s[1] || s[1] != s[2] || s[0] != s[2]){
      cout<<"Yes\n";
   }else
   {
      cout<<"No\n";
   }
   return 0;
}

Measured memory_bytes: 256
# frozen_string_literal: true

h, w, m = gets.split.map(&:to_i)
hw = m.times.map { gets.split.map(&:to_i) }

hh = Hash.new { false }
hi = Hash.new { 0 }
hj = Hash.new { 0 }

hw.each do |e|
  x = e[0]
  y = e[1]
  hh[[x, y]] = true
  hi[x] += 1
  hj[y] += 1
end

a = hi.to_a
b = hj.to_a

aa = a.max_by { |e| e[1] }
bb = b.max_by { |e| e[1] }

aaa = a.filter { |e| e[1] == aa[1] }
bbb = b.filter { |e| e[1] == bb[1] }
flag = true
aaa.each do |xx|
  bbb.each do |yy|
    x = xx[0]
    y = yy[0]
    unless hh[[x, y]]
      flag = false
      break
    end
  end
end
ans = aa[1] + bb[1]
ans -= 1 if flag
puts ans


Measured memory_bytes: 125740
#include <iostream>
using namespace std;
 
int main(){
    string w, s;
    int cnt=0;
    cin >> w;
    for(int i=0;i<w.size();i++) w[i]=tolower(w[i]);
    while(1){
        cin >> s;
        if(s=="END_OF_TEXT") break;
        for(int i=0;i<s.size();i++) s[i]=tolower(s[i]);
        if(s==w) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3152
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        System.out.println( ( A <= 8 && B <= 8 ) ? "Yay!" : ":(" );
    }
}


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

using namespace std;
int main() {
#ifdef LDT
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, n;
    cin >> a >> n;
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        a -= x;
    }
    cout << (a <=0 ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
    int n,k;
    cin>>n>>k;
    int x=n%k;
    cout<<min(x,k-x)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    string S,T;
    cin >> S >> T;
    int n = S.length();
    bool ans = false;
    for ( int i = 0; i < n; i++ ) {
        string s = "";
        for ( int j = 0; j < n; j++ ) {
            s += S[(j+i)%n];
        }
        if ( s == T ) { ans = true; }
    }

    cout << ( ans ? "Yes" : "No" ) << endl;

    return 0;
}

Measured memory_bytes: 256
/*2019/08/25 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}
int llasc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
int lldesc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}

typedef struct{
    int h;
    int num;
}group_t;

int asc_t(const void *a,const void *b){return ((group_t*)a)->h - ((group_t*)b)->h;}
//int desc_t(const void *a,const void *b){return ((struct_t*)b)->member - ((struct_t*)a)->member;}


int main(){
    int h[200000],n;
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
    }

    int cnt=0;
    int max=MAX;
    for(int i=n-1;i>0;i--){
        if(h[i]<=h[i-1]){
            cnt++;
        }else{
            if(max<cnt){
                max=cnt;
            }
            cnt=0;
        }
    }
    if(max<cnt){
        max=cnt;
    }

    printf("%d\n",max);

    return 0;


}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
namespace CsProgramSpace
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] u = (Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToArray());
            int c = 0;
            for(int i = u[0];i<=u[1];i++)
            {
                if (u[2] % i == 0)
                {
                    c++;
                }
            }
            Console.WriteLine(c);
        }
    }
}


Measured memory_bytes: 18460
n, y = map(int, input().split())

def judge(maisuu, kingaku, man, gesen):
  sen = maisuu - (man + gesen)
  if kingaku == (10000 * man + 5000 * gesen + 1000 * sen):
    return True
  return False

for i in range(n + 1):
  for j in range(n - i + 1):
    if judge(n, y, i, j):
      print('{} {} {}'.format(i, j, (n - i - j)))
      quit()
print('-1 -1 -1')


Measured memory_bytes: 3060
import heapq

N = int(input())
a = [int(n) for n in input().split()]
former = a[:N]

heapq.heapify(former)

former_sum = [sum(former)]


for k in range(N):
  heapq.heappush(former, a[N+k])
  former_sum.append(former_sum[k]+a[N+k]-heapq.heappop(former))

a = [n * (-1) for n in a]
latter = a[2*N:]
heapq.heapify(latter)
latter_sum = [sum(latter)]

for k in range(N):
  heapq.heappush(latter, a[2*N-k-1])
  latter_sum.append(latter_sum[k] + a[2*N-k-1] - heapq.heappop(latter))

res = [former_sum[k] + latter_sum[N-k] for k in range(N+1)]

print(max(res))

Measured memory_bytes: 38276
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#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()
#define Decimal fixed<<setprecision(20)

using namespace std;

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

int main()
{
	int n,a,b;cin >> n >> a >> b;
	string str;cin >> str;
	int cou = 0;
	int bcou = 0;
	
	REP(i,n)
	{
		if(str[i] == 'c')
		{
			cout << "No" << endl;
			continue;
		}
		if(cou < a+b)
		{
			if(str[i] == 'a')
			{
				cout << "Yes" << endl;
				cou++;
			}
			else if(bcou < b)
			{
				cout << "Yes" << endl;
				cou++;bcou++;
			}
			else
			{
				cout << "No" << endl;
			}	
		}
		else
		{
			cout << "No" << endl;
		}	
	}
	
	
	return 0;
}


Measured memory_bytes: 896
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

VI a, b;
bool d[100010];
signed main(void)
{
	string s, t = "";
	int m;
	cin >> s >> m;
	REP(i, s.size()) {
		if(s[i] == '+') {
			a.PB(stoi(t));
			b.PB(1);
			t = "";
		} else if(s[i] == '*') {
			a.PB(stoi(t));
			b.PB(0);
			t = "";
		} else {
			t += s[i];
		}
	}
	a.PB(stoi(t));
	//for(int i: a) cout << i << " "; cout << endl;
	//for(int i: b) cout << i << " "; cout << endl;

	bool f1 = false, f2 = false;
	int c = a[0];
	REP(i, b.size()) {
		if(b[i]) {
			c += a[i+1];
		} else {
			c *= a[i+1];
		}
	}
	//cout << c << " ";
	if(c == m) f1 = true;

	VI e;
	bool con = false;
	c = 0;
	REP(i, b.size()) {
		if(!b[i]) {
			if(!con) c = a[i]*a[i+1];
			else c *= a[i+1];
			d[i] = d[i+1] = true;
			con = true;
		} else {
			e.PB(c);
			c = 0;
			con = false;
		}
	}
	e.PB(c);
	REP(i, a.size()) {
		if(!d[i]) e.PB(a[i]);
	}
	int ret = 0;
	for(int i: e) ret += i;
	//cout << ret << endl;
	//for(int i: e) cout << i << " "; cout << endl;
	if(ret == m) f2 = true;

	if(f1 && f2) cout << "U" << endl;
	else if(!f1 && !f2) cout << "I" << endl;
	else if(f1 && !f2) cout << "L" << endl;
	else if(!f1 && f2) cout << "M" << endl;
	else assert(false);

	return 0;
}

Measured memory_bytes: 3228
#coding:utf-8

n, k, q = map(int, input().split())
a = [input() for i in range(q)]
point = [k-q] * n
#print(point)

for i in range(0, q):
    point[int(a[i])-1] += 1
    #print(point)

for i in point:
    if i <= 0:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 12864
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <iomanip>
using namespace std;

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

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


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int p_max = 0;
    int p_sum = 0;
    REP(i, n) {
        int p;
        cin >> p;
        p_max = max(p_max, p);
        p_sum += p;
    }
    p_sum -= p_max / 2;
    cout << p_sum << endl;
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = [-1] * (N+1)
for i in range(K):
  d_list = int(input())
  B = input().split()
  B = [int(x) for x in B]
  for i in range(1, N+1):
    if i in B:
      A[i] = 1
count = 0
for i in range(1, N+1):
  if A[i] == -1:
    count += 1
print(count)

Measured memory_bytes: 67908
#pragma GCC optimize("O3")
        #pragma comment(linker, "/stack:200000000")
        #pragma GCC optimize("unroll-loops")
         
        #include <algorithm>
        #include <bitset>
        #include <cassert>
        #include <chrono>
        #include <cmath>
        #include <complex>
        #include <cstdio>
        #include <cstdlib>
        #include <cstring>
        #include <ctime>
        #include <deque>
        #include <functional>
        #include <iomanip>
        #include <iostream>
        #include <iterator>
        #include <limits>
        #include <climits>
        #include <list>
        #include <map>
        #include <numeric>
        #include <queue>
        #include <random>
        #include <ratio>
        #include <set>
        #include <sstream>
        #include <stack>
        #include <string>
        #include <unordered_map>
        #include <unordered_set>
        #include <utility>
        #include <vector>
        using namespace std;
         
        typedef long long ll;
        typedef long double LD;
        #define int ll
        #define double LD
        #define pb push_back
        #define mp make_pair
        #define REP(i,n) for (int i = 0; i < n; i++)
        #define loop(i,n) for (int i = 0; i < n; i++)
        #define FOR(i,a,b) for (int i = a; i < b; i++)
        #define REPD(i,n) for (int i = n-1; i >= 0; i--)
        #define FORD(i,a,b) for (int i = a; i >= b; i--)
        #define remax(a,b) a = max(a,b)
        #define remin(a,b) a = min(a,b)
        #define mem(a, b) memset(a, b, sizeof a)
        #define append push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define print(x) cout << (x) << endl
        #define PRECISION(x) cout << fixed << setprecision(x)
        #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
        #define N 1005
        #define pb push_back
        const double PI=acos(-1);
        const int MOD = 1000000007;
        const int FMOD = 998244353;
        const double eps = 1e-9;
         
        mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
        

        signed main()
        {
        	int n;
        	cin>>n;
        	
        	map<string,int> mp1;
        	loop(i,n)
        	{
        		string s;
        		cin>>s;
        		
        		mp1[s]++;
			}
			cout<<"AC"<<" "<<"x"<<" "<<mp1["AC"]<<endl;
			cout<<"WA"<<" "<<"x"<<" "<<mp1["WA"]<<endl;
			cout<<"TLE"<<" "<<"x"<<" "<<mp1["TLE"]<<endl;
			cout<<"RE"<<" "<<"x"<<" "<<mp1["RE"]<<endl;
		}

Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>

#define PLANCNT 1000
#define PLANLEN (PLANCNT + 1)

char pl[PLANLEN];
int bh;

void read(void)
{
    if (scanf("%s", pl) != 1)
        exit(EXIT_FAILURE);
}

void exec(void)
{
    int dn, dw, ds, de, i;
    
    dn = dw = ds = de = 0;
    for (i = 0; pl[i] != '\0'; ++i) {
        dn += (pl[i] == 'N'), dw += (pl[i] == 'W');
        ds += (pl[i] == 'S'), de += (pl[i] == 'E');
    }
    bh = ((dn != 0 && ds != 0) || (dn == 0 && ds == 0)) &&
         ((dw != 0 && de != 0) || (dw == 0 && de == 0));
}

void print(void)
{
    printf("%s\n", bh ? "Yes" : "No");
}

void repl(void)
{
    read();
    exec();
    print();
}

int main(void)
{
    repl();
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
 
struct node{
	LL a, b, c;
	bool operator <(const node &A) const{
		return (a-b) < A.a - A.b;
	}
}box[MaxN + 5];
 
int n, x, y, z;
LL tot, ans;
priority_queue<LL, vector<LL>, greater<LL> > q;
LL lef[MaxN + 5];
 
int main(){
	scanf("%d %d %d", &x, &y, &z);
	n = x + y + z;
	for(int i = 1; i <= n; i++){
		scanf("%lld %lld %lld", &box[i].a, &box[i].b, &box[i].c);
		tot += box[i].c;
	}
	sort(box + 1, box + 1 + n);
	LL ans = 0, sum = 0;
	for(int i = 1; i <= y; i++){
		sum += box[i].b - box[i].c;
		q.push(box[i].b - box[i].c);
	}
	for(int i = y + 1; i <= n - x + 1; i++){
		lef[i] = sum;
		sum += box[i].b - box[i].c;
		q.push(box[i].b - box[i].c);
		sum -= q.top();
		q.pop();
	}
	while(!q.empty()) q.pop(); sum = 0;
	for(int i = n; i > n - x; i--){
		sum += box[i].a - box[i].c;
		q.push(box[i].a - box[i].c);
	}
	for(int i = n - x; i >= y; i--){
		ans = max(ans, tot + lef[i + 1] + sum);
		sum += box[i].a - box[i].c;
		q.push(box[i].a - box[i].c);
		sum -= q.top();
		q.pop();
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3832
from collections import deque
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
dis=deque([A[0]])
num=0
for i in range(1,len(A)):
    num+=dis.popleft()
    dis.append(A[i])
    dis.append(A[i])
print(num)

Measured memory_bytes: 32348
import sys
input = sys.stdin.readline

n=int(input())

A=list(map(int,input().split()))

B=[A[0]]

for i in range(len(A)-1):
    B.append((B[i]+A[i+1]) % (10**9+7))

ans=0

for i in range(n-1):
    
    ans += (A[i] * (B[-1]-B[i])  % (10**9+7))
    
#    for j in range(i+1,n):
        
#        ans += (A[i] * A[j]) % (10**9+7)
#
print(ans % (10**9+7))

Measured memory_bytes: 100308
#include <bits/stdc++.h>
#define rep(i, j, k) for (int (i) = (j); (i) < (k); ++(i))
#define repr(i, j, k) for (int (i) = (j); (i) <= (k); ++(i))

using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

using namespace std;

const int N = 1e5+5, M = 1e5+5;
const int MOD = 1000000007;
int nxt[N<<1], to[N<<1], head[N], cnt = 0;
Int ans;
int n, k;

void dfs(int u, int f) {
	int cnt = f ? k-2 : k-1;
	for (int i = head[u]; ~i; i = nxt[i]) {
		if (to[i] != f) {
			ans = ans * (cnt--) % MOD;
			dfs(to[i], u);
		}
	}
}

void add(int u, int v) {
	to[cnt] = v;
	nxt[cnt] = head[u];
	head[u] = cnt++;
}

void solve() {
	memset(head, -1, sizeof head);
	cin >> n >> k;
	
	rep(i, 0, n-1) {
		int u, v;
		cin >> u >> v;
		add(u, v), add(v, u);
	}
	
	ans = k;
	dfs(1, 0);
	cout << ans << endl;
}

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


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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  int r = 0;
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
    r = max(r, a[i]);
  }
  auto ok = [&] (int m) {
    int cuts = 0;
    for(int x : a) {
      cuts += (x + m - 1) / m - 1;
    }
    return cuts <= k;
  };
  int l = 1;
  while(l != r) {
    int m = (l + r) / 2;
    if(ok(m)) {
      r = m;
    } else {
      l = m + 1;
    }
  }
  cout << l << '\n';
}

Measured memory_bytes: 3984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define x first
#define y second
int32_t main()
{
	int n,m;
	cin>>n>>m;
	vector<pair<int,int>> s(n), c(m);
	for(int i=0;i<n;i++)
	{
		cin>>s[i].x>>s[i].y;
	}
	for(int i=0;i<m;i++)
	{
		cin>>c[i].x>>c[i].y;
	}
	int sx,sy;
	for(int i=0;i<n;i++)
	{
		sx=s[i].x;sy=s[i].y;
		int mn=1e18;
		for(int j=0;j<m;j++)
		{
			mn=min(mn,abs(sx-c[j].x)+abs(sy-c[j].y));
		}
		for(int j=0;j<m;j++)
		{
			if(abs(sx-c[j].x)+abs(sy-c[j].y)==mn)
			{
				cout<<j+1<<"\n";
				break;
			}
		}
	}

}

Measured memory_bytes: 256
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int h, w;
  rd(h, w);
  int n;
  rd(n);
  auto a = readln.split.to!(int[]);

  int[] b;
  foreach (i; 0 .. n) {
    foreach (_; 0 .. a[i]) {
      b ~= i + 1;
    }
  }
  auto c = new int[][](h, w);
  foreach (i; 0 .. h) {
    foreach (j; 0 .. w) {
      if ((i & 1) == 0) {
        c[i][j] = b[i * w + j];
      } else {
        c[i][w - j - 1] = b[i * w + j];
      }
    }
  }
  writefln("%(%(%s %)\n%)", c);
}

void rd(T...)(ref T x) {
  import std.stdio, std.string, std.conv;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 2556
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	string ans = "";
	
	if( n == 0 ) {
		cout << 0 << endl;
		return 0;
	}
	
	while( n ) {
		if( n % 2 == 0 ) {
			ans += '0';
		} else {
			ans += '1';
			n--;
		}
		
		n /= -2;
	}
	
	reverse(ans.begin(), ans.end());
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
import sys
import itertools

n, k = map(int, sys.stdin.readline().split())
a = list(map(int, sys.stdin.readline().split()))
a_len = len(a) - 1

b = [1]
labeled = set(b)
index = 1
loop_start = 0
while len(labeled) <= a_len:
  p = a[index - 1]
  if p in labeled:
    loop_start = b.index(p)
    break
  labeled.add(p)
  b.append(p)
  index = p
#print(f'{b=}')
#print(f'{loop_start=}')

loop_len = len(b) - loop_start
#print(f'{loop_len=}')

if k < len(b) - 1:
  print(b[k])
else:
  kk = k - loop_start
  # print(f'{kk=}')
  kk %= loop_len
  # print(f'{kk=}')
  kk += loop_start
  # print(f'{kk=}')

  print(b[kk])

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

int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N, M;
    cin >> N >> M;

    vector<vector<int>> vec(M);

    for(int i = 0; i < M; ++i) {
        int k;
        cin >> k;
        vec[i].resize(k);
        for(int j = 0; j < k; ++j) {
            cin >> vec[i][j];
            --vec[i][j];
        }
    }

    vector<int> p(M);
    for(int i = 0; i < M; ++i)
        cin >> p[i];

    int ans = 0;
    for(int i = 0; i < (1 << N); ++i) {
        bool ok = true;
        for(int j = 0; j < M; ++j) {
            int c = 0;
            for(int id : vec[j]) {
                if((i >> id) & 1) {
                    ++c;
                }
            }
            c %= 2;
            if(c != p[j]) {
                ok = false;
            }
        }
        if(ok) {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,-1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S;
    cin >> S;
    int cnt = 0;
    for(int i=0; i<3; i++){
        if(S[i] == '1') cnt++;
    }
    cout << cnt << endl;
   return 0;
}

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

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int a, b;
    cin >> a >> b;
    string s = "";
    string t = "";
    for (int i = 0; i < b; i ++) {
        s +='0' + a;
    }
    for (int i = 0; i < a; i++) {
        t += '0' + b;
    }
    cout << ( s < t ? s : t) << endl;
    return 0;
}

Measured memory_bytes: 256
//it's not my code
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<cctype>
#include<set>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;

inline int read() {
    int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
    for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f;
}

const int N = 500500, mod = 1e9 + 7;
int F[N], sum[N], mn[N], mx[N];
struct Edge{ int v, l, r, x; } A[N];
bool cmp1(const Edge &A,const Edge &B) { return A.v > B.v; }
bool cmp2(const Edge &A,const Edge &B) { return A.l == B.l ? A.r < B.r : A.l < B.l; } // 左端点相同时的排序！！！ 

int main() {
    int n = read();
    for (int i = 1; i <= n; ++i) 
        A[i].x = read(), A[i].v = read();
    sort(A + 1, A + n + 1, cmp1);
        
    mn[1] = A[1].x;
    for (int i = 2; i <= n; ++i) mn[i] = min(mn[i - 1], A[i].x);
    for (int i = 1; i <= n; ++i) {
        int l = 1, r = i - 1, p = i;
        while (l <= r) {
            int mid = (l + r) >> 1;
            if (mn[mid] < A[i].x) p = mid, r = mid - 1;
            else l = mid + 1;
        }
        A[i].l = p;
    }
    mx[n] = A[n].x;
    for (int i = n - 1; i >= 1; --i) mx[i] = max(mx[i + 1], A[i].x);
    for (int i = n; i >= 1; --i) {
        int l = i + 1, r = n, p = i;
        while (l <= r) {
            int mid = (l + r) >> 1;
            if (mx[mid] > A[i].x) p = mid, l = mid + 1;
            else r = mid - 1;
        }
        A[i].r = p;
    }
    sort(A + 1, A + n + 1, cmp2);
    int p = 1, Ans = 0;
    for (int i = 1; i <= n; ++i) {
        while (A[p].r < A[i].l - 1) 
            p ++;
        F[i] = (sum[i - 1] - sum[p - 1] + mod) % mod;
        if (A[i].l == 1) F[i] = (F[i] + 1) % mod;
        sum[i] = (sum[i - 1] + F[i]) % mod;
        if (A[i].r == n) Ans = (Ans + F[i]) % mod;
    }
    cout << Ans<<endl;
    return 0;
}

Measured memory_bytes: 12800
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    a = list(int(_) for _ in input().split())
    a.sort()
    
    print(abs(a[0]-a[1]) + abs(a[1]-a[2]))
    
if __name__ == '__main__':
    main()


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

int main(){
  string s;
  cin >> s;
  char c=s.at(0);
  int ans=0;
  for(int i=0,l=s.size();i<l;i++){
    if(s.at(i)!=c){
      ans++;
      c=s.at(i);
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define MILL (196470)

int main(){
    int i;
    int n;
    int day;
    int y,m,d;

    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%d %d %d",&y,&m,&d);

        y -= 1;
        m -= 1;
        d -= 1;

        day = 195*y;
        day += (5 * (y/3));
        
        if(m!=0){    
            if((y+1)%3 == 0 && y != 0){
                day += 20*m;
            }else{
                day += 19*m + ((m+1)/2);
            }
        }

        day += d;

        printf("%d\n",MILL-day);
    }


    return 0;
}


Measured memory_bytes: 2040