akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn = 100005;

int d[maxn];
int xx[maxn],yy[maxn];
int f[maxn];
int pd(int x){
  if(x!=f[x])f[x]=pd(f[x]);
  return f[x];
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    xx[i] = x;
    yy[i] = y;
    d[x]++;
    d[y]++;
  }
  bool has6 = false;
  bool haso = false;
  int cnt4 = 0;
  for(int i=1;i<=n;i++){
    if(d[i]&1){
      haso = true;
      break;
    }
    if(d[i]>=6){
      has6 = true;
    }
    if(d[i]==4)cnt4++;
  }
  if(haso){
    cout<<"No"<<endl;
  } else if(has6||cnt4>2){
    cout<<"Yes"<<endl;
  } else {
    if(cnt4<2){
      cout<<"No"<<endl;
    } else {
      int pos = -1;
      for(int i=1;i<=n;i++)if(d[i]==4){
        pos = i;
        break;
      }
      for(int i=1;i<=n;i++)f[i]=i;
      bool hasc = false;
      for(int i=0;i<m;i++){
        if(pos == xx[i]||pos==yy[i])continue;
        int x = pd(xx[i]);
        int y = pd(yy[i]);
        if(x==y){
          hasc = true;
          break;
        }
        f[x]=y;
      }
      if(hasc)cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1792
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.replace(/\n$/,"")).split("\n");
let s = ["","",""]

function isMatch(s1,s2){
    if(s1 != s2 || s1 == "+") return false
    return true
}

function search(s){
        // 斜め
    let t = s[0][0]
    for(var i = 1;i < 3;++i){
        if(!isMatch(t,s[i][i])) break
        if(i == 2) return t
    }
    t = s[2][0]
    for(var i = 1;i < 3;++i){
        if(!isMatch(t,s[2 - i][i])) break
        if(i == 2) return t
    }
    
    // 横
    for(var i = 0;i < 3;++i){
        t = s[i][0]
        
        for(var j = 1;j < 3;++j){
            if(!isMatch(t,s[i][j])) break
            if(j == 2) return t
        }
    }
    // 縦
    for(var i = 0;i < 3;++i){
        t = s[0][i]
        for(var j = 1;j < 3;++j){
            if(!isMatch(t,s[j][i])) break
            if(j == 2) return t
        }
    }
    return "NA"
}

while(1){
    for(var i = 0;i < 3;++i){
        s[i] = Arr.shift()
    }
    if(s[0] == "0"){
        break
    }
    console.log(search(s))
}


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

using namespace std;
using pii = pair<int,int>;

int countNum(int input){
    int i=1;
    int sum=0;
    while(input >= sum+i){
        sum += i;
        i++;
    }
    return --i;
}

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

    vector<pii> primeFactors;
    int i=2;
    long long n = N;
    while(n != 1){
        if(i > (int)sqrt(N)){
            primeFactors.push_back(pii(N,1));
            break;
        }
        
        if(n%i == 0){
            pii p(i,0);
            while(n%i == 0){
                n /= i;
                p.second++;
            }
            primeFactors.push_back(p);
        }

        if(i == 2)i++;
        else i += 2;
    }

    // for(auto p : primeFactors){
    //     cout << p.first << "^" << p.second << " * ";
    // }
    // cout << endl;

    int res = 0;
    for(auto p : primeFactors){
        res += countNum(p.second);
    }

    cout << res;
}

Measured memory_bytes: 3684
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
static const int MAX_N = 2000;
static const int INF = 1 << 30;

int N, K;
int A[MAX_N - 1], B[MAX_N - 1];
vector<int> G[MAX_N];
int dist[MAX_N];

void bfs(int s){
	dist[s] = 0;
	queue<int> qa;
	qa.push(s);
	while(!qa.empty()){
		int v = qa.front(); qa.pop();
		for(int i = 0; i < G[v].size(); i++){
			if(dist[G[v][i]] != INF) continue;
			dist[G[v][i]] = dist[v] + 1;
			qa.push(G[v][i]);
		}
	}
	return ;
}

void bfs2(int s1, int s2){
	dist[s1] = 0;
	queue<int> qa;
	qa.push(s1);
	while(!qa.empty()){
		int v = qa.front(); qa.pop();
		for(int i = 0; i < G[v].size(); i++){
			if(G[v][i] == s2 || dist[G[v][i]] != INF) continue;
			dist[G[v][i]] = dist[v] + 1;
			qa.push(G[v][i]);
		}
	}
	dist[s2] = 0;
	qa.push(s2);
	while(!qa.empty()){
		int v = qa.front(); qa.pop();
		for(int i = 0; i < G[v].size(); i++){
			if(G[v][i] == s1 || dist[G[v][i]] != INF) continue;
			dist[G[v][i]] = dist[v] + 1;
			qa.push(G[v][i]);
		}
	}
	return ;
}

