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

#define int long long
//typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


signed main() {
    int a,b;
    cin >> a >> b;
    int ans;
    if(a>b) swap(a,b);
    if(a==1 && b==2) ans=3;
    else if(a==1 && b==3) ans=2;
    else if(a==2 && b==3) ans=1;
    
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <stdio.h>
#include <inttypes.h>

#define MOD_BY INT32_C(1000000007)

int32_t mul(int32_t a, int32_t b) {
	return (int32_t)(((int64_t)a * b) % MOD_BY);
}

int32_t powint(int32_t a, int32_t n) {
	int32_t res = 1;
	while (n > 0) {
		if (n & 1) res = mul(res, a);
		a = mul(a, a);
		n >>= 1;
	}
	return res;
}

int32_t div(int32_t a, int32_t b) {
	return mul(a, powint(b, MOD_BY - 2));
}

int32_t sub(int32_t a, int32_t b) {
	return a < b ? a + MOD_BY - b : a - b;
}

int32_t n;
int32_t a[1000000];

int32_t idx[1000000];

int32_t kaizyo[1000000];

int main(void) {
	int32_t i;
	int32_t dupe[2] = {-1, -1}, newn;
	if (scanf("%"SCNd32, &n) != 1) return 1;
	n++;
	for (i = 0; i < n; i++) {
		if (scanf("%"SCNd32, &a[i]) != 1) return 1;
	}
	/* 階乗を事前に計算 */
	kaizyo[0] = kaizyo[1] = 1;
	for (i = 2; i <= n; i++) kaizyo[i] = mul(kaizyo[i - 1], i);
	/* 制約より同じ数字のペアが1個だけあるので、探す */
	for (i = 0; i < n; i++) {
		if (idx[a[i]] == 0) {
			idx[a[i]] = i + 1;
		} else {
			dupe[0] = idx[a[i]] - 1;
			dupe[1] = i;
			break;
		}
	}
	if (dupe[0] < 0) return 1;
	newn = n - (dupe[1] - dupe[0]) - 1;
	/* 計算 */
	for (i = 1; i <= n; i++) {
		int32_t all, dupesuru;
		/* 全部の組み合わせの計算 nCi*/
		all = div(kaizyo[n], mul(kaizyo[i], kaizyo[n - i]));
		/* 被る組み合わせの計算 (真ん中とその数字を除いた数)C(i-1) */
		dupesuru = div(kaizyo[newn], mul(kaizyo[i - 1], kaizyo[newn - (i - 1)]));
		printf("%"PRId32"\n", sub(all, dupesuru));
	}
	return 0;
}

/*
同じ数字のペアが1組だけある
それでかぶるのは→その数字を使用 && その数字の組の間を使用しない
*/


Measured memory_bytes: 9728
/*
title:C - Half and Half

url:https://abc095.contest.atcoder.jp/tasks/arc096_a

方針
atcoder begeinner contestのstrange bank に似ている問題
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

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

int main()
{
    int a, b, c;
    int x, y;
    cin >> a >> b >> c;
    cin >> x >> y;

    int ans = 0;
    int nmin = min(x, y);
    ans += min(a * nmin + b * nmin, c * nmin * 2);
    if (nmin == x)
    {
        ans += min(b * (y - nmin), c * 2 * (y - nmin));
    }
    else
    {
        ans += min(a * (x - nmin), c * 2 * (x - nmin));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, D, cnt = 0; cin >> N >> D;
    for (int i = 0; i < N; i++) {
        int x, y; cin >> x >> y;
        if (D >= sqrt(pow(x, 2) + pow(y, 2))) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3572
from operator import itemgetter
import sys

input = sys.stdin.readline

inf = float('inf')

N, Q = map(int, input().split())

events = []
method_events_append = events.append

for _ in range(N):
    s, t, x = map(int, input().split())
    method_events_append((s - x, 1, x))  # add_event
    method_events_append((t - x, -1, x))  # remove_event

events.sort(key=itemgetter(0))  # イベント処理時刻昇順ソート

under_construction = set()
method_uc_add = under_construction.add
method_uc_discard = under_construction.discard

min_stop = inf
not_chg_flg = True

cur = 0
for _ in range(Q):
    d = int(input())
    while cur < N * 2 and events[cur][0] <= d:
        exec_time, event_type, under_construction_x = events[cur]
        if event_type == 1:  # add_event
            method_uc_add(under_construction_x)
            if not_chg_flg:  # この分岐がないとdiscardされたmin_stopと比較する恐れがある
                min_stop = min(min_stop, under_construction_x)
        else:  # remove_event
            method_uc_discard(under_construction_x)
            if not_chg_flg and min_stop == under_construction_x:
                not_chg_flg = False
        cur += 1

    if not not_chg_flg:
        min_stop = min(under_construction) if under_construction else inf
        not_chg_flg = True
    print(min_stop if min_stop != inf else -1)


Measured memory_bytes: 68860
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define maxs(x,y) x = max(x,y)

int main() {
  int n;
  cin >> n;
  int n3 = n*3;
  vector<int> A(n3);
  rep(i,n3) cin >> A[i], --A[i];
  const int INF = 1e9;
  int m = n+1;
  vector<vector<int>> dp(m,vector<int>(m,-INF));
  int base = 0;

  auto upd = [&](int i, int j, int x) {
    maxs(dp[i][j], x);
    maxs(dp[j][i], x);
    maxs(dp[i][n], x);
    maxs(dp[n][i], x);
    maxs(dp[n][j], x);
    maxs(dp[j][n], x);
    maxs(dp[n][n], x);
  };
  upd(A[0],A[1],0);

  rep(ai,n-1) {
    // rep(i,m)rep(j,m) printf("%d %d : %d\n", i,j,dp[i][j]);
    int a = A[ai*3+2], b = A[ai*3+3], c = A[ai*3+4];
    vector<int> p = dp[n];
    vector<int> pa = dp[a];
    vector<int> pb = dp[b];
    vector<int> pc = dp[c];
    int pp = dp[n][n];
    int paa = dp[a][a];
    int pbb = dp[b][b];
    int pcc = dp[c][c];
    if (a == b && b == c) {
      base++;
      rep(i,m) {
        p[i]--;
        pa[i]--;
        pb[i]--;
        pc[i]--;
      }
      pp--;
      paa--; pbb--; pcc--;
    }
    rep(ri,3) {
      { // i,j,a,b,c -j,b,c-> i,a
        rep(i,m) {
          int now = p[i];
          if (b == c) maxs(now, pb[i]+1);
          upd(i,a,now);
        }
      }
      { // i,j,a,b,c -i,j,c-> a,b
        int now = max(pp, pcc+1);
        upd(a,b,now);
      }
      swap(a,b); swap(b,c);
      swap(pa,pb); swap(pb,pc);
      swap(paa,pbb); swap(pbb,pcc);
    }
    // rep(i,m)rep(j,m) printf("%d %d : %d\n", i,j,dp[i][j]);
  }

  int ans = 0;
  rep(i,m)rep(j,m) {
    int now = dp[i][j];
    if (i == A[n3-1] && i == j) ++now;
    maxs(ans, now);
  }
  ans += base;
  cout << ans << endl;
  return 0;
}

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

int main()
{
  string s;
  cin >> s;
  int n = s.size();
  vector<int> vec(n, 1);
  for (int i = 0; i <= n; i++)
  {
    if(s[i]==s[i+1]&&s[i]=='R'){
      vec[i + 2] += vec[i];
      vec[i] = 0;
    }
  }
  for (int i = n-1; i >=0;i--){
    if(s[i]==s[i-1]&&s[i]=='L'){
      vec[i - 2] += vec[i];
      vec[i] = 0;
  }
  }
  for (int i = 0; i < n;i++){
    cout << vec[i] << " ";
  }
}

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

vector <int> adj[100001];
int H[100001];
int n,m,a,b;

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

	cin >> n >> m;

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

	for(int i=0;i<m;i++)
	{
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	int res = 0;
	for(int i=1;i<=n;i++)
	{
		bool ok = true;
		for(auto j : adj[i])
		{
			if(H[j] >= H[i])
			{
				ok = false;
				break;
			}
		}
		res += ok;
	}

	cout << res << '\n';
	
	return 0;
}


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int N = 2e5 + 5;
int n;
pii a[N];

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i].first);
		a[i].second = i;
	}
	sort(a, a + n);
	if (a[0].first != 1) {
		printf("-1\n");
		return 0;
	}
	vector<vector<int>> b(n + 1); 
	for (int i = 0; i < n; i++) {
		b[a[i].first].push_back(a[i].second);
	}
	int pos = a[0].second, cnt = 1;
	for (int i = 2; i <= n; i++) {
		auto it = upper_bound(b[i].begin(), b[i].end(), pos);
		if (it == b[i].end())
			break;
		pos = *it;
		cnt++;
	}
	printf("%d\n", n - cnt);
	return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size())cout << a[i] << " ";cout << "\n"
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    ll Q;
    cin >> Q;
    string usiro = "",mae = "";
    ll tipe;
    ll rev = 0;
    rep(i,Q){
        cin >> tipe;
        if(tipe == 1){
            rev ^= 1;
        }
        else{
            ll t;char c;
            cin >> t >> c;
            if(rev == 0 && t == 1){
                mae += c;
            }
            else if(rev == 0 && t == 2){
                usiro += c;
            }
            else if(rev == 1 && t == 1){
                usiro += c;
            }
            else{
                mae += c;
            }
        }
    }
    if(rev == 0){
        reverse(all(mae));
        S = mae + S + usiro;
    }
    else{
        reverse(all(usiro));
        reverse(all(S));
        S = usiro + S + mae;
    }
    cout << S << endl;
    //cout << mae << "\n" << usiro << "\n";
}

Measured memory_bytes: 4216
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
using namespace std;

int main()
{
   int t;t=1;
   FAST
   while(t--)
   {
       int a,b,c,d;cin>>a>>b>>c>>d;
       bool ok1,ok2=true;
       while(true)
       {
           c-=b;
           if(c<=0) 
           {
               ok1=false;
               break;
           }
           a-=d;
           if(a<=0)
           {
               ok2=false;
               break;
           }
       }
       cout<<(ok2==false ? "No\n":"Yes\n");
   }
}

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

using namespace std;

int main(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int a = h1 * 60 + m1;
    int b = h2 * 60 + m2;

    cout << max(0, b - a - k) << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			int M = sc.nextInt();
			sc.close();

			int ans = ((100 * (N-M)) + (1900 * M)) * (int)Math.pow(2, M);
			System.out.println(ans);


	}

}


Measured memory_bytes: 21972
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
 
 
void swap (int *x, int *y) {
  int temp;    
 
  temp = *x;
  *x = *y;
  *y = temp;
}
 
int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }
 
  if(b==0){
    return a;
  }
 
  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }
 
  return b;
}
 
/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}
 
 
int modpow(int a,int n,int mod){
  int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}
 
int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}
 
int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}
 
void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }
 
  return;
}
 
void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }
 
  return;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int r, g, b;
  scanf("%d %d %d", &r, &g, &b);
  int k;
  scanf("%d", &k);
  int i;
  int min1=10;
  int min2=10;
  for(i=k; i>=0; i--){
    if(r < g*(pow(2,i))){
      min1=i;
    }
  }
  for(i=k; i>=0; i--){
    if(g*(pow(2,min1)) < b*(pow(2,i))){
      min2=i;
    }
  }
  int min=min1+min2;
  if(min > k){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}

Measured memory_bytes: 2424
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		String s = sc.next(); 
		
		// 計算
		String result = "No";
		if(n%2 == 0 && s.substring(0, n/2).equals(s.substring(n/2, n))) result = "Yes";
		
		// 出力
		System.out.println(result);
	}
}


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int n;
    cin >> n;
    static int64_t dist[100000];
    vector<pair<int,int>> edge[100000];
    for(int i=0;i<n-1;i++){
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        edge[u].push_back({v,w});
        edge[v].push_back({u,w});
    }
    queue<int> Q;
    Q.push(0);
    while(!Q.empty()){
        int t = Q.front();
        Q.pop();
        for(auto to : edge[t]){
            if(dist[to.first] != 0) continue;
            dist[to.first] = dist[t] + to.second;
            Q.push(to.first);
        }
    }

    for(int i=0;i<n;i++) cout << dist[i]%2 << endl;
    return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	ll a[n+1];
	for(int i=1; i<=n; i++){
		ll t;
		cin >> t;
		a[t]=i;
	}

	set<ll> s;
	s.insert(0);
	s.insert(n+1);
	ll ans=0;
	for(int i=1; i<=n; i++){
		set<ll>::iterator itr=s.lower_bound(a[i]), itl=itr--;
		ll l=*itl, r=*itr;
		ans+=i*(a[i]-l)*(r-a[i]);
		s.insert(a[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11136
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)



        
def main(): #startline--------------------------------------------
    n,k = map(int,input().split())
    h = list(map(int,input().split()))
    dp = [0]*n

    for i,h_ele in enumerate(h):
        if i > 0:
            p = max(i-k,0)
            dp[i] = min(k+abs(l-h_ele) for k,l in zip(dp[p:i],h[p:i]))

    print(dp[n-1])

if __name__ == "__main__":
    main() #endline===============================================
    

Measured memory_bytes: 15900
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <tuple>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main ()
{
    int N; cin >> N;
    vector<int> b(N);
    REP(i,N) cin >> b[i];

    vector<int> ans;
    while (true) {
        bool flag = false;
        for (int i = (int)b.size() - 1; i >= 0; i--) {
            if (flag) continue;
            if (i + 1 == b[i]) {
                b.erase(b.begin() + i);
                flag = true;
                ans.push_back(i + 1);
            }
        }
        if (!flag) {
            break;
        }
    }

    if (b.size() > 0) {
        cout << -1 << endl;
        return 0;
    }

    reverse(ans.begin(), ans.end());
    for (auto x: ans) cout << x << endl;

    return 0;
}


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

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

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <math.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define ll long long
using namespace std;

unsigned int factorial(unsigned int n){
    if (n==0) return 1;
    else return n*factorial(n-1);
}

int binary_search(vector<int> v,int key){
    int left=-1;
    int right=v.size();
    while(right-left>1){
        int mid=left+(right-left)/2;
        if (v[mid]>=key) right=mid;
        else left=mid;
    }
    return right;
}

int main(){
    int x=0;
    cin>>x;

    if(x==0){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void) {
	int n;
	int total = 0;

	cin >> n;
	
	vector<int> l(2*n);

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

	sort(l.begin(), l.end());

	for (int i = 0; i < 2*n; i += 2) {
		total += l[i];
	}

	cout << total << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner input = new Scanner(System.in);
    final char WALL = '#';
    final int MOD = 1_000_000_000 + 7;
      
    while (input.hasNext()) {
      int H = input.nextInt();
      int W = input.nextInt();
      char[][] grid = new char[H][W];
      
      for (int i = 0; i < grid.length; ++i) {
        grid[i] = input.next().toCharArray();
      }
      
      long[][] ways = new long[H][W];
      ways[0][0] = grid[0][0] != WALL ? 1 : 0;
      for(int i = 1; i < grid[0].length; ++i) {
        if (grid[0][i] != WALL) {
          ways[0][i] += ways[0][i - 1];
        }
      }
      
      for (int i = 1; i < grid.length; ++i) {
        if (grid[i][0] != WALL) {
          ways[i][0] += ways[i - 1][0];
        }
      }
      
      for (int i = 1; i < grid.length; ++i) {
        for (int j = 1; j < grid[i].length; ++j) {
          if (grid[i - 1][j]  != WALL) {
            ways[i][j] += ways[i - 1][j];
            ways[i][j] %= MOD;
          }
          
          if (grid[i][j - 1]  != WALL) {
            ways[i][j] += ways[i][j - 1];
            ways[i][j] %= MOD;
          }
        }
      }
      
      System.out.println(ways[H - 1][W - 1]);
    }
  }
}

Measured memory_bytes: 55500
mod=10**9+7
N=int(input())
Factorial=[1]*(N+1)
for i in range(1,N+1):
  Factorial[i]=Factorial[i-1]*(i)%mod
def power(x,y):
  if y==0:
    return 1
  elif y==1:
    return x%mod
  elif y%2==0:
    return power(x,y//2)**2%mod
  else:
    return (power(x,y//2)**2)*x%mod

inverseFactorial=[1]*(N+1)
inverseFactorial[N]=power(Factorial[N],mod-2)
for i in range(0,N)[::-1]:
  inverseFactorial[i]=(inverseFactorial[i+1]*(i+1))%mod
  
def comb(x,y):
  if x<y or y<0:
    return 0
  else:
    return (Factorial[x]*inverseFactorial[y]*inverseFactorial[x-y])%mod

list=[-1]*N
n=0
for i in input().split():
  if list[int(i)-1]<0:
    list[int(i)-1]=n
    n+=1
  else:
    a=list[int(i)-1]
    b=n-a-1
    c=N-n
for m in range(1,N+2):
    print((comb(a+b+c,m)+2*comb(a+b+c,m-1)-comb(a+c,m-1)+comb(a+b+c,m-2))%mod)

Measured memory_bytes: 70860
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, N = 1e5 + 10;
const ll LINF = LLONG_MAX;


int main() {
    fast();

    ll n;
    cin >> n;
    set<ll>sets;
    ll n1=n;
    for (ll i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            
            if (n/i == i) 
                sets.add(i);
  
            else {
                sets.add(n/i);
                sets.add(i); 
            }
        } 
    }   
    vec re(all(sets));
    if(re.size()==0){
        cout<<n1-1;
        return 0;
    }
    ll r=lower_bound(all(re),sqrt(n1))-re.begin();
    ll s=re[r]+n/re[r]-2;
    cout<<s;

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 640
#include<iostream>
#include<array>
#include<algorithm>
using namespace std;

int main(){

	array<int, 6> t{ {10, 100, 1000, 10000, 100000, 1000000} };
	int a, b;
	while (cin >> a >> b) {
		 int sum;
		 
		 sum = a + b;
		 auto result = find_if(t.begin(), t.end(), [sum](const int x){return sum < x; });
		 auto output = result - t.begin() + 1;
		 cout << output << endl;
	}


	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int binarySearch(vector<int> &array, int l, int r, int v)
{
    int mid = (l + r) / 2;
    if (l == mid)
        return array[mid];
    if (array[mid] == v)
        return array[mid];
    else if (array[mid] > v)
        return binarySearch(array, l, mid, v);
    else
        return binarySearch(array, mid, r, v);
}

int main()
{
    int N, M;
    while (1)
    {
        cin >> N >> M;
        if (N == 0 && M == 0)
            break;
        vector<int> array(N + 1);
        array[0] = 0;
        for (int i = 1; i < N + 1; i++)
        {
            cin >> array.at(i);
        }

        int n = ((N + 2) * (N + 1)) / 2;
        vector<int> darts(n);
        int index = 0;
        for (int i = 0; i < N + 1; i++)
        {
            for (int j = i; j < N + 1; j++)
            {
                darts[j - i + index] = array[i] + array[j];
            }
            index += N + 1 - i;
        }

        sort(darts.begin(), darts.end());

        int sum = 0, max_sum = -1;
        for (int i = 0; i < n; i++)
        {
            sum = darts[i];
            if (sum < M + 1)
            {
                //cout << sum << " " << binarySearch(darts, 0, N, M - sum) << " " << M - sum << endl;
                sum += binarySearch(darts, 0, n, M - sum);
                max_sum = max(sum, max_sum);
            }
        }

        cout << max_sum << endl;
    }
}



Measured memory_bytes: 5040
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 330030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;
using namespace std;

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

  ll n;
  cin>>n;
 ll ans=0;
 for(ll i=2;i*i<=n;i++)
 {
 	if(n%i==0)
 	{
 		ll x,y;
 		x=i-1;
 		y=n/i-1;
 		if(n/x==n%x)
 		ans+=x;
 		if(n%y==n/y)
 		ans+=y;
	 }
 }
 if(n==1)
 {
 	cout<<"0";
 	return 0;
 }
 if(n/(n-1)==1)
 ans+=n-1;
 cout<<ans;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T> ostream& operator<<(ostream &os, const vector<T> &v){os << "{";ITR(i,v){if(i!=v.begin())os << ","; os << *i;}os << "}"; return os;}
template <typename T, typename U> ostream& operator<<(ostream& os, const pair<T,U> &p){os << "(" << p.first << "," << p.second << ")"; return os;}

template <typename T> T& chmin(T &a, const T &b){return a = min(a,b);}
template <typename T> T& chmax(T &a, const T &b){return a = max(a,b);}

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

  vector<char> s(4); cin >> s;
  string ss;
  REP(i,4) ss.push_back(s[i]);
  sort(ALL(ss));
  dump(ss);

  cout << (ss=="1479" ? "YES" : "NO") << endl;

  
  return 0;
}


Measured memory_bytes: 256
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>

// type alias
using lint = long long;
using ldouble = long double;
template <class T>
using greater_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T>>;


/* ----- class ----- */

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Edges = std::vector<Edge<Cost>>;

template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;


/* ----- debug ----- */

#if __has_include("../setting/source/debug.hpp")
#include "../setting/source/debug.hpp"
#endif


/* ----- short functions ----- */

template <class T>
inline T sq(T a) { return a * a; }

template <class T>
inline T iceil(T n, T d) { return (n + d - 1) / d; }

template <class T>
T gcd(T a, T b) {
    while (b > 0) {
        a %= b;
        std::swap(a, b);
    }
    return a;
}

template <class T, class U>
T ipow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= b;
        n >>= 1;
        b *= b;
    }
    return ret;
}

