akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,lzcnt,mmx,abm,avx,avx2")

#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


const int BITS = 18;

int N, K, S, T;
int64_t ALL;
vector<int> A;
array<array<int64_t, 2>, BITS> fail;
vector<vector<int64_t>> choose;
vector<int64_t> up_to_K;
int64_t answer;

void recurse(int index, int sign, int64_t mask) {
    if (mask == 0)
        return;

    if (index == BITS) {
        answer += sign * up_to_K[__builtin_popcountll(mask)];
        return;
    }

    recurse(index + 1, sign, mask);
    recurse(index + 1, -sign, mask & fail[index][0]);
    recurse(index + 1, -sign, mask & fail[index][1]);
}

int main() {
    cin >> N >> K >> S >> T;

    if ((S | T) != T) {
        cout << 0 << '\n';
        return 0;
    }

    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;

        if ((a & S) != S || (a | T) != T)
            continue;

        A.push_back(a);
    }

    N = int(A.size());
    K = min(K, N);

    choose.assign(N + 1, vector<int64_t>(N + 1, 0));

    for (int i = 1; i <= N; i++) {
        choose[i][0] = choose[i][i] = 1;

        for (int j = 1; j < i; j++)
            choose[i][j] = choose[i - 1][j] + choose[i - 1][j - 1];
    }

    up_to_K.assign(N + 1, 0);

    for (int i = 1; i <= N; i++)
        for (int j = 1; j <= K; j++)
            up_to_K[i] += choose[i][j];

    ALL = (1LL << N) - 1;

    for (int bit = 0; bit < BITS; bit++) {
        fail[bit] = {0, 0};

        if ((S >> bit & 1) == 0) {
            for (int i = 0; i < N; i++)
                if (A[i] >> bit & 1)
                    fail[bit][0] |= 1LL << i;
        }

        if ((T >> bit & 1) == 1) {
            for (int i = 0; i < N; i++)
                if ((A[i] >> bit & 1) == 0)
                    fail[bit][1] |= 1LL << i;
        }
    }

    answer = 0;
    recurse(0, 1, ALL);
    cout << answer << '\n';
}


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

int main(){
  int h,w,count=0;
  string s;
  cin>>h>>w;
  vector<string> vec(h+2,"");
  for(int i=0;i<w+2;i++){
    vec.at(0)+=".";
    vec.at(h+1)+=".";
  }
  for(int i=1;i<h+1;i++){
    cin>>vec.at(i);
    vec.at(i)="."+vec.at(i)+".";
  }
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      if(vec.at(i).at(j)=='#'){
        cout<<'#';
      }else{
        count=0;
          for(int k=-1;k<2;k++){
            for(int l=-1;l<2;l++){
              if(vec.at(k+i).at(l+j)=='#'){
                count+=1;
              }
            }
          }
        cout<<count;
      }
    }
    cout<<endl;
  }
}
          
   


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
int a,ans=0;
cin>>a;
for(;;){
	if(a==7){
		ans++;
		break;
	}
	if(a<3){
		break;
	}else{
		a=a-4;
	}
	if(a%7==0){
		ans++;
		break;
	}
}

if(ans==1){
	cout<<"Yes"<<endl;
}else{
	cout<<"No"<<endl;
}



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
using namespace std;
const int mod = 1e9+7;
int dp[5005][5005];
string s;
int solve(int x,int y){
	if(~dp[x][y])return dp[x][y];
	if(y>s.size())return dp[x][y] = 0;
	if(s[x]==s[y]){
		return dp[x][y] = solve(x+1,y+1)+1;
	}
	else{
		return dp[x][y] = 0;
	}
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	while(cin >> n){
		memset(dp,-1,sizeof(dp));
		cin >> s;
		s = " " + s;
		f1(n){
			fr(j,i+1,n+1){
				solve(i,j);
			}
		}
		int mx = 0;
		f1(n){
			fr(j,i+1,n+1){
				mx = max(mx,min(dp[i][j],j-i));
			}
		}
		cout << mx << endl;
	}
}


Measured memory_bytes: 98304
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ld r;
    cin >> r;

    cout << fixed << setprecision(10) << r * 2.0 * M_PI << endl;
}


