akhauriyash/Code-Regression huggingface dataset:
def resolve():
    n=int(input())
    l=list(map(int, input().split()))
    sum=0
    ans=n*10**4
    for j in range(1,101):
        for i in range(n):
            sum+=(l[i]-j)**2
        ans=min(sum,ans)
        sum=0
    print(ans)
resolve()

Measured memory_bytes: 3060
#include <iostream>

int main(int argc, char const* argv[])
{
  int a, b;
  std::cin >> a >> b;
  if (a < b)
    std::cout << "a < b";
  else if (a > b)
    std::cout << "a > b";
  else
    std::cout << "a == b";
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << (ld)(w * h) / 2 << " " << ((2 * x == w && 2 * y == h) ? 1 : 0) << endl;
    return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <iomanip>

using namespace std;
typedef long long ll;

double length(double x1, double y1, double x2, double y2) {
    return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}


int main(){
    int n;
    int x[8], y[8];
    double sum = 0; 
    int touri = 0;
    cin >> n;
    vector<int> order(n); 
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        order[i] = i;
    }

    do {
        for (int i = 0; i < n - 1; i++) {
            sum += length(x[order[i]], y[order[i]], x[order[i+1]], y[order[i+1]]);
        }
        touri++;
    } while (next_permutation(order.begin(), order.end()));

    cout << fixed << setprecision(7) << sum / touri << endl;


    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    ll a, b, x;
    cin >> a >> b >> x;
    ll ans = 0;
    if(a%x!=0){
        a+=(x-a%x);
        if(b >= a)ans++;
    }
    else ans++;
    if(a < b)ans += (b-a)/x;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;



signed main(){
	int N;
	cin >> N;
	vector<int>a(N + 1);
	REP(i,N + 1){
		cin >> a[i];
	}
	vector<int>as(N + 2);
	REP(i,N + 1)as[i + 1] += as[i] + a[i];
	int ma = 0,ans = 0,now = 1;
	REP(i,N + 1){
		now -= a[i];
		if(now < 0){
			out(-1);
			return 0;
		}
		ans += now + a[i];
		now *= 2;
		CHMIN(now,as[N + 1] - as[i + 1]);
		//out(i,as[i],ans);
	}
	out(ans);
}

Measured memory_bytes: 4792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1000000007;
const int nmax=1000010;
ll fac[nmax],finv[nmax],inv[nmax];
 
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<nmax;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll com(int n,int k){
  if(n<k||n<0||k<0){
    return 0;
  }
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
 
int main(){
  COMinit();
  ll x,y;cin >> x >> y;
  ll t=abs(x-y);
  if((min(x,y)-t)%3!=0){
    cout << 0 << endl;
  }
  else{
    ll k=(min(x,y)-t)/3;
    cout << com(t+k*2,k) << endl;
  }
}

Measured memory_bytes: 23680
n, m = map(int, input().split())

nList = [list(map(int, input().split())) for _ in range(n)]
mList = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    minDistance = 10**9
    for j in range(m):
        d = abs(nList[i][0]-mList[j][0]) + abs(nList[i][1]-mList[j][1])
        if d < minDistance:
            minDistance = d
            mIndex = j + 1
    print(mIndex)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
void ans(int n,int k, int m){
    int i,itr;
    vector<int> world;
    for(i=0;i<n;i++){
        world.push_back(i+1);
    }
    itr=m-1;
    for(i=0;i<n-1;i++){
        world.erase(world.begin()+itr);
        itr=(itr-1+k)%world.size();
    }
    cout << world[0]<<endl;
}

int main(void){
    int n,k,m;
    while(1){
        cin >> n >> k >> m ;
        if(n==0){
            break;
        }
        ans(n,k,m);
    }
}

Measured memory_bytes: 3252
#include <stdio.h>
#define MAX 9999999999

int main(void)
{
    int mod;
    int N;
     
     scanf("%d", &N);
     mod = N; //初期値
     while(mod <= MAX)
     {
         if ((mod%2 == 0) && (mod%N == 0)){
               printf("%d", mod);
               return 0;
         }
         mod++;
     }
     return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int a[100000];
int b[100000];
int p[100000];
int q[100000];
int sum1[100001];
int sum2[100001];
int sum3[100001];
int par[100000];
int cnt[100000];

int find(int x) {
    if (par[x] == x) return x;
    return par[x] = find(par[x]);
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    
    if (x == y) return;
    
    par[x] = y;
}

int main() {
    int n, i;
    vector <pair<int, int>> v, w;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    for (i = 0; i < n; i++) scanf("%d", &b[i]);
    
    for (i = 0; i < n; i++) {
        v.push_back(make_pair(a[i], i));
        w.push_back(make_pair(b[i], i));
    }
    
    sort(v.begin(), v.end());
    sort(w.begin(), w.end());
    
    for (i = 0; i < n; i++) {
        p[v[i].second] = i;
        q[w[i].second] = i;
    }
    
    for (i = 0; i < n; i++) {
        sum1[i + 1] = sum1[i];
        if (v[i].first <= w[i].first) sum1[i + 1]++;
    }
    
    for (i = 1; i < n; i++) {
        sum2[i + 1] = sum2[i];
        if (v[i].first <= w[i - 1].first) sum2[i + 1]++;
    }
    
    for (i = 0; i < n - 1; i++) {
        sum3[i + 1] = sum3[i];
        if (v[i].first <= w[i + 1].first) sum3[i + 1]++;
    }
    
    if (sum1[n] != n) {
        puts("No");
        
        return 0;
    }
    
    for (i = 0; i < n; i++) par[i] = i;
    
    for (i = 0; i < n; i++) {
        int x = p[i], y = q[i], m1 = min(x, y), m2 = max(x, y);
        
        unite(x, y);
        
        if (a[i] > b[i]) continue;
        if (sum1[m1] != m1) continue;
        if (sum1[n] - sum1[m2 + 1] != n - m2 - 1) continue;
        
        if (x < y) {
            if (sum2[y + 1] - sum2[x + 1] != y - x) continue;
        } else if (x > y) {
            if (sum3[x] - sum3[y] != x - y) continue;
        }
        
        puts("Yes");
        
        return 0;
    }
    
    for (i = 0; i < n; i++) cnt[find(i)]++;
    
    for (i = 0; i < n; i++) {
        if (cnt[i] == n) {
            puts("No");
            
            return 0;
        }
    }
    
    puts("Yes");
    
    return 0;
}


Measured memory_bytes: 5100
#include <iostream>
#include <algorithm>

using namespace std;

int X[100000];
int diff[100000];

int main()
{
	int N, M;
	int move = 0;

	cin >> N >> M;
	for (int i = 0; i < M; i++) cin >> X[i];

	if (N >= M) move = 0;
	else {
		sort(X, X + M);

		for (int i = 1; i < M; i++) diff[i - 1] = X[i] - X[i - 1];
		sort(diff, diff + M - 1);

		for (int i = 0; i < M - N; i++) move += diff[i];
	}

	cout << move << endl;

	return 0;
}

Measured memory_bytes: 1024
//Name: Period
//Level: 2
//Category: 数学,メモ化
//Note:

/**
 * 筆算をシミュレーションしながら、これまでに出た余りと出た場所を覚えておく。
 * 同じ余りが出た場合、直前にその余りが出た場所から末尾までが循環節となる。
 *
 * オーダーは O(Q + log P)。
 */
#include <iostream>
#include <map>
#include <string>

using namespace std;

bool solve() {
    int P, Q;
    if(!(cin >> P >> Q)) return false;

    string ans, loop;
    map<int,int> dict;
    int rem = P * 10;
    for(int i = 0; ; ++i) {
        if(rem == 0) break;
        auto it = dict.find(rem);
        if(it != dict.end()) {
            for(int j = 0; j < it->second; ++j) loop += " ";
            for(int j = it->second; j < i; ++j) loop += "^";
            break;
        }
        dict[rem] = i;
        ans += '0' + (rem / Q);
        rem %= Q;
        rem *= 10;
    }
    cout << ans << endl;
    if(loop != "") cout << loop << endl;
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1204
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cstring>
#include<functional>
#include<bits/stdc++.h>

#define vec2c vector<vector<char>>
#define vec2i vector<vector<int>>
#define vecc vector<char>
#define vecs vector<string>
#define veci vector<int>
#define vecd vector<double>
#define rep(i, n) for(int i=0; i < (int)(n); i++)
#define rrep(i, n) for(int i=(int)(n); i>=0;i--)
#define rep1e(i, n) for(int i=1; i <= (int)(n); i++)
#define rep1ne(i, n) for(int i=1; i < (int)(n); i++)

#define MAX 100010

using namespace std;

unsigned digit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {

	int A, P;
	cin >> A >> P;

	int total = (A * 3) + P;
	int cnt = 0;
	while(total >= 2) {
		cnt++;
		total -= 2;
	}

	cout << cnt << endl;
  return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

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

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

  ll n; cin >> n;
  string s;cin >> s;
  int op = 0, ed = 0;
  rep(i, 0, n){
    if(s[i] == '(') op++;
    else {
      if(op == 0) ed++;
      op = max(0, op-1);
    }
  }
  string sop, sed;
  rep(i, 0, ed)sop += "(";
  rep(i, 0, op)sed += ")";
  cout << sop + s + sed << endl;

  return 0;
};


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;

int main(){
	int N;
	cin >> N;
	
	vector<int> a(N);

	int count = 0;
	for(int i = 0; i < N; i++){
		cin >> a.at(i);
	}

	for(int i = 0; i < N; i++){
		if((i + 1) % 2 == 1){
			if(a.at(i) % 2 == 1){
				count++;
			}
		}
	}	
	cout << count << "\n";

}


Measured memory_bytes: 3628
N,Q = map(int,input().split())
S = input()
t = [0] * (N + 1)

for i in range(N):
    if S[i : i + 2] == 'AC':
        t[i + 1] = t[i] + 1
    else:
        t[i + 1] = t[i]

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Measured memory_bytes: 6060
use std::cmp::{max, min};
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(
        it,
        n: usize,
        vw: [(usize, usize); n],
        q: usize,
        vl: [(u1, usize); q]
    );
    let nu = min(2usize.pow(9) - 1, n);
    let wm = vl.iter().map(|(_, l)| *l).max().unwrap();
    let mut dp = vec![vec![0; wm + 1]; nu];

    let (v, w) = vw[0];
    for j in w..(wm + 1) {
        dp[0][j] = v;
    }

    for i in 1..nu {
        let (v, w) = vw[i];
        for j in 0..(wm + 1) {
            let pi = (i - 1) / 2;
            dp[i][j] = max(if j >= w { dp[pi][j - w] + v } else { 0 }, dp[pi][j]);
        }
    }

    let mut vws = vec![(0usize, 0usize)];
    let mut buf = vec![];
    for &(i, l) in vl.iter() {
        if i < nu {
            println!("{}", dp[i][l]);
        } else {
            let mut u = i;
            while u >= nu {
                let (vu, lu) = vw[u];
                for &(v, l) in vws.iter() {
                    buf.push((v + vu, l + lu));
                }
                vws.append(&mut buf);
                buf.clear();
                u = (u - 1) / 2;
            }

            let mut ret = dp[u][l];
            for &(v, w) in vws.iter() {
                if l >= w {
                    ret = max(ret, dp[u][l - w] + v)
                }
            }
            vws.clear();
            vws.push((0, 0));
            println!("{}", ret);
        }
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 412524
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int maxi , len , mini;
string a;
vector<int>v;
char c;
int main(){
    cin >> a;
    len = a.size();
    mini = 300;
    for(int i = 0 ; i < len ; i++){
        c = a[i];
        v.clear();
        
        v.pb(0);
        for(int j = 0 ; j < len ; j++){
            if(a[j] == c){
                v.pb(j);
            }
        }
        v.pb(len - 1);
    
        maxi = 0;
        for(int j = 1 ; j < v.size() ; j++){
            if(j == 1 || j == v.size() - 1)maxi = max(maxi , v[j] - v[j - 1]);
            else maxi = max(maxi , v[j] - v[j - 1] - 1);
        }
        mini = min(mini , maxi);
    }
    cout << mini << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定
#include <list> //前後に数値を入れれる配列



#define REP(i,m,n) for(int i = (int) (m);i < (int) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = 3.141592653589793; //円周率

//常設関数↓

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//degree → radian
ll chg_DegRad(int deg) {
	return deg * PI / 180.0;
}

//radian → degree
ll chg_RadDeg(int rad) {
	return rad * 180.0 / PI;
}

//提出コード↓

int n;
int a;
int ret;

int main() {

	cin >> n;
	ret = n;
	while (ret != 0) {
		a += ret % 10;
		ret /= 10;
	}
	if (n % a == 0) cout << "Yes" << endl;
	else cout << "No" << endl;








	return 0;
}



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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0; i<n; i++)cin>>a.at(i);

  int bt=0, ans=0;
  while(bt!=1 && ans<=n){
    bt=a.at(bt)-1;
    ans++;
  }
  if(ans==n+1)cout<<-1<<endl;
  else cout<<ans<<endl;
}

Measured memory_bytes: 640
while True:
    data_set = input().split(" ")
    if data_set[1] == "+":
        calc = int(data_set[0]) + int(data_set[2])
        print(calc)
    elif data_set[1] == "-":
        calc = int(data_set[0]) - int(data_set[2])
        print(calc)
    elif data_set[1] == "*":
        calc = int(data_set[0]) * int(data_set[2])
        print(calc)
    elif data_set[1] == "/":
        calc = int(data_set[0]) // int(data_set[2])
        print(calc)
    elif data_set[1] == "?":
        break


Measured memory_bytes: 5592
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np
MOD = 998244353

N = int(input())
A = [int(input()) for _ in range(N)]
S = sum(A)

# 赤の和がS/2以上となるものを求めて3倍
# 和に対して何通りあるのか

dp = np.zeros(S+1, dtype=np.int64)
dp[0] = 1
for a in A:
    prev = dp
    dp = prev * 2 # 赤以外を採用
    dp[a:] += prev[:-a] # 赤
    dp %= MOD

answer = pow(3,N,MOD) - dp[(1+S)//2:].sum() * 3
# 2色が反例となる場合を引きすぎている
if S % 2 == 0:
    dp = np.zeros(S+1, dtype=np.int64)
    dp[0] = 1
    for a in A:
        dp[a:] += dp.copy()[:-a]
        dp %= MOD
    answer += dp[S//2] * 3
answer %= MOD
print(answer)


Measured memory_bytes: 14520
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
int inf=1000001000;
ll INF=100000000000000000;

int main() {
  int n;
  cin >> n;
  rep(ii,n){
      vector<ll> a(9,0);
      rep(i,9){
          string s;
          cin >> s;
          ll y=1;
          for(int j=s.size()-1;j>=0;j--){
              int u=s[j]-'0';
              if (u>10 || u<0){
                  u=s[j]-'a';
                  u+=10;
              }
              a[i]+=u*y;
              y*=16;
          }
      }
      ll w=0;
      ll ans=0;
    rep(i,32){
        ll r=0;
        rep(j,8){
            r+=a[j]%2;
            a[j]/=2;
        }
        if ((r+w)%2==a[8]%2) w=(r+w)/2;
        else{
            ans+=pow(2,i);
            r=8-r;
            w=(r+w)/2;
        }
        a[8]/=2;
    }
    string g;
    while(true){
        int q=ans%16;
        if (q<10) g.push_back('0'+q);
        else g.push_back('a'+q-10);
        ans/=16;
        if (ans==0) break;
    }
    reverse(all(g));
    cout << g << endl;
  }
}



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

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type,Name, n,m,d)vector<vector<Type>> Name(n, vector<Type>(m, d))
#define P pair
using namespace std;
using ll = long long;


int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	rep(i, n) {
		cout << s[i] << t[i] << flush;
	}

	cout << endl;
	return 0;
}


Measured memory_bytes: 3668
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
#define ar array
const int mxN=2e5;
const int MOD=1e9+7;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
int main()
{
    fastio;
    ll i,j;
    ll r,g,b,k;
    cin>>r>>g>>b;
    cin>>k;
    if(r<g&&g<b)
        cout<<"Yes"<<endl;
    else
    {
         for(i=0;;i++)
         {
             if(g>r||k==0)
                break;
             else
             {
                 g*=2;
                 k--;
             }
         }
         for(i=0;;i++)
         {
             if(b>g||k==0)
                break;
             else
             {
                 b*=2;
                 k--;
             }
         }
          if(r<g&&g<b)
        cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;

    }
}





Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
int a[105];
int main(void){
    int n,ans=0;cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    int c=0;
    while(c<n){
        int x=a[c],cnt=1;c++;
        while(a[c]==x){
            cnt++;
            c++;
        }
        ans+=cnt/2;
    }
    cout<<ans<<endl;
    return 0;
}     


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

int main(){
	int n, m;
	cin >> n >> m;
	vector<int> a, b, c;
	int s, t, e;
	while(cin >> s >> t >> e, s+t+e){a.push_back(s); b.push_back(t); c.push_back(e);}
	int l; cin >> l;
	for(int i=0; i< l; i++){
		vector<int> d(m);
		for(int j=0; j < m; j++) cin >> d[j];
		vector<int> ret(n);
		for(int j=0; j < a.size(); j++){
			ret[a[j]-1] += d[b[j]-1]*c[j];
		}
		for(int j=0; j< n; j++) cout << (j==0?"" : " ") << ret[j];
		cout << endl;
	}
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int N;
    cin >> N;
    Vl A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    Vl ans(N);
    for (int i = 0; i < N; i += 2) {
        ans[0] += A[i];
    }
    for (int i = 1; i < N; i += 2) {
        ans[0] -= A[i];
    }

    for (int i = 0; i < N - 1; i++) {
        ans[i + 1] = 2 * A[i] - ans[i];
    }

    for (int i = 0; i < N - 1; i++) {
        cout << ans[i] << ' ';
    }
    cout << ans[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 2944
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
#define plzAC(NOTWA) printf("%d\n", NOTWA)
#define plsAC(NOTWA) printf("%s\n", NOTWA)

using ll = long long;

const int INF = 2147483647;
//const ll LINF = ll();今度書く

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {

	int a, b;
	char op;
	scanf("%d%*c%c%d", &a, &op, &b);
	if (op == '+') {
		a += b;
	}
	else {
		a -= b;
	}
	plzAC(a);

	return 0;
}


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

struct test {
    long H;
    long ans;
} td[] =
    {
        {
            2,
            3,
        },
        {
            4,
            7,
        },
        {
            1000000000000,
            1099511627775,
        },
    };

void
solver(long h)
{
    long num_enemy=1;
    long sum=0;

    do {
        sum += num_enemy;
        h /= 2;
        num_enemy *= 2;
    }
    while (h>0);
    printf("%ld\n", sum);
}

int
main(int argc, char *argv[])
{
    long H;
#if 0
    int tt;
    for(tt=0;tt<sizeof(td)/sizeof(struct test); tt++) {
        solver(td[tt].H);
        printf("%ld\n",td[tt].ans);
    }
#endif
    scanf("%ld", &H);
    solver(H);
    return 0;
}

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

#define ll long long int

int main()
{
    ll x, y;
    ll num;
    int ans = 1;

    cin >> x >> y;
    num = x;
    while (1)
    {
        if (num * 2 <= y)
        {
            ans++;
            num *= 2;
        }
        else
            break;
    }
    cout << ans << endl;
}


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



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class CChristmasEve {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n, k;
        in >> n >> k;
        vi H(n);
        in >> H;
        sort(all(H));
        int res = INT_MAX;
        FOR(i, k - 1, n) {
            ckmin(res, H[i] - H[i - k + 1]);
        }
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    CChristmasEve solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
int main(){
    int a,b;
    std::cin>>a>>b;
    a=a==1?14:a;
    b=b==1?14:b;
    std::string str[3] = {"Alice", "Draw", "Bob"};
    std::string* ans = &str[1];
    std::cout<<ans[(a>b?-1:(a==b?0:1))] << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <array>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <climits>
#include <utility>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <complex>
#include <numeric>

#include <time.h>
#include <float.h>

#define loop(i, start, end) for(int i = (start); i <= (end); i++)
#define loopRev(i, start, end) for(int i = (start); i >= (end); i--)
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCases(t) cin >> t; while(t--)
#define PN(n) cout << (n)
#define PN1(n) cout << (n) << " "
#define PN2(a, b) cout << (a) << " " << (b) << " "
#define PN3(a, b, c) cout << (a) << " " << (b) << " " << (c) << " "
#define PNN1(n) cout << (n) << endl
#define PNN2(a, b) cout << (a) << " " << (b) << endl
#define PNN3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define PrintObject(ar) for(auto var: ar) cout << var << " "; cout << endl
#define PrintMap(map) for(auto var: map) PNN2(var.first, var.second)
#define IN1(n) cin >> n
#define IN2(a, b) cin >> a >> b
#define IN3(a, b, c) cin >> a >> b >> c
#define ALL(s) s.begin(), s.end()
#define ENTER PNN1("")
#define llPair std::pair<lli, lli>
#define iiPair std::pair<int, int>
// #define ONLINE_JUDGE

typedef long long int lli;
typedef long int li;
typedef unsigned long long int ulli;
typedef long double ld;

using namespace std;

template <typename T>
T ii() {
	T a;
	IN1(a);
	return a;
}

int main(void){
	FLASH
	#ifndef ONLINE_JUDGE
		freopen("input-stream.txt", "r", stdin);
		freopen("output-stream.txt", "w", stdout);
	#endif

	lli a;
	ld b;
	IN2(a, b);
	lli nb = (lli) round(b * 100);
	PNN1(a * nb / 100);

	return 0;
}


Measured memory_bytes: 3796
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pranay2516
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CUbiquity solver = new CUbiquity();
        solver.solve(1, in, out);
        out.close();
    }

    static class CUbiquity {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt(), mod = (int) 1e9 + 7;
            long ans = 1;
            out.println((func.power(10, n, mod) - 2 * func.power(9, n, mod) + func.power(8, n, mod) + mod + mod) % mod);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class func {
        public static long power(int x, int y, int mod) {
            if (y == 0) return 1;
            long p = power(x, y / 2, mod);
            p = (p * p) % mod;
            return (y % 2 == 0) ? p : (x * p) % mod;
        }

    }
}



Measured memory_bytes: 32408
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		while(sc.hasNext()){
			new aoj0077().doIt();
		}
	}
	class aoj0077 {
		char num[] ={'0','1','2','3','4','5','6','7','8','9'};
		StringBuilder build(char ctr[],int length){
			StringBuilder result = new StringBuilder();
			for(int i = 0;i < length;i++){
				if(i < length - 2 && ctr[i] == '@'){
					for(int j = 0;j < 10;j++){
						if(ctr[i + 1] == num[j]){
							for(int k = 0;k < j;k++){
								result.append((char)(ctr[i+2]));
							}
						}
					}
					i = i + 2;
				}else{
					result.append((char)(ctr[i]));
				}
			}
			return result;
		}
		void doIt() {
			String n = sc.next();
			char nctr[] = n.toCharArray();
			System.out.println(build(nctr,nctr.length));
		}
	}
}

Measured memory_bytes: 17280
#include<bits/stdc++.h>
using lint=long long;
void cmn(lint&x,lint y){if(x>y)x=y;}
void cmx(lint&x,lint y){if(x<y)x=y;}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,T;std::cin>>n>>T;
    std::vector<std::pair<lint,lint>>heavy;
    std::vector<lint>light;
    while(n--){
        lint a,b;std::cin>>a>>b;
        if(a)heavy.emplace_back(a,b);
        else light.push_back(b+1);
    }
    std::sort(heavy.begin(),heavy.end(),[](auto&&p,auto&&q){
            return (p.second+1)*q.first<p.first*(q.second+1);
    });
    light.push_back(0);
    std::sort(light.begin(),light.end());
    std::partial_sum(light.begin(),light.end(),light.begin());
    lint lg=std::log2(T+1);
    std::vector<lint>dp(lg+1,T+1);
    dp.at(0)=0;
    for(auto&&p:heavy){
        lint a,b;std::tie(a,b)=p;
        for(lint i=lg;i>0;i--){
            cmn(dp.at(i),(dp.at(i-1)+1)*(a+1)+b);
        }
    }
    lint ans=0;
    for(lint i=0,j=light.size()-1;i<=lg;i++){
        if(T<dp.at(i))break;
        for(;T<dp.at(i)+light.at(j);j--);
        cmx(ans,i+j);
    }
    std::cout<<ans<<'\n';
}


Measured memory_bytes: 6512
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = /*1'000'000'007LL;*/ 998'244'353LL;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

template<typename T>
T power(T x, long long n, const T &m){
	if(n == 0) return 1;
	if(n == 1) return x;
	T tmp = power(x, n/2, m);
	if(n%2 == 0) return tmp * tmp % m;
	else return tmp * tmp % m * x % m;
}

template<typename T>
T inverse(T x, const T& m){
	return power(x, m-2, m);
}

int A, B, C, D;

ll dp[3005][3005], sum[3005][3005];

ll POW[3005][3005], INV[3005][3005];

signed main(){
	cin >> A >> B >> C >> D;
	for(ll i=1; i<=3004; i++){
		POW[i][0] = 1;
		INV[i][0] = inverse(power(i, 0, MOD), MOD);
		ll tmp = inverse(i, MOD);
		for(int j=1; j<=3004; j++){
			POW[i][j] = POW[i][j-1] * i % MOD;
			INV[i][j] = INV[i][j-1] * tmp % MOD;
		}
	}

	for(int x=D; x>=B; x--){
		for(int ymax=A; ymax<=C; ymax++){
			if(x == D){
				dp[x][ymax] = POW[x][C-ymax];
				continue;
			}
			dp[x][ymax] = dp[x+1][ymax] * ymax % MOD;
			dp[x][ymax] += (sum[x+1][C] - sum[x+1][ymax] + MOD) % MOD
				* INV[x][ymax];
			dp[x][ymax] %= MOD;
		}
		sum[x][A-1] = 0;
		for(int ymax=A; ymax<=C; ymax++){
			sum[x][ymax] = sum[x][ymax-1] + dp[x][ymax] * POW[x-1][ymax];
			sum[x][ymax] %= MOD;
		}
	}
	cout << dp[B][A] << endl;
}

Measured memory_bytes: 285516
// Author -> Preeyadarshee Dev
// Bc pata nhi kis baat ka attitude hai
// Joker ka dialogue suit karta hai yahan to
// " For my whole life, I thought I didn't exist. But now,I do. "
// I will meet you once. #Intequam
// This is fucking motivation.
// train hard win easy :D
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculation
#include<bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                    long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define inf                   987654319
#define eps                   0.000000000000001
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define endl                 '\n'
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={1,-1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};
vector<int> adj[300010];
vector<int> val(300010),dis(200010),vis(300010,0);
int myrandom (int i) { return std::rand()%i;}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    ll a,b,x;
    cin>>a>>b>>x;
    if(2*x>=a*a*b)
    {
        long double lo=0,hi=b;
        while(hi-lo>eps)
        {
            long double mid=(lo+hi)/2;
            long double vol=((0.5*mid)+(b-mid))*a*a;
            if(vol>x)
            {
                lo=mid;
            }
            else
            {
                hi=mid;
            }
        }
        cout<<fixed<<setprecision(20)<<(180/PI)*atan(hi/a)<<endl;
    }
    else
    {
        long double lo=0,hi=a;
        while(hi-lo>eps)
        {
            long double mid=(lo+hi)/2;
            long double vol=0.5*b*mid*a;
            if(vol<x)
            {
                lo=mid;
            }
            else
            {
                hi=mid;
            }
        }
        cout<<fixed<<setprecision(20)<<(PI/2-atan(hi/b))*180/PI<<endl;
    }
}
// t4xxnve1
// 11906472
// YHUHA8ZBJH
// Preeyadarshee Dev Team 808db2e1





Measured memory_bytes: 10368
a,b=map(int,input().split())
b=b-1
s=input()
l=len(s)
s2=[]
for i in range(l):
    if(i == b):
        s2.append(s[b].lower())
    else:
        s2.append(s[i])
for j in range(l):
    print(s2[j], end ='')
print()

Measured memory_bytes: 3060
import numpy as np
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))

c = []
for i, j in enumerate(a):
    c += [i + 1] * j
c = np.array(c).reshape(H, W)
c[1::2, :] = c[1::2, ::-1]

for r in range(H):
    row = c[r, :]
    print(*row, sep=' ')


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

struct Query {
    int i, l, r;
};

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

    int N, Q;
    cin >> N >> Q;
    vector<int> c(N);
    for (int i = 0; i < N; i++) cin >> c[i];
    vector<Query> queries(Q);
    for (int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        queries[i] = {i, l - 1, r - 1};
    }
    int S = (int) sqrt(N);
    sort(queries.begin(), queries.end(), [&](const auto& q1, const auto& q2) {
        if (q1.l / S != q2.l / S) return q1.l < q2.l;
        return q1.r < q2.r;
    });

    vector<int> colors(N+1);
    vector<int> ans(Q);
    int curL = 0, curR = 0, cnt = 1;
    colors[c[0]] = 1;
    for (auto& q : queries) {
        while (curL < q.l) {
            colors[c[curL]]--;
            if (colors[c[curL]] == 0) cnt--;
            curL++;
        }
        while (curL > q.l) {
            curL--;
            if (colors[c[curL]] == 0) cnt++;
            colors[c[curL]]++;
        }
        while (curR < q.r) {
            curR++;
            if (colors[c[curR]] == 0) cnt++;
            colors[c[curR]]++;
        }
        while (curR > q.r) {
            colors[c[curR]]--;
            if (colors[c[curR]] == 0) cnt--;
            curR--;
        }
        ans[q.i] = cnt;
    }
    for (int i = 0; i < Q; i++) {
        cout << ans[i] << '\n';
    }
}