// 0-indexed
template <class T, class U>
inline T kthbit(T a, U k) { return (a >> k) & 1; }

template <class T, class U>
inline T mask(T a, U k) { return a & ((1 << k) - 1); }

template <class T>
std::map<T, int> compress(std::vector<T>& v) {
    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());

    std::map<T, int> rev;
    for (int i = 0; i < v.size(); ++i) rev[v[i]] = i;
    return rev;
}

template <class T>
T Vec(T v) { return v; }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return std::vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}


/* ----- constants ----- */

// const int INF = std::numeric_limits<int>::max() / 3;
// const lint INF = std::numeric_limits<lint>::max() / 3;
// const ldouble PI = acos(-1);
// const ldouble EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));


using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    cout << max({A + B, A - B, A * B}) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;

int main(void){

	string moun;
	int m,h;

	while(1){

		cin>>moun;

		if(moun=="-") break;

		cin>>m;

		for(int i=0;i<m;i++){
			cin>>h;
			moun+=moun.substr(0,h);
			moun=moun.substr(h);
		}
		cout<<moun<<endl;
	}

	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define int long long
int func(int n,int m, vector<vector<int>>v)
{
     
    for(int i=1;i<n;i++)
    {
      for(int j=0;j<3;j++)
    
        v[i][j]+=max(v[i-1][(j+2)%3],v[i-1][(j+1)%3]);
    }
  
    return max({v[n-1][0],v[n-1][1],v[n-1][2]});
}

int32_t main() {
    int m,n,d;
    cin>>n;
  m=3;
    vector< vector<int> >v(n,vector<int>(m)) ;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>d;
            v[i][j]=(d);
    
        }
    }
    cout<<func(n,m,v);
  return 0;
}