int main(){
	cin >> N >> K;
	for(int i = 0; i < N - 1; i++){
		cin >> A[i] >> B[i];
		A[i]--; B[i]--;
		G[A[i]].push_back(B[i]);
		G[B[i]].push_back(A[i]);
	}
	int res = N;
	if(K % 2 == 0){
		for(int i = 0; i < N; i++){
			fill(dist, dist + N, INF);
			bfs(i);
			int cnt = 0;
			for(int j = 0; j < N; j++){
				if(dist[j] > K / 2) cnt++;
			}
			res = min(cnt, res);
		}
	}else{
		for(int i = 0; i < N - 1; i++){
			fill(dist, dist + N, INF);
			bfs2(A[i], B[i]);
			int cnt = 0;
			for(int j = 0; j < N; j++){
				if(dist[j] > (K - 1) / 2) cnt++;
			}
			res = min(cnt, res);
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 384
s = int(input())

a = set([s])
ai = s
for i in range(2, 10**6+1):    
    if ai % 2 == 0:
        ai = ai // 2
    else:
        ai = 3 * ai + 1
    if ai in a:
        ans = i
        break
    a.add(ai)
    
print(i)

Measured memory_bytes: 2940
#include<iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
    int n, m;
    cin >> n >> m;
    if (n == m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
'''
https://atcoder.jp/contests/abc150/tasks/abc150_c
'''
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    k, x = map(int, input().split())
    if k*500>=x:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

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

using namespace std;
#define deb(x) cout << #x << ": " << x << endl
#define fo(i, n) for (ll i = 0; i < n; i++)
#define fkn(i, k, n) for (i = k; i < n; i++)
#define ll long long
#define F first;
#define S second;
#define PB(x) push_back(x);
#define MP(x,y) make_pair(x,y);
typedef vector<ll> vll;

bool powerOfTwo(ll x)
{
    return !(x & (x - 1));
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    char al;
    cin>>al;
    if(al >= 97)
    {
        cout << "a";
       

}
else{
    cout << "A";
}
}




Measured memory_bytes: 3640
#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()
typedef long long ll;
template <class T> using vec = vector<T>;
int main() {
    const ll MAXX = 1000000000000001;
    ll N;
    cin >> N;
    vector<ll> v;
    v.push_back(26);
    while(v.back() <= MAXX)v.push_back(v.back() * 26);
    rep(i,v.size()-1)v[i+1] += v[i];
    ll len = 0;
    rep(i,v.size()){
        if(N<=v[i]){
            len = i+1;
            if(i >= 1)N -= v[i-1];
            break;
        }
    }
    string ans = "";
    N--;
    for(int i = 1; i <= len; i++){
        ans.push_back(char('a' + N%26));
        N /= 26;
    }
    reverse(all(ans));
    cout << ans << endl;
}

Measured memory_bytes: 3608
while True:
    n,x=map(int,input().split())
    if n==0 and x==0:
        break
    else:
        count=0
        for i in range(1,n-1):
            for j in range(i+1,n):
                for k in range(j+1,n+1):
                    if i+j+k==x:
                        count=count+1  
    print(count)


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N + 1, 0);
    vector<bool> checked(N + 1, false);
    bool flag = true;
    for (int i = 0; i < M ; i++) {
        int s, c;
        cin >> s >> c;
        if (N != 1 && s == 1 && c == 0) {
            flag = false;
        }
        if (checked[s] && A[s] != c) {
            flag = false;
        }
        A[s] = c;
        checked[s] = true;
    }

    if (flag) {
        for (int i = 1; i <= N; i++) {
            if (N == 1 && !checked[1]) {
                cout << 0;
            } else {
                if (i == 1 && !checked[1]) {
                    cout << 1;
                } else {
                    cout << A[i];
                }
            }
        }
        cout << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import itertools

N = int(input())
X = [list(map(int, input().split())) for i in range(N)]
x = list(itertools.permutations(range(N)))
res = 0
for a in x:
    for i in range(N - 1):
        res += ((X[a[i]][0] - X[a[i + 1]][0]) ** 2 + (X[a[i]][1] - X[a[i + 1]][1]) ** 2) ** 0.5
print(res / len(x))


Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

// ほんとか？

int main() {
	IN(int, n);
	vector<string> s(n);
	cin >> s;
	
	vector<pair<int, int>> v;
	RF(e, s) {
		int sum = 0, mi = 0;
		RF(c, e) {
			if(c == '(') { sum++; } else { sum--; }
			setmin(mi, sum);
		}
		v.EB(mi, sum);
	}
	sort(ALL(v), [](auto x, auto y) -> bool {
		auto [m1, s1] = x;
		auto [m2, s2] = y;
		return (min(m1, s1 + m2) > min(m2, s2 + m1));
	});
	
	int sum = 0, mi = 0;
	bool ans = true;
	for(auto [mm, ss]: v) {
		if(sum + mm < 0) { ans = false; break; }
		sum += ss;
	}
	
	OUT(ans && sum == 0 ? "Yes" : "No");
}


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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T, class Op = multiplies<T>>
constexpr T power(T a, long long n, Op op = Op(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  --n;
  for (int len = 1; ; ++len) {
    if (n < power(26LL, len)) {
      string res;
      for (int _ = len; _--; ) {
        res += 'a' + n % 26;
        n /= 26;
      }
      reverse(begin(res), end(res));
      cout << res << '\n';
      exit(0);
    } else {
      n -= power(26LL, len);
    }
  }
}


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

int main(int argc, char const *argv[])
{
	char n;
	int ans=0;
	for (int i = 0; i < 4; ++i)
	{
		cin>>n;
		if (n=='2')
		{
			++ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main() {
  int n;
  cin >> n;
  while(true) {
    if(IsPrime(n)) {
      cout << n << endl;
      break;
    }
    ++n;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int n,i,count=0;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  int j,mini,p;
  for(i=0;i<n;i++){
    mini = i;
    for(j=i;j<n;j++){
      if (a[j]<a[mini]){
	mini=j;
      }
    }
    if(mini != i){
      p=a[i];
      a[i]=a[mini];
      a[mini]=p;
      count++;
      int t;
      /*for(t=0;t<n;t++){
	printf("%d",a[t]);
	if(t<n-1) printf(" ");
	if (t==n-1) printf("\n");
	}*/
    }
  }
  
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i<n-1) printf(" ");
    if (i==n-1) printf("\n");
  }
  printf("%d\n",count);
  return 0;
}

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

using namespace std;

#define ll long long

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

	ll CDlcm = C * D / __gcd(C, D);

	ll bb = B / C + B / D - B / CDlcm;
	ll aa = (A - 1) / C + (A - 1) / D - (A - 1) / CDlcm;

	cout << B - A + 1 - (bb - aa) << endl;
	return 0;
}


Measured memory_bytes: 256
N,q = list(map(int,input().split(' ')))
que=[]
time=0
for _ in range(N):
    t1,t2 = input().split(' ')
    que.append((t1,int(t2)))
while len(que)!=0:
    task = que.pop(0)
    if task[1] > q:
        ntask = (task[0],task[1] -q)
        que.append(ntask)
        time +=q
    else:
        print(task[0],time+task[1])
        time +=task[1]


Measured memory_bytes: 12236
// ABC170C - 

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	int X, N;
	cin >> X >> N;

	if (N == 0) {
		cout << X << endl;
		return 0;
	}

	int a[102] = {0};
	for (int i= 0; i < N; i++) {
		int p;
		cin >> p;
		a[p] = 1;
	}

	if (a[X] == 0) {
		cout << X << endl;
		return 0;
	}

	int mint = X;
	int maxt = X;
	for (int i = X - 1; i >= 0; i--) {
		if (a[i] == 0) {
			mint = i;
			break;
		}
	}
	for (int i = X + 1; i <= 101; i++) {
		if (a[i] == 0) {
			maxt = i;
			break;
		}
	}

	if (X - mint <= maxt - X) {
		cout << mint << endl;
	} else {
		cout << maxt << endl;
	}


	return 0;
}


Measured memory_bytes: 3636
from collections import defaultdict, deque
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate
import sys


def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007



n, t = LI()
nums = LI()


ret = t
for i in range(len(nums) - 1):
    if nums[i] + t < nums[i+1]:
        ret += t
    else:
        ret += nums[i+1] - nums[i]


print(ret)




Measured memory_bytes: 78292
#include<bits/stdc++.h>
using namespace std;
bool f(int x) {
  int keta = 0;
  while(x) {
    keta++;
    x /= 10;
  }
  return keta%2 == 1;
}


int main(){
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (f(i)) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

const int mod = 998244353;

int mul(int x, int y) {
    return (1LL * x * y) % mod;
}

int power(int a, int b) {
    if (b == 0) {
        return 1 % mod;
    }
    if (b % 2 == 0) {
        return power(mul(a, a), b / 2);
    }
    return mul(a, power(a, b - 1));
}

int inv(int x) {
    return power(x, mod - 2);
}

const int max_f = 300333;

int f[max_f], rf[max_f];

void get_all_f() {
    f[0] = rf[0] = 1;
    for (int i = 1; i < max_f; ++i) {
        f[i] = mul(i, f[i - 1]);
    }
    rf[max_f - 1] = inv(f[max_f - 1]);
    for (int i = max_f - 2; i > 0; --i) {
        rf[i] = mul(i + 1, rf[i + 1]);
    }
}

int get_c(int n, int k) {
    if (n < k) {
        return 0;
    }
    return mul(f[n], mul(rf[k], rf[n - k]));
}

int n, x, y, ans;
long long k;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    get_all_f();
    cin >> n >> x >> y >> k;
    for (int i = 0; i <= n && k >= 0; ++i, k -= x) {
        if (k % y == 0 && k / y <= n) {
            ans += mul(get_c(n, i), get_c(n, k / y));
            ans %= mod;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>

int main(){
  int x[100];
  int p,i,j;
  int n;
  int min = 10000000;
  int sum;
  int t,r;

  scanf("%d", &n);

  for(i = 0;i < n;i++) scanf("%d", &x[i]);

  for(p = 0;p <= 100;p++){
    sum = 0;
    for(i = 0;i < n;i++) sum += (x[i] - p)*(x[i] - p);

    if(sum < min) min = sum;
  }

  printf("%d\n", min);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> PP;
vector<P> g[100005];
int ans[100005];
int num[100005];
  
int main() {
  int n;
  cin >> n;
  for(int i = 0; i < n - 1; i++) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(P(b,i));
    g[b].push_back(P(a,i));
    num[a]++;
    num[b]++;
  }

  int d = 0;
  for(int i = 0; i < n; i++) d = max(d,num[i]); 

  queue<PP> q;
  q.push(PP(P(0,-1),-1));

  while(!q.empty()) {
    PP E = q.front();
    q.pop();
    P e = E.first;
    int c = E.second;
    for(int i = 0; i < g[e.first].size(); i++) {
      if(g[e.first][i].first == e.second) continue;
      q.push(PP(P(g[e.first][i].first,e.first),++c));
      ans[g[e.first][i].second] = c;
    }
  }

  cout << d << endl;
  for(int i = 0; i < n - 1; i++) cout << ans[i] % d + 1 << endl; 

  
}
  
	    


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

using namespace std;

const int N=100;
int a,b;
int v[N+5][N+5];

int dr[]={-1,-1,0,1,1,1,0,-1};
int dc[]={0,1,1,1,0,-1,-1,-1};

int nr;

void put_black(){
    if(b==0)return;
    for(int i=1;i<=nr;i++)
        for(int j=1;j<=2*nr;j++){
            bool ok=1;
            for(int k=0;k<8;k++){
                int rn=i+dr[k];
                int cn=j+dc[k];
                if(v[rn][cn]=='#'){
                    ok=0;
                    break;
                }
            }
            if(ok==1){
                b--;
                v[i][j]='#';
                if(b==0)
                    return;
            }
        }
}

void put_white(){
    if(a==0)return;
    for(int i=nr+1;i<=2*nr;i++)
        for(int j=1;j<=2*nr;j++){
            bool ok=1;
            for(int k=0;k<8;k++){
                int rn=i+dr[k];
                int cn=j+dc[k];
                if(v[rn][cn]=='.'){
                    ok=0;
                    break;
                }
            }
            if(ok==1){
                a--;
                v[i][j]='.';
                if(a==0)
                    return;
            }
        }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>a>>b;
    nr=50;
    for(int i=1;i<=nr;i++)
        for(int j=1;j<=2*nr;j++)
            v[i][j]='.';
    for(int i=nr+1;i<=2*nr;i++)
        for(int j=1;j<=2*nr;j++)
            v[i][j]='#';
    a--;
    b--;
    put_black();
    put_white();
    cout<<2*nr<<" "<<2*nr<<"\n";
    for(int i=1;i<=2*nr;i++){
        for(int j=1;j<=2*nr;j++){
            cout<<char(v[i][j]);
        }
        cout<<"\n";
    }
    return 0;
}
/**



**/


Measured memory_bytes: 256
///
// File:  alds1_10_c.cpp
// Author: ymiyamoto
//
// Created on Tue Oct 17 01:36:16 2017
//

#include <cstdint>
#include <iostream>
#include <string>

using namespace std;
static uint32_t dp[1001][1001];

static void init_dp(uint32_t len1, uint32_t len2)
{
  for (uint32_t i = 0; i < len1; i++) {
    dp[i][0] = 0;
  }
  for (uint32_t i = 0; i < len2; i++) {
    dp[0][i] = 0;
  }
}

int32_t main()
{
  uint32_t n;
  cin >> n;

  for (uint32_t i = 0; i < n; i++) {
    string str1, str2;
    cin >> str1;
    cin >> str2;
    init_dp(str1.size(), str2.size());
    for (uint32_t i = 1; i <= str1.size(); i++) {
      for (uint32_t j = 1; j <= str2.size(); j++) {
        if (str1[i - 1] == str2[j - 1]) {
          dp[i][j] = dp[i - 1][j - 1] + 1;
        } else {
          dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
      }
    }
    cout << dp[str1.size()][str2.size()] << endl;
  }

  return 0;
}

Measured memory_bytes: 7056
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

struct K {
  ll a, b;
};
bool operator<(const K& k1, const K& k2) {
  if(k1.b != k2.b) return k1.b > k2.b;
  return k1.a < k2.a;
}

K vs[100000+10];

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

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

  REP(i, n) {
    cin >> vs[i].a >> vs[i].b;
  }
  sort(vs, vs + n);
  set<int> ss;
  REP(i, m) {
    ss.insert(i);
  }
  ll res = 0;
  REP(i, n) {
    const K& k = vs[i];
    auto it = ss.upper_bound(m - k.a);
    if(it != ss.begin()) {
      --it;
      res += k.b;
      ss.erase(it);
    }
  }
  cout << res << endl;
  
  return 0;
}


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

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

    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
}



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

#define ll long long int

using namespace std;

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

    set<string> t;

    ll n = s.size();
    for (ll i = 0; i < n; ++i) {
        for (ll j = 1; j <= k && i + j <= n; ++j) {
            // cerr << s.substr(i, j) << endl;
            t.insert(s.substr(i, j));
        }
    }

    auto iter = t.begin();
    for (ll i = 1; i < k; ++i) {
        ++iter;
    }

    cout << *iter << endl;
}


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

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

    if(b < a*c){
        cout << b/a << endl;
    }
    else{
        cout << c << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 1020000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 998244353;



typedef pair<P,vl> pp;
ll h,w;
char s[105][105];
map<pair<P,vl>,ll> f;

bool in(ll y, ll x){
	return 0 <= y && y < h && 0 <= x && x < w;
}

int main(){
	cin >> h >> w;
	rep(i,h) rep(j,w) cin >> s[i][j];
	queue<pp> q;
	vl t(6);
	t[0] = 6, t[1] = 1, t[2] = 2, t[3] = 3, t[4] = 5, t[5] = 4;
	f[pp(P(0,0),t)]++;
	q.emplace(P(0,0),t);
	while(!q.empty()){
		auto u = q.front(); q.pop();
		ll y = u.first.first;
		ll x = u.first.second;
		vl v = u.second;
		ll now = s[y][x] - '0';
		rep(i,4){
			ll ny = y + dy[i];
			ll nx = x + dx[i];
			if(s[ny][nx] == '#') continue;
			if(in(ny,nx)){
				vl nnxt(6);
				if(dy[i]==1){
					nnxt[0] = v[2];
					nnxt[1] = v[4];
					nnxt[2] = v[1];
					nnxt[3] = v[3];
					nnxt[4] = v[0];
					nnxt[5] = v[5];
				}else if(dy[i]==-1){
					nnxt[0] = v[4];
					nnxt[1] = v[2];
					nnxt[2] = v[0];
					nnxt[3] = v[3];
					nnxt[4] = v[1];
					nnxt[5] = v[5];
				}else if(dx[i]==1){
					nnxt[0] = v[3];
					nnxt[1] = v[5];
					nnxt[2] = v[2];
					nnxt[3] = v[1];
					nnxt[4] = v[4];
					nnxt[5] = v[0];
				}else if(dx[i]==-1){
					nnxt[0] = v[5];
					nnxt[1] = v[3];
					nnxt[2] = v[2];
					nnxt[3] = v[0];
					nnxt[4] = v[4];
					nnxt[5] = v[1];
				}
				ll nxt = s[ny][nx] - '0';
				if(nxt != nnxt[0]) continue;
				if(f.find(pp(P(ny,nx),nnxt)) == f.end()){
					f[pp(P(ny,nx),nnxt)]++;
					q.emplace(P(ny,nx),nnxt);
				}
			}
		}
	}
	bool flag = false;
	vl vv(6);
	rep(i,6) vv[i] = i+1;
	do{
		if(f.find(pp(P(h-1,w-1),vv)) != f.end()){
			flag = true;
			break;
		}
	}while(next_permutation(all(vv)));
	if(flag) puts("YES");
	else puts("NO");
}


Measured memory_bytes: 4288
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    ll a,b ,v,w,t;
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;
    if(t*(v-w) >= abs(a-b)) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3636
package main

import "fmt"

func main() {
	var n, p int
	fmt.Scan(&n)
	fmt.Scan(&p)

	all := n*3 + p

	var re int
	for {
		if all <= 1 {
			break
		}
		all -= 2
		re++
	}
	fmt.Println(re)
}


Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    ll n, d; cin >> n >> d;
    ll cnt = 0;
    
    rep(i, n){
        ll x, y; cin >> x >> y;
        if(x * x + y * y <= d * d) cnt++;
    }
    cout << cnt << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 3612
import math
A, B, H, M = map(int, input().split())

h = 360 * H / 12 + 30 * M / 60
m = 360 * M / 60

kakudo = h - m
if kakudo >= 180:
  kakudo = 360 - kakudo

ans = A**2 + B**2 - 2 * A * B * math.cos(math.radians(kakudo))

print(math.sqrt(ans))


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

int main() {
    string a,b;
    cin>>a>>b;
    int f=0;
    int l=0,r=0;
    vector<char>v;
    for(int i=0;i<10000;i++){
        if(f%2==0 && l!=a.length()){
            v.push_back(a[l]);
            l++;
            f++;
        }else if(f%2!=0 && r!=b.length()){
            v.push_back(b[r]);
            r++;
            f++;
        }
    }
    for(int i=0;i<v.size();i++)cout<<v[i];
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include<set>
#include<vector>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    int num = 1;
    int ans = 0;
    while(num < b){
            --num;
            num += a;
            ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    X = list(map(int, input().split()))
    result = []
    for n in range(1, 100):
        tmp = 0
        for x in X:
            tmp += (x - n)**2
        result.append(tmp)
    print(min(result))


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(void)
{
	int t[31],f[2],a;
	for(int i=1;i<31;i++){
		t[i]=0;
	}
	
	for(int i=1;i<29;i++){
		cin>>a;
		t[a]=a;
	}
	
	for(int i=1;i<31;i++){
		if(t[i]==0){
			cout<<i<<"\n";
		}
	}
	
	return 0;
}

Measured memory_bytes: 3096
#include<stdio.h>

int main()
{
	int high[10];
	int i, j, temp;
	
	for(i = 0; i < 10; i++){
		scanf("%d",&high[i]);
	}
	
	for (i = 0; i < 10; i++){
		for (j = 9; j > i; j--){
			if (high[j - 1] < high[j]){
				temp = high[j];
				high[j] = high[j - 1];
				high[j - 1]= temp;
			}
		}
	
	}
	printf("%d\n%d\n%d\n",high[0], high[1], high[2]);
	
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define test long long int t; cin>>t; while(t-->0)
#define fIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define loop(n) for(long long int i=0;i<n;i++)
using namespace std;
int main()
{
    fIO
    int n;
    cin>>n;
    int a[n];
    int c=1;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int maxh=a[0];
    for(int i=1;i<n;i++)
    {
        if(a[i]>=maxh)
        {
            maxh=a[i];
            c++;
        }
        
    }
    cout<<c;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn usize() -> usize {
    read()
}

fn vec_usize(n: usize) -> Vec<usize> {
    let mut vec = Vec::new();
    for _ in 0..n {
        vec.push(usize())
    }
    vec
}

fn main() {
    let n = usize();
    let bs = vec_usize(n - 1);
    let mut a = vec![0; n];

    a[0] = bs[0];
    for i in 1..n - 1 {
        a[i] = bs[i - 1].min(bs[i]);
    }
    a[n - 1] = bs[n - 2];
    let sum: usize = a.into_iter().sum();
    println!("{}", sum);
}


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

int main()
{
    int n, k;
    cin >> n >> k;
    long long r[k] = {};
    for(int i=1; i<=n; i++) r[i%k]++;
    
    long long ans = 0;
    for(int i=0; i<k; i++){
        int a = i%k;
        int b = (k-a)%k;
        int c = b;
        if((b+c)%k != 0) continue;
        ans += r[a]*r[b]*r[c];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
a = [[int(i) for i in input().split()] for j in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]

a_true = [[False for i in range(3)] for j in range(3)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if a[j][k] == b[i]:
                a_true[j][k] = True
                
bingo = True

#print(a_true)
#exit()
                
for i in range(3):
    for j in range(3):
        if a_true[i][j] == False:
            bingo = False
            break
    if bingo == True:
        #print(i,j)
        print('Yes')
        exit()
    bingo = True

bingo = True

for i in range(3):
    for j in range(3):
        if a_true[j][i] == False:
            bingo = False
            break
    if bingo == True:
        print('Yes')
        exit()
    bingo = True

if a_true[1][1] == True:
    if a_true[0][0] == True:
        if a_true[2][2] == True:
            print('Yes')
            exit()
    elif a_true[0][2] == True:
        if a_true[2][0] == True:
            print('Yes')
            exit()
else:
    print('No')
    exit()

print('No')

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
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;
}
ll n;
vpl v;
ll memo[2010][2010];
ll dfs(ll l,ll r){
    if(l>r)return 0;
    if(memo[l][r]!=-1)return memo[l][r];
    ll now=n-(r+1-l);
    ll ret1=v[now].fi*abs(v[now].se-l);
    ll ret2=v[now].fi*abs(v[now].se-r);
    ll ret=max(ret1+dfs(l+1,r),ret2+dfs(l,r-1));
    memo[l][r]=ret;
    return ret;
}
int main(){
    cin >> n;
    v.resize(n);
    rep(i,n){
        ll a;cin >> a;
        v[i]={a,i};
    }
    sort(all(v));rev(all(v));
    rep(i,2010)rep(j,2010)memo[i][j]=-1;
    cout << dfs(0,n-1) <<endl;
} 

Measured memory_bytes: 35252
#include <iostream>
#include <ios>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

using i64 = long long;
using P = pair<i64, i64>;

int main(){
    string s;
    cin >> s;
    i64 n = s.length();
    s += 'R';
    i64 l = 0, r;
    vector<i64> ans(n);
    for(int i = 1; i < n + 1; ++i){
        if(s[i] != s[i - 1]){
            if(s[i] == 'L'){
                r = i;
            }else{
                ans[r - 1] = (r - l + 1) / 2 + (i - r) / 2;
                ans[r] = (r - l) / 2 + (i - r + 1) / 2;
                l = i;
            }
        }
    }
    for(int i = 0; i < n; ++i) cout << ans[i] << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int n;
long long f[87];
int main()
{
    cin>>n;
    f[0]=2,f[1]=1;
    for(int i=2;i<=n;i++)f[i]=f[i-1]+f[i-2];
    cout<<f[n];
}

Measured memory_bytes: 256
#include<iostream>
#define ll long long 
using namespace std;
ll knap(ll val[],ll wt[],ll n,ll  w)
{
  ll dp[n+1][w+1];
  for(ll i=0;i<=n;i++)
    for(ll j=0;j<=w;j++)
    {
      if(i==0||j==0)
        	dp[i][j]=0;
      else if(wt[i-1]>j)
           dp[i][j]=dp[i-1][j];
      else
        	dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
                                          }
     return dp[n][w];
}
int main()
{
    ll n,w;
    cin>>n>>w;
    ll val[n],wt[n];
    for(ll i=0;i<n;i++)
        cin>>wt[i]>>val[i];
    ll res=knap(val,wt,n,w);
    cout<<res<<endl;
}
     

Measured memory_bytes: 82384
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};
use std::collections::VecDeque;

fn main() {
    let k: i64 = read();
    let mut vd: VecDeque<i64> = VecDeque::new();
    let mut cnt = 0;
    for i in 1..10 {
        vd.push_back(i);
    }
    let mut current = 0;

    while cnt < k {
        current = vd.pop_front().unwrap();
        cnt += 1;
        // println!("current: {}, cnt: {}", current, cnt);

        if current % 10 != 0 && current % 10 != 9 {
            vd.push_back(current * 10 + (current % 10 - 1));
            vd.push_back(current * 10 + (current % 10));
            vd.push_back(current * 10 + (current % 10 + 1));
        }

        if current % 10 == 0 {
            vd.push_back(current * 10 + (current % 10));
            vd.push_back(current * 10 + (current % 10 + 1));
        }
        if current % 10 == 9 {
            vd.push_back(current * 10 + (current % 10 - 1));
            vd.push_back(current * 10 + (current % 10));
        }
    }
    println!("{}", current);
}


Measured memory_bytes: 6396
(* log(n) (n >= 2) *)
let rec is_divisible n m c =
  if c = 0 then
    true
  else
    if n mod m = 0 then
      is_divisible (n / m) m (c - 1)
    else
      false

(* O(√p * log(p)) *)
let solve n p =
  if n = 1 then
    p
  else (* n >= 2 *)
    let m = int_of_float (floor (sqrt (float_of_int p))) in
    let rec loop g =
      if g <= 1 then
        1
      else
        if is_divisible p g n then
          g
        else
          loop (g - 1)
    in
      loop m (* n >= 2 では g <= m (∵ 指数関数の単調増加性より) *)

let _ = Scanf.scanf "%d %d" (fun n p -> solve n p |> string_of_int |> print_endline)

Measured memory_bytes: 4480
#include<stdio.h>

int main(void)
{
	int a,b[10],c,i,j;
	while(1)
	{
		scanf("%d",&a);
		if(a <= 0)break;
		for(i = 0;i <10;i++)b[i] = 0;
		for(i = 0;i < a;i++)
		{
			scanf("%d",&c);
			b[c] += 1;
		}

		for(i = 0;i < 10;i++)
		{
			if(b[i] == 0)
			{
				printf("-");
			}
			else
			{
				for(j = 0;j < b[i];j++)
				{
					printf("*");
				}
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 572
#include<stdio.h>

int bubbleSort(int A[], int n){
    int flag = 1;
    int i = 0;
    int cnt = 0;
    int j;

    while(flag == 1){
        flag = 0;
        for(j=n-1;j>i;j--){
            if(A[j-1] > A[j]){
                int swap = A[j];
                A[j]=A[j-1];
                A[j-1]=swap;
                flag = 1;
                cnt++;
            }
        }
        i++;
    }
    return cnt;
}


int main(){
    int i, n, ans;
    int A[100];

    scanf("%d", &n);

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

    ans = bubbleSort(A, n);

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

    return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<long long>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  int ans=100000;
  for(int i=0;i<n;i++){
    int cnt=0;
    while(a[i]%2==0){
      a[i]/=2;
      cnt++;
    }
    ans=min(ans,cnt);
}
  cout<<ans<<endl;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
n = int(input())
a = [int(i) for i in input().split()]
ans = [[0 for _ in range(w)] for _ in range(h)]
cnt = 0
idx = 0
color = 1

for i in range(h):
    for j in range(w):
        cnt += 1
        if i%2 == 0:
            ans[i][j] = color
        else:
            ans[i][w-1-j] = color
        if cnt == a[idx] and idx != n-1:
                cnt = 0
                idx += 1
                color += 1

for i in range(h):
    for j in range(w):
        if j != w-1:
            print(ans[i][j],end=" ")
        else:
            print(ans[i][j])

Measured memory_bytes: 3912
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
void vout(vl V) {
	for (ll i = 0; i < (ll)V.size(); i++) cout << V[i] << " ";
	cout << endl;
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color; vll path; vl A; vl dp; vl Ans;
int main(){
	cin >> N;
	vl A(N);
	for (i = 0; i < N; i++) cin >> A[i];
	for (i = 0; i < N; i++) {
		while (A[i] % 2 == 0) {
			A[i] /= 2;
			ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll> 
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,x,ans=1e12,ans_=0;cin>>n>>m>>x;
  lvector price(n,0),understand(m,0);
  vector<lvector> val(n,lvector(m,0));
  rep(i,n) {
    cin>>price[i];
    rep(j,m) cin>>val[i][j];
  }
  for(ll b=0;b<(1<<12);++b) {
    fill(ALL(understand),0);
    ans_=0;
    for(ll book=0;book<n;++book) {
      if(b&(1<<book)) {
        ans_+=price[book];
        rep(i,m) understand[i]+=val[book][i];
      }
    }
    if(*min_element(ALL(understand))>=x) ans=min(ans,ans_);
  }
  print((ans<1e12)?ans:-1);
  return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>
int main(void){

    int sum=0;
    int c = getchar();

    for(int i;i<4;i++){
        switch(c){
        case '+': sum++;
                  break;
        case '-': sum--;
                  break;
        }
        c = getchar();
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 128
//============================================================================
// Name        : d.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
#include<string>
using namespace std;

int main() {
	int h,w;cin>>h>>w;
	vector<string> s(h);
	for(int i=0;i<h;i++){
		cin>>s[i];
	}
	int ans=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			vector<vector<int>> d(h,vector<int>(w,500));
			if(s[i][j]=='#')continue;
			d[i][j]=0;
			for(int k=0;k<500;k++){
				for(int i2=0;i2<h;i2++){
					for(int j2=0;j2<w;j2++){
						if(s[i2][j2]=='#')continue;
						if(i2!=h-1){
							d[i2][j2]=min(d[i2][j2],d[i2+1][j2]+1);
						}
						if(i2){
							d[i2][j2]=min(d[i2][j2],d[i2-1][j2]+1);
						}
						if(j2!=w-1){
							d[i2][j2]=min(d[i2][j2],d[i2][j2+1]+1);
						}
						if(j2){
							d[i2][j2]=min(d[i2][j2],d[i2][j2-1]+1);
						}
					}
				}
			}
			for(int i2=0;i2<h;i2++){
				for(int j2=0;j2<w;j2++){
					if(s[i2][j2]=='#')continue;
					ans=max(ans,d[i2][j2]);
				}
			}
		}

	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#define MAX_N 100
#define MAX_M 100
using namespace std;

int n, m, t_sum, h_sum;
int t[MAX_N], h[MAX_M];

void solve() {
  int sum = 200;
  int t_ans, h_ans;

  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < m; ++j) {
      if(t_sum - t[i] + h[j] == h_sum - h[j] + t[i] && t[i] + h[j] < sum) {
        t_ans = t[i];
        h_ans = h[j];
        sum = t[i] + h[j];
      }
    }
  }
  if(sum == 200) cout << -1 << endl;
  else cout << t_ans << ' ' << h_ans << endl;
}

int main() {
  while(cin >> n >> m && n && m) {
    t_sum = 0, h_sum = 0;
    for(int i = 0; i < n; ++i) {
      cin >> t[i];
      t_sum += t[i];
    }
    for(int i = 0; i < m; ++i) {
      cin >> h[i];
      h_sum += h[i];
    }
    solve();
  }
  return 0;
}



Measured memory_bytes: 3112
#include<iostream>
#include<string>
 
using namespace std;
typedef long long ll;
 
int H, W;
ll cost[10][10];
ll d[10][10];
int in[200][200];
const ll INF = 1145141919810893;
 
int main() {
	cin >> H >> W;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++)cin >> cost[i][j];
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++)cin >> in[i][j];
	}
 
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			if (i == j)d[i][j] = 0;
			else d[i][j] = cost[i][j];
		}
	}
	for (int k = 0; k < 10; k++) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				if (d[i][j] > d[i][k] + d[k][j])d[i][j] = d[i][k] + d[k][j];
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (in[i][j] != -1) {
				ans += d[in[i][j]][1];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384