Measured memory_bytes: 15476
#include <cstdio>

using namespace std;

int isPalindromic(int n){
  int rev = 0, t;
  
  t = n;
  while (t){
    rev = rev*10 + t%10;
    t /= 10;
  }
  return rev==n;
}

int main(void){
  int a, b, ans;
  scanf("%d%d", &a, &b);
  
  ans = 0;
  for (int i=a; i<=b; i++){
    ans += isPalindromic(i);
  }
  printf("%d\n", ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp(a, b) make_pair(a, b)
#define ls (rt << 1)
#define rs (rt << 1 | 1) 
typedef pair<int, int> pii; 
const ll mod = 1e9 + 7;
template <class T> T lowbit(T x){return ((x)&(-(x)));}
const int maxn = 2e5 + 10;
map<ll, int> M;
ll ans;
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
	{
		int val;
		scanf("%d", &val);
		ans += M[i - val];
		++M[i + val];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 26376
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);



int main() {
    ios_base::sync_with_stdio(false);

    ll n,m,k;
    cin >> n >> m >> k;
    vector<ll> a(n+1),b(m+1);
    rep(i,n) {
        ll ain;
        cin >> ain;
        a[i+1]=a[i]+ain;
    }
    rep(i,m) {
        ll bin;
        cin >> bin;
        b[i+1]=b[i]+bin;
    }
    int ans=0;
    rep(i,n+1) {
        int j=upper_bound(b.begin(),b.end(),k-a[i])-b.begin();
        if (j>0) ans=(ans>i+j-1)?ans:i+j-1;
    }
    cout << ans << endl;
    return 0;   
}

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

using namespace std;

int n, m, f[10010], x[10010], y[10010];
double ans = 0.0;

struct edge {
	int u, v;
	double w;
	bool operator < (const edge &b) const { return w < b.w; }
}e[1000010];

double getdis(int u, int v) {
	return sqrt((double)(x[u] - x[v]) * (x[u] - x[v]) + (double)(y[u] - y[v]) * (y[u] - y[v]));
}

int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }

int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++i) {
		f[i] = i;
		scanf("%d%d", &x[i], &y[i]);
	}
	int u, v;
	for(int i = 1; i <= m; ++i) {
		scanf("%d%d", &u, &v);
		e[i].u = u;
		e[i].v = v;
		e[i].w = getdis(u, v);
	}
	sort(e + 1, e + m + 1);
	for(int i = m; i >= 1; --i) {
		int fu = find(e[i].u);
		int fv = find(e[i].v);
		if(fu != fv) f[fu] = fv;
		else ans += e[i].w;
	}
	printf("%.3lf\n", ans);
	return 0;
} 


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