Measured memory_bytes: 11136
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
 
using namespace std;

#define mod 1000000007

int main()
{
    int n;
    cin >> n;
    int a[100001];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    long long int nowprice = 2;
    long long int ans = a[0] - 1;
    for(int i = 1; i < n; i++){
        if(nowprice == a[i]){
            nowprice++;
        } else if(nowprice < a[i]){
            ans += (a[i] - 1) / nowprice;
        }
        // cout << a[i] << " " << ans << " " << nowprice << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define mod 1000000007
using namespace std;
#define maxval 10003000

bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{
       if(a.first!=b.first) return(a.first > b.first);
       else return (a.second<b.second);
} 
ll power(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x);
        x=(x*x);
        n=n/2;
    }
    return result;
}
bool isPrime(ll k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    ll i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}


int main(){
   IOS;
ll t;t=1;//cin>>t;
while(t--){
ll n;cin>>n;
string s;cin>>s;
ll end=s.size()-1;
ll g=0;
ll start=0;
for(ll i=0;i<n;i++){
    if(s[i]=='R') g++;

}
for(ll i=0;i<n;i++){
    if(s[i]=='R') start++;
    else break;
}
for(ll j=n-1;j>=0;j--){
    if(s[j]=='W') end--;
    else break;
}
if(start>end){
    cout<<"0\n";return 0;
}
ll w=0;ll r=0;
for(ll i=start;i<=end;i++){
    if(s[i]=='W') w++;
    else r++;
}
ll x=0;ll ans=LONG_MAX;
ans=min(g,n-g);
for(ll i=start;i<=end;i++){
    if(r==0) break;
    if(s[i]=='W'){
        r--;w++;x++;
        ans=min(x+r,ans);
    }
    else {r--;}
}
cout<<min(ans,x+r)<<"\n";
    

}


    
    
    
    





return 0;}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  ll ans=0;
  ans+=n*(n-1)/2;
  ans+=m*(m-1)/2;
  cout<<ans<<endl;
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int i=0; i<n; i++)
#define FOR1(i, n) for(int i=1; i<=n; i++)
#define FORI(i, n) for(int i=n-1; i>=0; i--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, (T)x); }
template<class T, class U, typename... W> void init(vector<T> &v, U x, size_t n, W... m) { v=vector<T>(n);  for(auto& a : v) init(a, x, m...); }

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int T = 1;
//    cin >> T;
    FOR1(tt, T){
        int n, k;
        cin >> n >> k;
        vector<int> p(n+1);
        FOR1(i, n) cin >> p[i];
        vector<int> c(n+1);
        FOR1(i, n) cin >> c[i];

        ll inf = 1e18;
        ll sol = -inf;
        FOR1(i, n){
            int u = i;
            ll s = 0;
            int len = 0;
            do{
                u = p[u];
                s += c[u];
                len++;
                if (len <= k)
                    umax(sol, s);
            }while(u != i);

            if (k >= 3*len) {
                int q = (k - 3*len) / len;
                len += q * len;
                s += q * s;
                umax(sol, s);
            }

            while (len < k) {
                u = p[u];
                s += c[u];
                umax(sol, s);
                len++;
            }
        }
        cout << sol << endl;
    }

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    vector<int> iroha1(3), iroha2 = {5, 5, 7};
    rep(i, 3) cin >> iroha1.at(i);
    sort(all(iroha1));
    if(iroha1==iroha2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    long h, w;
    readlnTo(h, w);
    auto n = readLong();
    auto a = readLongs();

    auto c = new long[][](h, w);
    long[] s;
    foreach(i; iota(n)) {
        s ~= [i+1].cycle().take(a[i]).array;
    }
    
    foreach(i; iota(h)) {
        foreach(j; iota(w)) {
            c[i][j] = s[w*i + j];
        }
        if(i % 2 == 1) {
            c[i].reverse();
        }
    }
    c.each!(a => a.map!(to!string).join(" ").writeln())();

}