Measured memory_bytes: 3792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define rrep(i, n) for(long long i = (long long)(n - 1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using ll = long long;

int main()
{
	string s;
	cin >> s;

	if (s[2] == s[3] && s[4] == s[5])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

signed main() {
	int n, k;
	cin >> n >> k;
	if (k == 0) {
		cout << n * n << endl;
		return 0;
	}
	int ans = 0;
	for (int i = k + 1; i <= n; i++) {
		ans += (n / i) * (i - k);
		if (n % i >= k) {
			ans += (n % i) - (k - 1);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void swap(int *a, int *b);  /* a??¨b??\????????? */

int main(void){
  int a, b, c;

  scanf("%d%d%d", &a, &b, &c);

  if(a > b){
    swap(&a, &b);
  }
  if(b > c){
    swap(&b, &c);
  }
  if(a > b){
    swap(&a, &b);
  }
  printf("%d %d %d\n", a, b, c);

  return 0;
}


void swap(int *a, int *b){
  int x;

  x = *a;
  *a = *b;
  *b = x;
}

Measured memory_bytes: 596
import itertools
H, W, M = map(int, input().split())
Bh = [0]*(H+1)
Bw = [0]*(W+1)
OD = set()

for _ in range(M):
    h, w = map(int, input().split())
    Bh[h] += 1
    Bw[w] += 1
    OD.add((h, w))

M1 = max(Bh)
M2 = max(Bw)
l1 = [i for i, x in enumerate(Bh) if x == M1]
l2 = [j for j, x in enumerate(Bw) if x == M2]
for i, j in itertools.product(l1, l2):
    if (i, j) not in OD:
        break
else:
    print(M1+M2-1)
    exit()
print(M1+M2)


Measured memory_bytes: 180584
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        long sum = 0;
        long i = 0;
        HashMap<Long , Long> map = new HashMap<>();
        for(i = 0; i < n ; i++){
            long ai = in.nextLong();
            if(map.containsKey(ai)) {
                Long f = map.get(ai);
                map.remove(ai);
                map.put(ai , f+1);
            } else {
                Long one = new Long(1);
                map.put(ai , one);
            }
            sum = sum + ai;
        }
        long q = in.nextInt();
        for(i = 0 ; i < q; i++){
            long bi = in.nextLong();
            long ci = in.nextLong();
            if(map.containsKey(bi)){
                long f = map.get(bi);
                sum = sum - bi*f;
                sum = sum + ci*f;
                map.remove(bi);
                if(map.containsKey(ci)){
                    f += map.get(ci);
                    map.remove(ci);
                }
                map.put(ci,f);
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 71788
/*
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
*/
#include <stdio.h>
#include <string.h> 
int ans = 1 << 25;
char str[100010];
int main()
{
	scanf("%s", str);
	int len = strlen(str);
	for (int _ = 1; _ < len; ++ _)
	{
		if (str[_] != str[_ - 1])
		{
			ans = ans > (_ > len - _? _: len - _)? (_ > len - _? _: len - _): ans;
		}
	 } 
	 return !printf("%d\n", ans > len? len: ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
数値型から文字列に変換　to_string(number);これは簡単
文字列から数値型に変換　stoi(number)
文字列からllに変換　stoll(number)*/

//ここから書き始める
int main(){
		int n ;
		cin >> n;
		cout << n*n*n<<endl;
}


Measured memory_bytes: 256
num = list(map(int, input().split(' ')))
insert = num[0]
minimum = num[1]
mylist = [0 for i in range(insert)]

for i in range(insert):
    mylist[i] = (list(map(int, input().split(' '))))
    
sort_list = sorted(mylist)
sum_num = 0
for i in range(insert):
    sum_num += sort_list[i][1]
    if sum_num >= minimum:
        print(sort_list[i][0])
        break

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

ll gcd(ll a,ll b){
    if(b==0) return a;
    else{
        return gcd(b,a%b);
    }
}

ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}

int main(){

    int n,m;
    cin >> n >> m;
    string s,t;
    cin >> s >> t;

    ll l=lcm(n,m);

    ll ss=l/n;
    ll tt=l/m;

    for(int i=0;i<n;i++){
        if(((ll)ss*i)%tt==0){
            if(s[i]!=t[((ll)ss*i)/tt]){
                cout << -1 << endl;
                return 0;
                break;
            }
        }
    }
    cout << l << endl;

    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#include<cstdlib>
using namespace std;
const int maxn=100005;
int cost[maxn],dp[maxn];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&cost[i]);
    }
    dp[2]=abs(cost[2]-cost[1]);
    dp[3]=min(abs(cost[3]-cost[1]),dp[2]+abs(cost[3]-cost[2]));
    for(int i=4;i<=n;i++){
        dp[i]=min(abs(cost[i]-cost[i-2])+dp[i-2],abs(cost[i]-cost[i-1])+dp[i-1]);
    }
    printf("%d",dp[n]);
    return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<vector<int> > g(n);
    int i;
    for(i=0; i<n-1; i++) {
        int a,b;
        scanf("%d%d", &a, &b);
        g[a-1].push_back(b-1);
        g[b-1].push_back(a-1);
    }
    vector<int> c(n);
    for(i=0; i<n; i++) {
        scanf("%d", &c[i]);
    }
    sort(c.begin(), c.end());

    set<pair<int,int> > z;   // val, id
    vector<int> cnt(n);
    for(i=0; i<n; i++) {
        cnt[i]=(int)g[i].size();
        z.insert(make_pair(cnt[i],i));
    }

    ll pnt=0;
    vector<int> ans(n);
    int cnt_ans=0;
    while(!z.empty()) {
        auto it0 = z.begin();
        int k   = it0->second;
        ans[k]=c[cnt_ans];
        if(cnt_ans<n-1) {
            pnt += c[cnt_ans];
        }
        cnt_ans++;

        auto it=g[k].begin();
        for(; it!=g[k].end(); ++it) {
            int tmp=(*it);
            if(z.find(make_pair(cnt[tmp],tmp))!=z.end()) {
                z.erase(make_pair(cnt[tmp],tmp));
                cnt[tmp]--;
                z.insert(make_pair(cnt[tmp],tmp));
            }
        }
        z.erase(*it0);
    }

    printf("%lld\n", pnt);
    for(i=0; i<n; i++) {
        printf("%d ", ans[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>

int main ()
{
	int a,b;

	scanf("%d %d", &a, &b);

	if (a<=5)
		printf("0\n");

	else if (a<=12)
		printf("%d\n",b/2);

	else
		printf("%d\n",b);

	return 0;
}



Measured memory_bytes: 128
from collections import OrderedDict
import sys
input = sys.stdin.readline

def resolve():
    n = int(input())

    count = OrderedDict()
    for _ in range(n):
        name = input()
        if name not in count.keys():
            count[name] = 1

        else:
            count[name] += 1

    count = OrderedDict(
        sorted(count.items(), key=lambda x: x[0])
    )
    max_polls = max(count.values())

    for k, v in count.items():
        if v == max_polls:
            print(k)
            
resolve()

Measured memory_bytes: 156300
I=lambda:map(int,input().split());F=1e21;r=range;n,m=I();f=[-F,F];X=set([0]+f);Y=set(X);R=[(f,F),(f,-F)];H=[(F,f),(-F,f)]
for i in r(n):a,b,c=I();R+=[((a,b),c)];Y.add(c);X.add(a);X.add(b)
for i in r(m):a,b,c=I();H+=[(a,(b,c))];X.add(a);Y.add(b);Y.add(c)
s=dict(enumerate(sorted(X)));K=len(s);t=dict(enumerate(sorted(Y)));L=len(t);h=dict(zip(s.values(),s.keys()));w=dict(zip(t.values(),t.keys()));V=[[0]*-~K for i in r(L+1)];U=[i[:]for i in V];v=[i[:]for i in V]
for(a,b),c in R:U[w[c]][h[a]]+=1;U[w[c]][h[b]]+=-1
for i in r(L):
 for j in r(K):U[i][j+1]+=U[i][j]
for d,(e,f)in H:V[w[e]][h[d]]+=1;V[w[f]][h[d]]+=-1
for j in r(K):
 for i in r(L):V[i+1][j]+=V[i][j]
q=[(h[0],w[0])];v[w[0]][h[0]]=1;a=0
while q:
 x,y=q.pop();a+=(s[x]-s[x+1])*(t[y]-t[y+1])
 for e,f in[(-1,0),(1,0),(0,1),(0,-1)]:
  c=x+e;d=y+f
  if(K>c>=0<=d<L)*v[d][c]==0:
   if U[(f>0)+y][x]|e==0 or V[y][(e>0)+x]|f==0:q+=[(c,d)];v[d][c]=1
if a>F:a='INF'
print(a)


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

using namespace std;

int main() {
	while (true) {
		int n, pmax;
		int stone[50] = {};

		cin >> n >> pmax;
		if (!n && !pmax) break;

		int i;
		int p = pmax;
		for (i = 0; 1; i++) {
			if (p) {
				p--;
				stone[i % n]++;
				if (!p && stone[i % n] == pmax) {
					break;
				}
			}
			else {
				p += stone[i % n];
				stone[i % n] = 0;
			}
		}

		cout << i % n << endl;
	}

	return 0;
}


Measured memory_bytes: 3092
N, K = gets.split(" ").map(&:to_i)
pos = gets.split(" ").map(&:to_i)

min_val = 98765432109876543210

0.upto(N - K) do |s|
  e = s + K - 1
  val = [pos[s].abs, pos[e].abs].max
  val += [pos[s].abs, pos[e].abs].min * 2 if pos[s] * pos[e] <= 0
  min_val = [val, min_val].min
end

p min_val


Measured memory_bytes: 11012
fn main() {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    println!("{}", solve(&input));
}

fn solve(input: &str) -> i64 {
    let mut iter = input.split_whitespace().map(|w| w.parse().unwrap());
    let n: i64 = iter.next().unwrap();
    let x: Vec<i64> = (0..n).map(|_| iter.next().unwrap()).collect();
    let m: i64 = (x.iter().sum::<i64>() + n / 2) / n;
    x.iter().map(|&xi| (xi - m).pow(2)).sum()
}

Measured memory_bytes: 4352
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;


void solve()
{
    int K, n;
    scanf("%d%d", &K, &n);
    vector<int> a(n);
    int i;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
  
    ll ans = LINF;
    for (i = 0; i < n; i++) {
        int j = (i + 1) % n;
        int tmp=a[j] - a[i];
        if (tmp <= 0) tmp += K;
        ans=MIN(ans, K - tmp);
    }
    printf("%lld\n", ans);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}

Measured memory_bytes: 1024
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
#define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); i++)	
using namespace std;


int max(int a,int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	string s;
	int count = 0;
	cin >> s;
	rep(i, 3) {
		if (s[i] == '1') {
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7
n = gets.to_i
a = gets.split.map(&:to_i)
b = Array.new(n, 0)
prev = 0
for i in 0...n do
  b[i] = (prev + a[i]) % MOD
  prev = b[i]
end
sum = 0
for i in 0...(n - 1) do
  sum = (sum + a[i] * (b[n - 1] - b[i])) % MOD
end
puts sum


Measured memory_bytes: 29532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    ll X, y = 100;
    cin >> X;
    int cnt = 0;
    while (y < X) {
        y = ll(y * 1.01);
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include <iomanip>

int main(){
	int n;
	int k;
	std::cin>>n>>k;

	std::vector<long double> aList(n);

	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	for(int i=0; i<n; i++)
		aList[i]+= 1; 

	long double ans= 0;
	for(int i=0; i<k; i++)
		ans+= aList[i];

	long double tmp= ans;

	for(int i=0; i<n-k; i++){
		tmp= tmp- aList[i] + aList[i+k];
		if(tmp > ans)
			ans= tmp;
	}

	std::cout << std::fixed;
	std::cout<<std::setprecision(10)<<ans/(long double)2<<std::endl;

	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define MOD 1000000007
#define F first
#define S second

typedef long long ll;
using namespace std;

int main()
{
    int n, ans = 0, a[3010];
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i) {
        int part = 0;
        for (int j = 0; j < n; ++j)
            part += (a[j] - 1) % a[i];
        ans = max(ans, part);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{min, max};
use std::io;

fn op(v: usize) -> char {
    if v == 0 { '+' } else { '-' }
}


fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let a: i64 = line[0..1].parse().unwrap();
    let b: i64 = line[1..2].parse().unwrap();
    let c: i64 = line[2..3].parse().unwrap();
    let d: i64 = line[3..4].parse().unwrap();

    for ops1 in 0..2 {
        for ops2 in 0..2 {
            for ops3 in 0..2 {
                let mut e = a;
                if ops1 == 0 { e += b } else { e -= b }
                if ops2 == 0 { e += c } else { e -= c }
                if ops3 == 0 { e += d } else { e -= d }
                if e == 7 {
                    println!("{}{}{}{}{}{}{}=7", a, op(ops1), b, op(ops2), c, op(ops3), d);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PB push_back
#define CL(a,x) memset(a, x, sizeof(a))
#define ar6 array<int, 6>
typedef long long LL;
const int P = 1e9+7;
const int N = 2e5+5;
const double PI = acos(-1);
mt19937 rng(time(0));

int n, d[N];
LL c[N];

int main(){
	scanf("%d",&n);
	LL ans = -1, sum = 0;
	rep(i,1,n) scanf("%d%lld",d+i,c+i), ans += c[i], sum += c[i]*d[i];
	ans += (sum-1) / 9;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <iostream>
#include <iomanip>
using namespace std;

int main(void)
{
	int a, b, d, r;
	double f;
	cin >>a>>b;
	r=a%b;
	d=(a-r)/b;
	f=(double)a/b;
	cout <<d<<" "<<r<<" " <<fixed << setprecision(10) << f << endl;;
    
	
	return 0;
}

Measured memory_bytes: 1248
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		try {
		    Scanner sc=new Scanner(System.in);
		    float r=sc.nextFloat();
		    System.out.println(2*3.14*r);
		} catch(Exception e) {
		}
	}
}


Measured memory_bytes: 37404
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.C_Challenge
{
    class ABC_093
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] abc = ReadInts();
            Array.Sort(abc);
            int cnt = 0;
            cnt += (abc[2] - abc[1]) / 2;
            abc[1] += (abc[2] - abc[1]) / 2 * 2;
            cnt += (abc[2] - abc[0]) / 2;
            abc[0] += (abc[2] - abc[0]) / 2 * 2;
            Array.Sort(abc);
            if (abc[0] < abc[1])//-1 0 0
            {
                cnt += 2;
            }
            else if (abc[1] < abc[2])
            {
                cnt += 1;
            }
            Console.WriteLine(cnt);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main() {
  int A, B, C, D;

  cin >> A >> B >> C >> D;

  if ( ( A + B ) > ( C + D ) ) {
    cout << "Left" << endl;
  } else if ( ( A + B ) < ( C + D ) ) {
    cout << "Right" << endl;
  } else
    cout << "Balanced" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a, b, d, e, f = 0, i;
	while (scanf("%d", &a))
	{
		if (a == 0)break;
		scanf("%d", &b);
		f = 0;
		for (i = 0;i < b;i++)
		{
			scanf("%d %d", &d, &e);
			f = f + (e - d);
		}
		if(a - f <= 0)
		{
			printf("OK\n");
		}
		else
		{
			printf("%d\n", a - f);
		}
		f = 0;
	}
	return 0;
}

Measured memory_bytes: 612
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func nextInt3() (int, int, int) {
	return nextInt(), nextInt(), nextInt()
}

func nextInt4() (int, int, int, int) {
	return nextInt(), nextInt(), nextInt(), nextInt()
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	x, y := nextInt(), nextInt()

	for a := 0; a <= x; a++ {
		b := x - a
		if 2*a+4*b == y {
			puts("Yes")
			return
		}
	}

	puts("No")
}


Measured memory_bytes: 1764
#include <math.h>
#include <iostream>
#include <algorithm>
#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);
}
for (int i=0;i<n;i++)
{
cout << a.at(n-1-i);
if (i!=n-1)cout << " ";
}
cout << endl;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b >= a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n;
  cin >> n;
  vl h(n);
  rep(i, n) cin >> h[i];
  
  ll ans=0, M=0;
  rep(i, n) {if(chmax(M, h[i])) ans++;}
  cout << ans << newl;
  return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int asc(const void* a, const void* b) {
	return *(int*)a- *(int*)b;
}

int main()
{
	int k, x;
	cin >> k >> x;
	for (int i = x - k + 1; i <= x + k - 1; i++){
		cout << i << ' ';
	}
}

Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0; string S;
    cin >> N >> S;  

    //本文
    ll ans = 0;
    for(int i = 0; i<1000;i++){
        int num[3] = {i/100, (i%100)/10,i%10};
        int f = 0;
        for(int j = 0; j < N; j++){
            if(S[j]==('0'+num[f])) f++;
            if(f==3) break;
        }
        if(f==3) ans ++;
    }

    cout << ans;


    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3712
//xsharawi is back
//SPEEEEEEEEEED IS KEEEEEEEEEEY
//REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEAD
#include <bits/stdc++.h>
using namespace std;
typedef string s;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7;
#if !defined(ONLINE_JUDGE)
#include "C:\debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define ins insert
#define vl vector<ll>
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
int main(){
    speed;
    ll n, ans = 1;
    cin >> n;
    for( ll i = 1; i <= n; i++ ){
        ans = ( (ans % MOD) * ( i % MOD ) ) % MOD;
    }
    cout << ans << endl;















return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/


Measured memory_bytes: 3580
def main():
    s = input()
    K = int(input())
    lst = sorted(set(s))
    ans = []

    def dfs(c):
        ans.append(c)
        if len(ans) < K:
            for li in lst:
                if c + li in s:
                    return dfs(c + li)

    for li in lst:
        dfs(li)
    print(ans[K - 1])
    return


main()


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

int main() {
  int s,w;
  cin >> s >> w;
  if(s<=w) cout << "unsafe" << endl;
  else cout << "safe" << endl;

}


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

int main() {
    int A, B;
    cin >> A >> B;
    bool B_Divisor[B+1];
    for (int i = 1; i <= B; i++) {
        B_Divisor[i] = false;
    }
    for (int i = 1; i <= B; i++) {
        if (B%i == 0) {
            B_Divisor[i] = true;
        }
    }
    bool result = false;
    for (int i = 1; i <= B; i++) {
        if (B_Divisor[i] && A == i) {
            result = true;
        }
    }
    cout << (result?A+B:B-A) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <stdexcept>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>

using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define fill(x, y) memset(x, y, sizeof(x))
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define itn int
#define re return
#define prev PREV
#define next NEXT

#define sz(x) ((int)x.size())

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int MAXN = 1e5 + 10;
#define FILENAME ""

const ll maxn = 500000 + 10;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, s1, s2;
    cin >> s >> s1 >> s2;
    cout << (char) (s[0] - 'a' + 'A') << (char) (s1[0] - 'a' + 'A') << (char)(s2[0] - 'a' + 'A');
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*; 

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

                boolean result = check(n);

                if(result)
                        System.out.println("Yes");
                else
                        System.out.println("No");
        }

        public static boolean check(int n){

                while(n>0){
                        int rem = n%10;
                        if(rem==7)
                                return true;
                        n/=10;
                }
                return false;
        }
} 


Measured memory_bytes: 27084
(function (input) {
    var inputs = input.replace(/\r/g, '').split("\n")[0].split(' '),
        a = parseInt(inputs.shift()),
        b = parseInt(inputs.shift()),
        square = a * b,
        tsubo = square / 3.305785;

    console.log(tsubo.toFixed(6));
})(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve(){
    ll h,w,n;
    cin>>h>>w>>n;
    vec<ll> a(n);
    REP(i,n) cin>>a[i];

    vvec<ll> ans(h,vec<ll>(w,0));
    ll pos=0;
    REP(i,h){
        REP(j,w){
            ans[i][j]=pos+1;
            a[pos]--;
            if(a[pos]==0) pos++;
        }
    }

    REP(i,h){
        if(i%2){
            REP2(j,w) cout<<ans[i][j]<<" ";
            cout<<en;
        }else{
            REP(j,w) cout<<ans[i][j]<<" ";
            cout<<en;
        }
    }
}

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

    solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 512
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ull a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

//fast power
ll calc(ll a, ll b) {
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        ll d = calc(a, b / 2);
        return (d * d) % MOD;
    }
    else return (a * calc(a, b - 1)) % MOD;
}

//fast combination
ll comb(ll n, ll a) {
    ll b = 1, c = 1;
    for (ll i = 1; i <= a; ++i) {
        b = b * i % MOD;
        c = c * (n - i + 1) % MOD;
    }

    return c * calc(b, MOD - 2) % MOD;
}

int main(void) {
    cin >> n >> a >> b;

    c = a + b;
    if (c == 0) {
        cout << 0 << endl;
        return 0;
    }
    ll nc = (n / c);
    ll nca = n % c;
    if (nca > a) nca = a;
    ll ans = nc * a + nca;

    cout << ans << endl;

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> r(N);
  for(int i=0; i<N; i++){
    cin >> r[i];
  }
  sort(r.begin(), r.end());
  int count = 1;
  for(int i=1; i<N; i++){
    if(r[i] != r[i-1]){
      count ++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int a[n + 1];
    for(int i = 1; i <= n; i++)
        scanf("%d",&a[i]);
    int ans = 0;
    for(int i = 1; i <= n; i+= 2)
        if(a[i] % 2 == 1)
            ans ++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1648
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
typedef long long ll;
typedef long double ld;
#define PI  3.14159265358979323846

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
string S;

vector<string>A;


int main() {
    cin >> S;
    ll ans = 0;
    ll num = S.length();
    rep(bit,1<<(num-1)) {
        ll count = 0;
        string tmpS = S;
        for (ll j = 0; j < num - 1;++j) {
            if (bit&(1<<j)) {
                tmpS.insert(j+1+count, "+");
                count++;
            }
        }
        A.push_back(tmpS);
    }
    rep(i,A.size()) {
        ll tmpAns = 0;
        rep(j,A[i].length()) {
            if (A[i][j]!='+') {
                tmpAns *= 10;
                tmpAns += (A[i][j]-'0');
                if (j== A[i].length()-1) {
                    ans += tmpAns;
                }
            }
            else if(A[i][j] == '+'){
                ans += tmpAns;
                tmpAns = 0;
            }
            
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
N = gets.to_i

m = 0
i = 0
(1..N).each{ |a|
  i = a
  m += i
  break if m >= N
}

r = m - N
ans = [i]
(1...i).reverse_each { |a|
  if r >= a
    r -= a
  else
    ans << a
  end
}
puts ans

Measured memory_bytes: 1916
<?php

fscanf(STDIN, "%d %d", $a, $b);

$result = 0;
for ($i = 0; $i < 2; ++$i) {
    if ($a > $b) {
        $result += $a;
        --$a;
    } else {
        $result += $b;
        --$b;
    }
}
echo $result;


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

int main(){
  string p,s;
  cin>>p>>s;
  p=p+p;
  bool flag=false;
  for(int i=0;i<(int)p.size()-(int)s.size()+1;i++){
    
    string t=p.substr(i, s.size() );
    
    if( t == s ){
      flag=true;
      break;
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}




Measured memory_bytes: 3228
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll i,j,n,k;
    cin>>n;
    ll ans=0;
    while(n>0)
    {
     if(n%10==2)
     ans++;
     n/=10;
     
    }

    cout<<ans<<endl;

    return 0;
}





Measured memory_bytes: 3608
def strings_with_the_same_length(n:int, s:str, t:str) -> str:
    message = []
    for i in range(n):
        message.append(s[i])
        message.append(t[i])
    message_x = "".join(message)
    return message_x

n = int(input())
s, t = input().split()
print(strings_with_the_same_length(n, s, t))

Measured memory_bytes: 3060
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
#include<functional>
using namespace std;
const long long INF=10000000009;
int n;
long long a,b;
long long h[100005];
long long h1[100005];
bool check(long long x)
{
	long long tot=0;
	for(long long i=0;i<n;i++)
		h1[i]=h[i]-x*b;
	long long a1=a-b;
	for(long long i=0;i<n;i++)
	{
		if(h1[i]<=0)
			continue;
		long long now=h1[i]/a1;
		if(h1[i]%a1!=0)
			now++;
		tot+=now;
		if(tot>x)
			return false;
	}
	if(tot>x)
		return false;
	return true;
}
int main()
{
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)
		cin>>h[i];
	long long l=1,r=INF,mid;
	while(l<=r)
	{
		mid=(l+r)/2;
		if(check(mid))
			r=mid-1;
		else
			l=mid+1;
	}
	cout<<r+1;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int dp[100005];
int input[100005];
int frog(int n, int k){
    int res;
    if(n == 1) res = abs(input[1] - input[0]);
    else if(n == 0) res = 0;
    else if(dp[n] != -1){
        return dp[n];
    }
    else{
        res = abs(input[n - 1] - input[n]) + frog(n - 1, k);
        for(int i = 1; i <= min(k, n); i++)
        res = min(abs(input[n - i] - input[n]) + frog(n - i, k), res);
    }
    dp[n] = res;
    return res;
}
int main()
{
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        dp[i] = -1;
    }
    for(int i = 0;  i < n; i++){
        cin >> input[i];
    }
    cout << frog(n - 1, k);


}

Measured memory_bytes: 12160