#define ll long long
#define pb push_back
#define mp make_pair

void solve() {

	int a,b,c;
	cin >> a >> b >> c;
	if(a == b and b ==c)cout << "No";
	else if(a ==b or b == c or a == c)cout << "Yes";
	else cout << "No";

	
    


}


int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);

    ll T;
    T = 1;
    //cin >> T;
    while (T--) {
        solve();
    }




}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int Next[200200][30];
bool Vis[200200];
int Prev[200200];
int main()
{
	string S;
	cin>>S;
	int N=S.length();
	S="\n"+S;
	for(int i=0;i<26;i++)
		Next[N][i]=-1;
	for(int i=N-1;i>=0;i--)
		for(int j=0;j<26;j++)
			if(S[i+1]-'a'==j)
				Next[i][j]=i+1;
			else	Next[i][j]=Next[i+1][j];
	queue<int> Q;
	//bfs可能超时(@TwT@)但我只会这个了
	//Plus:啊。bfs不会超时 
	Q.push(0);
	Vis[0]=true;
	Prev[0]=-1;
	while(!Q.empty())
	{
		int X=Q.front();
		Q.pop();
		for(int i=0;i<26;i++)
			if(Next[X][i]==-1)
			{
				//Yeah竟然这么快就写输出了
				string Ans;
				Ans+=('a'+i);
				while(X!=-1)
				{
					Ans+=S[X];
					X=Prev[X];
				}
				reverse(Ans.begin(),Ans.end());
				cout<<Ans.substr(1)<<endl;
				return 0;
			}
			else if(!Vis[Next[X][i]])
			{
				int Y=Next[X][i];
				Vis[Y]=true;
				Prev[Y]=X;
				Q.push(Y);
			}
	}
	return 0;
}
//frqnvhydscshfcgdemurlfrutcpzhopfotpifgepnqjxupnskapziurswqazdwnwbgdhyktfyhqqxpoidfhjdakoxraiedxskywuepzfniuyskxiyjpjlxuqnfgmnjcvtlpnclfkpervxmdbvrbrdn

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

int main(){
    int n, m, count = 0;
    while(1){
        cin >> n >> m;
        if(n == 0 && m == 0) break;
        vector< vector<int> > a(50000, vector<int>(n));
        rep(i, n){
            cin >> a.at(count).at(i);
        }
        int max_ = 0;
        for(int i = 0; i < n-1; i++){
            for(int j = i+1; j < n; j++){
                if(a.at(count).at(i)+a.at(count).at(j) <= m){
                    max_ = max(a.at(count).at(i)+a.at(count).at(j), max_);
                }
            }
        }
        if(max_ == 0){
            cout << "NONE" << endl;
        }
        else {
        cout << max_ << endl;
        }
        count++;
    }
    return 0;
}


Measured memory_bytes: 200156