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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

void print(deque <ll> &q)
{
    for(deque<ll>::iterator it = q.begin(); it != q.end(); ++it)
    {
        cout << *it << ' ';
    }
    cout << '\n';
}

int main()
{
    int k;

    cin >> k;

    deque<ll> deq;

    if(k <= 9){cout << k << '\n';return 0;}

    for(ll i = 1; i <= 9LL; ++i)
    {
        deq.push_back(i);
    }

    int brojac = 9;

    while(brojac != k)
    {
        ll x = deq.front();

        if(x % 10 != 0)
        {
            deq.push_back(x*10LL+(x%10-1LL));
            ++brojac;
            if(brojac==k)break;
        }
        deq.push_back(x*10LL+x%10);
        ++brojac;
        if(brojac==k)break;
        //print(deq);
        if(x % 10 != 9)
        {
            deq.push_back(x*10LL+(x%10+1LL));
            ++brojac;
        }
        deq.pop_front();
        //print(deq);
    }

    cout << deq.back() << '\n';

    return 0;
}


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

int main() {
  
  int N, K, ans;
  cin >> N >> K;
  ans = 1;
  
  for (int i = 0; i < N; i++) {
    if (ans * 2 <= ans + K) {
      ans *= 2;
    }
    else {
      ans += K;
    }
  }
  
  cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

	int a, b;
	int road[n];

	for (int i = 0; i < n; i++) {
		road[i] = 0;
	}

	for (int i = 0; i < m; i++) {
	
		cin >> a >> b;
		road[a - 1]++;
		road[b - 1]++;
	}
	
	for (int i = 0; i < n; i++) {
		cout << road[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import queue

INF = 10 ** 10

H, W = map(int, input().split())

costs = [[-1] * (W+2)]
for _ in range(H):
    costs.append([-1] + list(map(lambda c: -1 if c == '#' else INF, input())) + [-1])
costs.append([-1] * (W+2))

num_of_white = sum(row.count(INF) for row in costs)

togo = queue.Queue()
togo.put((1, 1))
costs[1][1] = 1

arrived = False
while not togo.empty():
    x, y = togo.get()
    
    if x == H and y == W:
        arrived = True
        break
    
    for dx, dy in ((-1, 0), (1, 0), (0, -1), (0, 1)):
        if costs[x+dx][y+dy] > costs[x][y] + 1:
            costs[x+dx][y+dy] = costs[x][y] + 1
            togo.put( (x+dx, y+dy) )

if arrived:
    print(num_of_white - costs[H][W])
else:
    print(-1)

Measured memory_bytes: 42600
#include "iostream"
using namespace std;

int main()
{

	while (1) {
		int k = 0;
		int total = 0;
		int NA = 1;
		int left[10000] = { 0 };
		cin >> k;
		if (k == 0) {
			break;
		}
		for (int i = 0; i < k; i++) {
			cin >> left[i];
			if (left[i] >= 2)
				NA = 0;
			if (left[i] >= 1)
				total++;
		}
		if (NA == 1) {
			cout << "NA" << endl;
		}
		else {
			cout << total + 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <cassert>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

int gcd(int x, int y) {
    if (!y) return x;
    return gcd(y, x % y);
}

template <typename Operator>
struct SegmentTree {
    Operator OP;
    using TypeNode = decltype(OP.NodeE);
    int length;
    vector<TypeNode> node;
    SegmentTree (int N) {
        length = 1;
        while (length < N) length <<= 1;
        node.assign(length << 1, OP.NodeE);
    }
    SegmentTree (vector<TypeNode> &vec) {
        length = 1;
        while (length < vec.size()) length <<= 1;
        node.assign(2 * length, OP.NodeE);
        for (int i = 0; i < vec.size(); ++i) node[i + length] = vec[i];
        for (int i = length - 1; i > 0; --i) node[i] = OP.func(node[(i << 1) + 0], node[(i << 1) + 1]);
    }
    void update(int idx, TypeNode val) {
        idx += length;
        node[idx] = OP.change(node[idx], val);
        while (idx >>= 1) node[idx] = OP.func(node[(idx << 1) + 0], node[(idx << 1) + 1]);
    }
    TypeNode get(int l, int r) {
        l += length;
        r += length;
        TypeNode vl = OP.NodeE, vr = OP.NodeE;
        while (r > l) {
            if (l & 1) vl = OP.func(vl, node[l++]);
            if (r & 1) vr = OP.func(node[--r], vr);
            l >>= 1;
            r >>= 1;
        }
        return OP.func(vl, vr);
    }
};

template <typename NodeType>
struct hoge {
    NodeType NodeE = 0;
    NodeType func(NodeType x, NodeType y) {return gcd(x, y);}
    NodeType change(NodeType x, NodeType y) {return y;}
};

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    
    SegmentTree<hoge<int>> ST(a);
    int ans = 0;
    REP(i, n) ans = max(ans, gcd(ST.get(0, i), ST.get(i + 1, n)));
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4580
X, N = input().split()
X = int(X)
N = int(N)
searchA = X
searchB = X
max = 100
z = X

if N != 0:
  A = list(map(int, input().split()))
  for val in range(max):
    if searchA in A:
      if searchA > -1:
        searchA -= 1
      else:
        continue
    else:
      z = searchA
      break
    if searchB in A:
      if searchB < 102:
        searchB += 1
      else:
        continue
    else:
      z = searchB
      break
    
print(z)

    


Measured memory_bytes: 9204
from collections import defaultdict

import sys
sys.setrecursionlimit(10**6)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
        s=input()
        print('ABC' if s=="ARC" else "ARC")


if __name__ == "__main__":
    main()

Measured memory_bytes: 9300
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
ll gcd(ll a,ll b) {
    while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
    }
    return a;
}

int main(){
    ll A;
    cin >> A;
    ll B;
    cin >> B;
    ll N=gcd(A,B);
    ll counter=1;
  for(auto p : prime_factor(N)) {
      counter++;
  }
  cout <<counter<<endl;

return 0;
}  



Measured memory_bytes: 256
s = input()

if int(s) < 10:
    print(int(s))
elif all([x == "9" for x in s[1:]]):
    print(int(s[0]) + 9 * (len(s) - 1))
else:
    print(int(s[0]) - 1 + 9 * (len(s) - 1))


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>

#define MAXN 100000

typedef long long ll;

using namespace std;

struct node { int no, w; } typedef NODE;

vector<NODE> list[MAXN];
ll FROMK[MAXN];

void calculatek ( int N, int K )
{
  queue<int> Q;

  for ( int i = 0; i < N; ++i ) FROMK[i] = -1;
  FROMK[K] = 0;
  Q.push(K);

  while ( !Q.empty() ) {
    int top = Q.front(); Q.pop();
    for ( int i = 0,q = list[top].size(); i < q; ++i ) {
      if ( FROMK[list[top][i].no] != -1 ) continue;
      FROMK[list[top][i].no] = FROMK[top]+list[top][i].w;
      Q.push(list[top][i].no);
    }
  }

}


int main()
{
  int N,K,Q,tmp;
  int a,b,c;

  cin >> N; tmp = N; --tmp;

  while(tmp--) {
    scanf("%d%d%d", &a, &b, &c);
    --a; --b;
    list[a].push_back({b,c});
    list[b].push_back({a,c});
  }

  cin >> Q >> K;
  --K;
  calculatek(N,K);

  while(Q--) {
    scanf("%d%d", &a, &b);
    --a; --b;
    cout << FROMK[a]+FROMK[b] <<"\n";
  }
}


Measured memory_bytes: 8820
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

string s;
int x,y;

bool check(int s, int t, vector<int> v, bool isX = true) {
  vector<vector<bool>> dp(2,vector<bool>(16010,false));
  int cur = 0, nxt = 1;
  dp[cur][s+8000] = true;
  REP(i,v.size()) {
    fill(ALL(dp[nxt]),false);
    REP(j,16010) if (dp[cur][j]) {
      if (i == 0 && isX) {
        dp[nxt][j+v[i]] = true;
      } else {
        dp[nxt][j-v[i]] = dp[nxt][j+v[i]] = true;
      }
    }
    swap(cur,nxt);
  }
  return dp[cur][t+8000];
}

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

  cin >> s >> x >> y;
  s += "T";
  vector<int> v[2];
  int p = 0, c = 0;
  REP(i,s.size()) {
    if (s[i] == 'T') {
      v[p].push_back(c);
      c = 0;
      p ^= 1;
    } else {
      c++;
    }
  }
  cout << (check(0,x,v[0]) && check(0,y,v[1],false) ? "Yes" : "No") << endl;

  return 0;
}

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

num = n % 10
if num == 2 or num == 4 or num == 5 or num == 7 or num == 9:
    print("hon")
elif num == 0 or num == 1 or num == 6 or num == 8:
    print("pon") 
else:
    print("bon")

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

int main(void){
  int x,y,ans;
  ans = 0;
  cin >> x >> y;

  if(x > y){
    ans += x;
    x--;
  }else{
    ans += y;
    y--;
  }

  if(x > y){
    ans += x;
  }else{
    ans += y;
  }

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int>like(m);
	rep(i, n) {
		int k; cin >> k;
		rep(i, k) {
			int a; cin >> a;
			a--;
			like[a]++;
		}
	}
	int count = 0;
	rep(i, m) {
		if (like[i] == n) {
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(void)
{
	int a,b,c,d,h1,h2,k1,k2;
	scanf("%d %d %d %d %d %d %d %d",&h1,&h2,&k1,&k2,&a,&b,&c,&d);
	if((a*h1)+(b*h2)+(h1/10*c)+(h2/20*d)<(a*k1)+(b*k2)+(k1/10*c)+(k2/20*d)){
		printf("kenjiro\n");
	}
	if((a*h1)+(b*h2)+(h1/10*c)+(h2/20*d)>(a*k1)+(b*k2)+(k1/10*c)+(k2/20*d)){
		printf("hiroshi\n");
	}
	if((a*h1)+(b*h2)+(h1/10*c)+(h2/20*d)==(a*k1)+(b*k2)+(k1/10*c)+(k2/20*d)){
		printf("even\n");
	}	
	return 0;
}


Measured memory_bytes: 2692
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

const int max_n = 100;
const int ten = 10;
ll f[max_n][ten];
ll p[max_n][ten + 1];
ll n;

void solve() {
    ll ans = -inf;
    for (int i = 1; i < pow(2, ten); ++i) {
        ll same_time_count[n];
        fill(same_time_count, same_time_count + n, 0);
        rep(j, ten) {
            if ((1 & i >> j) == 1) {
                rep(k, n) if (f[k][j] == 1) same_time_count[k]++;
            }
        }
        ll temp = 0;
        rep(k, n) temp += p[k][same_time_count[k]];
        ans = max(temp, ans);
    }
    cout << ans << endl;
}

int main() {
    cin >> n;
    rep(i, n) rep(j, 10) cin >> f[i][j];
    rep(i, n) rep(j, 11) cin >> p[i][j];
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));

		String[] strs = reader.readLine().split(" ");
		Stack<Integer> stack = new Stack<Integer>();

		for (String s : strs) {
			if (Character.isDigit(s.charAt(0)))
				stack.push(Integer.parseInt(s));
			else {
				int pop1 = stack.pop();
				int pop2 = stack.pop();
				switch (s.charAt(0)) {
				case '+':
					stack.push(pop2 + pop1);
					break;
				case '-':
					stack.push(pop2 - pop1);
					break;
				default:
					stack.push(pop2 * pop1);
					break;
				}
			}
			/*System.out.println(stack.stream().map(String::valueOf)
					.collect(Collectors.joining(", ", "[", "]")));*/
		}
		System.out.println(stack.pop());
	}
}

Measured memory_bytes: 17096
#include <stdio.h>
#include <stdlib.h>
	/*??????????????°??????????????????atoi???????????????*/
#include <string.h>
	/*??????????????????????????????????????????strtok???????????????*/

int main(void)
{
	int n, i, num_i;
	char sn[7];

	fgets(sn, sizeof(sn), stdin);
	n = atoi(sn);
		/*scanf?????¨\n?????\?????????????????????????????§???fgets?????????*/

	int sl = 9 * 100;
	char i_str[sl], *snum;

	fgets(i_str, sizeof(i_str), stdin);

	snum = strtok(i_str, " \n");

	int r_nums[n];
	i = n - 1;

	while (snum != NULL) {
		num_i = atoi(snum);
		r_nums[i] = num_i;
		snum = strtok(NULL, " \n");
		i--;
	}

	for (i = 0; i < n - 1; i++)
		printf("%d ", r_nums[i]);

	printf("%d\n", r_nums[n - 1]);

	return 0;
}

Measured memory_bytes: 528
def main():
    s = input()

    if len(s) < 26:
        for i in range(ord("a"), ord("z") + 1):
            c = chr(i)
            if c not in s:
                ans = s + c
                break

    else:
        ans = -1
        for i in range(1, 26)[::-1]:
            if s[i-1] < s[i]:
                for j in range(i, 26)[::-1]:
                    if s[j] > s[i-1]:
                        ans = s[:i-1] + s[j]
                        break
                break

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
def attention(N: int, S: str) -> int:
    # 西から順に i 人までのうち西を向いている人の数
    Se = [0] * (N + 1)
    for i, c in enumerate(S):
        Se[i + 1] = Se[i] + (1 if c == 'W' else 0)

    min_people = float('inf')
    for i, c in enumerate(S):
        w2e = Se[i]  # 西から東に向きを変える人数
        e2w = (N - (i + 1)) - (Se[N] - Se[i + 1])
        min_people = min(min_people, w2e + e2w)

    return min_people


if __name__ == "__main__":
    N = int(input())
    S = input()
    ans = attention(N, S)
    print(ans)


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

int main() {
  int W, H, x, y;
  cin >> W >> H >> x >> y;
  
  int isOtherWay = x + x == W && y + y == H;
  double S = (double)W * H / 2;
  
  cout << S << " " << isOtherWay << endl;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();

    let ans = (b - a) * (b - a + 1) / 2 - b;
    ans.to_string()
}


Measured memory_bytes: 2112
#include <iostream>
using namespace std;
int gcd(int,int);
int gcd(int,int,int);
int main(){
	int k;
	long long int sum = 0;
	cin >> k;
	for(int a = 1;a <= k;a ++){
		for(int b = 1;b <= k;b++){
			for(int c = 1;c <= k;c++){
				sum += gcd(a,b,c);
			}
		}
	}
	cout << sum;
	return 0;
}
int gcd(int a,int b){
	while(1){
		int buf = b;
		b = a % b;
		a = buf;
		if(!b){
			return a;
		}
	}

}

int gcd(int a,int b,int c){
	return gcd(a,gcd(b,c));
}


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

int main() {
  char a;
  cin >> a;
  
  if( a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o' ){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <unordered_map>

using namespace std;
using str = string;

#define rep(a,l,r) for(int a=(l);a<(r);a++)
#define get cin>>
#define put cout<<

void run() {

	int n; get n;
	int ans{0};
	rep(i,0,n){
		int a;get a;
		ans += a - 1;
	}

	put ans;
}

int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);run();return 0;}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    int R;
    cin >> R;
    if(R < 1200)
    cout << "ABC" << endl;
    else if(R < 2800)
    cout << "ARC" << endl;
    else 
    cout << "AGC" << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

class union_find_tree {
public:
	using size_type = std::int_fast32_t;
	using container = std::vector<size_type>;
	
protected:
	container data;
	size_type comp_sz;

private:
	const size_type find(size_type k) {
		if(data[k] < 0) return k;
		return data[k] = find(data[k]);
	}

public:
	union_find_tree() = default;
	union_find_tree(const union_find_tree &) = default;
	union_find_tree(union_find_tree &&) = default;

	union_find_tree(const size_type & N) : data(N, -1), comp_sz(N) {}

	union_find_tree & operator=(const union_find_tree &) = default;
	union_find_tree & operator=(union_find_tree &&) = default;
	
	const bool unite(size_type x, size_type y) {
		x = find(x); y = find(y);
		if(x == y) return false;
		if(data[x] > data[y]) std::swap(x, y);
		
		data[x] += data[y];
		data[y] = x;
		comp_sz--;
		return true;
	}
	
	const bool is_same(const size_type & x, const size_type & y) { return find(x) == find(y); }
	const size_type size() const { return data.size(); }
	const size_type size(const size_type & k) { return -data[find(k)]; }
	const size_type comp(const size_type & k) { return find(k); };
	const size_type comp_size() const { return comp_sz; }
	const size_type operator[](const size_type & k) { return find(k); }
	
	void swap(union_find_tree & r) {
		using std::swap;
		data.swap(r.data);
		swap(comp_sz, r.comp_sz);
	}
	void clear(const size_type & N = 0) {
		data.assign(N, -1);
		comp_sz = N;
	}
};

int main() {
	int n, m, k; scanf("%d%d%d", &n, &m, &k);
	std::vector<int> a(m), b(m), c(k), d(k);
	for(int i = 0; i < m; i++) {
		scanf("%d%d", &a[i], &b[i]);
		a[i]--; b[i]--;
	}
	for(int i = 0; i < k; i++) {
		scanf("%d%d", &c[i], &d[i]);
		c[i]--; d[i]--;
	}
	
	union_find_tree uf(n);
	for(int i = 0; i < m; i++) uf.unite(a[i], b[i]);
	
	std::vector<int> ans(n);
	for(int i = 0; i < n; i++) ans[i] = uf.size(i) - 1;
	for(int i = 0; i < m; i++) {
		ans[a[i]]--;
		ans[b[i]]--;
	}
	for(int i = 0; i < k; i++) {
		if(!uf.is_same(c[i], d[i])) continue;
		ans[c[i]]--;
		ans[d[i]]--;
	}
	
	for(int i = 0; i < n; i++) printf("%d ", ans[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 3584
# ABC 075 B

# H, W = 4, 3
# S = "#.."\
#     "..#"\
#     ".#."\
#     ".#."

H, W = map(int, input().split())
S = ''
for _ in range(H):
    S += input()
    

def cell_of(x, y):
    return S[W*x + y]

def neighbor_indice_of(x, y):
    return [
        (x+m, y+n)
        for m in range(-1, 2)
        for n in range(-1, 2)
        if 0 <= x+m < H and 0 <= y+n < W
    ]

def neighbors_of(x, y):
    return [cell_of(i, j) for i, j in neighbor_indice_of(x, y)]

def mine(x, y):
    cell = cell_of(x, y)
    if cell != '.':
        return cell
    return str(neighbors_of(x, y).count('#'))


for x in range(H):
    print(''.join([mine(x, y) for y in range(W)]))

Measured memory_bytes: 3064
#include<stdio.h>
#define ll long long 
int main(){
    ll k,n,i;
    scanf("%lld%lld",&k,&n);
    ll a[n];
    for(i=0;i<n;i++) scanf("%lld",&a[i]);
    ll b[n+1];
    b[n]=k-a[n-1]+a[0];
    for(i=1;i<n;i++) b[i]=a[i]-a[i-1];
    ll p=1;
    ll m=b[1];
    for(i=1;i<n+1;i++)
        if(m<b[i]){
            m=b[i];
            p=i;
        }
    ll ans=0;
    ans=k-b[p];
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3328
// Coordinate compression

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
 
#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)



int solve()
{

int k,n;
cin>>k>>n;
vi a;
rep(i,0,n)
{
  int x;
  cin>>x;
  a.pb(x);
}

rep(i,0,n)
{
  a.pb(k+a[i]);
}

int ans=1e9;

rep(i,0,n)
{
  ans=min(ans,a[i+n-1]-a[i]);
}
cout<<ans;



  return 0;
}


 
signed main()
{  int t=1;

 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
  
   cin.exceptions(cin.failbit);                                                                    
     
 
  clock_t time_req;
                                                                                                                   
//cin>>t;
 
    int k=1;
     
   while(t--)
     {
      solve();
     }
        exit(0);
 
 
         time_req = clock() - time_req;
    cout <<endl<< "Processor time taken is "
      << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;
 
    return 0;
 
}

Measured memory_bytes: 6556
#include <cstdio>

int main(){
    int n,i;
    scanf("%d",&n);
    int array[n];
    for(i = 0;i < n;i++){
        scanf("%d",&array[i]);
    }
    for(i = n - 1;i >= 0;i--){
        if(i != 0){
            printf("%d ",array[i]);}
        else printf("%d",array[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2656
#include<bits/stdc++.h>
using namespace std;
int gcd[500][500];
int main() {
	int a,c,n;
	long long tot = 0;
	char s[50000];
	scanf("%d",&n);
	scanf(" %s",s);
	int r[5000],g[5000],b[5000];
	r[n] = 0;
	g[n] = 0;
	b[n] = 0;
	for(int i=n-1;i>=0;i--) {
		r[i] = s[i] == 'R' ? r[i+1]+1 : r[i+1];
		b[i] = s[i] == 'B' ? b[i+1]+1 : b[i+1];
		g[i] = s[i] == 'G' ? g[i+1]+1 : g[i+1];
	}
	for(int i=0;i<n-1;i++) {
		for(int j=i+1;j<n-1;j++) {
			int d = j-i;
			if(s[i]=='R' && s[j]=='G') {
				tot+=b[j+1];
				//0 4   10
				if(j+d<n) {
					if(s[j+d]=='B') tot-=1;	
				}
			}
			if(s[i]=='R' && s[j]=='B') {
				tot+=g[j+1];
				if(j+d<n) {
					if(s[j+d]=='G') tot-=1;	
				}
			}
			if(s[i]=='G' && s[j]=='R') {
				tot+=b[j+1];
				if(j+d<n) {
					if(s[j+d]=='B') tot-=1;	
				}
			}
			if(s[i]=='G' && s[j]=='B') {
				tot+=r[j+1];
				if(j+d<n) {
					if(s[j+d]=='R') tot-=1;	
				}
			}
			if(s[i]=='B' && s[j]=='G') {
				tot+=r[j+1];
				if(j+d<n) {
					if(s[j+d]=='R') tot-=1;	
				}
			}
			if(s[i]=='B' && s[j]=='R') {
				tot+=g[j+1];
				if(j+d<n) {
					if(s[j+d]=='G') tot-=1;	
				}
			}
		}
	}
	
		printf("%lld",tot);
}


Measured memory_bytes: 3868
# https://atcoder.jp/contests/abc132/tasks/abc132_d
# K個を区別なくi個のグループに分ける通りの数？
# 制約はたかだか2000
# 赤の壁のパターンを考えるとか？[WIP]
# mod取りながらcombination


MOD = 10**9 + 7


def combination_mod(n, r, mod):
    if r > n:
        return 0  # このような通りの数は無いため便宜上こう定義する
    r = min(r, n - r)
    nf = rf = 1
    for i in range(r):
        nf = nf * (n - i) % mod
        rf = rf * (i + 1) % mod
    return nf * pow(rf, mod - 2, mod) % mod


C = [[1], [1, 1]]
'''
1
1, 1
1, 2, 1
1, 3, 3, 1
# '''
# for i in range(2, 2002):
#     tmp = [1]
#     for j in range(1, i):
#         tmp.append((C[i - 1][j - 1] + C[i - 1][j]) % MOD)
#     tmp.append(1)
#     C.append(tmp)


N, K = list(map(int, input().split()))
left1 = N - K + 1
left2 = K - 1
for i in range(1, K + 1):
    ans = combination_mod(left1, i, MOD) * combination_mod(left2, i - 1, MOD)
    # print(ans)
    print(ans % MOD)

# for i in range(1, K + 1):
#     ans = C[left1][i] * C[left2][i - 1]
#     # print(ans)
#     print(ans % MOD)


Measured memory_bytes: 3444
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(vector<int>::iterator itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

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

using namespace std;

int t, max_num, f = 0;
vector<int> ans;

int get_nextnum(int x){
  char s[10];
  sprintf(s, "%d", x);
  return s[0] + '0';
}

int calc_digit(int x){
  int res = 0;
  while(x != 0){
    x /= 10;
    res++;
  }
  return res;
}

void solve(vector<int> v, int digit, int n, int num){
  if(n == digit){
    int sum = 0;
    v.pb(num);
    REPI(itr,v){
      sum += *itr;
    }
    if(t >= sum && sum == max_num){
      f = 1;
    }else if(t >= sum && sum > max_num){
      max_num = sum;
      f = 0;
      ans.clear();
      copy(v.begin(), v.end(), back_inserter(ans));
    }
    return;
  }
  
  solve(v, digit, n + 1, num);
  if(get_nextnum(num) != 0){
    int tmp = 1;
    REP(i,digit - n){
      tmp *= 10;
    }
    v.pb(num / tmp);
    solve(v, digit, n + 1, num % tmp);
  }
}

int main(){

  while(true){
    int num;
    scanf("%d %d", &t, &num);
    
    if(t == 0 && num == 0)  break;
    if(t == num){
      printf("%d %d\n", t, num);
      continue;
    }
    int digit = calc_digit(num);
    max_num = -1, f = 0;
    vector<int> v;
    solve(v, digit, 1, num);
    if(max_num == -1){
      printf("error\n");
    }else if(f == 1){
      printf("rejected\n");
    }else{
      printf("%d ", max_num);
      REPI(itr, ans){
        printf("%d", *itr);
        vector<int>::iterator itrt = itr;
        itrt++;
        if(itrt != ans.end()){
          printf(" ");
        }
      }
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
#include <time.h>
#include <assert.h>


using namespace std;



#define For(i,x,n)  for(long long i=x;i<n;i++)
#define rFor(i,x,n) for(long long i=x;i>=n;i--)
#define itFor(it,st)   for(auto it=st.begin() ; it!=st.end() ; it++)
#define MOD 1000000007
#define PI 3.141592653589793
#define INF 999999999999999999
#define N 1000005
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sp " "
#define cont continue
#define brk break

#define deb1(x)                cout<<#x<<": "<<x<<endl
#define deb2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define deb3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define deb4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

using namespace std;

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed;
    cout<<setprecision(3);
    srand(time(NULL));

    ll tt;
    // cin>>tt;
    tt=1;
    while(tt--){
        // deb1("s");
        ll a[5];
        For(i,0,5)
        cin>>a[i];
        // deb1(a[2]);
        For(i,0,5){
            if(a[i]==0){
                cout<<i+1<<"\n";
                return 0;
            }
        }
    }    
    
    //cout<<"\nTime used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case
    return 0;
}

//s1.substr(1,3) - return 3 characters starting from position 1 as substring of string sz1. eg sz1="shreynumh" sz1.substr(2,5)="reyan"
//num = atoi(s.c_str()); //convert string s to integer num
//n.erase(i,std::string::npos); //erase i th position in string n , decreasing string size
//s.find(b)!= std::string::npos - finds string b in string a - true if found
//cout<<"Time used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case                


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

namespace Atc_0007
{
    class Program
    {
        static void Main(string[] args)
        {
            var fStr = Console.ReadLine();

            var N = int.Parse(fStr.Split(' ')[0]);
            var D = int.Parse(fStr.Split(' ')[1]);
            int index = 0;
            int result = 0;

            while (index < N)
            {
                index++;

                var rStr = Console.ReadLine();

                var x = Int64.Parse(rStr.Split(' ')[0]);
                var y = Int64.Parse(rStr.Split(' ')[1]);
               
                if (Math.Sqrt(x * x + y * y) <= (double)D)
                {
                    result++;
                }
            }

            Console.WriteLine(result);

        }
    }
}


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

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

    if ( a > x ) cout << "NO";
    else if ( a == x ) cout << "YES";
    else if ( a < x && a + b >= x ) cout << "YES";
    else if ( a < x && a + b <  x ) cout << "NO";
    return 0;
}

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

V.sort()
A=0

for i in range(N-1):
  if i ==0:
    A = (V[i]+V[i+1])/2

  if i >=1:
    A = (A+V[i+1])/2
    
print(A)

Measured memory_bytes: 3060
from sys import stdin
from itertools import accumulate

def solve():
    file_input = stdin
    
    N = int(file_input.readline())
    G = tuple(tuple(map(int, line.split())) for line in file_input)
    
    # accumulated rows
    ar = ((0,) + tuple(accumulate(line)) for line in G)
    
    # accumulated columns
    ac = ((0,) + tuple(accumulate(line)) for line in zip(*G))
    ac_1 = next(ac)
    ac = tuple(zip(*ac))
    
    ans = 0
    for i, t1 in enumerate(zip(G, ar, ac, ac_1)):
        G_i, ar_i, ac_i, ac_1i = t1
        ar_ii = ar_i[i]
        for j, t2 in enumerate(zip(G[i:], ar_i[i+1:], ac[i+1:], ac_1[i+1:]), start=i):
            G_j, ar_ij, ac_j, ac_1j = t2
            if ar_ij - ar_ii > ans:
                ans = ar_ij - ar_ii
                
            if i == j:
                continue
            
            col_max = ac_1j - ac_1i
            
            for ac_jk, ac_ik, G_ik, G_jk in zip(ac_j, ac_i, G_i[1:], G_j[1:]):
                col = ac_jk - ac_ik
                
                if col_max > 0:
                    c_ans = col_max + col
                    if c_ans > ans:
                        ans = c_ans
                else:
                    if col > ans:
                        ans = col
                
                t_col_max = col_max + G_ik + G_jk
                if t_col_max > col:
                    col_max = t_col_max
                else:
                    col_max = col
    print(ans)

solve()


Measured memory_bytes: 13032
#include<stdio.h>
#include<string.h>
int henkan(char);
void bubbleSort(char *,char *,int);
void selectionSort(char *,char *,int);

int main(){
  char A1[40],A2[40];
  char B1[40],B2[40];
  char C[2];
  int N;
  int i;
  int flag=1;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%s",C);
    A1[i]=B1[i]=C[0];
    A2[i]=B2[i]=C[1];
  }
  bubbleSort(A1,A2,N);
  for(i=0;i<N;i++){
    printf("%c%c",A1[i],A2[i]);
    if(i!=N-1) printf(" ");
  }
  printf("\n");
  printf("Stable\n");
  selectionSort(B1,B2,N);
  for(i=0;i<N;i++){
    printf("%c%c",B1[i],B2[i]);
    if(i!=N-1) printf(" ");
    if(A1[i]!=B1[i] || A2[i]!=B2[i]) flag=0;
    }
  printf("\n");
  if(flag) printf("Stable");
  else printf("Not stable");
  printf("\n");

  return 0;
  
}
int henkann(char c){
  return c-48;
}
void bubbleSort(char A1[],char A2[],int N){
  int flag=1;
  int j;
  char tmp1,tmp2;
  while(flag){
    flag=0;
    for(j=N-1;j>0;j--){
      if(henkann(A2[j])<henkann(A2[j-1])){
	tmp2=A2[j];
	tmp1=A1[j];
	A2[j]=A2[j-1];
	A1[j]=A1[j-1];
	A2[j-1]=tmp2;
	A1[j-1]=tmp1;
	flag=1;
      }
    }
  }
}

void selectionSort(char A1[],char A2[],int N){
  int i,j,minj;
  char tmp1,tmp2;
  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A2[minj]>A2[j]){
	minj=j;
      }
    }
    tmp2=A2[i];
    tmp1=A1[i];
    A2[i]=A2[minj];
    A1[i]=A1[minj];
    A2[minj]=tmp2;
    A1[minj]=tmp1;
  }
}


Measured memory_bytes: 2104
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] A = new int[N];
		
		for(int i=0; i<N; i++)
			A[i] = sc.nextInt();

		int[] d = new int[N+1];
		
		for(int i=0; i<K; i++) {
			Arrays.fill(d, 0);
			for(int j=0; j<N; j++) {
				d[Math.max(j-A[j], 0)]++;
				d[Math.min(j+A[j]+1, N)]--;
			}
			int cur = 0;
			for(int j=0; j<N; j++) {
				cur += d[j];
				A[j] = cur;
			}
			if(d[0]==N && d[N]==-N)
				break;
		}
		
		for(int i=0; i<N; i++)
			pw.print(A[i] + (i==N-1 ? "\n" : " "));
		
		sc.close();
		pw.close();
	}
}


Measured memory_bytes: 50328
package main

import (
	"fmt"
	"sort"
)

func main() {
	a := make([]int, 3)
	fmt.Scan(&a[0], &a[1], &a[2])
	sort.Ints(a)
	if a[2]%2 == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(a[0] * a[1])
	}
}


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

template <typename A>
string to_string(multiset<A> v) {
    bool first = true;
    string result = "[";
    for (A i : v) {
        if (!first) result += ", ";
        first = false;
        result += to_string(i); 
    }
    return result + "]";
}

int main() {
    int n; 
    cin >> n;
    multiset<int> slimes;

    for (int i = 0; i < pow(2, n); ++i) {
        int slime;
        cin >> slime;
        slimes.insert(slime);
    }
    cout << endl;
    multiset<int> created;

    ll firstSlime = *(slimes.rbegin());
    created.insert(firstSlime);
    slimes.erase(firstSlime);
    for (int i = 0; i < n; ++i) {
        multiset<int> buffer;
        for (multiset<int>::reverse_iterator it = created.rbegin(); it != created.rend(); ++it)  { 
            ll slime = *it;
            
            if (slimes.lower_bound(slime) == slimes.begin()) {
                cout << "No" << endl;
                return 0;
            }

            ll toCreate = *(--slimes.lower_bound(slime));
            buffer.insert(toCreate);
            slimes.erase(slimes.lower_bound(toCreate));
        }
        for (int s : buffer) created.insert(s);
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 18688
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))

left = 1
right= max(A)

import math

while True:
  
  cl = 0
  for i in range(N):
    cl += math.ceil(A[i]/left) - 1
  
  mid = (left + right)//2
  cm = 0
  for i in range(N):
    cm += math.ceil(A[i]/mid) - 1
  if(cl<=K):
    right = left
    break
  if(cm<=K):
    right = mid
  else:
    left = mid
  if(abs(left-right)<=1):
    break

print(right)
  
 
  
    
    














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

int main(){
  long long n;
  cin >> n;
  long long G=100;
  for(long long i=1;;i++){
    G=G+G/100;
    if(G >= n){
      cout << i << endl;
      return 0;
    }
  }
}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<vector<char>> table(H, vector<char>(W));

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> table.at(i).at(j);
    }
  }

  vector<int> skipH;
  for (int i = 0; i < H; i++) {
    int cnt = 0;
    for (int j = 0; j < W; j++) {
      if (table.at(i).at(j) == '.') {
        cnt++;
      }
      if (cnt == W) {
        skipH.push_back(i);
      }
    }
  }

  vector<int> skipW;
  for (int j = 0; j < W; j++) {
    int cnt = 0;
    for (int i = 0; i < H; i++) {
      if (table.at(i).at(j) == '.') {
        cnt++;
      }
      if (cnt == H) {
        skipW.push_back(j);
      }
    }
  }

  for (int i = 0; i < H; i++) {
    bool flag = false;
    for (int skip : skipH) {
      if (i == skip) {
        flag = true;
        break;
      }
    }
    
    if (flag == true) {
      continue;
    }
    
    for (int j = 0; j < W; j++) {
      bool flag = false;
      for (int skip : skipW) {
        if (j == skip) {
          flag = true;
          break;
        }
      }

      if (flag == true) {
        continue;
      }

      cout << table.at(i).at(j);
    }
    cout << endl;
  }
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;

const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



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

	int n,k;
	cin >>n >>k;
	
	cout << (n%k? 1:0) <<"\n";
	return 0;
}


Measured memory_bytes: 764
n, q = map(int, input().split())
que = []
for _ in range(n):
    p, t = input().split()
    que.append([p, int(t)])

now = 0
while len(que) != 0:
    if que[0][1] > q:
        que[0][1] -= q
        now += q
        que.append(que.pop(0))
    else:
        now += que[0][1]
        print("{} {}".format(que[0][0], now))
        que.pop(0)

Measured memory_bytes: 15568
#include<bits/stdc++.h>
using namespace std;
#define int long long  
#define mod 1000000007
#define am 998244353
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){ 
  int c=max(a,b)-min(a,b);
  return c;
}
int gcd(int a,int b){//最大公約数
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
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;
    }
  }
}
int lcm(int a,int b){//最小公倍数
    return (a*b)/gcd(a,b);
}	    
signed main(){
// __builtin_ctz(N);      Nを２で何回割り切れるかを返す
//(n+1)*n/2;              １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c=0;
    cin>>a>>b;
    if(a==1) c=300000;
    if(a==2) c+=200000;
    if(a==3) c+=100000;
    if(b==1) c+=300000;
    if(b==2) c+=200000;
    if(b==3) c+=100000;
    if(a+b==2) c+=400000;
    cout<<c<<"\n";
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

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

	string ignore, s;
	cin >> ignore >> s >> ignore;

	cout << 'A' << s[0] << 'C';

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using vi = vector<int>; using vll = vector<long long>; 
using vvi = vector<vector<int> >; using vb = vector<bool>;
using pii = pair<int,int>; 
#define pb push_back
#define all(v) v.begin(),v.end()
#define llmax 9223372036854775807
#define intmax 2147483647
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const ll mod = 1e9+7;
//////////////////////////////////////////
#define test(t) int t; cin>>t; while(t--)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
////////////////////////////////////////////
#define tki take_input 
#define tkii take_input<int>
template <typename T> void take_input(vector<T> &a, int size){ T tmp; for(int i=0;i<size;i++){ cin>>tmp; a.push_back(tmp); } }
#define prv print_vector
#define prvi print_vector<int> 
template <typename T> void print_vector(vector<T> v){ for(int i=0;i<v.size();i++){ cout<<v[i]<<" "; } cout<<endl; }
/////////////////////////////////////////

int main(){
	fastio;

	int n; cin>>n;
	vll a; tki<ll>(a,n);
	ll up = 1e18;

	bool zero = false;
	bool ok = true;
	ll ans = 1;
	rep(i,n){
		if(a[i] == 0) zero = true;
		else if(ans <= (up/a[i])) ans *= a[i]; 
		else ok = false;
	}

	if(zero) cout<<0<<endl;
	else if(!ok) cout<<-1<<endl;
	else cout<<ans<<endl;
}

Measured memory_bytes: 4288
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

ll x[1010];
ll y[1010];
ll z[1010];
ll sum[1010];

void solve(){

    ll n,m;
    cin >> n >> m;
    rep(i,n){
        cin >> x[i] >> y[i] >> z[i];
    }

    ll ans = 0;
    rep(i,2){
        rep(j,2){
            rep(k,2){
                rep(c,n){
                    ll xt,yt,zt;
                    if(i==1) xt=-x[c];
                    else xt=x[c];
                    if(j==1) yt=-y[c];
                    else yt=y[c];
                    if(k==1) zt=-z[c];
                    else zt=z[c];
                    sum[c]=xt+yt+zt;
                }
                sort(sum,sum+n,greater<ll>());
                ll anstmp = 0;
                rep(p,m){
                    anstmp += sum[p];
                }
                ans = max(ll(ans), ll(anstmp));
            }
        }
    }

    cout << ans << endl;


}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}
 