Measured memory_bytes: 1404
// #pragma GCC optimize("O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

template<typename T>
void read(vector<T>& vec) {
    for (auto& v : vec) {
        cin >> v;
    }
}

const int mod = 998244353;

ll binpow(ll a, int p) {
	ll res = 1;
	while (p) {
		if (p & 1) {
			(res *= a) %= mod;
		}
		p >>= 1;
		(a *= a) %= mod;
	}
	return res;
}

const int N = 3'005;

ll dp[N][N];

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

	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	dp[a][b] = 1;
	for (int i = a + 1; i <= c; i++) {
		dp[i][b] = dp[i - 1][b] * b % mod;
	}
	for (int j = b + 1; j <= d; j++) {
		dp[a][j] = dp[a][j - 1] * a % mod;
	}
	for (int i = a + 1; i <= c; i++) {
		for (int j = b + 1; j <= d; j++) {
			dp[i][j] = dp[i - 1][j] * j + dp[i][j - 1] * i - dp[i - 1][j - 1] * (i - 1) * (j - 1);
			dp[i][j] = (dp[i][j] % mod + mod) % mod; 
		}
	}
	cout << dp[c][d] << endl;
    return 0;
}


Measured memory_bytes: 73972
// header file section
#include <iostream>
#include <cstdio>
#include <cfloat>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <numeric>
#include <algorithm>

