akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <deque>
#include <stack>
#include <iomanip>
#include <cmath>


using namespace std;


typedef long long ll;
typedef long double ld;


const ll MOD_CONST = 1000000007ll;


ll modSum(ll a, ll b, ll MOD = MOD_CONST) {
  return ((a % MOD) + (b % MOD)) % MOD;
}


ll modSubtract(ll a, ll b, ll MOD = MOD_CONST) {
  return (((a % MOD) - (b % MOD)) + MOD + MOD) % MOD;
}


ll modProd(ll a, ll b, ll MOD = MOD_CONST) {
  return ((a % MOD) * (b % MOD)) % MOD;
}


ll getPowMod(ll x, ll e, ll MOD = MOD_CONST) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    ll tmp = getPowMod(x, e/2, MOD);
    return modProd(tmp, tmp);
  } else {
    ll tmp = getPowMod(x, e-1, MOD);
    return modProd(tmp, x);
  }
}


ll getPow(ll x, ll e) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    ll tmp = getPow(x, e/2);
    return tmp * tmp;
  } else {
    ll tmp = getPow(x, e-1);
    return tmp * x;
  }
}


ll getInverse(ll x, ll MOD = MOD_CONST) {
  return getPowMod(x, MOD-2, MOD);
}


bool isEven(ll x) {
  ll tmp = ((x % 2) + 2) % 2;
  return tmp == 0;
}


ll getSumOfDigitsInBase(ll n, ll b) {
  ll ret = 0;
  while (n > 0) {
    ret += n % b;
    n /= b;
  }
  return ret;
}


vector<int> getKMP(string &s) {
  int len = (int)s.size();
  vector<int> ret (len, 0);
  for (int i = 1 ; i < len ; i++) {
    int at = ret[i-1];
    while (at > 0 && s[i] != s[at]) {
      at = ret[at-1];
    }
    if (s[i] == s[at]) {
      at++;
    }
    ret[i] = at;
  }
  return ret;
}


string getSubstring(string &s, int from, int to) {
  int l = to-from+1;
  if (l <= 0) {
    return "";
  }
  return s.substr(from, l);
}

ll gcd(ll a, ll b, ll & x, ll & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    ll x1, y1;
    ll d = gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}


pair<ll, ll> getIntersectingRange(ll a1, ll b1, ll a2, ll b2) {
  ll s = max(a1, a2);
  ll e = min(b1, b2);

  return {s, e};
}


bool isNonEmptyIntersection(ll a1, ll b1, ll a2, ll b2) {
  auto p = getIntersectingRange(a1, b1, a2, b2);
  return p.first <= p.second;
}













const int MAXN = 100001;


int N;
ll x;
ll ar[MAXN];


void input() {
  cin >> N >> x;
  for (int i = 1 ; i <= N ; i++) {
    cin >> ar[i];
  }
}


void preprocess() {
}


void solve() {
  ll ans = max(0ll, ar[1]-x);
  ar[1] = min(ar[1], x);
  for (int i = 2 ; i <= N ; i++) {
    ans += max(0ll, ar[i] + ar[i-1] - x);
    ar[i] = min(ar[i], x-ar[i-1]);
  }
  cout << ans;
}


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

  int T;
//  cin >> T;
  T = 1;

  for (int i = 0 ; i < T ; i++) {
    input();
    preprocess();
    solve();
  }

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <map>
#include <set>
using namespace std;

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

	int32_t fisrt = -1, last = -1;

	for (size_t i = 0; i < s.size(); i++) {
		if (fisrt < 0 && s[i] == 'A') {
			fisrt = i;
			break;
		}
	}

	for (ssize_t i = s.size() - 1; i >= 0; i--) {
		if (last < 0 && s[i] == 'Z') {
			last = i;
			break;
		}
	}

	cout << (last - fisrt + 1) << endl;

	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int L = scanner.nextInt();
        int[] a = new int[N];
        int sum = 0;
        int min = Integer.MAX_VALUE;
        int cmin = Integer.MAX_VALUE;
        for(int i = 0; i < N; i ++) {
            a[i] = L + i;
            sum += a[i];
            if(cmin > Math.abs(a[i])){
                cmin = Math.abs(a[i]);
                min = a[i];
            }
        }
        System.out.println(sum - min);
    }

}


