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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    ll N,A,B;
    cin >> N >> A >> B;

    if( (B-A)%2 == 0 ) cout << (B-A)/2 << endl;
    else
    {
        // 1 or Nで試合
        ll ans = min( B-1, N-A );
        // 1で折り返す場合
        chmin(ans, (B+A-1)/2);
        // Nで折り返す場合
        chmin(ans, (N+(N-B)+1-A)/2);
        cout << ans << endl;
    }
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll N;
  scanf("%lld", &N);

  if (N == 1) {
    cout << "Hello World" << endl;
  } else {
    ll A, B;
    scanf("%lld %lld", &A, &B);

    cout << (A + B) << endl;
  }
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define int  long long
using namespace std;
int32_t main()
{
    int n;
	cin>>n;
	int a[n+1],c=0;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
		if(a[i]&1&&i&1)
		++c;
	}
	cout<<c;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int64 comb(int64 n, int64 r){
    double retval = 1;
    r = min(r, n-r);
    REP(i,r){
        retval *= (n - i);
        retval /= (i + 1);
    }
    return (int64)(retval + 1e-2);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,a,b;
    cin >> n >> a >> b;
    map<int32,int32> v;
    REP(i,n){
        int32 vi;
        cin >> vi;
        v[vi]++;
    }
    if(v.rbegin()->second >= a){
        cout << fixed << setprecision(6) << (double)(v.rbegin()->first) << endl;
        int64 ans2 = 0;
        FOR(i,a,min(v.rbegin()->second, b) + 1){
            ans2 += comb(v.rbegin()->second, i);
            // cout << i << " " << comb(v.rbegin()->second, i) << " " << ans2 << endl;
        }
        cout << ans2 << endl;
        return 0;
    }
    double ans = 0;
    int32 cnt = a;
    for(auto i = v.rbegin(); i != v.rend(); i++){
        if(i->second < cnt){
            ans += i->first * i->second;
            cnt -= i->second;
        }else{
            ans += i->first * cnt;
            ans /= a;
            cout << fixed << setprecision(6) << ans << endl;
            cout << comb(i->second, cnt) << endl;
            return 0;
        }
    }
    return 0;
}

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long

bool allsame(const string& str) {
    char c = str[0];
    return str == string(sz(str), c);
}

string s;
int minChanges()
{
    int ret = 987654321;
    for(char c : s)
    {
        string tmp = s; int cnt = 0;
        while(allsame(tmp) == false)
        {
            for(int i = 0; i < sz(tmp) - 1; ++i)
                if(tmp[i + 1] == c) tmp[i] = c;
            tmp.pop_back();
            ++cnt;
        }
        ret = min(ret, cnt);
    }
    return ret;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
    cin >> s;

    cout << minChanges() << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void sort_num(int a, int b, int c){
    int num[3] = {a, b, c};
    int tmp = 0;
    int i = 0;
    for(i = 0; i < 2; i++){
        if (num[i] > num[i + 1]){
            tmp = num[i];
            num[i] = num[i + 1];
            num[i + 1] = tmp;
        } 
    }
    if (num[0] > num[1]){
        tmp = num[0];
        num[0] = num[1];
        num[1] = tmp;
    }     


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

int main(void){
    int a = 0;
    int b = 0;
    int c = 0;
    scanf("%d %d %d", &a, &b, &c);
    sort_num(a, b, c);

    return 0;
}



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

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

       if(n==0) break;

       int len[40];
       for (int i = 0; i < n; i++) {
           string w;
           cin>>w;

           len[i]=w.size();
       }
       for (int i = 0; i < n; i++) {
           bool flg=false;
           int sta=0;
           int sum=0;

           for (int j = i; j < n; j++) {
               sum+=len[j];
               if(sum==5||sum==12||sum==17||sum==24||sum==31){
                   sta++;
               }
               if (sta==5) {
                   flg=true;
                   break;
               } else if(sum>=31){
                   break;
               }
           }

           if(flg){
               cout<<i+1<<endl;
               break;
           }
       }
    }
    return 0;
}



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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

bool isperi(string S) {
  string ts = S; reverse(all(ts));
  return S == ts;
}

int main() {
  string S; cin >> S;
  int l = S.length();
  string result = isperi(S.substr(0,(l-1)/2)) && isperi(S.substr((l+1)/2,(l-1)/2)) && isperi(S) ? "Yes" : "No";
  cout << result << endl;
  return 0;
}

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