using namespace std;
using llong = long long;

// library section
// ===

llong n, m, k;
llong a[200005];
llong b[200005];

int main() {
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= m; i++) cin >> b[i];

    for (int i = 1; i <= n; i++) a[i] += a[i - 1];
    for (int i = 1; i <= m; i++) b[i] += b[i - 1];

    llong ans = 0;
    for (int i = 0; i <= n; i++) {
        if (a[i] > k) continue;

        llong kk = k - a[i];
        llong valid = 0;
        llong invalid = m + 1;

        while (invalid - valid > 1) {
            llong mid = (valid + invalid) / 2;
            if (b[mid] <= kk) valid = mid;
            else invalid = mid;
        }

        ans = max(ans, i + valid);
    }

    cout << ans << endl;


    return 0;
};


Measured memory_bytes: 6676
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int N;
    cin >> N;
    vector<int> num(N);
    REP(i, N-1) {
        int A;
        cin >> A;
        A--;
        num[A]++;
    }
    REP(i, N) cout << num[i] << "\n";
}

Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll n;
    cin>>n;
    ll a[n+1]={};
    for(int i=0;i<=n;i++){
        cin>>a[i];
    }
    if(n==0){
        if(a[0]==1){
            cout << 1 << endl;
            return 0;
        }
        cout << -1 << endl;
        return 0;
    }
    if(a[0]!=0){
        cout << -1 << endl;
        return 0;
    }
    ll sum[n+2]={};
    for(int i=n;i>=0;i--){
        sum[i] = sum[i+1] + a[i];
    }
    ll now = 1;
    ll ans = 1;
    for(int i=1;i<=n;i++){
        now *= 2;
        chmin(now,sum[i]);
        ans += now;
        now -= a[i];
        if(now < 0){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;

}


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

#define FOR(i,start,end) for(int i=start; i<(int)(end); i++)
#define REP(i,n) FOR(i,0,n)
#define SIZE_OF_ARRAY(array)  (sizeof(array)/sizeof((array)[0]))

template<class T> void print(const T& value) { cout << value << "\n"; }

int main() {

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

    int array[3];
    scanf("%d %d %d", &array[0], &array[1], &array[2]);

    sort(array, array + 3);
    printf("%d %d %d\n", array[0], array[1], array[2]);

    return 0;
}



Measured memory_bytes: 3280
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			for (int k = 1; k <= 9; k++) {
				if (i + j + k > 9) continue;
				string s = string(i, '3') + string(j, '5') + string(k, '7');
				do {
					if (atoi(s.c_str()) <= N) ans++;
				} while (next_permutation(s.begin(), s.end()));
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int a[2][111];
int dp[(1<<18)+11][51];

void amin(int &a, int b)
{
	a=min(a,b);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i&1][i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>a[(i+1)&1][i];
	}
	for(int i=0;i<(1<<n);i++)
	{
		for(int j=0;j<=50;j++)
		{
			dp[i][j]=int(1e9);
		}
	}
	dp[0][0]=0;
	for(int i=0;i<(1<<n);i++)
	{
		for(int k=0;k<=50;k++)
		{
			if(dp[i][k]>=int(1e9)) continue;
			for(int j=0;j<n;j++)
			{
				if(!(i&(1<<j)))
				{
					int v = dp[i][k];
					int cnt = __builtin_popcount(i);
					if(a[cnt&1][j]>=k)
					{
						for(int l=j+1;l<n;l++)
						{
							if(i&(1<<l)) v++;
						}
						amin(dp[i^(1<<j)][a[cnt&1][j]],v);
					}
				}
			}
		}
	}
	int mn=int(1e9);
	for(int i=0;i<=50;i++) mn=min(mn,dp[(1<<n)-1][i]);
	if(mn>=int(1e9)) mn=-1;
	cout<<mn<<'\n';
}


Measured memory_bytes: 52608