Measured memory_bytes: 23764
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vi v(n);
	REP(i, n)cin >> v[i];
	sort(ALL(v));
	vi a(n), b(n);
	REP(i, n - 1)a[i + 1] = gcd(a[i], v[i + 1] - v[i]);
	RREP(i, n - 1)b[i] = gcd(b[i + 1], v[i + 1] - v[i]);
	int ans = 0;
	chmax(ans, gcd(b[1], v[1]));
	chmax(ans, gcd(a[n - 2], v[n - 2]));
	REP(i, n - 2) {
		int tmp = gcd(a[i], b[i + 2]);
		tmp = gcd(tmp, v[i + 2] - v[i]);
		tmp = gcd(tmp, v[i + 2]);
		chmax(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1408
n = int(input())
if n & (-n) == n: print('No'); exit(0)
m = n - 1 + n % 2
print('Yes')
l = [(3, 2), (2, 1), (1, 3+n), (3+n, 2+n), (2+n, 1+n)]
for x, y in l:
  print(x, y)
for i in range(4, m+1):
  print(i, 1)
  print((i^1) + n, i)
if n != m:
  t = n & (-n)
  print(n, t)
  print(t^1^n, n*2)

Measured memory_bytes: 5436
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <ctime>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
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;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int 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 = 510000;
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 T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll a,b; cin >> a >> b;
	cout << a*b << endl;
}

Measured memory_bytes: 3644
import unittest


class TestA(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(5, 7, 5), 'Yes')

    def test_2(self):
        self.assertEqual(think(4, 4, 4), 'No')

    def test_3(self):
        self.assertEqual(think(4, 9, 6), 'No')

    def test_4(self):
        self.assertEqual(think(3, 3, 4), 'Yes')


def solve():
    a, b, c = read()
    result = think(a, b, c)
    write(result)


def read():
    return read_int(3)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a, b, c):
    s = set()
    s.add(a)
    s.add(b)
    s.add(c)
    return 'Yes' if len(s) == 2 else 'No'


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 49392
#include <iostream>
#include<string>
using namespace std;
string s[1919];
string t[1919];
int main() {
	int n;
	int a=0, b=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i]>>t[i];
		if (s[i] > t[i]) { a += 3; }
		else if (s[i] < t[i]) { b += 3; }
		else { a++; b++; }
	}
	cout << a << ' ' << b << endl;
}



