akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

#define POWER_MAX 20

int main(void) {
    int num, llimit;
    get_int2(&num, &llimit);

    static int power2[POWER_MAX];
    power2[0] = 1;
    int i = 0;
    for(i = 1; i < POWER_MAX; i++) {
        power2[i] = power2[i-1] * 2;
    }

    static int map[POWER_MAX];
    for(i = 1; i <= num; i++) {
        int point = i;
        int cnt = 0;
        while(point < llimit) {
            cnt++;
            point *= 2;
        }
        map[cnt]++;
#ifdef DEBUG
        printf("%d -> %d\n", i, cnt);
#endif
    }

    double ans = 0;
    for(i = 0; i < POWER_MAX; i++) {
        ans += 1.0 / num * (1.0/power2[i]) * map[i];
    }
    printf("%.10lf\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int n,m,map[16][16],x,y,z,mmh[1<<15][15],o[1<<15][15];
inline int work(int a,int b){
	int mmh=0;
	for (int i=0;i<n;i++)
	if ((a>>i)&1) mmh+=o[b][i];
	return mmh;
}
int main(){
	scanf("%d%d",&n,&m);
	memset(map,0,sizeof(map));
	memset(mmh,63,sizeof(mmh));
	while(m--){
		scanf("%d%d%d",&x,&y,&z);x--;y--;
		map[x][y]=map[y][x]=z;
	}
	for (int i=0;i<(1<<n);i++)
	for (int j=0;j<n;j++){
		o[i][j]=0;
		for (int k=0;k<n;k++)
		if ((i>>k)&1) o[i][j]+=map[j][k];
	}
	mmh[1][0]=0;
	for (int i=0;i<(1<<n);i++)
	for (int j=0;j<n;j++)
	if ((i>>j)&1){
		for (int k=0;k<n;k++)
		if (map[j][k])
		if (!((i>>k)&1)) mmh[i|(1<<k)][k]=min(mmh[i|(1<<k)][k],mmh[i][j]+work(i,1<<k)-map[j][k]);
		
		int u=(1<<n)-1-i;
		for (int p=u;p;p=(p-1)&u) mmh[i|p][j]=min(mmh[i|p][j],mmh[i][j]+work(i^(1<<j),p));
	}
	printf("%d\n",mmh[(1<<n)-1][n-1]);
}

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

using namespace std;
typedef long long ll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

// http://baitop.hatenadiary.jp/entry/2018/07/09/193455
// https://linuxnosusume.blogspot.com/2018/03/arc092abc091-d-two-sequences.html

int main() {
 int n;
 long long ans = 0;
 cin >> n;
 
 vector<int> a(n),b(n);
 vector<int> ma(n),mb(n);
 
 for (int i = 0;i < n;i++){
  cin >> a[i];
 } 
 for (int i = 0;i < n;i++){
  cin >> b[i];
 }
 
 long long cnt = 0;
 
 for (int k = 0;k <= 28;k++){
  long long t = pow(2,k);
  for (int i = 0;i < n;i++){
   ma[i] = a[i] % (2*t);
   mb[i] = b[i] % (2*t);
  }
  sort(mb.begin(),mb.end());
  for (int i = 0;i < n;i++){
   cnt += lower_bound(mb.begin(),mb.end(),2*t-ma[i]) - lower_bound(mb.begin(),mb.end(),t-ma[i]) +
       mb.end() - lower_bound(mb.begin(),mb.end(),3*t-ma[i]);
  }
  if (cnt%2 == 1) ans += t;
  cnt = 0;
 }
 
 cout << ans << endl;
 
 return 0;
 
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define INF 10000000001
#define DIM 200001
#define mod 1000000007
#define PI 3.1415926535897932384626433
#define se second
#define fi first
#define pb push_back
#define T true
#define F false
#define endl "\n"
typedef char ch;
typedef bool boll;
typedef string st;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef set < string > sst;
typedef set < long long > sl;
typedef queue < long long > que;
typedef vector < long long > vec;
typedef map < long long, long long > mll;
typedef pair < long long, long long > pll;
typedef vector < pair < long long, long long > > vpl;
typedef pair < long long, unsigned long long > pul;
ll t,n,z,x,c,s;
int main()
{
    fast;
    ch cc;
    cin>>cc;
    cc++;
    cout<<cc<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
const int MN = 200200;
const ll M = 998244353;
int st[MN];
bitset<MN> dv;
vi fac;
ll ct[MN];
inline ll mul(ll a, ll b) {return (a*b)%M;}
inline ll norm(ll n) {return ((n%M)+M)%M;}
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	for(int i=0;i<n;i++) {
		st[i] = s[i]-'0';
	}
	for(int i=1;i<=n;i+=2) {
		if(!(n%i)) {
			dv.set(n/i);
			fac.push_back(i);
		}
	}
	for(int i=0;i<fac.size();i++) {
		ll val = 0;
		ll sz = n/fac[i];
		ll sub = 0;
		for(int i=0;i<sz;i++) {
			val *= 2;
			val += st[i];
			val %= M;
		}
		for(int i=sz;i<n;i++) {
			if(st[i] > 1-st[i-sz]) {
				break;
			}
			if(st[i] < 1-st[i-sz]) {
				sub = 1;break;
			}
		}
		val += 1-sub;
		val %= M;
		ct[sz] = val;
	}
	for(int i=1;i<=n;i++) {
		if(dv[i]) {
			for(int j=2;j*i<=n;j++) {
				if(dv[i*j]) {
					ct[i*j] -= ct[i];
					ct[i*j] = norm(ct[i*j]);
				}
			}
		}
	}
	ll res = 0;
	for(int i=0;i<=n;i++) {
		if(dv[i]) {
			res += norm(2*i*ct[i]);
		}
	}
	cout << norm(res) << '\n';
}


Measured memory_bytes: 1428
N, C, K = [int(x) for x in input().split()]
T = []
for i in range(N):
    T.append(int(input()))

T.sort()
T = [[t, t+K] for t in T]

bus = [[]]
bus_no = 0
limit = T[0][1]

for t in T:
    if (len(bus[bus_no]) < C and t[0] <= limit):
        bus[bus_no].append(t)
    else:
        bus.append([])
        bus_no += 1
        bus[bus_no].append(t)
        limit = t[1]

print(len(bus))

Measured memory_bytes: 31292
N,L=gets.split.map &:to_i
A=gets.split.map &:to_i
a=[]
b=[]
s=nil
(N-1).times{|i|
	if A[i]+A[i+1]>=L
		s=i+1
	end
}
if !s
	puts "Impossible"
else
	puts "Possible"
	puts [*1...s]
	puts [*s..N-1].reverse
end

Measured memory_bytes: 13372
#include <stdio.h>

int main(void)
{
  int i;
  int j;
  int a[10] = {0};
  int temp;

  for( i=0; i < 10; i++ )
    scanf("%d", &a[i]);
  
  for( i = 0; i < 9; i++ ) 
    for( j = i+1; j < 10; j++ )
      if ( a[i] < a[j] ) {
	temp = a[i];
	a[i] = a[j];
	a[j] = temp;
      }
  
  for( i=0; i<3; i++ )
    printf("%d\n", a[i]);
  
  return 0;
  }

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <cctype>

using namespace std;

string puzzle[9];
int pl2id[9], pl2rot[9];

bool check(char a, char b) {
  return toupper(a) == toupper(b) && a != b;
}

int dfs(int k, bool *used) {
  if(k == 9) return 1;
  
  int ret = 0;
  for(int id=0; id<9; id++) {
    if(used[id]) continue;

    for(int rot=0; rot<4; rot++) {
      bool ok = true;
      // 上と一致
      if(k >= 3) ok &= check(puzzle[id][(rot+1)%4], puzzle[pl2id[k-3]][(pl2rot[k-3]+3)%4]);
      // 左と一致
      if(k%3 > 0) ok &= check(puzzle[id][rot], puzzle[pl2id[k-1]][(pl2rot[k-1]+2)%4]);
      
      if(ok) {
	pl2id[k] = id;
	pl2rot[k] = rot;
	used[id] = true;
	ret += dfs(k+1, used);
	used[id] = false;
      }
    }
  }
  
  return ret;
}

int main() {
  int n;
  cin >> n;
  while(n--) {
    for(int i=0; i<9; i++) {
      cin >> puzzle[i];
    }
    
    bool used[9] = {};
    cout << dfs(0, used) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ull unsigned long long
#define db double
#define vi vector<ll>
#define vvi vector<vector<int> >
#define vvii vector<vector<pii> >
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl "\n"
#define pii pair<ll,ll>
#define piii pair<ll,pair<ll,ll> >
#define mem(a,b) memset(a , b , sizeof a ) ; 
#define pb push_back
#define pf push_front
#define F first 
#define S second 
#define mp make_pair
#define all(v) v.begin(),v.end()

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}



#define deb1(a) cout<<#a<<"=*"<<a<<endl;
#define deb2(a) cout<<#a<<"=@"<<a<<endl;
#define deb3(a) cout<<#a<<"=#"<<a<<endl;
#define deb4(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;
#define deb5(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;


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


ll mod=1000000007;
ll vis[212345]={0};
vvi v(212345);
ll d[212345]={0};


ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}





int main()
{
speed
ll n;
cin>>n;
ll s=0;
ll a[n];
rep(i,0,n)
{
	cin>>a[i];
	s=s^a[i];
}
rep(i,0,n) cout<<(s^a[i])<<" ";
}



Measured memory_bytes: 9676
//(UNCOMMENT WHEN SUBMITTING)
//#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
// #pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)
// #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

// clang-format off
#define range(i) for (int _ = 0; _ < i; _++)
#define vprnt(v) for (auto vi : v) cout << vi << " "; cout << endl;
#define fastio() ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define all(x) (x).begin(), (x).end()
using namespace ::std;
int nxt() {int x;cin >> x;return x;}
ll nxtll() {ll x;cin >> x;return x;}
// clang-format on

int main() {
    fastio();

    int N = nxt();
    int K = nxt();

    vector<int> A(N);
    generate(all(A), nxt);

    int lo = 1, hi = 1e9, res = 1e9;
    int mid = (lo + hi) / 2;
    while (lo <= hi) {
        mid = lo + (hi - lo) / 2;
        // cout << lo << " : " << hi << endl;
        int trials = 0;
        for (int i = 0; i < N; i++) {
            if (A[i] > mid) {
                trials += A[i] / mid + (A[i] % mid ? 1 : 0) - 1;
            }
        }
        if (trials > K) {
            lo = mid + 1;
        } else {
            hi = mid - 1;
            res = min(res, mid);
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3924
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const long double EPS = 1E-10;

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




int main(){
    int K, A, B; std::cin >> K >> A >> B;
    bool okay(false);
    if(!(A % K)) okay = true;
    if(B/K > A/K) okay = true;
    std::cout << (okay ? "OK" : "NG") << std::endl;
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

int main(){
	
	int N;
	
	cin >> N;
	
	int DP[8][2000];
	
	for(int i = 0; i < 8; i++){
		for(int j = 0; j < 2000; j++){
			DP[i][j] = 0;
		}
	}
	
	DP[4][0] = 1;
	
	int state[8][8];
	
	for(int i = 0; i < 8; i++){
		for(int j = 0; j < 8; j++){
			if(i % 2 * j % 2 || (i / 2) % 2 * (j / 2) % 2 || (i / 4) % 2 * (j / 4) % 2){
				state[i][j] = 1;
			}else{
				state[i][j] = 0;
			}
		}
	}
	
	int index[4];
	
	string str;
	
	cin >> str;
	
	for(int i = 0; i < N; i++){
		if(str[i] == 'J'){
			index[0] = 4;
			index[1] = 5;
			index[2] = 6;
			index[3] = 7;
		}else if(str[i] == 'O'){
			index[0] = 2;
			index[1] = 3;
			index[2] = 6;
			index[3] = 7;
		}else{
			index[0] = 1;
			index[1] = 3;
			index[2] = 5;
			index[3] = 7;
		}
		for(int j = 0; j < 4; j++){
			for(int k = 0; k < 8; k++){
				if(state[index[j]][k] == 1){
					DP[index[j]][i + 1] += DP[k][i];
					DP[index[j]][i + 1] = DP[index[j]][i + 1] % 10007;
				}
			}
		}
	}
	
	int ans = 0;
	
	for(int i = 0; i < 8; i++){
		ans += DP[i][N];
		ans = ans % 10007;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3240
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;

struct Mint {
	static const ll mod = (ll)(1e9 + 7);	
	ll val;

	Mint() { val = 0; }
	Mint(ll a) {
		val = a;
		verify_value();
	}

	void verify_value() {
		if (val >= mod) val %= mod;
		if (val < 0) val %= mod, val += mod;
	}

	Mint pow(ll p) const {
		Mint cur = Mint(val), ret = 1;
		while (p > 0) {
			if (p & 1) ret *= cur;
			cur *= cur;
			p >>= 1LL;
		}
		return ret;
	}
	Mint inv() const {
		if (val == 0) cerr << "CAUTION: inv() is called with 0." << endl;
		return pow(mod - 2); 
	}

	Mint operator+() const { return *this; }
	Mint operator-() const { return Mint(mod - val); }

	Mint operator+=(const Mint &a) {
		val += a.val;
		if (val >= mod) val -= mod;
		return Mint(val);
	}
	Mint operator*=(const Mint &a) {
		val *= a.val;
		if (val >= mod) val %= mod;
		return Mint(val);
	}
	Mint operator-=(const Mint &a) { return *this += -a; }
	Mint operator/=(const Mint &a) { return *this *= a.inv(); }

	Mint operator++() { return *this += Mint(1); }
	Mint operator--() { return *this -= Mint(1); }
	Mint operator++(int) {
		Mint ret = *this;
		++(*this);
		return ret;
	}
	Mint operator--(int) {
		Mint ret = *this;
		--(*this);
		return ret;
	}
};

Mint operator+(const Mint &a, const Mint &b) {
	ll ret = a.val + b.val;
	if (ret >= Mint::mod) ret -= Mint::mod;
	return Mint(ret);
}
Mint operator*(const Mint &a, const Mint &b) {
	ll ret = a.val * b.val;
	if (ret >= Mint::mod) ret %= Mint::mod;
	return Mint(ret);
}
Mint operator-(const Mint &a, const Mint &b) { return a + (-b); }
Mint operator/(const Mint &a, const Mint &b) { return a * b.inv(); }

ostream &operator<<(ostream &out, const Mint &a) { return out << a.val; }
istream &operator>>(istream &in, Mint &a) {
	in >> a.val;
	a.verify_value();
	return in;
}


using Matrix = vector<vector<Mint>>;

Matrix matmul(const Matrix &a, const Matrix &b) {
	int n = (int)a.size();
	Matrix ret(n, vector<Mint>(n));
	for (int i = 0; i < n; i++) {
		for (int k = 0; k < n; k++) {
			for (int j = 0; j < n; j++) {
				ret[i][j] += a[i][k] * b[k][j];
			}
		}
	}
	return ret;
}

Matrix matpow(Matrix a, ll p) {
	int n = (int)a.size();
	Matrix ret(n, vector <Mint>(n));
	for (int i = 0; i < n; i++) ret[i][i] = 1;
	while (p > 0) {
		if (p & 1) ret = matmul(ret, a);
		a = matmul(a, a);
		p >>= 1LL;
	}
	return ret;
}

int main() {
	int n; ll k; cin >> n >> k;
	Matrix a(n, vector<Mint>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) cin >> a[i][j];
	}
	a = matpow(a, k);
	Mint ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			ans += a[i][j];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.*;

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

    String S = "1" + sc.next();

    S = S.replaceAll("eraser", "");
    S = S.replaceAll("erase", "");
    S = S.replaceAll("dreamer", "");
    S = S.replaceAll("dream", "");
    
    System.out.println(S.equals("1") ? "YES": "NO");
  }
}


Measured memory_bytes: 30316
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
while(true) {
int d, n, m;
vector<int> s;
scanf("%d", &d);
if(d == 0)
break;
scanf("%d%d", &n, &m);
s.resize(n + 1);
for(int i = 0; i < n - 1; ++i)
scanf("%d", &s[i]);
s[n - 1] = 0;
s[n] = d;
sort(s.begin(), s.end());
s.push_back(s[n - 1] - d);
sort(s.begin(), s.end());
int sum = 0;
for(int i = 0; i < m; ++i) {
int t;
scanf("%d", &t);
int r = lower_bound(s.begin(), s.end(), t) - s.begin();
int l = r - 1;
sum += min(abs(s[l] - t), abs(s[r] - t));
}
printf("%d\n", sum);
}
return 0;
}

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

int main(){
    int n; cin >> n;
    int s = 0; int e = 1000;
    for (int i=0; i<n; i++){
        int m; cin >> m;
        s = max(s, m);
        e = min(e, m);
    }
    cout << s-e << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int a[200001];
int main()
{
	int n;
	cin>>n;
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]<a[i-1])
		{
			ans+=(long long)(a[i-1]-a[i]);
			a[i]=a[i-1];
		}
	}
	cout<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 4400
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    int N, Z, W; std::cin >> N >> Z >> W;
    std::vector<int> a(N);
    for(int i(0); i < N; ++i) std::cin >> a[i];
    int ans(std::abs(a[N-1] - W));
    if(N > 1) chmax(ans, std::abs(a[N-1] - a[N-2]));
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T1, class T2>
bool chmax(T1 &a, const T2 b){if(a < b){a = b; return true;} return false;}
template <class T1, class T2>
bool chmin(T1 &a, const T2 b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
void co() { cout << endl; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << endl; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18L+1;
constexpr ll MOD = 1e9L+7;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

struct union_find{
    vector<ll> par;
    vector<ll> size;

    union_find(ll n){
        par.resize(n);
        size.assign(n, 1);
        for(int i = 0; i < n; ++i) par[i] = i;
    }

    ll root(ll x){
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y){
        x = root(x), y = root(y);
        if(x != y){
            if(size[x] > size[y]) swap(x, y);
            par[y] = x;
            size[x] += size[y];
        }
    }

    ll getSize(ll x){
        return size[root(x)];
    }

    bool same(ll x, ll y){
        return root(x) == root(y);
    }
};

int main(void){
    ll n, m;
    cin >> n >> m;

    union_find uf(n);
    rep(i, m){
        ll a, b;
        cin >> a >> b;
        --a, --b;
        uf.unite(a, b);
    }

    ll ans = 0;
    rep(i, n) chmax(ans, uf.getSize(i));
    co(ans);

    return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  const int MAX = 111111;
  vector<int> primes;
  vector<bool> isPrime(MAX, true);
  isPrime[0] = isPrime[1] = false;
  for (int i = 2; i * i <= MAX; i++) {
    if (isPrime[i]) {
      for (int j = i + i; j <= MAX; j += i) {
        isPrime[j] = false;
      }
    }
  }
  for (int i = 2; i <= MAX; i++) {
    if (isPrime[i]) {
      primes.push_back(i);
    }
  }
  int x;
  cin >> x;
  cout << *lower_bound(primes.begin(), primes.end(), x) << '\n';
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define MAXINF 1001001001
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repc(it, x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rrepc(it, x) for(auto it = (x).rbegin(); it != (x).rend(); ++it)
#define all(x) (x).begin(), (x).end()

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, n;
    cin >> h >> n;
    vector<int> a(n), b(n);
    int maxa = 0; 
    rep(i, n) {
        cin >> a[i] >> b[i];
        maxa = max(maxa, a[i]);
    }
    vector<int> dp(h+maxa, MAXINF);
    dp[0] = 0;
    rep(i, n) rep(j, h+maxa) {
        int nj = min(j+a[i], h);
        dp[nj] = min(dp[nj], dp[j] + b[i]);
    }
    cout << dp[h] << endl;
    return 0;
}

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


int B[26];

int main(){
	int n;
	string s;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> s;
		int vis[26]={0},A[26]={0};
		for(int j=0;j<s.size();j++){
			if(!vis[s[j]-'a']) A[s[j]-'a']++;
		}
		if(i==0){
			for(int j=0;j<26;j++){
				B[j]=A[j];
			}
		}
		else{
			for(int j=0;j<26;j++){
				B[j]=min(A[j],B[j]);
			}
		}
	}
	
	
	sort(s.begin(),s.end());
	for(int i=0;i<s.size();i++){
		if(B[s[i]-'a']){
			cout << s[i];
			B[s[i]-'a']--;
		}
	}
	cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
void swap_int(int* x, int* y) {
    int temp;
    temp = *x;
    *x = *y;
    *y = temp;
}
void swap_char(char* x, char* y) {
    char temp;
    temp = *x;
    *x = *y;
    *y = temp;
}

void sort(int* array, int n, int mode) {
    int i, j;
    if (mode) {  // 1 is ascending order
        for (i = 0; i < n - 1; i++) {
            for (j = i + 1; j < n; j++) {
                if (array[i] > array[j]) {
                    swap_int(&array[i], &array[j]);
                }
            }
        }
    } else {  // 0 is descending order
        for (i = 0; i < n - 1; i++) {
            for (j = i + 1; j < n; j++) {
                if (array[i] < array[j]) {
                    swap_int(&array[i], &array[j]);
                }
            }
        }
    }
}
int max(int x, int y) {
    if (x > y) {
        return x;
    } else {
        return y;
    }
}
int min(int x, int y) {
    if (x > y) {
        return y;
    } else {
        return x;
    }
}
int main(void) {
    int r, d, x;
    int i, j, k;
    int temp;

    scanf("%d %d %d", &r, &d, &x);

    temp = r * x - d;
    printf("%d\n", temp);
    for (i = 1; i < 10; i++) {
        temp = temp * r - d;
        printf("%d\n", temp);
    }
    return 0;
}

Measured memory_bytes: 128
#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[i];
  sort(a.begin(), a.end());
  double ans = a[0];
  for(int i = 1; i < n; i++) ans = (ans + a[i]) / 2;
  cout << ans << endl;
}

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

#define INF 1000000

int tmp[10][10];
bool ans[10][10][10];

int main(){
	for(int i=0;i<10;i++)for(int j=0;j<10;j++)tmp[i][j]=INF;
	int n;	cin>>n;
	string s;	cin>>s;

	for(int m=1; m<n-1; m++){

		int d1,d2,d3;
		d2=s[m]-'0';

		for(int L=m-1; L>=0; L--){
			d1=s[L]-'0';
			tmp[d1][d2]=min(tmp[d1][d2],m);
		}
	}

	for(int d1=0;d1<10;d1++){
		for(int d2=0;d2<10;d2++){
			if(tmp[d1][d2]==INF)continue;

			for(int p=tmp[d1][d2]+1; p<n; p++){
				int d3=s[p]-'0';
				ans[d1][d2][d3]=true;
			}
		}
	}

	int cnt=0;
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			for(int k=0;k<10;k++){
				if(ans[i][j][k])cnt++;
			}
		}
	}

	cout<<cnt<<endl;


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<map>
#include<iomanip>
#include<limits>
#include<queue>
#include<set>
#include<cstdio>
#include<cstring>

using namespace std;

int main(){


	int N;
	cin >> N;
	int f[100005];
	memset(f,0x3f,sizeof(f));
	f[0] = 0;

	for(int i = 1 ;i <= N;i++){
		for(int j = 1;j <= i;j*=6) f[i] = min(f[i],f[i-j] + 1);
		for(int j = 1;j <= i;j*=9) f[i] = min(f[i],f[i-j] + 1);
	}

	cout << f[N] << endl;

	return 0;

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define  f(i,a,b) for( i=a;i<b;i++) 
#define ll long long int
using namespace std;

int main()
{	
	int m=-1,x=0;
	string n; cin>>n;

	char c= n[0];

	for(int i=0;i<n.size();i++)
		{
			if(c==n[i]) x++,m  =max(m,x);
			else x=0;
		
	}
	if(m>=3) {cout<<"Yes"; return 0;}

	c =n[1],m=-1,x=0;
	for(int i=0;i<n.size();i++)
		{
			if(c==n[i]) x++,m  =max(m,x);
			else x=0;
		
	}
	if(m>=3) {cout<<"Yes"; return 0;}

	c= n[2],m=-1,x=0;
	for(int i=0;i<n.size();i++)
		{
			if(c==n[i]) x++,m  =max(m,x);
			else x=0;
		
		
	}
	if(m>=3) {cout<<"Yes"; return 0;}

	c=n[3],m=-1,x=0;
	for(int i=0;i<n.size();i++)
		{
			if(c==n[i]) x++,m  =max(m,x);
			else x=0;
		
	}
	if(m>=3) {cout<<"Yes"; return 0;}

	
	
		cout<<"No";





	

 	
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

class Stack
{
private:
	vector<int> s;
	int pos;
public:
	Stack(int n)
	{
		s.resize(n);
		pos = 0;
	}
	void push(int a)
	{
		s[pos++] = a;
	}
	int pop()
	{
		return s[--pos];
	}
};

int main()
{
	string symbol;
	Stack s(200);
	int op1, op2;
	while (cin >> symbol, !cin.eof())
	{
		if (symbol == "+")
		{
			op2 = s.pop();
			op1 = s.pop();
			s.push(op1 + op2);
		}
		else if (symbol == "-")
		{
			op2 = s.pop();
			op1 = s.pop();
			s.push(op1 - op2);
		}
		else if (symbol == "*")
		{
			op2 = s.pop();
			op1 = s.pop();
			s.push(op1 * op2);
		}
		else
		{
			s.push(atoi(symbol.c_str()));
		}
	}
	cout << s.pop() << endl;
    return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <string>

int main(int argc, char *argv[]) {
  char c;
  int count = 0, max = 0;
  while (std::cin >> c) {
    if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
      ++count;
      max = std::max(max, count);
    } else {
      count = 0;
    }
  }
  std::cout << max << std::endl;
}


Measured memory_bytes: 256
h,w,m=map(int,input().split())
H=[0]*(3*10**5+1)
W=[0]*(3*10**5+1)
M=[]
for i in range(m):
    h,w=map(int,input().split())
    M.append([h,w])
    H[h]+=1
    W[w]+=1

p=max(H)
q=max(W)

X=set([i for i in range(3*10**5+1) if H[i]==p])
Y=set([i for i in range(3*10**5+1) if W[i]==q])

cnt=0
for i in range(m):
    if M[i][0] in X and M[i][1] in Y:
        cnt+=1

if cnt==len(X)*len(Y):
    print(p+q-1)
else:
    print(p+q)


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define INF (int)1e8
#define EPS 1e-9

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
  int N, X;
  cin >> N >> X;
  vi m(N);
  rep(i, N) cin >> m[i];

  int res = N, sum = 0;
  rep(i, N) sum += m[i];
  int mi = INF;
  rep(i, N) mi = min(mi, m[i]);
  int cnt = 0;
  while (true) {
    sum += mi;
    if (sum <= X)
      cnt++;
    else {
      res += cnt;
      break;
    }
  }

  cout << res << endl;
}

Measured memory_bytes: 256
N, K, *A = map(int, open(0).read().split())
a = 0
b = 0
for i in range(N):
    for j in range(N):
        if A[j] > A[i]:
            a += 1
            if j < i:
                b += 1
print((b * K + a * K * (K-1) // 2)%(10**9+7))



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

int Findgcd_by_Euclid(int, int);

int main()
{
	int monster;
	int d;
	int i;
	int gcd;
	scanf("%d", &d);

	scanf("%d", &monster);
	gcd = monster;

	for (i = 1; i < d; i++)
	{
		scanf("%d", &monster);
		gcd = Findgcd_by_Euclid(monster, gcd);
	}
	printf("%d", gcd);
	return 0;
}

int Findgcd_by_Euclid(int a, int b)
{
	int c;
	while (b)
	{
		c = a % b;
		a = b;
		b = c;
	}
	return a;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <functional>
#define MOD 1000000007
#define MAX 0x3f3f3f3f
#define MAX2 0x3f3f3f3f3f3f3f3fll
#define ERR 1e-10
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
using namespace std;
 
typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
int n;
pll a[200000];
int px, py;
ll d;
 
map<ll, set<pll>> xmq, ymq;
map<ll, map<ll, ll>> xmq2, ymq2;
 
int main()
{
	int i, j, k, l;
	cin>>n>>px>>py, px--, py--;
	for(i=0;i<n;i++) scanf("%lld%lld", &a[i].first, &a[i].second), tie(a[i].first, a[i].second)=mp(a[i].first+a[i].second, a[i].first-a[i].second);
	d=max(abs(a[px].first-a[py].first), abs(a[px].second-a[py].second));
	vector<int> v;
	v.push_back(px), v.push_back(py);
	for(i=0;i<n;i++)
	{
		if(i != px && i != py)
		{
			xmq[a[i].first].emplace(a[i].second, i);
			ymq[a[i].second].emplace(a[i].first, i);
		}
		xmq2[a[i].first][a[i].second]++;
		ymq2[a[i].second][a[i].first]++;
	}
	for(auto &e : xmq2)
	{
		e.second[-MAX2]=e.second[MAX2]=0;
		ll now=0;
		for(auto &f : e.second)
		{
			now+=f.second;
			f.second=now;
		}
	}
	for(auto &e : ymq2)
	{
		e.second[-MAX2]=e.second[MAX2]=0;
		ll now=0;
		for(auto &f : e.second)
		{
			now+=f.second;
			f.second=now;
		}
	}
	for(i=0;i<v.size();i++)
	{
		int now=v[i];
		ll x=a[now].first, y=a[now].second;
		set<ll> xnew;
		auto ix=xmq[x-d].lower_bound(mp(y-d, -MAX));
		for(;ix != xmq[x-d].end() && ix->first <= y+d;ix++)
		{
			xnew.insert(ix->second);
		}
		ix=xmq[x+d].lower_bound(mp(y-d, -MAX));
		for(;ix != xmq[x+d].end() && ix->first <= y+d;ix++)
		{
			xnew.insert(ix->second);
		}
		ix=ymq[y-d].lower_bound(mp(x-d, -MAX));
		for(;ix != ymq[y-d].end() && ix->first <= x+d;ix++)
		{
			xnew.insert(ix->second);
		}
		ix=ymq[y+d].lower_bound(mp(x-d, -MAX));
		for(;ix != ymq[y+d].end() && ix->first <= x+d;ix++)
		{
			xnew.insert(ix->second);
		}
		for(auto e : xnew)
		{
			v.push_back(e);
			xmq[a[e].first].erase(mp(a[e].second, e));
			ymq[a[e].second].erase(mp(a[e].first, e));
		}
	}
	ll ans=0;
	for(auto e : v)
	{
		ll x=a[e].first, y=a[e].second;
		auto dodo=[](map<ll, map<ll, ll>> &mq, ll x, ll y1, ll y2)
		{
			if(!mq.count(x)) return 0ll;
			auto ix1=prev(mq[x].lower_bound(y1));
			auto ix2=prev(mq[x].lower_bound(y2+1));
			return ix2->second-ix1->second;
		};
		ans+=dodo(xmq2, x-d, y-d, y+d-1);
		ans+=dodo(ymq2, y+d, x-d, x+d-1);
		ans+=dodo(xmq2, x+d, y-d+1, y+d);
		ans+=dodo(ymq2, y-d, x-d+1, x+d);
	}
	cout<<ans/2<<endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int count =0;
  
  for(int i= 0; i<10;i++){
    count += 1000;
    
    if(count >= N){
      cout << count - N <<endl;
      break;
    }
    
  }
    
  
}
    

Measured memory_bytes: 3628
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

int main() {
	int N, W, H;
	cin >> N >> W >> H;
	
	int x, y, w;
	vector<pii> xl, yl;
	REP(i, N) {
		cin >> x >> y >> w;
		xl.push_back(pii(x - w, x + w));
		yl.push_back(pii(y - w, y + w));
	}
	xl.push_back(pii(0, 0));
	xl.push_back(pii(W, W));
	yl.push_back(pii(0, 0));
	yl.push_back(pii(H, H));
	sort(ALL(xl));
	sort(ALL(yl));

	bool xok = true, yok = true;
	int xm = 0, ym = 0;
	REP(i, N + 2) {
		if (xm < xl[i].first) {
			xok = false;
		}
		else {
			xm = max(xm, xl[i].second);
		}
		if (ym < yl[i].first) {
			yok = false;
		}
		else {
			ym = max(ym, yl[i].second);
		}
	}

	cout << (xok|yok ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 2904
n=int(input())
As=[int(input()) for _ in range(n)]
As.sort()
As_uniq=list(set(As))

ans=0
c=1
for i in range(1,n):
  if As[i]==As[i-1]:
    c+=1
  else:
    if c%2==1:
      ans+=1
    c=1
if c % 2 == 1:
  ans += 1
print(ans)

Measured memory_bytes: 13256
using System;

namespace Project
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			string s = Console.ReadLine();
			string[] sar = s.Split(' ');
			int[] a = new int[n];
			for (int i = 0; i < sar.Length; i++)
			{
				a[i] = int.Parse(sar[i]);
			}
			for (int i = 0; i < sar.Length; i++)
			{
				Console.Write(a[sar.Length - (i + 1)]);
				if (i == sar.Length - 1) { break; }
				else { Console.Write(" ");}
			}
			Console.Write("\n");
		}
	}
}

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

int main(){
  int n,p[1000000],mi=1e9;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  int num=0;
  for(int i=0;i<n;i++){
    if(mi>p[i]){
      mi=p[i];
      num++;
    }
  }
  cout<<num<<endl;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

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

    vector<lint> x(n), y(m);
    rep(i, n){
        cin >> x[i];
    }
    rep(i, m){
        cin >> y[i];
    }

    vector<lint> xsum(n + 1), ysum(m + 1);
    REP(i, 1, n + 1){
        xsum[i] = x[i - 1] + xsum[i - 1];
    }
    REP(i, 1, m + 1){
        ysum[i] = y[i - 1] + ysum[i - 1];
    }

    lint dxsum = 0, dysum = 0;
    REP(i, 1, n){
        dxsum += x[i] * i - xsum[i];
        dxsum %= MOD;
    }
    REP(i, 1, m){
        dysum += y[i] * i - ysum[i];
        dysum %= MOD;
    }

    lint ans = (dxsum * dysum) % MOD;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3456
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<iostream>
#include<set>
#include<map>
#define re register
#define ll long long
using namespace std;
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9'|| ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return sum*f;
}
struct node{
	double x,y;
	node operator+(node b){return (node){x+b.x,y+b.y};}
	node operator-(node b){return (node){x-b.x,y-b.y};}
	node operator*(double b){return (node){x*b,y*b};}
	double len(){return sqrt(x*x+y*y);}
};
double cross(node a,node b){return a.x*b.y-a.y*b.x;}
double dot(node a,node b){return a.x*b.x+a.y*b.y;}
node projection(node p1,node p2,node p){
	node v=p2-p1;
	return p1+v*(dot(v,p-p1)/dot(v,v));
}
int main(){
	node p1,p2,p;
	p1.x=gi();p1.y=gi();p2.x=gi();p2.y=gi();
	int Q=gi();
	while(Q--){
		p.x=gi();p.y=gi();
		node P=projection(p1,p2,p);
		printf("%.8lf %.8lf\n",P.x,P.y);
	}
	return 0;
}



Measured memory_bytes: 3232
#include<iostream>

using namespace std;

int H, W, N, a[10001], ans[100][100] = {}, c = 1;
bool flag = false;

int main() {
	cin >> H >> W >> N;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}

	for (int y = 0; y < H; y++) {
		if (y % 2 == 0) {
			for (int x = 0; x < W; x++) {
				ans[x][y] = c;
				a[c]--;
				if (a[c] == 0) {
					c++;
				}
			}
		}
		else {
			for (int x = W - 1; x >= 0; x--) {
				ans[x][y] = c;
				a[c]--;
				if (a[c] == 0) {
					c++;
				}
			}
		}
	}

	for (int y = 0; y < H; y++) {
		for (int x = 0; x < W - 1; x++) {
			cout << ans[x][y] << " ";
		}
		cout << ans[W - 1][y] << endl;
	}

	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

namespace ALDS1_3
{
    class Progarm
    {
        static void Main()
        {
            var i = new LinkedList<string>();
            var l = int.Parse(Console.ReadLine());
 
            for (var j = 0; j < l; j++)
            {
                var _t = Console.ReadLine().Split();
                 
                if (_t.Length == 1)
                {
                    if (_t[0] == "deleteFirst")
                        i.Remove(i.First);
                    else
                        i.Remove(i.Last);
                }
                else
                {
                    if (_t[0] == "insert")
                        i.AddFirst(_t[1]);
                    else
                    {
                        var node = i.First;

                        while (node != null)
                        {
                            if (node.Value == _t[1])
                            {
                                i.Remove(node);
                                break;
                            }

                            node = node.Next;
                        }
                    }
                }        
            }

            Console.WriteLine(string.Join(" ", i.ToArray()));
         }
    }
}

Measured memory_bytes: 144052
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define UP 1
#define DOWN -1
#define FLAT 0

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int N; cin >> N;
	vector<int> a(N, 0);
	rep (i, N){
		cin >> a[i];
	} // end rep

	int res = 1;
	int updown = FLAT; // up := UP down := DOWN flat := FLAT
	rep (i, N){
		if (i == 0){
			continue;
		} // end if
		if (a[i-1] > a[i]){
			if (updown == UP){
				++res;
				updown = FLAT;
			}else{
				updown = DOWN;
			} // end if
		}else
		if (a[i-1] < a[i]){
			if (updown == DOWN){
				++res;
				updown = FLAT;
			}else{
				updown = UP;
			} // end if
		} // end if
	} // end rep

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 640
/*やっとACできた。BGS無理やり理解した甲斐があったk
もう二度と冷えたくない
いやダイヤダイヤだ
*/
#include <bits/stdc++.h>

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line
int h , w ;
vector<string> field;

const int mod = 1e9+7;
int dy[4] = {0,0,1,-1};
int dx[4] = {1,-1,0,0};
int main()
{
	//BFSで最短手数を求める。白の数-(最短ゴール手数+1)が答え。()の中は、白の数から使う白の数を引いたものと捉えられる。
	cin >> h >> w ;
	field.resize(h);
	rep(i,h) cin >> field[i] ;//xとyの添字に注意
	int gy = h - 1 , gx = w - 1 ;
	//count[gy][gx]が最短手数になるよう幅優先探索を施す
	//以下BFSゴリラ実装(俺の天才コードを見ろ)
	bool seen[55][55] ;
	int count[55][55];
	rep(i,55)rep(j,55) seen[i][j] = false , count[i][j] = 0 ;
	queue<pair<int,int>> que;
	que.push(make_pair(0,0));
	seen[0][0] = true; 
	while(!que.empty()){
		auto point = que.front();
		que.pop();
		int ry =point.first;
		int rx = point.second;
		int move = count[ry][rx];
		for(int dir = 0 ; dir < 4 ; dir ++){
			int ny = ry + dy[dir];
			int nx = rx + dx[dir];
			if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
			if(field[ny][nx] == '#') continue;
			if(seen[ny][nx]) continue;
			seen[ny][nx] =  true ;
			que.push(make_pair(ny,nx));
			count[ny][nx] = move + 1 ;
		}
	}
	int mini = count[gy][gx]; //ゴールまでの最短点数
	//ここまで天才によるゴリラ
	//TODO 最短手数に1足すのを忘れずに
	mini ++ ; //必要な白の個数

	//マップに白が何個あるかを数える
	int white = 0 ;
	rep(i,h){
		rep(j,w){
			if(field[i][j] == '.'){
				white ++ ;
			}
		}
	}
	if(seen[gy][gx]){
		cout << white - mini << endl;
	}else cout << -1 << endl;

}


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

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

    static class CDiceAndCoin {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int n = s.nextInt();
            int k = s.nextInt();
            double ans = 0.0;
            for (int i = 1; i <= n; i++) {
                int j = i;
                int count = 0;
                while (j < k) {
                    j *= 2;
                    count++;
                }

                ans += ((1.0 / n) * Math.pow(0.5, count));
            }
            out.println(ans);
        }

    }

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

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

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

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

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

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

        }

    }
}



Measured memory_bytes: 21460
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var nx = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var ar = Array.ConvertAll(ReadLine().Split(' '), long.Parse);
        var result = 0L;
        for(var i = 1; i < nx[0]; i++)
        {
            var sum = ar[i] + ar[i - 1];
            result += Max(0, sum - nx[1]);
            ar[i] = Max(0, ar[i]-Max(0,sum - nx[1]));
        }
        WriteLine(result);
    }

    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 27484
#include<stdio.h>

long ans[ 100000000 ] ;


long max( long a ,long b )
{
	if( a < b )
	{
		return b ;
	}

	return a ;
}


int main()
{
	long n ,k ;

	while( scanf( "%ld %ld" ,&n ,&k ) ,n || k )
	{

		long i ;
		for( i = 1 ; i <= n ; i++ )
		{
			scanf( "%ld" ,&ans[ i ] ) ;

			ans[ i ] += ans[ i - 1 ] ;

			if( i >= k )
			{
				ans[ 0 ] = max( ans[ i ] - ans[ i - k ] ,ans[ 0 ] ) ;
			}
		}

		printf( "%ld\n" ,ans[ 0 ] ) ;
	}

	return 0 ;
}

Measured memory_bytes: 1380
#include <stdio.h>
#include <stdlib.h>
#define num 100000
#define true 1
#define false 0

void isPrime();
int isCheck(int i,int j,int m,int a,int b);
int isbigger(int num1,int num2);
int is1(int i,int j);
int N;
int *prime;

int main(){
  prime = (int *)malloc(num);
  isPrime();
  int m,a,b;
  int i,j,x,y;
  while(scanf("%d %d %d",&m,&a,&b ),m){
    int max=0;
    for(i=0;i<N;i++){
      for(j=0;j<N;j++){
        if(isCheck(i,j,m,a,b)) break;
        if(isbigger(max,prime[i]*prime[j])&&is1(i,j)) {
          max = prime[i]*prime[j];
          x = i;
          y = j;
        }
      }
    }
    printf("%d %d\n",prime[x],prime[y] );
  }

  free(prime);
  exit(0);
}

void isPrime(){
  int i,index=0;

  for (int j = 2;j < num;j++){
    for (i = 2;i < j;++i){
      if (j % i == 0){
        break;
      }
    }
    if (j == i){
      *(prime+index) = j;
      index++;
    }
  }
  N = index;
}

int isCheck(int i,int j,int m,int a,int b){
  double min = (double)a/b;
  double real = (double)prime[i]/prime[j];
  int pq = prime[i]*prime[j];
  if(min<=real&&pq<=m)  return false;
  return true;
}

int is1(int i,int j){
  double real = (double)prime[i]/prime[j];
  if (real<=1.0) return true;
  return false;
}

int isbigger(int num1,int num2){
  if (num1 >= num2){
    return false;
  }
  return true;
}



Measured memory_bytes: 1980