void solve() {
    ll N;
    cin >> N;
    ll ans = 0;
    for(ll a = 1; a < N; a++) {
        ans += (N - 1) / a;
    }
    cout << ans << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long P = sc.nextLong();
    HashMap<Long, Long> map = new HashMap<>();
    for (long i = 2; i * i <= P; i++) {
      while (P % i == 0) {
        if (map.containsKey(i)) {
          long tmp = map.get(i);
          map.put(i, tmp + 1);
        } else {
          map.put(i, 1L);
        }
        P /= i;
      }
    }
    if (P != 1) {
      map.put(P, 1L);
    }
    long ans = 1;
    for (Long key : map.keySet()) {
      if (map.get(key) >= N) {
        ans *= (long)Math.pow(key, map.get(key) / N);
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23380
import java.io.*;

public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true){
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
            StringBuilder sb = new StringBuilder();

            if( h == 0 && w == 0)break;
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                    sb.append("#");
                }
                sb.append("\n");
            }
            System.out.println(sb);
        }

    }
}

Measured memory_bytes: 25256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final StringBuilder sb = new StringBuilder();
        final int n = Integer.parseInt(br.readLine());
        final card[] A = new card[n];
        for(int i = 0; i<n; i++)
            A[i] = new card(br.readLine(), i);
        quickSort(A, 0, n-1);
        sb.append(isStable(A) ? "Stable\n" : "Not stable\n");
        for(int i = 0; i<n; i++)
            sb.append(A[i]).append('\n');
        System.out.print(sb);
    }
    private static int partition(card[] A, int p, int r){
        final card x = A[r];
        int i = p;
        card t;
        for(int j = p; j<r; j++){
            if(A[j].getNum()<=x.getNum()){
                t = A[i];
                A[i] = A[j];
                A[j] = t;
                i++;
            }
        }
        A[r] = A[i];
        A[i] = x;
        return i;
    }
    private static void quickSort(card[] A, int p, int r){
        if(p>=r) return;
        final int q = partition(A, p, r);
        quickSort(A, p, q-1);
        quickSort(A, q+1, r);
    }
    private static boolean isStable(card[] A){
        for(int i = 1, n = A.length; i<n; i++){
            if(A[i-1].getNum()==A[i].getNum()&&A[i-1].getId()>A[i].getId()) return false;
        }
        return true;
    }
}

class card{
    final private String str;
    final private int num;
    final private int id;
    card(String str, int id){
        this.str = str;
        num = Integer.parseInt(str.substring(2));
        this.id = id;
    }
    final int getId(){
        return id;
    }
    final int getNum(){
        return num;
    }
    @Override
    public final String toString(){
        return str;
    }
}

Measured memory_bytes: 48884
N=int(input())
L=list(map(int,input().split()))
L.sort()
ans=0
for i in range(len(L)):
    a=L[i]
    for j in range(i+1,len(L)):
        if L[j]!=a:
            b=L[j]
            for k in range(j+1,len(L)):
                if L[k]!=b:
                    if a+b>L[k]:
                        ans+=1
                    else:
                        break
print(ans)


Measured memory_bytes: 9196