Measured memory_bytes: 3280
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main()
{
    string s; cin >> s;
    int count = 0;
    rep(i,s.length()) {
        count += s[i] - '0';
    }
    if (count % 9 == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3712
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int ans=2e9,a[100005];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",a+i);
	}
	for(int i=1;i<=n-k+1;i++)
	{
		ans=min(ans,a[i+k-1]-a[i]+min(abs(a[i+k-1]),abs(a[i])));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

class Main{
	static public void main(String[] args){
		Scanner sc=new Scanner(System.in);
		boolean flag=false;
		int K=sc.nextInt();
		int A=sc.nextInt();
		int B=sc.nextInt();
		
		for(int i=A;i<=B;i++){
			if(i%K==0){
				flag=true;break;
			}
			else{
				flag=false;
			}
			
		}
		
		if(flag)System.out.println("OK");
		else System.out.println("NG");
	}
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int K[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6};

int A[15];
//! マッチをn本使った時の文字列の最大長
int dp[10005];

int main()
{
    int N, M;
    cin >> N >> M;
    REP(i, M)
    {
        cin >> A[i];
        A[i]--;
    }

    sort(A, A + M, [](int a, int b) { return K[a] == K[b] ? a > b : K[a] < K[b]; });
    vector<int> t;

    dp[0] = 0;
    REP(i, M)
    {
        dp[K[A[i]]] = 1;
    }
    FOR(i, N + 1, 2)
    {
        int m = dp[i];
        REP(j, M)
        {
            if (i - K[A[j]] < 0)
                continue;
            if (dp[i - K[A[j]]] == 0)
                continue;
            m = std::max(dp[i - K[A[j]]] + 1, m);
        }
        dp[i] = m;
    }
    //! dp復元
    int p = N;
    while (p > 0)
    {
        int max = 0;
        int np = p;
        REP(i, M)
        {
            if (dp[p] - 1 != dp[p - K[A[i]]])
                continue;
            if (dp[p] == 1 && p - K[A[i]] != 0)
                continue;
            if (max < A[i] + 1)
            {
                max = A[i] + 1;
                np = p - K[A[i]];
            }
        }
        t.push_back(max);
        p = np;
    }

    sort(t.begin(), t.end(), [](int a, int b) { return a > b; });
    REP(i, t.size())
    {
        cout << t[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
line = gets
line = line.split(" ")
def abs(n)
	if n<0
		-n
	else
		n
	end
end

def simple_calc(x,y)
	if abs(x)==abs(y)
		if x==y
			0
		else
			1
		end
	elsif x==0
		if y>0
			y
		else
			abs(y)+1
		end
	elsif x>0
		if y>0
			if x>y
				x-y+2
			else
				y-x
			end
		else #y<0
			if x>-y
				x+y+1
			else
				-y-x+1
			end
		end
	else #x<0
		if y>0
			if -x>y
				-y-x+1
			else
				y+x+1
			end
		else #y<0
			if x>y
				2+x-y
			else
				y-x
			end
		end
	end
end
print( simple_calc(line[0].to_i,line[1].to_i) )

Measured memory_bytes: 1788
using static System.Math;
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]); var wmax = int.Parse(line[1]);
        var vaL = new int[n + 1]; var w = new int[n + 1];
        var vmax = readData(vaL, w);
        var dp = new long[n + 1, n * vmax + 1];
        setDP(dp);
        for (int i = 0; i < n; i++)
            for (int j = 0; j <= n * vmax; j++)
                if (j < vaL[i]) dp[i + 1, j] = dp[i, j];
                else dp[i + 1, j] = Min(dp[i, j], dp[i, j - vaL[i]] + w[i]);
        var ans = 0;
        for (int i = 0; i <= n * vmax; i++)
            if (dp[n, i] <= wmax) ans = i;
        Console.WriteLine(ans);
    }
    public static int readData(int[] vaL, int[] w)
    {
        for (int i = 0; i < vaL.Length - 1; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            vaL[i] = int.Parse(line[1]);
            w[i] = int.Parse(line[0]);
        }
        return vaL.Max();
    }
    public static void setDP(long[,] dp)
    {
        var imax = dp.GetLength(1);
        for (int i = 0; i < imax; i++)
            dp[0, i] = 99999999999;
        dp[0, 0] = 0;
    }
}

Measured memory_bytes: 91872
#include <iostream>
#include <utility>
using namespace std;
static const int MOD = 1000000007;
static const int MAX = 666667;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int x, y; cin >> x >> y;
    int out;

    if ((x + y) % 3 != 0) out = 0;
    else if (x * 1.0 / y > 2 || y * 1.0 / x > 2) out = 0;
    else {
        COMinit();
        out = COM((x + y) / 3, (2*x - y) / 3);
    }

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 15872
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		for(int i=1; i<=1100; i++) {
			if(i*8/100==A && i*10/100==B) {
				System.out.println(i);
				sc.close();
				return;
			}
		}
		System.out.println(-1);
		sc.close();
	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,d;
    cin>>n>>d;
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        ll a=pow(x,2)+pow(y,2);
        if(d*d>=a)
        ans++;
        else
        continue;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>

constexpr int TLE = 9999;

int main()
{
	int N, T;
	std::cin >> N >> T;

	int cost = TLE;
	for (int i = 0; i < N; ++i)
	{
		int c, t;
		std::cin >> c >> t;

		if (t <= T && c < cost)
			cost = c;
	}

	if (cost == TLE)
		std::cout << "TLE" << std::endl;
	else
		std::cout << cost << std::endl;

	return 0;
}


Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
def make_divisors(n):
  lower_divisors,upper_divisors=[],[]
  i=1
  while i*i<=n:
    if n%i==0:
      lower_divisors.append(i)
      if i!=n//i:
        upper_divisors.append(n//i)
    i+=1
  return lower_divisors+upper_divisors[::-1]
N=int(input())
t=make_divisors(N)
u=[]
count=0
if N==1:
  print(0)
else:
  for i in range(1,len(t)):
    if 2>len(factorization(t[i])):
      u.append(t[i])
  for i in range(len(u)):
    if N%u[i]==0:
      N=int(N//u[i])
      count+=1
    if N==1:
      break
  print(count)

Measured memory_bytes: 9544
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <string.h>
#include <iomanip>

using namespace std;

int main()
{
	string s;
	cin >>s;
	
	for (int i=0; i<s.size()-1; i++)
	{
		if (s[i] == s[i+1])
		{ 
		cout <<"Bad" <<endl;
		return 0;
		}
	}
	
	cout <<"Good" <<endl;
	
	
	
	
	
	
	
	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
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 long long INF = 1LL << 60;

int main() {
  int N, K; cin >> N >> K;
  long long h[100010];
  for (int i = 0; i < N; ++i) cin >> h[i];
  
  long long dp[100100];
  for (int i = 0; i < 100100; ++i) dp[i] = INF;
  
  dp[0] = 0;
  
  for (int i = 0; i < N; ++i) {
    for (int j = 1; j <= K; ++j) {
      chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
    }
  }
  
  cout << dp[N-1] << endl;
  
  return 0;
}


Measured memory_bytes: 1792
import java.io.*;

public class Main{
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = br.readLine();
		int i, all, tmp;
		int n = s.length();
		int[] result = new int[n];

		for(i=0; i<n-1; i++){
			if( s.charAt(i) == 'R' && s.charAt(i+1) == 'L' ){
				tmp = countLeftR(s, i);
				all = tmp + countRightL(s, i+1, n);
				result[i] = result[i+1] = all/2;
				if( all % 2 == 1 ){
					if( tmp % 2 == 0 )
						result[i+1]++;
					else
						result[i]++;
				}
			}
		}

		System.out.print(result[0]);
		for(i=1; i<n; i++)
			System.out.print(" " + result[i]);
		System.out.println();
	}

	public static int countLeftR(String s, int pos){
		int count = 0;
		for(int i=pos; 0<=i && s.charAt(i) == 'R'; i--)
			count++;
		return count;
	}

	public static int countRightL(String s, int pos, int n){
		int count = 0;
		for(int i=pos; i<n && s.charAt(i) == 'L'; i++)
			count++;
		return count;
	}
}


Measured memory_bytes: 39236
#include <bits/stdc++.h>
#define ll long long
using namespace std;
vector<int>vec;
int grid[101][101];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int n,h,w,a;
    cin>>h>>w>>n;
    vec.resize(n+1);
    for (int i=1;i<=n;i++)
    cin>>vec[i];
    int x=0,y=0,d=1;
    for (int i=1;i<=n;i++){
     while(vec[i]){
       grid[x][y]=i;
        y+=d;
        if (y==w||y==-1){
            d*=-1;
            y+=d;
            x++;
        }
        vec[i]--;
     }
    }
    for (int i=0;i<h;i++){
        for (int j=0;j<w;j++)
            cout<<grid[i][j]<<" ";
            cout<<endl;
    }
    return 0;

}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <time.h>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;

#define rep(i, n) for (i = 0; i < n; i++)
#define all(c) (c).begin(), (c).end()
#define P pair<int, int>

int main()
{
  int n;
  cin >> n;
  map<string, int> mp;
  string s;
  for (int i = 0; i < n; i++)
  {
    cin >> s;
    mp[s]++;
  }

  int mx = 0;
  for (auto el : mp)
  {
    mx = max(mx, el.second);
  }

  for (auto el : mp)
  {
    if (el.second == mx)
    {
      cout << el.first << endl;
    }
  }
}


Measured memory_bytes: 25216
#include <stdio.h>

int N, T[112345], M, P[112], X[112];
int sum = 0;
int ans = 0;

int main(void) {
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) { scanf("%d", &T[i]); }
	scanf("%d", &M);
	for (int i = 0; i < M; ++i) { scanf("%d%d", &P[i], &X[i]); }

	for (int i = 0; i < N; ++i) { sum += T[i]; }
	for (int i = 0; i < M; ++i) {
		printf("%d\n", sum - (T[P[i] - 1] - X[i]));
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

const long double EPS = 0.0000001;

int main(){
	int H,W;
	char a[502][502];
	char b[502][502],c[502][502];
	scanf("%d%d",&H,&W);
	for(int i = 0 ; i < H ; i ++){
		scanf("\n");
		for(int j = 0 ; j < W ; j ++){
			scanf("%c",&a[i][j]);
		}
	}
	
	for(int i = 0 ; i < H ; i ++){
		for(int j = 0 ; j < W ; j ++){
			b[i][j] = '.';
			c[i][j] = '.';
		}
	}
	
	for(int j = 0 ; j < W ; j ++){
		b[0][j] = '#';
		c[H-1][j] = '#';
	}
	for(int i = 1 ; i <= H-2 ; i ++){
		for(int j = 0 ; j < W ; j ++){
			if(j&1){
				b[i][j] = '#';
			}
			else c[i][j] = '#';
			if(a[i][j] == '#'){
				b[i][j] = '#';
				c[i][j] = '#';
			}
		}
	}
	
	for(int i = 0 ; i < H ; i ++){
		for(int j = 0 ; j < W ; j ++){
			printf("%c",b[i][j]);
		}
		printf("\n");
	}
	printf("\n");
	for(int i = 0 ; i < H ; i ++){
		for(int j = 0 ; j < W ; j ++){
			printf("%c",c[i][j]);
		}
		printf("\n");
	}
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main() {
  ll N,cnt=0;
  cin>>N;
  vector<ll> A(N);
  rep0(i,N){cin>>A[i];}
  //shellSort
  ll m=19;
  vector<ll> G={N/2,N/4,N/8,N/16,N/32,N/64,N/128,N/256,N/512,N/1024,N/2048,N/4096,N/8192,N/16384,N/32768,N/65536,N/131072,N/262144,N/524288};
  //insertionSort (A,n,g)
  for(ll k=0;k<m;k++){
  for(ll i=G[k];i<N;i++){
        ll v=A[i],j=i-G[k];
        while(j>=0&&A[j]>v){
            A[j+G[k]]=A[j];
            j=j-G[k];
            cnt++;
            A[j+G[k]]=v;
        }
    }
  }
    cout<<m<<endl;
    rep0(i,m){if(i!=m-1){cout<<G[i]<<" ";} else{cout<<G[i]<<endl;}}
  cout<<cnt<<endl;
    rep0(i,N){cout<<A[i]<<endl;}
}


Measured memory_bytes: 10664
// AOJ 2135 Reverse a Road
// 2018.2.26 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define QMAX 15000
typedef struct { short t, s, r; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && (que[l].t < que[i].t ||
		que[l].t == que[i].t && que[l].r < que[i].r)) min = l; else min = i;
	if (r < qsize && (que[r].t < que[min].t ||
		que[r].t == que[min].t && que[r].r < que[min].r)) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t, int r)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t, que[i].r = r;
	while (i > 0 && (que[min = PARENT(i)].t > que[i].t ||
		   que[min].t == que[i].t && que[min].r > que[i].r)) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

short hi[1002], *to[1002], *no[1002]; char *re[1002];
char mk[1002][1002][2];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int dijkstra(int *rno, int start, int goal)
{
	int i, s, t, r, e, k, f;

	memset(mk, 0, sizeof(mk));
	qsize = 0;
	enq(start, 0, 0);
	while (qsize) {
		s = que[0].s, t = que[0].t, r = que[0].r, deq();
		if (s == goal) { *rno = r; return t; }

		if (r == 0) {
			for (i = 0; i < hi[s]; i++) {
				e = to[s][i], k = no[s][i], f = re[s][i];
				if (f == 0) {
					if (!mk[e][k][0]) mk[e][k][0] = 1, enq(e, t+1, 0);
				} else {
					if (!mk[s][k][1]) mk[s][k][1] = 1, enq(e, t+1, k);
				}
			}
		} else {
			for (i = 0; i < hi[s]; i++) {
				e = to[s][i], k = no[s][i], f = re[s][i];
				if (f || mk[e][k][1]) continue;
				mk[e][k][1] = 1, enq(e, t+1, r);
			}
		}
	}
	return -1;
}

int main()
{
	int N, S, T, M, a, b, i, j, k, ans;
	short *memo;

	while (N = in()) {
		N++, S = in(), T = in();
		M = in();

		memset(hi, 0, N << 1);
		memo = malloc(M << 2);
		j = 0, i = M; while (i--) {
			memo[j++] = a = in(), memo[j++] = b = in();
			hi[a]++, hi[b]++;
		}

		for (a = 0; a < N; a++) if (hi[a]) {
			to[a] = malloc(hi[a] << 1);
			no[a] = malloc(hi[a] << 1);
			re[a] = malloc(hi[a]);
		}
		memset(hi, 0, N << 1);
		j = 0; for (i = 1; i <= M; i++) {
			a = memo[j++], b = memo[j++];
			k = hi[a]++, to[a][k] = b, no[a][k] = i, re[a][k] = 0;
			k = hi[b]++, to[b][k] = a, no[b][k] = i, re[b][k] = 1;
		}
		free(memo);

		ans = dijkstra(&k, S, T);
		printf("%d %d\n", ans, k);
	}
	return 0;
}


Measured memory_bytes: 5064
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var list = new Array(3);
  list[0] = myconv(next(),4);
  list[1] = myconv(next(),4);
  list[2] = myconv(next(),4);
  var N = myconv(next(),1);
  for(var i = 0; i < N; i++){
    var tmp = myconv(next(),1);
    for(var j = 0; j < 3; j++){
      for(var k = 0; k < 3; k++){
        if(list[j][k] == tmp){
           list[j][k] = 0;
        }
      }
    }
  }
  if(list[0][0] == 0 && list[0][1] == 0 && list[0][2] == 0){
     myout("Yes");
    return;
  }
  if(list[1][0] == 0 && list[1][1] == 0 && list[1][2] == 0){
     myout("Yes");
    return;
  }
  if(list[2][0] == 0 && list[2][1] == 0 && list[2][2] == 0){
     myout("Yes");
    return;
  }
  if(list[0][0] == 0 && list[1][0] == 0 && list[2][0] == 0){
     myout("Yes");
    return;
  }
  if(list[0][1] == 0 && list[1][1] == 0 && list[2][1] == 0){
     myout("Yes");
    return;
  }
  if(list[0][2] == 0 && list[1][2] == 0 && list[2][2] == 0){
     myout("Yes");
    return;
  }
  if(list[0][0] == 0 && list[1][1] == 0 && list[2][2] == 0){
     myout("Yes");
    return;
  }
  if(list[0][2] == 0 && list[1][1] == 0 && list[2][0] == 0){
     myout("Yes");
    return;
  }
  myout("No");
}


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

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

  if (s == "SUN") {
      ans = 7;
  } else if (s == "MON") {
      ans = 6;
  } else if (s == "TUE") {
      ans = 5;
  } else if (s == "WED") {
      ans = 4;
  } else if (s == "THU") {
      ans = 3;
  } else if (s == "FRI") {
      ans = 2;
  } else if (s == "SAT") {
      ans = 1;
  } else {
      ans = 100;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
D=list(input().split())

temp=N
f=False
while f==False:
    num=set(list(str(temp)))
    f=True
    for i in num:
        if i in D:
            f=False
            break
    if f==True:
        print(temp)
        exit()
    temp+=1


Measured memory_bytes: 2940
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

int decode(char c){
  if ('A' <= c && c <= 'Z')
    return c - 'A';
  if ('a' <= c && c <= 'z')
    return c - 'a' + 26;
  if ('0' <= c && c <= '9')
    return c - '0' + 52;
  if (c == '+')
    return 62;
  if (c == '/')
    return 63;
}

uint64_t pw(uint64_t base, uint64_t index) {
  if (index == 0) return 1;
  if (index % 2) return base * pw(base, index - 1);
  return pw(base*base, index/2);
}

uint64_t calch(vector<vector<bool>>& pa, uint64_t a, uint64_t b){
  int p=pa.size();
  vector<uint64_t> prh1(p);
  REP(i,p){
    REP(j,p){
      prh1[i] *= a;
      prh1[i] += pa[i][j];
    }
  }
  uint64_t prh2 = 0;
  REP(i,p){
    prh2 *= b;
    prh2 += prh1[i];
  }
  return prh2;
}

int main() {
  while(1){
    int w,h,p;
    cin>>w>>h>>p;
    if(!w)break;
    if (w<p || h<p) {
      cout<<0<<endl;
      REP(i,h+p) {
        string line;
        cin >> line;
      }
      continue;
    }
    vector<vector<bool>> t(h,vector<bool>(w));
    int wd6 = (w+5)/6;
    REP(i,h){
      string line;
      cin>>line;
      REP(j,wd6){
        int val = decode(line[j]);
        REP(k,6){
          if(j*6+k >= w) break;
          t[i][j*6+k] = (val >> (5-k)) & 1;
        }
      }
    }
    vector<vector<uint64_t>> rh1(h, vector<uint64_t>(w-p+1));
    uint64_t a = 353;
    uint64_t ap = pw(a, p);
    REP(i,h){
      REP(j,p){
        rh1[i][0] *= a;
        rh1[i][0] += t[i][j];
      }
      REP(j,w-p)
        rh1[i][j+1] = t[i][j+p] + rh1[i][j] * a - t[i][j] * ap;
    }
    vector<vector<uint64_t>> rh2(w-p+1, vector<uint64_t>(h-p+1));
    uint64_t b = 557;
    uint64_t bp = pw(b, p);
    REP(i,w-p+1){
      REP(j,p){
        rh2[i][0] *= b;
        rh2[i][0] += rh1[j][i];
      }
      REP(j,h-p)
        rh2[i][j+1] = rh1[j+p][i] + rh2[i][j] * b - rh1[j][i] * bp;
    }
    int pd6 = (p+5)/6;
    vector<vector<bool>> pa(p,vector<bool>(p));
    REP(i,p){
      string line;
      cin>>line;
      REP(j,pd6){
        int val=decode(line[j]);
        REP(k,6){
          if (j*6+k >= p) break;
          pa[i][j*6+k] = (val >> (5-k)) & 1;
        }
      }
    }
    set<uint64_t> hs;
    REP(i,4){
      hs.insert(calch(pa, a, b));
      vector<vector<bool>> rv=pa;
      for (auto& v:rv) reverse(begin(v),end(v));
      hs.insert(calch(rv, a, b));
      REP(j,(p+1)/2){
        REP(k,p/2){
          bool tmp = pa[j][k];
          pa[j][k] = pa[k][p-j-1];
          pa[k][p-j-1] = pa[p-j-1][p-k-1];
          pa[p-j-1][p-k-1] = pa[p-k-1][j];
          pa[p-k-1][j] = tmp;
        }
      }
    }
    int sum = 0;
    for (auto& v: rh2)
      for (auto hv: hs)
        sum += count(begin(v),end(v),hv);
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 14840
#include<stdio.h>

int main(){

    int a,b,d,r;
    double f;

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

    d = a/b;
    r = a%b;
    f =1.0* a/b;

    printf("%d %d %.5f\n",d,r,f);

    return 0;
}


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

int main() {
  int n;
  unsigned long long int s = 0;
  cin >> n;
  for (int i=0; i<n+1; i++) {
    if(i%5!=0 && i%3!=0) {
      s += i;
    }
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3532
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

vector<int> get_prime(int n){
    bool is_prime[n+1];
    is_prime[0]=false;
    is_prime[1]=false;
    for(int i=2; i<=n; i++) is_prime[i]=true;
    for(int i=2; i*i<=n; i++){
        if(is_prime[i]){
            for(int j=2*i; j<=n; j+=i){
                is_prime[j]=false;
            }
        }
    }
    vector<int> p;
    for(int i=2; i<=n; i++){
        if(is_prime[i]) p.push_back(i);
    }
    return p;
}

int main(){
	ll n;
	cin >> n;
	vector<int> p=get_prime(n), p_cnt(p.size(),0);
	for(int i=2; i<=n; i++){
        int t=i;
		for(int j=0; j<p.size(); j++){
			while(t>1 && t%p[j]==0){
                t/=p[j];
                p_cnt[j]++;
			}
		}
	}
    vector<int> c(5,0);
    for(int i=0; i<p.size(); i++){
        if(p_cnt[i]>=74) c[0]++;
        if(p_cnt[i]>=24) c[1]++;
        if(p_cnt[i]>=14) c[2]++;
        if(p_cnt[i]>=4) c[3]++;
        if(p_cnt[i]>=2) c[4]++;
    }
    cout << c[0]+c[1]*(c[4]-1)+c[2]*(c[3]-1)+c[3]*(c[3]-1)*(c[4]-2)/2 << endl;
	return 0;
}

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

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
  int n,x,y;
  cin>>n;
  x=n*800;
  y=(n/15)*200;
  cout<<x-y<<endl;
}

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

void ng() {
  puts("-1");
  exit(0);
}

int main() {
  int n;
  ll tot = 0;
  cin >> n;
  vector<int> d(n + 1);
  for (int i = 0; i <= n; i++) {
    cin >> d[i];
    tot += d[i];
  }
  ll now = 1, ans = 0;
  for (int i = 0; i <= n; i++) {
    if (now < d[i]) {
      printf("-1\n");
      return 0;
    }
    ans += now;
    now -= d[i];
    tot -= d[i];
    now = min(now * 2, tot);
  }
  cout << ans << endl;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> ii;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vii;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<vector<ld>> vvld;
typedef vector<bool> vbl;
typedef vector<vbl> mbl;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(s) (s).begin(), (s).end()
const ll MOD = 1e9 + 7;

// Nice one AtCoder, nice one.
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int x;
    cin >> x;
    int a = -120, b = -120;
    for (int i = a; i <= 120; i++)
    {
        for (int j = a; j <= 120; j++)
        {
            if (i*i*i*i*i -j*j*j*j*j == x)
            {
                cout << i <<  ' ' << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3648
#include <iostream>
#include <cmath>

using namespace std;

unsigned int tanri(unsigned int moto, int tosi, int tesu, double nenri) {
	int risi = 0;
	for (int i = 0; i < tosi; i++) {
		risi += (double)moto * nenri;
		moto -= tesu;
	}
	//cout << moto+risi << endl;
	return moto+risi;
}

unsigned int fukuri(unsigned int moto, int tosi, int tesu, double nenri){
	for (int i = 0; i < tosi; i++) {
		moto += (double)moto * nenri;
		moto -= tesu;
	}
	//cout << moto << endl;
	return moto;
}

int main() {
	int n;

	cin >> n;
	for (int i = 0; i < n; i++) {
		unsigned int moto;
		int year;
		cin >> moto >> year;
		int m;
		cin >> m;
		int tf;
		double nritu;
		int tryo;
		unsigned int maxkane = 0;
		for (int j = 0; j < m; j++) {
			cin >> tf >> nritu >> tryo;
			if (tf == 0) {
				maxkane = max(maxkane, tanri(moto, year, tryo, nritu));
			} else {
				maxkane = max(maxkane, fukuri(moto, year, tryo, nritu));
			}
		}
		cout << maxkane << endl;
	}

	return 0;
}

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

int main(){

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

	int cnt = 0;
	for(int i=0; i<n; i++){
		if( t[i] < a || b <= t[i] ) cnt++;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  int a, ans=INF;
  REP(i,n) {
    cin >> a;
    int c=0;
    while(a%2==0) { c++; a/=2; }
    ans=min(ans,c);
  }
  COUT(ans);
  return 0;
}

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

int main()
{
    int a,b;
    cin>>a>>b;
    if (a>b)
        cout<<"a > b"<<endl;
    if(a<b)
        cout<<"a < b"<<endl;
    if(a==b)
        cout<<"a == b"<<endl;

    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  vector<vector<char>> a(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a.at(i).at(j);
    }
  }
  vector<bool> H(h,true);
  vector<bool> W(w,true);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(a.at(i).at(j)=='#'){
        H.at(i)=false;
        W.at(j)=false;
      }
    }
  }
  for(int i=0;i<h;i++){
    if(H.at(i))continue;
    for(int j=0;j<w;j++){
      if(W.at(j))continue;
      cout<<a.at(i).at(j);
    }
    cout<<endl;
  }
  return 0;
}

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

int main() {
  int k,x;
  cin >> k >> x;
  if(500*k>=x) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
using System;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var input = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int ans = 0;
            input[0] -= input[2];
            while (input[0] >= input[1] + input[2])
            {
                ans++;
                input[0] -= input[1] + input[2];
            }
            Console.WriteLine(ans);
        }
    }
}

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

int main() {
	int x,y,a,b,c;cin>>x>>y>>a>>b>>c;
  vector<int64_t> p(a),q(b),r(c);
  rep(i,a)cin>>p[i];
  rep(i,b)cin>>q[i];
  rep(i,c)cin>>r[i];
  sort(all(p),greater<int64_t>());
  sort(all(q),greater<int64_t>());
  
  vector<int64_t> s(x+y+c);
  rep(i,x)s[i]=p[i];
  rep(i,y)s[x+i]=q[i];
  rep(i,c)s[x+y+i]=r[i];
  sort(all(s),greater<int64_t>());

  int64_t sum=0;
  rep(i,x+y)sum+=s[i];

  cout<<sum;
  
  

}

Measured memory_bytes: 4736
S = input()
T = input()
cnt = len(S)-len(T)+1
res = []
for i in range(cnt):
    res2 = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            res2 += 1
    res.append(res2)
print(min(res)) 

Measured memory_bytes: 9092
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int func1(string line) {
    int res=0;
    rep(i,line.size()) {
        if(i==0) res=line[0]-'0';
        else if(i%2==1) {
            if(line[i]=='+') {
                res+=line[i+1]-'0';
            }
            else {
                res*=line[i+1]-'0';
            }
            i++;
        }
    }
    return res;
}
template<class T>
string to_s(T x) {
    stringstream ss;
    ss<<x;
    return ss.str();
}
int to_i(string s) {
    int res;
    stringstream ss;
    ss<<s;
    ss>>res;
    return res;
}
int func2(string line) {
    vector<string> vec;
    set<int> S;
    bool f[20]={};
    rep(i,line.size()) {
        if(line[i]=='*') {
            f[i-1]=1;
            f[i]=1;
            f[i+1]=1;
        }
    }
    int x=1,idx=0;
    while(idx<20) {
        while(!f[idx]&&idx!=20) idx++;
        if(idx==20) break;
        while(f[idx]) {
            if(isdigit(line[idx])) {
                x*=(line[idx]-'0');
                S.insert(idx);
            }
            idx++;
        }
        vec.pb(to_s(x));
        x=1;
    }

    rep(i,line.size()) {
        if(!S.count(i)) {
            if(line[i]!='+'&&line[i]!='*') vec.pb(to_s(line[i]));
        }
    }
    int res=0;
    rep(i,vec.size()) res+=to_i(vec[i]);
    return res;
}
string line;
int x;
int main() {
    cin>>line;
    cin>>x;
    int x1=func1(line);
    int x2=func2(line);

    if(x==x1&&x==x2) {
        cout<<"U"<<endl;
    }
    else if(x==x1) {
        cout<<"L"<<endl;
    }
    else if(x==x2) {
        cout<<"M"<<endl;
    }
    else {
        cout<<"I"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1244
from collections import deque
S = deque(list(input()))
Q = int(input())
re = 0
for i in range(Q):
    X = input().split()
    if X[0] == "1":
        re += 1
    else:
        if (int(X[1]) + re)%2 == 1:
            S.appendleft(X[2])
        else:
            S.append(X[2])
while S:
    if re % 2:
        print(S.pop(),end = "")
    else:
        print(S.popleft(),end = "")
print()


Measured memory_bytes: 7520
#include <stdio.h>
 
int cmp(const void *p,const void *q) {
    return *(int*)q-*(int*)p;
}
 
int main(void) {
	int i;
	int h[10];
	for(i=0;i<10;i++) scanf("%d",&h[i]);
	qsort(h,10,sizeof(int),cmp);
	for(i=0;i<3;i++) 
	printf("%d\n",h[i]);
	return 0;
}

Measured memory_bytes: 604
k = int(input())

s = 0
for i1 in range(1, k+1):
    for i2 in range(1, i1+1):
        x1, x2 = i1, i2
        while x2 != 0:
            x1, x2 = x2, x1 % x2
        gcd1 = x1
        s2 = i1 == i2
        for i3 in range(i1, k+1):
            x1, x2 = gcd1, i3
            while x2 != 0:
                x1, x2 = x2, x1 % x2
            gcd2 = x1

            s3 = i2 == i3 or i1 == i3
            if s2 and s3:
                s = s + gcd2
            elif s2 or s3:
                s = s + gcd2*3
            else:
                s = s + gcd2*6
print(s)


Measured memory_bytes: 9212
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int a[4]={},mn,i,j,n,m;
	string s;
	cin>>s;
	int l=s.length();
	FOR(i,0,l){
		a[(s[i]-'a')]++;
	}
	mn=a[0];
	if(a[1]<mn)mn=a[1];
	if(a[2]<mn)mn=a[2];
	a[0]-=mn;
	a[1]-=mn;
	a[2]-=mn;
	if(a[0]<2&&a[1]<2&&a[2]<2)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;

    return 0;
}


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

int main()
{
	int n;
	int a[3][3];
	int b[10];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}

	for (int k = 0; k < n; k++) {
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (b[k] == a[i][j]) {
					a[i][j] -= b[k];
				}
			}
		}
	}

	bool suc = false;
	for (int i = 0; i < 3; i++) {
		if ((a[i][0] == 0) && (a[i][1] == 0) && (a[i][2] == 0)) {
			suc = true;
			break;
		}
		if (((a[0][i]) == 0) && ((a[1][i]) == 0) && ((a[2][i]) == 0)) {
			suc = true;
			break;
		}
		if ((a[0][0] == 0) && (a[1][1] == 0) && (a[2][2] == 0)) {
			suc = true;
			break;
		}
		if ((a[0][2] == 0) && (a[1][1] == 0) && (a[2][0] == 0)) {
			suc = true;
			break;
		}
	}
	cout << (suc ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <set>
#include <string>
#include <cstring>
using namespace std;
#define LL long long
const int maxn = 110;
int a[maxn];
int dp[20][16 * 9 + 100][2];
int dfs(int pos,int sum,int limit){
  if (pos == -1)
  {
     return sum;
  }
  if (dp[pos][sum][limit] != -1) return dp[pos][sum][limit];
  int up = limit ? a[pos] : 9;
  int ans = 0;
  for (int i = 0; i <= up; i++){
      ans = max(dfs(pos - 1,sum + i,limit && a[pos] == i),ans);
  }
  //cout<<ans<<endl;
  dp[pos][sum][limit] = ans;
  return ans;

}
int solve(LL n){
    int pos = 0;
    while (n)
    {
        a[pos++] = n % 10;
        n /= 10;
    }
    return dfs(pos - 1,0,1);
} 
int main(){
  LL n;
  memset(dp,-1,sizeof(dp));
  scanf("%lld",&n);
  printf("%d\n",solve(n));
}

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

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

int main() {
	string s;cin>>s;
	int ans=0;
	if(s[0]=='A'){
		if(s[1]=='B'||s[2]=='B'){
			ans=1;
		}
	}else{
		if(s[1]=='A'||s[2]=='A'){
			ans=1;
		}
	}
	if(ans){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256