int main()
{
    int n;
    while(cin>>n,n){
        int graph[n+1][n+1];
        for(int i=0;i<n+1;i++){
            for(int j=0;j<n+1;j++){
                graph[i][j]=0;
            }
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                cin>>graph[i][j];
                graph[i][n] += graph[i][j];
            }
            for(int j=0;j<n+1;j++){
                graph[n][j] += graph[i][j];
            }
        }
        for(int i=0;i<n+1;i++){
            for(int j=0;j<n+1;j++){
                printf("%5d",graph[i][j]);
            }
            cout<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1192
#include <iostream>

using namespace std;

int main(void) {
    int N;
    cin >> N;

    for(int i=1; i<10; i++) {
        for(int j=0; j<10; j++) {
            if(i*j == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)

int main() {
    // your code goes here
    ll x,y,a,b,c,p[100005],q[100005],r[100005],ans=0;
    ll sumv[100005]={0},sumc[100005],mx=0;
    vector<ll> v;
    cin >> x >> y >> a >> b >> c;
    rep(i,0,a-1) cin >> p[i];
    rep(i,0,b-1) cin >> q[i];
    rep(i,0,c-1) cin >> r[i];
    sort(p,p+a);
    sort(q,q+b);
    sort(r,r+c);
    rep(i,a-x,a-1) v.push_back(p[i]);
    rep(i,b-y,b-1) v.push_back(q[i]);
    sort(v.begin(),v.end());
    reps(i,v){
        if(i==0) sumv[i]=v[i];
        else sumv[i]=sumv[i-1]+v[i];
    }
    ans=sumv[x+y-1];
    repr(i,c-1,max(c-x-y,0ll)){
        if(i==c-1) sumc[c-1-i]=r[i];
        else sumc[c-1-i]=sumc[c-2-i]+r[i];
    }
    rep(i,0,min(x+y,c)-1) mx=max(mx,sumc[i]-sumv[i]);
    cout << ans+mx << endl;
    return 0;
}



Measured memory_bytes: 6132
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
#define ll long long
#define pi pair<ll,ll>
ll a[800001],  b[500009], lastcall[800000], value[500000];
string s;
vector<ll>v;
int main()
{
    IO;
    ll j=1, n, m, k, kk=1, m1=0, a1=8, grtr=0, a2=20, l, t, ds,r,mx=0, cnt=0, mn=INT_MAX, h=0, mod=1e9+7, i; char ch;
    cin>>n;
    while(n){
        l = n%26; l--; if(l<0) l = 25;
        ch = 'a'+ l; s+=ch; if(l==25) n-=26;
        n/=26;
    }
    reverse(s.begin(), s.end());
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

pair<int, int> f(int k, int x, int y) {
	int d = abs(x) + abs(y);
	assert(d <= 2 * k);
	assert(d % 2 == 0);
	
	bool X = (x < 0); if(X) { x *= -1; }
	bool Y = (y < 0); if(Y) { y *= -1; }
	bool Z = (x < y); if(Z) { swap(x, y); }
	
	int v = (x - y) / 2;
	int ax = v;
	int ay = k - v;
	
	if(Z) { swap(ax, ay); }
	if(Y) { ay *= -1; }
	if(X) { ax *= -1; }
	
	return { ax, ay };
}

int k, x, y;

int main() {
	cin >> k >> x >> y;
	
	if(k % 2 == 0 && (abs(x) + abs(y)) % 2 != 0) {
		cout << -1 << endl;
		return 0;
	}
	
	vector<pair<int, int>> ans;	
	while(true) {
		ans.EB(x, y);
		int d = abs(x) + abs(y);
		if(d == k) { break; }
		
		if(
			(k % 2 == 0 && d <= 2 * k) ||
			(k % 2 != 0 && (
				((d <= k) || (d <= 2 * k && d % 2 == 0))
			))
		) {
			if(d <= k && d % 2 != 0) { x += k; continue; }
			auto p = f(k, x, y);
			x = p.FI;
			y = p.SE;
		} else {
			bool A = (x >= +y);
			bool B = (x >= -y);
			
			if(  A &&   B) { x -= k; }
			if(! A && ! B) { x += k; }
			if(! A &&   B) { y -= k; }
			if(  A && ! B) { y += k; }
		}
	}
	
	reverse(ALL(ans));
	cout << SI(ans) << "\n";
	RF(e, ans) { cout << e.FI << " " << e.SE << "\n"; }
	
	return 0;
}


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

using namespace std;

int main (void) {
    int N;
    cin >> N;

    int s = 0;
    int d = N;
    while ( d > 0 ) {
        s += d % 10;
        d /= 10;
    }

    if ( N % s == 0 )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3620
n=gets.chomp.to_i
a=gets.chomp.split(" ").map { |e| e.to_i  }.sort.reverse

arice = 0
bob = 0

for i in 0..n-1 do
  if i%2 == 0
    arice += a[i]
  else
    bob += a[i]
  end
end

puts arice - bob


Measured memory_bytes: 1788
S = input()

target = list('ACGT')

count_list = [0] * len(S)
for i in range(len(S)):
    if S[i] in target:
        count_list[i] = 1

max_length = 0
for start in range(len(S)):
    if count_list[start] == 0:
        continue
    for end in range(start, len(S)):
        if count_list[end] == 0:
            break

        max_length = max(sum(count_list[start : end+1]), max_length)

print(max_length)

Measured memory_bytes: 8976
import sys
import numpy as np

def retmin(a, b):
    if a > b:
        return b
    return a# N 足場の数
n = int(input())

# h1, h2, ... , hn 各足場の高さ
h = list(map(int, input().split()))

dp = np.full(n+1, 9999999999999)
dp[0] = 0
dp[1] = abs(h[1] - h[0])

# 2番目から
for i in range(2, n):
    # １つ手前からくる
    dp[i] = retmin(dp[i], abs(h[i-1]-h[i])+dp[i-1])
    # ２つ手前からくる
    dp[i] = retmin(dp[i], abs(h[i-2]-h[i])+dp[i-2])
print(int(dp[n-1]))



Measured memory_bytes: 22716
#!/usr/bin/env python


def read():
    row, col = map(int, raw_input().split())
    b = []
    for i in range(row):
        b.append(raw_input())
    return b


def work(b):
    print "#" * (len(b[0]) + 2)
    for line in b:
            print "#" + line + "#"
    print "#" * (len(b[0]) + 2)
   

if __name__ == "__main__":
    work(read())


Measured memory_bytes: 2568
#include "bits/stdc++.h"
using namespace std;
const int maxN=1e5+10;
const long long MOD=1e9+7;
int n;
long long k;
long long ans[maxN];
long long res=0LL;
long long fast_mi(long long a,int p)
{
	if(p==0)
	{
		return 1LL;
	}
	long long tmp=fast_mi(a,p>>1);
	tmp=tmp*tmp%MOD;
	if(p&1)
	{
		tmp=tmp*a%MOD;
	}
	return tmp;
}
int main()
{
	cin>>n>>k;
	for(long long x=k;x>=1LL;x--)
	{
		long long multi_num=k/x;
		long long num=fast_mi(multi_num,n);
		for(int i=x+x;i<=k;i+=x)
		{
			num=(num-ans[i]+MOD)%MOD;
		}
		ans[x]=num;
		res=(res+num*x)%MOD;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 4348
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

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

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int M = (int)3e7;
const int K = 10000;
const int N = (int)1e5 + 228;
const ll MX = (ll)1e10 + 228;

using namespace std;

bool np[M];
int n;
ll s[N];

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~resheto
	np[1] = true;
	vector < int > a, b;
	for (int i = 2; i < M; i++)
	{
		if (!np[i])
		{               	
			if (i <= K)
				a.pb(i);
			else
				b.pb(i);			
			if (1ll * i * i < M)
			{
				for (int j = i * i; j < M; j += i)
					np[j] = true;		
			}
		}
	}
	//~read
	scanf("%d", &n);
	forn(i, n)
		scanf("%lld", &s[i]);
	//~solve
	map < ll, int > cnt;
	set < ll > st;
	forn(i, n)
	{
		ll x = s[i];
		vector < pair < int, int > > p;
		for (auto y : a)
		{
			while(x % (1ll * y * y * y) == 0)	
				x /= 1ll * y * y * y;
		}
		st.insert(x);
		cnt[x]++;
	}
	int ans = 0;
	map < ll, bool > was;
	for (auto x : st)
	{
		if (was.count(x))
			continue;
		ll y = 1;
		ll z = x;
		for (auto i : a)
		{
			if (x % i == 0)
			{
				y *= i;
				z /= i;
				if (x / i % i != 0)
					y *= i;							 
				else
					z /= i;
			}
		}	
		if (z != 1)
		{
			ll k = sqrt(z);
			while(k * k < z)
				k++;
			while(k * k > z)
				k--;
			if (k * k == z)
			{
				y *= k;
			}
			else if (z < M && !np[z])
			{
				y *= z;
				y *= z;
			}
			else
				y = -1;
		}
		if (x == 1)
		{
			ans += min(1, cnt[1]);
			continue;
		}
		was[x] = was[y] = true;
		int res = max(cnt[x], cnt[y]);
		ans += res;
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 64244
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <set>

using namespace std;

template<typename T>inline T get(){T x;cin>>x;return x;}

int main()
{
    int n = get<int>();
    int ans = INT_MAX;
    for (int i = 0; i < n; i++) {
        int a = get<int>();
        int c;
        for (c = 0; a % 2 == 0; c++)
            a /= 2;
        ans = min(c, ans);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    set<string> ng;
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
        if (!ng.insert(S[i]).second) { printf("No\n"); return 0; }
    }
    char now = S[0][(int)S[0].length()-1];
    for (int i = 1; i < N; i++) {
        if (now != S[i][0]) {
            printf("No\n");
            return 0;
        }
        now = S[i][(int)S[i].length()-1];
    }
    
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

sum_beat = 0

for i in range(n):
    if a_list[i] + a_list[i + 1] <= b_list[i]:
        sum_beat += a_list[i] + a_list[i + 1]
        a_list[i + 1] = 0
    else:
        sum_beat += b_list[i]
        a_list[i + 1] = a_list[i + 1] - max(b_list[i] - a_list[i], 0)

print(sum_beat)

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

int main() {
  int N, cnt = 0;
  long long D;
  cin >> N >> D;
  // vector<long long> X(N), Y(N);
  long long X, Y;

  rep(i, N) {
    // cin >> X[i] >> Y[i];
    // if(sqrt((X[i]*X[i])+(Y[i]*Y[i])) <= D) cnt++;
    cin >> X >> Y;
    if (sqrt((X * X + Y * Y)) <= D) cnt++;
  }
  cout << cnt << '\n';
}

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

int main(){
	int h,w,n,current=0;
	cin >>h >>w >>n ;	
	int a;
	vector<vector<int>>c(h,vector<int>(w,0));

	for(int i=0;i<n;i++){
		cin >>a ;
		for(int j=0;j<a;j++){
			if((current/w)%2==0) c[current/w][current%w]=i+1;
			else c[current/w][w-(current%w)-1]=i+1;
			current++;
		}
	}

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(j==w-1) cout<<c[i][j]<<endl;
			else cout<<c[i][j]<<" ";
		}
	}


	return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	boolean[] prime = new boolean[246913];
	
	void run() {
		prime();
		while (true) {
			int n = sc.nextInt();
			if( n == 0) break;
			System.out.println(countPrime(n));
		}
	}
	
	void prime() {
		for(int i=2;i<=246912;i++) {
			if( !prime[i] ) {
				for(int j=i*2;j<246913;j+=i) 
					prime[j] = true;
			}
		}
	}
	
	int countPrime(int n) {
		int cnt = 0;
		for(int i=n+1;i<=2*n;i++) 
			if( !prime[i] ) cnt++;
		return cnt;
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
using Graph = vector<vector<int>>;

void init(vector<int> &dist) { fill(dist.begin(), dist.end(), -1); }
int main() {
  int n, x, y;
  cin >> n >> x >> y;

  Graph G(n);

  for (int i = 0; i < n - 1; i++) {
    G[i].push_back(i + 1);
    G[i + 1].push_back(i);
  }

  x--;
  y--;
  G[x].push_back(y);
  G[y].push_back(x);

  vector<int> dist(n, -1);  //ある点からdist[i] までの距離

  queue<int> que;

  vector<int> ans(n, 0);

  for (int i = 0; i < n; i++) {
    init(dist);
    que.push(i);
    dist[i] = 0;
    while (!que.empty()) {
      int temp = que.front();
      que.pop();
      for (int nv : G[temp]) {
        if (dist[nv] == -1) {
          que.push(nv);
          dist[nv] = dist[temp] + 1;
        }
      }
    }
    for (int j = 0; j < dist.size(); j++) {
      ans[dist[j]]++;
    }
  }

  for (int i = 1; i < ans.size(); i++) {
    cout << ans[i] / 2 << endl;
  }
}

Measured memory_bytes: 384
a,b = gets.chomp.split(" ").map(&:to_i)
s = Array.new(100)
50.times do |i|
  s[i] = "#"*100
  s[i+50] = "."*100
end
if a != 1
  a -= 1
  for i in 0..a-1
    s[(i/50)*2][(i%50)*2] = "."
  end
end
if b != 1
  b -= 1
  for i in 0..b-1
    s[(i/50)*2+51][(i%50)*2] = "#"
  end
end
puts "100 100"
s.each do |str|
  puts str
end

Measured memory_bytes: 1788
#include<stdio.h>
int array[1000];
int number;


void hyouzi(int i){

  printf("node %d: key = %d, ",i,array[i]);
  if(parent(i)>=1){printf("parent key = %d, ",array[parent(i)]);}
  if(left(i)<=number){printf("left key = %d, ",array[left(i)]);}
  if(right(i)<=number){printf("right key = %d, ",array[right(i)]);}

      printf("\n");
}




int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}


int main(){

  
  scanf("%d",&number);


  
  int i;
  for(i=1;i<=number;i++){
    scanf("%d",&array[i]);
    }


  for(i=1;i<=number;i++){

    hyouzi(i);
  }


  

  return 0;
}



Measured memory_bytes: 2116
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ub              upper_bound
#define lb              lower_bound
#define isrt            insert
#define clr             clear
#define rsz             resize
#define ff              first
#define ss              second
#define lli             long long int
#define pb              push_back
#define pf              push_front
#define mkp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<int>
#define mii             map<lli,lli>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define INF             1e9
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define endl            "\n"


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

lli maxm(lli a, lli b)
{
    return (a >= b ? a : b);
}


lli minm(lli a, lli b)
{
    return (a <= b ? a : b);
}

lli power(lli x, lli y, lli p)
{
    lli res = 1;

    x = x % p;
    if (x == 0)
        return 0;

    while (y > 0)
    {

        if (y & 1)
            res = (res * x) % p;


        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

lli nCrmodp(lli n, lli r, lli p)
{
    if (r == 0)
        return 1;
    if (r == 1)
        return n;


    lli pro = 1, k = n;
    while (k > r)
    {
        pro *= k;
        pro %= p;
        --k;
    }

    k = 2;
    while (k <= (n - r))
    {
        pro *= power(k, (p - 2), p);
        pro %= p;
        ++k;
    }

    return pro;
}


string num_str(lli n, lli k)
{
    string str = "";
    lli x = n;
    while (x != 0)
    {
        string s = to_string(x % k);
        str = s + str;
        x /= k;
    }

    return str;
}


lli first_big(lli n, lli k, lli arr[])
{
    lli l = 0;
    lli r = n - 1;

    lli leftGreater = n;

    while (l <= r) {
        lli m = l + (r - l) / 2;

        if (arr[m] > k) {
            leftGreater = m;
            r = m - 1;
        }

        else
            l = m + 1;
    }

    return leftGreater;
}

void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main()
{
    c_p_c();

    lli x;

    cin >> x;

    if (x >= 30)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

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

int k, x;

int main()
{
    scanf("%d %d", &k, &x);
    for (int i = x - k + 1; i <= x + k - 1; i++)
        printf("%d%c", i, i + 1 <= x + k - 1? ' ': '\n');
    return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n, m, k; cin >> n >> m >> k;
    vector<ll> a(n);
    vector<ll> a_sum(n + 1, 0);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
        a_sum[i + 1] = a_sum[i] + a[i];
    }

    vector<ll> b(m);
    vector<ll> b_sum(m + 1, 0);
    for (ll i = 0; i < m; ++i) {
        cin >> b[i];
        b_sum[i + 1] = b_sum[i] + b[i];
    }

    ll ans = 0;
    for (ll i = 0; i <= n; ++i) {
        ll cnt = i;
        ll t = k - a_sum[i];
        if (t < 0) break;

        auto itr = upper_bound(b_sum.begin(), b_sum.end(), t);
        cnt += (itr - b_sum.begin()) - 1;
        ans = max(ans, cnt);
    }

    cout << ans << endl;
}

Measured memory_bytes: 9560
N, M = map(int, input().split())
A = list(map(int, input().split()))
cnt = 0
sum_A = sum(A)
A.sort(reverse=True)
for a in A:
    if a >= sum_A / (4 * M):
        cnt += 1
    else:
        break
if cnt >= M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9100
n = int(input())
a, b = map(int, input().split())
ans = [0] * 3
for p in map(int, input().split()):
    if p <= a:
        ans[0] += 1
    elif b + 1 <= p:
        ans[2] += 1
    else:
        ans[1] += 1
print(min(ans))

Measured memory_bytes: 3060
n,m=map(int,input().split())
x=sorted(list(map(int,input().split())))
l=[0]*(m-1)
if n>=m:
    ans=0
else:
    for i in range(m-1):
        l[i]=x[i+1]-x[i]

    l=sorted(l,reverse=True)
    ans=sum(l)-sum(l[:n-1])
print(ans)

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }


int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s;
  while (cin >> s) {
    cout << 700 + count(s.begin(), s.end(), 'o') * 100 << endl;
  }
  
  return 0;
}


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

const int N = 100000 + 5;

int n;
int m;
bool vis[N];
int memo[N];
vector<int> G[N];

int DP(int u){
	if(vis[u]) return memo[u];
	int ans = 0;
	for(int v : G[u]){
		ans = max(ans, 1 + DP(v));
	}
	vis[u] = true;
	return memo[u] = ans;
}

int main(){
	scanf("%d %d", &n, &m);
	for(int i = 0; i < m; i++){
		int u, v;
		scanf("%d %d", &u, &v);
		G[u].emplace_back(v);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		ans = max(ans, DP(i));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 11716
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;


map<P, ll> mp;
int ans[100010];  // color of each node
vector<ll> g[100010];
bool seen[100010];

int main(){
    int n;
    cin >> n;
    rep(i, n - 1){
        ll u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        mp[make_pair(u, v)] = w;
        mp[make_pair(v, u)] = w;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    queue<P> que; // node, cost from 0
    seen[0] = true;
    ans[0] = 0;
    que.push(make_pair(0, 0));
    while(!que.empty()){
        P p = que.front(); que.pop();
        ll v = p.first;
        ll cost = p.second;
        if (cost % 2 != 0) ans[v] = 1;
        for (auto nv : g[v]){
            if (seen[nv]) continue;
            seen[nv] = true;
            ll ncost = cost + mp[make_pair(v,nv)];
            // cout << nv << " " << ncost << endl;
            que.push(make_pair(nv, ncost));
        }
    }
    
    rep(i, n) cout << ans[i] << endl;


    return 0;
}

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

using namespace std;

int main() {

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

	bool gflag = true;
	int counter = 0;
	while (gflag) {
		gflag = 0;
		for (int j = n - 1; j >= 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				gflag = 1;
				counter++;
			}
		}
	}
	for (int i = 0; i < n-1; i++) {
		cout << a[i] << " ";
	}
	cout << a[n - 1] << endl;
	cout << counter << endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
 
#define mod 1000000007
#define rep(i,n) fp(i,0,n)  
#define fp(i,a,b) for(int i=(a);i<(b);++i)
#define fn(i,a,b) for(int i=(a);i>(b);i--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define ff first
#define ss second
typedef pair<int, int> ii; 
typedef vector<ii> vii;
typedef vector<int> vi;
typedef unsigned long long int ll;
#define rs(t) string t;cin>>t
#define ri(t) int t;cin>>t
#define rll(t) long long int t;cin>>t
#define mk make_pair
#define pb push_back
#define po pop_back
 
 
 
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll ans = 0;
  ll m,d;
  cin >> m >> d;
  fp(i,2,10){
    fp(j,2,10){
      if(i*10+j>d)
        break;
      if(i*j<=m)
        ans++;
    }
  }
  
  cout << ans << endl;
  
   
  
}

Measured memory_bytes: 256
import math
from collections import deque
n,m,q=[int(_) for _ in input().split()]
lista=[[int(i) for i in input().split()] for j in range(q)]
v=deque()  #0,0,0,0,0....,0
def make(a,b,c): #a=list b=maxlen c=max
    global v
    if len(a)==b:
        v.append(a)
    else:
        for i in range(a[-1],c+1):
            make(a+deque([i]),b,c)
for t in range(1,m+1):
    make(deque([t]),n,m)
max=0
for j in v:
    point=0
    for l in lista:
        if j[l[1]-1]-j[l[0]-1]==l[2]:
            point+=l[3]
    if max<point:
        max=point
print(max)

Measured memory_bytes: 67752
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B_017_44
{
    internal class Program
    {
        private static void Main(string[] args)
        {

            new Logic_B().Start();//OK

        }

        public class Logic_B
        {
            public void Start()
            {
                var W = Console.ReadLine();
                var isGood = true;
                for (int i = 0; i < W.Length; i++)
                {
                    var C = W[i];

                    var count = 0;
                    for (int j = 0; j < W.Length; j++)
                    {
                        if (W[i] == W[j])
                        {
                            count++;
                        }
                    }

                    if (count % 2 != 0)
                    {
                        isGood = false;
                        break;
                    }
                }
                Console.WriteLine(isGood ? "Yes" : "No");
            }
        }
}
}

Measured memory_bytes: 11092
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int x,y,a,b,c; cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];
    vector<pair<int,int>> v;
    rep(i,a) v.pb(mp(p[i], 0));
    rep(i,b) v.pb(mp(q[i], 1));
    rep(i,c) v.pb(mp(r[i], 2));

    sort(all(v));
    reverse(all(v));
    int yet = 0;
    int rc = 0, bc=0;
    ll ans = 0;
    rep(i, v.size()){
        int cl = v[i].second;
        int num = v[i].first;

        if(rc==x && cl==0) continue;
        if(bc==y && cl==1) continue;

        if(rc < x && cl == 0){
            ans = num + ans;
            rc++;
        }

        if(bc < y && cl == 1){
            ans = num + ans;
            bc++;
        }

        if(cl==2){
            yet++;
            ans = num + ans;
        }

        if(yet+bc+rc >= x+y) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7664
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

int n,p[1005],x[1005],dp[1005][2],k=1,kdp[1005][5005],s,y[1005][2];

pi h[1005];

vector <int> g[1005];

int DoKPS(int w){
    for(int i=0;i<=s;i++){
        for(int j=0;j<=w;j++){
            kdp[i][j]=INF;
        }
    }
    kdp[0][0]=0;
    int ans=0;
    for(int i=1;i<=s;i++){
        for(int j=0;j<=w;j++){
            kdp[i][j]=kdp[i-1][j];
            if(j>=h[i].x) kdp[i][j]=min(kdp[i][j],kdp[i-1][j-h[i].x]+h[i].y);
            ans=min(ans,kdp[i][j]);
        }
    }
    return ans;
}

void DFS(int nod){
    for(int i : g[nod]) DFS(i);
    if(!k) return;
    int t=0,ty=0; s=0;
    for(int i : g[nod]){
        if(!dp[i][1]){
            t+=x[i];
            ty+=y[i][0];
        }
        else if(!dp[i][0]){
            t+=y[i][1];
            ty+=x[i];
        }
        else if(y[i][1]<=x[i]){
            t+=y[i][1];
            ty+=x[i];
            s++;
            h[s]={x[i]-y[i][1],y[i][0]-x[i]};
        }
        else{
            t+=x[i];
            ty+=y[i][1];
            s++;
            h[s]={y[i][1]-x[i],x[i]-y[i][0]};
        }
    }
    if(t<=x[nod]){
        dp[nod][0]=1;
        t=DoKPS(x[nod]-t);
        y[nod][0]=ty+t;
    }
    t=0; ty=0; s=0;
    for(int i : g[nod]){
        if(!dp[i][0]){
            t+=x[i];
            ty+=y[i][1];
        }
        else if(!dp[i][1]){
            t+=y[i][0];
            ty+=x[i];
        }
        else if(y[i][0]<=x[i]){
            t+=y[i][0];
            ty+=x[i];
            s++;
            h[s]={x[i]-y[i][0],y[i][1]-x[i]};
        }
        else{
            t+=x[i];
            ty+=y[i][0];
            s++;
            h[s]={y[i][0]-x[i],x[i]-y[i][1]};
        }
    }
    if(t<=x[nod]){
        dp[nod][1]=1;
        t=DoKPS(x[nod]-t);
        y[nod][1]=ty+t;
    }
    if(!dp[nod][0] && !dp[nod][1]) k=0;
    //cout << nod << ' ' << dp[nod][0] << ' ' << y[nod][0] << ' ' << dp[nod][1] << ' ' << y[nod][1] << '\n';
}

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    for(int i=2;i<=n;i++){
        cin >> p[i];
        g[p[i]].pb(i);
    }
    for(int i=1;i<=n;i++) cin >> x[i];
    DFS(1);
    if((dp[1][0] || dp[1][1]) && k) cout << "POSSIBLE";
    else cout << "IMPOSSIBLE";
}


Measured memory_bytes: 17408
#include <stdio.h>

int main(){
    int a, b, x=0;
    scanf("%d%d", &a, &b);
    x=(a+b)/2;
    if((a+b)%2==0){
         printf("%d", x);
    }else{
        printf("IMPOSSIBLE");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main(){
	int a, b;
	cin >> a >> b;
	if (a+b>=10) {
		cout << "error" << endl;
	}
	else {
		cout << a + b << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
/*#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif
*/

using namespace std;
#define m 1000000001
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repb(i,a,b) for(int i=a;i>=b;--i)
#define repv(arr)  for(auto it=arr[i].begin();it!=arr[i].end();++it)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define mp make_pair 
#define LCM(a,b) boost::math::lcm(a,b)
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    vi f(10001,0);
    for(int x=1;x<101;++x){
        for(int y=1;y<101;++y){
            for(int z=1;z<101;++z){
                int pro=x*x+y*y+z*z+x*y+y*z+z*x;
                if(pro<=10000){
                    ++f[pro];
                }
            }
        }
    }
    rep(i,1,n+1){
        cout<<f[i]<<endl;
    }
    
    
}


Measured memory_bytes: 3652
#include<stdio.h>

struct dice
{
    int n[6] ; //number
};
struct dice dice1 ;

void v() //vertical
{
    int mem = 0 ;
    mem = dice1.n[0] ;
    dice1.n[0] = dice1.n[4] ;
    dice1.n[4] = dice1.n[5] ;
    dice1.n[5] = dice1.n[1] ;
    dice1.n[1] = mem ;
}

void s() //side
{
    int mem = 0 ;
    mem = dice1.n[1] ;
    dice1.n[1] = dice1.n[2] ;
    dice1.n[2] = dice1.n[4] ;
    dice1.n[4] = dice1.n[3] ;
    dice1.n[3] = mem ;
}

int main()
{
    int i = 0 ,j = 0 ;
    int t = 0 ,f = 0 ; //top ,front
    int q = 0 ;
    int cmp = 0 ;

    for (i = 0 ;i < 6 ;i++ )
    {
        scanf("%d" ,&dice1.n[i] ) ;
    }

    scanf("%d" ,&q ) ;

    for (i = 0 ;i < q ;i++ )
    {
        scanf("%d %d" ,&t ,&f ) ;


        j = 0 ;
        while (dice1.n[0] != t)
        {
            v() ;
            j++ ;
            if (j == 7) s() ;
        }
        j = 0 ;
        while (dice1.n[1] != f)
        {
            s() ;
            j++ ;
            if (j == 7) break ;
        }

        if (dice1.n[0] == t && dice1.n[1] == f)
        {
            printf("%d\n" ,dice1.n[2] ) ;
        }
    }

    return 0 ;
}

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

using namespace std;

using ll = long long;

int calc(int n) {
    int ok = 0, ng = 1000;
    while (ng - ok > 1) {
        int mid = (ok + ng) / 2;
        (mid * (mid - 1) <= 2 * n ? ok : ng) = mid; 
    }
    return (ok * (ok - 1) == 2 * n ? ok : -1);
}

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

    int k = calc(n);
    if (k == -1) {
        cout << "No\n";
    } else {
        int cnt = 1;
        vector< vector<int> > ans(k);
        for (int i = 0; i < k; ++i) {
            for (int j = 0; j < i; ++j) {
                ans[i].push_back(cnt);
                ans[j].push_back(cnt);
                ++cnt;
            }
        }
        
        cout << "Yes\n";
        cout << k << "\n";
        for (int i = 0; i < k; ++i) {
            cout << ans[i].size();
            for (int j : ans[i]) {
                cout << " " << j;
            }
            cout << "\n";
        }
    }
    return 0;
}

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

using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> ans(n);
    rep(i,n){
        if(i%2 == 0){
            ans[0] += a[i];
        }else{
            ans[0] -= a[i];
        }
    }
    rep(i,n){
        if(i == 0) continue;
        ans[i] = 2*(a[i-1] - ans[i-1]/2);
    }
    rep(i,n) printf("%d%c", ans[i], i == n-1 ? '\n' : ' ');
}

Measured memory_bytes: 2816
# import numpy as np
# import scipy as sp

n = int(input())
info = []
for i in range(n):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        info.append([i, x-1, y])

ans = 0
for i in range(2 ** n):
    bit = [0] * n
    for j in range(n):
        if ((i >> j) & 1):
            bit[j] = 1

    flag = True
    # print(bit)
    for idx, j in enumerate(bit):
        if not flag:
            break
        if j == 1:
            for k in [x for x in info if x[0] == idx]:
                # print(' ', k)
                if bit[k[1]] != k[2]:
                    flag = False
    if flag:
        ans = max(ans, sum(bit))
    # print(ans)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int x,n;
    cin >> x >> n;
    vector<int> vec(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> vec[i];
    }
    sort(vec.begin(), vec.end());

    int ans = 0;
    for(int i = 0; i < 100; ++i)
    {
        if(find(vec.begin(),vec.end(),x-i) == vec.end())
        {
            ans = x-i;
            break;
        }
        if(find(vec.begin(),vec.end(),x+i) == vec.end())
        {
            ans = x+i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
  string s;
  cin>>s;
  ll l = s.length();
  ll sum = 0;
  for(ll i=0;i<l;i++){
    
    sum = sum + s[i] - '0';
  }
  if(sum%9==0)
     cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
 
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li k;
    string s;
    cin >> k >> s;
    if (k >= sz(s)) {
        cout << s << endl;
    } else {
        cout << s.substr(0, k) << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3604
#include <iostream>                                                  
#include <vector>                                                    
using namespace std;                                                 
                                                                     
int main() {                                                         
  vector<int> Case;                                                  
  while (true) {                                                     
    int x;                                                           
    cin >> x;                                                        
    if (x==0) {                                                      
      break;                                                         
    }                                                                
    Case.push_back(x);                                               
  }                                                                  
  for (int i=0; i<Case.size(); i++) {                                
    cout << "Case" << " " << i+1 << ":" << " " << Case[i] << endl;   
  }                                                                  
  return 0;                                                          
}                                                                    
                                                                     
                                                                     
                                                                     
                                                                     
                                                                     
                        

Measured memory_bytes: 3256