akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>

using namespace std;


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

	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		h[i] = tmp;
	}
	int max = *std::max_element(h.begin(), h.end());
	int ans = 0;
	for (int i = 1; i <= max; i++) {
		for (int j = 0; j < n; j++) {
			if (j == 0) {
				if (i <= h[j]) ans++;
			}
			else if (h[j - 1] < i && h[j] >= i) {
				ans++;
			}
		}
	}

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

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using lint = long long;

int main()
{

    lint h, w;
    scanf("%lld", &h);
    scanf("%lld", &w);

    std::vector<std::vector<lint>> maze(h, std::vector<lint>(w, 0));
    std::vector<std::vector<lint>> lit_h(h, std::vector<lint>(w, 0));
    std::vector<std::vector<lint>> lit_v(h, std::vector<lint>(w, 0));

    for (int i = 0; i < h; ++i)
    {
        std::string s;
        std::cin >> s;

        for (int j = 0; j < w; ++j)
        {
            if (s[j] == '#')
                maze[i][j] = 1;
        }
    }

    for (int i = 0; i < h; ++i)
    {
        lint stream = 0;
        std::vector<lint> write_cells;
        for (int j = 0; j <= w; ++j)
        {
            if (j == w || maze[i][j] == 1)
            {
                for (auto write = write_cells.begin(); write != write_cells.end(); write++)
                {
                    lit_h[i][*write] = stream;
                }
                stream = 0;
                write_cells.clear();
            }
            else
            {
                stream++;
                write_cells.push_back(j);
            }
        }
    }

    for (int j = 0; j < w; ++j)
    {
        lint stream = 0;
        std::vector<lint> write_cells;
        for (int i = 0; i <= h; ++i)
        {
            if (i == h || maze[i][j] == 1)
            {
                for (auto write = write_cells.begin(); write != write_cells.end(); write++)
                {
                    lit_v[*write][j] = stream;
                }
                stream = 0;
                write_cells.clear();
            }
            else
            {
                stream++;
                write_cells.push_back(i);
            }
        }
    }

    lint ans = 0;

    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            lint cand = lit_h[i][j] + lit_v[i][j] - 1;
            ans = std::max(ans, cand);
        }
    }

    printf("%lld", ans);

    return 0;
}


Measured memory_bytes: 94208
# -*- coding: utf-8 -*-

def solve(N, M, A, B):
    include = False
    for h in range(N-M+1):
        for w in range(N-M+1):
            match = True
            for i in range(M):
                for j in range(M):
                    if(A[h+i][w+j] != B[i][j]):
                        match = False
            if(match):
                include = True

    print("Yes" if include else "No")

if __name__ == '__main__':
    N, M = map(int, input().split())
    A, B = [], []
    for i in range(N):
        A.append(input())
    for j in range(M):
        B.append(input())

    solve(N, M, A, B)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int k=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();
		System.out.println((b-b%k>=a)?"OK":"NG");
	}
}

Measured memory_bytes: 35624
#include<stdio.h>


int main() {
	int i, j, k, f = 0, n, t, m, b, h, w;
//	char a[1100][1100];
//	int q = -1;

	scanf("%d %d", &n,&k);

	m = n - k + 1;

	printf("%d",m);


	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main(){
	int n, q;
	queue<string> name;
	queue<int> time;

	cin >> n >> q;

	for(int i = 1; i <= n; i++){
		string tmpname;
		int tmptime;

		cin >> tmpname >> tmptime;

		name.push(tmpname);
		time.push(tmptime);
//		cout << i << "unchi\n";
	}

	int alltime = 0;
	int sum = 0;

	while(sum < n){
		if(time.front() > q){
			int tmptime = time.front();
			string tmpname = name.front();
			name.pop();
			time.pop();
			name.push(tmpname);
			time.push(tmptime - q);
			alltime += q;
//			cout << tmptime << "おじさん\n";
		}else{
			alltime += time.front();
			cout << name.front() << " " << alltime << "\n";
			name.pop();
			time.pop();
			sum++;
		}
	}
}


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

typedef long long ll;
const int N = 105, MOD = 1e9 + 7;
int n, m, k, fac[N << 1], ifac[N << 1];

int fpow(int a, int m) {
	int ans = 1;
	for(; m; m >>= 1) {
		if(m & 1) ans = ans * 1ll * a % MOD;
		a = a * 1ll * a % MOD;
	}
	return ans;
}

struct Edge {
	int nxt, v;
}e[N << 1];
int bccno[N], bcc_cnt,siz_e[N], siz_p[N], dfs_clock, low[N], pre[N], head[N], cnt, top;
pair<int, int> stk[N];

void add(int u, int v) {
	e[++cnt] = (Edge){head[u], v}, head[u] = cnt;
	e[++cnt] = (Edge){head[v], u}, head[v] = cnt;
}
void dfs(int u, int fa) {
    low[u] = pre[u] = ++dfs_clock;
    for(int i = head[u]; ~i; i = e[i].nxt) {
    	int v = e[i].v;
    	if(v == fa) continue;
    	if(!pre[v]) {
    		stk[++top] = make_pair(u, v);
    		dfs(v, u);
    		low[u] = min(low[u], low[v]);
    		if(low[v] >= pre[u]) {
    			bcc_cnt++;
    			while(523) {
                    int x = stk[top].first, y = stk[top].second;
    			    top--;
    			    siz_e[bcc_cnt]++;
    			    if(bccno[x] != bcc_cnt) {bccno[x] = bcc_cnt; siz_p[bcc_cnt]++;}
    			    if(bccno[y] != bcc_cnt) {bccno[y] = bcc_cnt; siz_p[bcc_cnt]++;}
    			    if(x == u && y == v) break;
    			}
    		}
    	}
    	else if(pre[v] < pre[u]) {stk[++top] = make_pair(u, v); low[u] = min(low[u], pre[v]);}
    }
}
int C(int n, int m) {
	return fac[n] * 1ll * ifac[m] % MOD * ifac[n - m] % MOD;
}
int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

int main() {
    memset(head, -1, sizeof head);
    scanf("%d %d %d", &n, &m, &k);
    fac[0] = ifac[0] = ifac[1] = 1;
    for (int i = 1; i <= m + k; ++i) fac[i] = fac[i - 1] * 1ll * i % MOD;
    for (int i = 2; i <= m + k; ++i) ifac[i] = (MOD - MOD / i) * 1ll * ifac[MOD % i] % MOD;
    for (int i = 2; i <= m + k; ++i) ifac[i] = ifac[i - 1] * 1ll * ifac[i] % MOD;
    for(int i = 1; i <= m; i++) {
    	int u, v;
    	scanf("%d %d", &u, &v);
    	add(u, v);
    }
    for(int i = 1; i <= n; i++) {
    	if(!pre[i]) dfs(i, 0);
    }
    int ans1 = 1, ans2 = 1, ans3 = 1;
    for(int i = 1; i <= bcc_cnt; i++) {
    	if(siz_e[i] == 1) ans1 = ans1 * 1ll * k % MOD;
    	else if(siz_e[i] == siz_p[i]) {
            int sum = 0;
            for(int j = 1; j <= siz_e[i]; j++) {
                sum += fpow(k, gcd(siz_p[i], j));
                if(sum >= MOD) sum -= MOD;
            }
            ans2 = ans2 * 1ll * sum % MOD * fpow(siz_e[i], MOD - 2) % MOD; 
    	} else ans3 = ans3 * 1ll * C(siz_e[i] + k - 1, k - 1) % MOD;
    }
    printf("%lld\n", ans1 * 1ll * ans2 % MOD * ans3 % MOD);
    return 0;
}

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

struct dsu {
  int cc;
  vector<int> p, sz;
  dsu(int n = 0) : cc(n), p(n, -1), sz(n, 1) {}
  int root(int v) const {
    while (p[v] != -1) v = p[v];
    return v;
  }
  bool unite(int u, int v) {
    u = root(u), v = root(v);
    if (u == v) return false;
    --cc;
    if (sz[u] < sz[v]) swap(u, v);
    p[v] = u;
    sz[u] += sz[v];
    return true;
  }
  bool same(int u, int v) const { return root(u) == root(v); }
  int size(int v) const { return sz[root(v)]; }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, h, w;
  cin >> n >> h >> w;
  vector<int> x(n), y(n);
  vector<vector<int>> row(h), col(w);
  for (int v = 0; v < n; ++v) {
    cin >> x[v] >> y[v];
    --x[v], --y[v];
    row[x[v]].push_back(v);
    col[y[v]].push_back(v);
  }
  dsu d(n);
  for (auto&& e : row) {
    sort(begin(e), end(e), [&](int u, int v) {
      return y[u] < y[v];
    });
    for (int i = 0; i < (int)e.size() - 1; ++i) {
      d.unite(e[i], e[i + 1]);
    }
  }
  for (auto&& e : col) {
    sort(begin(e), end(e), [&](int u, int v) {
      return x[u] < x[v];
    });
    for (int i = 0; i < (int)e.size() - 1; ++i) {
      d.unite(e[i], e[i + 1]);
    }
  }
  int res = n - 1;
  res += d.cc - 1;
  bool ex = false;
  ex |= *min_element(begin(x), end(x)) == 0;
  ex |= *max_element(begin(x), end(x)) == h - 1;
  ex |= *min_element(begin(y), end(y)) == 0;
  ex |= *max_element(begin(y), end(y)) == w - 1;
  res += d.cc >= 2 and not ex;
  cout << res << '\n';
}



Measured memory_bytes: 10248
n,m = list(map(int, input().split()))
if n==1:
  print(m)
else:
  ans = [m]
  for i in range(n-1):
    ans.append(m-(n-i)+1)
    ans.append(m+i+1)
  ans.sort()
  print(' '.join(map(str, ans)))

Measured memory_bytes: 3060
def main():
    n, x, m = map(int, input().split())
    dic = {}
    p = 0
    while not x in dic:
        p += 1
        dic[x] = p
        x = (x**2) % m
    if n <= p:
        ans = 0
        for ky in dic.keys():
            if dic[ky] <= n:
                ans += ky
        print(ans)
    else:
        ans = 0
        for ky in dic.keys():
            ans += ky
        n -= p
        q = dic[x]
        ln = p - q + 1
        tmp = 0
        for ky in dic.keys():
            if q <= dic[ky] <= p:
                tmp += ky
        tmp *= n // ln
        ans += tmp
        n %= ln
        for ky in dic.keys():
            if q <= dic[ky] < q + n:
                ans += ky
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 75152
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

const vector<int> dy = {-1, 0, 1, 0};
const vector<int> dx = {0, -1, 0, 1};

int main() {
  int h, w, white = 0, rst = 0;
  cin >> h >> w;
  
  vector<vector<char>> map(h + 2, vector<char>(w + 2, '#'));
  queue<pair<int, int>> black;
  
  for (int row = 1; row <= h; row++) {
    for (int column = 1; column <= w; column++) {
      cin >> map[row][column];
      if (map[row][column] == '.') white++;
      else black.push(make_pair(row, column));
    }
  }
  
  vector<vector<int>> distances(h + 2, vector<int>(w + 2, -1));
  
  while (!black.empty() || white != 0) {
    int y = black.front().first;
    int x = black.front().second;
    if (distances[y][x] == -1) distances[y][x] = 0;
    black.pop();
    
    for (int i = 0; i < 4; i++) {
      int ny = y + dy.at(i);
      int nx = x + dx.at(i);

      if (distances.at(ny).at(nx) == -1 && map.at(ny).at(nx) == '.') {
        black.push({ny, nx});
        distances.at(ny).at(nx) = distances.at(y).at(x) + 1;
        rst = max(rst, distances.at(ny).at(nx));
        white--;
      }
    }
  }
  
  cout << rst << endl;
  return 0;
}

Measured memory_bytes: 13456
mod = 10**9+7
M = 2*10**6

fact = [1]*(M+1)
factinv = [1]*(M+1)
inv = [1]*(M+1)
for n in range(2,M+1):
    fact[n] = n*fact[n-1]%mod
    inv[n] = -inv[mod%n]*(mod//n)%mod
    factinv[n] = inv[n]*factinv[n-1]%mod

def comb(n,k):
    return fact[n]*factinv[k]*factinv[n-k]%mod

def main(K,S):
    n = len(S)
    ans = 0

    for k in range(K+1):
        ans += comb(n+k-1,k)*pow(25,k,mod)*pow(26,K-k,mod)
        ans %= mod
    print(ans)

if __name__ == '__main__':
    K = int(input())
    S = input()
    main(K,S)

Measured memory_bytes: 117536
#include <iostream>
#include <map>
#include <string>

using namespace std;
map<string,int> table;
int main(){
    string word, frequent, longest;
    size_t N=0;
    while (cin >> word) {
        table[word]++;
        if(table[word]>N){
            N = table[word];
            frequent = word;
        }
        if(word.size()>longest.size()){
            longest = word;
        }
    }
    cout << frequent << " " << longest << endl;
}

Measured memory_bytes: 2980
from fractions import gcd

a,b = map(int,input().split())

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)

    if temp!=1:
        arr.append(temp)

    if arr==[]:
        arr.append(n)

    return arr
  
a = factorization(a)
b = factorization(b)
if (len(a)==1 and a[0] == 1) or (len(b)==1 and b[0] == 1):
  print(1)
else:
  print(len(set(a) & set(b)) + 1)

Measured memory_bytes: 5340
#include <bits/stdc++.h>
using namespace std;
#define N 510000
char s[N],s1[N];
int len,len1,sum;
void add()
{
	int i;
	for(i=1;i<=len&&s[i]=='9';i++)
		s[i]='0',sum-=9;
	if(i==len+1)
	{
		len++;
		s[len]='0';
	}
	s[i]++,sum++;
}
int main()
{
	//freopen("tt.in","r",stdin);
	scanf("%s",s1+1);
	len1=strlen(s1+1);
	reverse(s1+1,s1+1+len1);
	int pre=0;
	for(int i=1;i<=len1;i++)
	{
		int t=(s1[i]-'0')*9+pre;
		s[i]=t%10+'0';
		pre=t/10;
	}
	len=len1;
	if(pre)s[++len]=pre+'0';

	for(int i=1;i<=len;i++)
		sum+=s[i]-'0';
	for(int i=1;;i++)
	{
		for(int j=1;j<=9;j++)add();
		if(sum<=9*i)
		{
			printf("%d\n",i);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 1280
import sys
def input():
    return sys.stdin.readline()[:-1]
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

import bisect
from collections import deque

lis = deque()
for i in range(n):
    ind = bisect.bisect_left(lis,a[i])
    if ind==0:
        lis.appendleft(a[i])
    else:
        lis[ind-1] = a[i]

print(len(lis))


Measured memory_bytes: 8064
let f=Scanf.scanf open List;;let s(a,b)=(b,a);;let($)d c=match d with|[x;y;z]->(match c with|'N'->[y;s x;z]|'S'->[s y;x;z]|'E'->[s z;y;x]|'W'->[z;y;s x]|'Z'->[x;z;s y]|_->[])|_->[]and z=f"%d %d %d %d %d %d\n"(fun a b c d e f->[(a,f);(b,e);(c,d)]);;for _=1to f"%d
"(fun i->i)do f"%d %d
"(fun x y->Printf.printf"%d
"(fst(nth(hd(filter(fun d->x=(fst(hd d))&&y=(fst(nth d 1)))(concat(map(fun d->[d;d$'Z';d$'Z'$'Z';d$'Z'$'Z'$'Z'])[z;z$'N';z$'W';z$'E';z$'S';z$'S'$'S']))))2)))done

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

using namespace std;

#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;

const int M = 888;
const int N = M * M;

int n, m, k;
char a[M][M];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
bool u[M][M];
int d[M][M];
pii q[N];
int qs = 0, qf = 0;

void read() {
    cin >> n >> m >> k;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            cin >> a[i][j];
}

bool inside(int x, int y) {
    return 1 <= x && x <= n && 1 <= y && y <= m;
}

void bfs() {
    while (qs < qf) {
        int x, y;
        tie(x, y) = q[qs++];
        for (int i = 0; i < 4; ++i) {
            int tx = x + dx[i];
            int ty = y + dy[i];
            if (inside(tx, ty) && !u[tx][ty] && a[tx][ty] != '#') {
                d[tx][ty] = d[x][y] + 1;
                u[tx][ty] = true;
                q[qf++] = pii{tx, ty};
            }
        }
    }
}

int dist(int x, int y) {
    int ans = min({
            x - 1,
            n - x,
            y - 1,
            m - y
            });
    return ans;
}

void kill() {
    int sx, sy;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j) {
            if (a[i][j] == 'S')
                sx = i, sy = j;
        }


    u[sx][sy] = true;
    q[qf++] = pii{sx, sy};
    bfs();

    int ans = 1e9;

    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            if (u[i][j] && d[i][j] <= k) {
                ans = min(ans, 1 + (dist(i, j) + k - 1) / k);
            }

    cout << ans << endl;
}


int main() {
#ifdef LOCAL
  assert(freopen("c.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  read();
  kill();

}



Measured memory_bytes: 11008
N,P = map(int, input().split())
gc = []
if N == 1:
    print(P)
    exit(0)

for i in range(2,int(1e7)+1):
    if P % i == 0:
        cnt = 0
        while P % i== 0 and P != 0:
            cnt += 1
            P //= i
        gc.append( (i, cnt) )
        if P == 0:
            break
ans = 1
for g,c in gc:
    if c >= N:
        ans *= g**(c//N)
print(ans)


Measured memory_bytes: 3064
N = input().rstrip()
N_list = list(N)

select_num = int(N_list[0])
next_str = ''
next_str += str(select_num)
next_str += str(select_num)
next_str += str(select_num)

if int(next_str) >= int(N):
  print(next_str)
else:
  select_num += 1
  next_str = ''
  next_str += str(select_num)
  next_str += str(select_num)
  next_str += str(select_num)
  print(next_str) 


Measured memory_bytes: 3060
N, X, Y = map(int, input().split())

d = [0] * N
for i in range(1, N):
    for j in range(i + 1, N + 1):
        if j <= X:
            a = j - i
        elif i <= X and j >= Y:
            a = (X - i) + (j - Y) + 1
        else:
            a = min(j - i, abs(X - i) + 1 + abs(Y - j))

        d[a] += 1
for ans in d[1:]:
    print(ans)


Measured memory_bytes: 74284
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 3;
int a[N], b[N];
int n;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i] >> b[i];
	}

	int T = 0;
	for(int i = n; i >= 1; i--)
	{
		a[i] += T;
		int tmp = a[i] / b[i];
		if(a[i] % b[i] != 0)
			tmp++;
		T += tmp * b[i] - a[i];
	}

	cout << T ;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL

int H, W;
vector<tuple<int, int, int, int>> ans(0);

void func(P p1, P p2){
  int a = p1.first, b = p1.second, c = p2.first, d = p2.second;
  int y = a, x = b;
  while(true){
    if(y % 2 == 0){
      if(x != W-1){
        ans.push_back(make_tuple(y, x, y, x+1));
        x++;
      }
      else{
        ans.push_back(make_tuple(y, x, y+1, x));
        y++;
      }
    }
    else{
      if(x != 0){
        ans.push_back(make_tuple(y, x, y, x-1));
        x--;
      }
      else{
        ans.push_back(make_tuple(y, x, y+1, x));
        y++;
      }
    }
    if(y == c && x == d) break;
  }
  
}

int main(){
  cin >> H >> W;
  vvi a(H, vi(W, 0));
  vector<P> odd(0);
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> a.at(i).at(j);
    }
  }
  for(int i = 0; i < H; i++){
    if(i % 2 == 0){
      for(int j = 0; j < W; j++){
        if(a.at(i).at(j) % 2 != 0) odd.push_back(P(i, j));
      }
    }
    else{
      for(int j = W-1; j >= 0; j--){
        if(a.at(i).at(j) % 2 != 0) odd.push_back(P(i, j));
      }
    }
  }

  
  int num = odd.size()/2;

  for(int i = 0; i < num; i++){
    int p = 2 * i, q = 2 * i + 1;
    func(odd.at(p), odd.at(q));
  }
  cout << ans.size() << endl;
  for(auto x: ans) cout << get<0>(x)+1 << ' ' << get<1>(x)+1 << ' ' << get<2>(x)+1 << ' ' << get<3>(x)+1 << endl;
}

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

using namespace std;
int h, w;
int a, b;
const int N = 1003;
int ar[N][N];
bool ok() {
    for (int i = 0; i < h; i++) {
        int cnt_0 = 0;
        for (int j = 0; j < w; j++) {
            cnt_0 += ar[i][j] == 0;
        }
        int x = min(cnt_0, w - cnt_0);
        if (x != a) {
            return false;
        }
    }
    for (int j = 0; j < w; j++) {
        int cnt_0 = 0;
        for (int i = 0; i < h; i++) {
            cnt_0 += ar[i][j] == 0;
        }
        int x = min(cnt_0, h - cnt_0);
        if (x != b) {
            return false;
        }
    }
    return true;
}

void print() {
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << ar[i][j];
        }
        cout << "\n";
    }
}

int main() {
    cin >> h >> w >> a >> b;
    if (a == 0 || b == 0) {
        if (b == 0) {
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if (j < a) {
                        ar[i][j] = 0;
                    } else {
                        ar[i][j] = 1;
                    }
                }
            }
        } else {
            for (int j = 0; j < w; j++) {
                for (int i = 0; i < h; i++) {
                    if (i < b) {
                        ar[i][j] = 0;
                    } else {
                        ar[i][j] = 1;
                    }
                }
            }
        }
        if (ok()) {
            print();
        } else {
            cout << -1;
        }
        return 0;
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            ar[i][j] = 0;
        }
    }
    for (int i = 0; i < b; i++) {
        for (int j = 0; j < a; j++) {
            ar[i][j] = 1;
        }
    }
    for (int i = b; i <= h; i++) {
        for (int j = a; j <= w; j++) {
            ar[i][j] = 1;
        }
    }

    if (ok()) {
        print();
    } else {
        print();
        cout << -1;
    }
	return 0;
}


Measured memory_bytes: 5120
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        int n = Integer.valueOf(arr01[0]);
        int r = Integer.valueOf(arr01[1]);

        System.out.println(n >= 10 ? r : 100 * (10 - n) + r);
    }
}


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

int main(){
  int n,m;
  cin >> n >> m;
  int c=m/n;
  int ans;
  if(n==1){
    cout << m << endl;
  }
  else{
    for(int i=1;i<=c;i++){
      if(m%i==0){
      ans=i;
     }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
using namespace std;
int main() {
	int a = 0, b = 0, c = 0, d = 0, e = 0, count = 0;
	cin >> a >> b;
	if (a == 2 || b == 2) {
		cout << "No" << endl;
	}
	else { cout << "Yes" << endl; }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<double> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  vector<int> v;
  for (int i = 0; i < n; i++) {
    v.push_back(i);
  }
  double sum = 0;
  do {
    for (int i = 1; i < n; i++) {
      sum += sqrt((x[v[i]] - x[v[i - 1]])*(x[v[i]] - x[v[i - 1]]) + (y[v[i]] - y[v[i - 1]])*(y[v[i]] - y[v[i - 1]]));
    }
  } while(next_permutation(v.begin(), v.end()));
  double z = 1;
  for (int i = 1; i <= n; i++) {
    z *= i;
  }
  double ans = sum/z;
  printf("%.16lf\n", ans);
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x >= y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x <= y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int n, h, w;
  cin >> n >> h >> w;
  cout << (n - h + 1) * (n - w + 1) << '\n';
}


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

int main() {
  int N;
  long long Sum=0;
  cin >> N;
  vector<long long> A(N);
  map<long long, int> M;
  rep(i, N) cin >> A.at(i);
  rep(i, N) M[i+A.at(i)]++;
  rep(i, N) Sum+=M[i-A.at(i)];
  cout << Sum << endl;
}

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



int main() {

    int n; cin >> n;
    int ans = 1000000000;

    rep(i,n) {
        int tmp; cin >> tmp;
        int cnt = 0;

        if(tmp%2 != 0) {
            ans = 0;
            break;
        }
        while(tmp%2 == 0) {
            tmp /= 2;
            cnt++;
        }
        ans = min(ans,cnt);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

bool judge(vector<int> v){
    for(int i = 0; i < 8; i++)  if(v[i] != v[i+1])  return false;
    for(int i = 9; i < 11; i++) if(v[i] != v[i+1])  return false;
    for(int i = 12; i < 14; i++) if(v[i] != v[i+1])  return false;
    for(int i = 15; i < 17; i++) if(v[i] != v[i+1])  return false;
    for(int i = 18; i < 20; i++) if(v[i] != v[i+1])  return false;
    for(int i = 21; i < 29; i++) if(v[i] != v[i+1])  return false;
    return true;
}

pair<int,int> rot[4][5] = {
    {{23,0}, {26,3}, {29,6}, {9,20}, {15,17}},
    {{21,6}, {22,7}, {23,8}, {12,17}, {9,11}},
    {{21,2}, {24,5}, {27,8}, {11,18}, {12,14}},
    {{27,0}, {28,1}, {29,2}, {14,15}, {18,20}},
};

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

    while(n-- > 0){
        vector<int> v(30);
        for(int i = 0; i < 30; i++) cin >> v[i];
        
        queue<pair<int,vector<int>>> q;
        q.push({0, v});

        while(!q.empty()){
            auto p = q.front(); q.pop();

            if(judge(p.second)){
                cout << p.first << endl;
                break;
            }
            
            v = p.second;

            for(int i = 0; i < 4; i++){
                vector<int> n = v;
                for(int j = 0; j < 5; j++){
                    swap(n[rot[i][j].first], n[rot[i][j].second]);
                }
                
                q.push({p.first+1, n});
            }
        }

    }

    return 0;
}


Measured memory_bytes: 15264
#include"bits/stdc++.h"
using namespace std;
int a,b;
int main(){
    cin>>a>>b;
    if(a>0)cout<<"Positive";
    else if(a==0||(a<0&&b>0))cout<<"Zero";
    else if((abs(b)-abs(a))%2!=0)cout<<"Positive";
    else cout<<"Negative";
    return 0;
}

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

using namespace std;

int store[202];

int main() {
  int n, l;
  cin >> n >> l;
  for(int i = 0; i < n; i++) {
    store[i] = l + i;
  }
  int sum = 0;
  for(int i = 0; i < n; i++) sum += store[i];
  int diff = INT_MAX, ans = 0;
  for(int i = 0; i < n; i++) {
    if(abs(sum - (sum - store[i])) < diff) {
      diff = abs(sum - (sum - store[i]));
      ans = (sum - store[i]);
    }
  }
  cout << ans << '\n';
}


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

using namespace std;

int main() {
  string S;
  cin>>S;
  
  int min=1000000;
  for(int i=0;i<S.size()-2;++i){
    int x=stoi(S.substr(i,3));
    int y=abs(x-753);
    if(y<min)
      min=y;
  }
  
  cout<<min<<endl;
  
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a,b,c,d,e,f;
  int x1,y1;
  int i;
  double x,y;
  double  A,B;

  while(scanf("%d %d %d %d %d %d\n%",&a,&b,&c,&d,&e,&f) != EOF){

   

    A = (c*d-f*a);

    B = (b*d-e*a);

    y = (double)A/(double)B;

  
  
    x = (c-b*y)/a;


    if(x>=0){
      x1 = x*1000+0.5;
      x = (double)x1/1000;
    }else{
      x1 = (-1)*x*1000+0.5;
      x = (double)x1/1000*(-1);
    }

    if(y>=0){
      y1 = y*1000+0.5;
      y = (double)y1/1000;
    }else{
      y1 = (-1)*y*1000+0.5;
      y = (double)y1/1000*(-1);
    }
  
    printf("%.3lf %.3lf\n",x,y);
    
    i++;
  }
  return 0;
}

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

using namespace std;
#define BUF (1000)
#define ll long long 

ll n,k;
ll ans = 0;

int main(void){
	cin >> n >> k;

	for(int b=k+1;b<=n;b++){
		ans+=(b-k)*(n/b);
		if(k==0) ans--;
		ll tmp = n%b-k+1;
		if(tmp>0){
			ans+=tmp;
		}
	}

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


Measured memory_bytes: 256
#include <stdio.h>

long long gcd(long long a, long long b)
{
	if (a > b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}
	if (b % a == 0) return a;
	else return gcd(b % a, a);
}

int main()
{
	int i, N;
	long long M, a[100001];
	scanf("%d %lld", &N, &M);
	for (i = 1; i <= N; i++) scanf("%lld", &(a[i]));
	
	long long g = a[1], l, b;
	for (i = 2; i <= N; i++) g = gcd(g, a[i]);
	for (b = 2; (g & b) == 0; b <<= 1);
	for (i = 1, l = b >> 1; i <= N; i++) {
		a[i] /= b;
		if (a[i] % 2 == 0) break;
		l *= a[i] / gcd(a[i], l);
		if (l > M) break;
	}
	
	if (i <= N) printf("0\n");
	else printf("%lld\n", (M + l) / l / 2);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2508
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Clue = Tuple!(long, "x", long, "y", long, "h");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

long cnt;

void main()
{
    auto n = lread();
    real t = cast(double) n / 3;
    writefln("%.15s", t * t * t);
}

bool is_reverse(string s)
{
    bool ret = true;
    foreach(i; iota(s.length))
    {
        ret &= (s[i] == s[$ - 1 - i]);
    }
    return ret;
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

int main(){
    int a, b;
    string s;
    cin >> a >> b;
    
    if(a > b){
        s = "a > b";
    }else if(a < b){
        s = "a < b";
    }else if(a == b){
        s = "a == b";
    }
    
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3224
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    String[] s = new String[N];

    for (int i = 0; i < N; i++) {
      String s_ = sc.next();
      int n_ = sc.nextInt();
      int distance = 100 - n_;
      s_ = s_ + "/" + String.format("%03d", distance) + "/" + String.format("%03d", i);
      s[i] = s_;
    }

    sc.close();

    Arrays.sort(s);

    for (int i = 0; i < N; i++) {
      String[] r = s[i].split("/");
      System.out.println(Integer.valueOf(r[2]) + 1);
    }

  }

}

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

int main(){
  int N;

  cin >> N;

  if(N % 2 == 0)
  {
    cout << (N/2.0)/N << endl;
  }
  else
  {
    cout << ((N-1)/2.0+1)/N << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#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++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int64_t a, b, x;
    cin >> a >> b >> x;
    if (a == 0)
    {
        cout << (b / x) + 1 << endl;
        return 0;
    }
    int64_t aa = (a - 1) / x;
    int64_t bb = b / x;
    cout << bb - aa << endl;
}


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

int main()
{
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << (H - h) * (W - w) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define s true
using namespace std;
int abs(int i,int j){
	int f=i-j;
	if(f<0){
		i*=-1;
	}
	return f;
}

int main(){
	int num[102];
	for(int i=0;i<102;i++){
		num[i]=0;
	}
	int a,b,menge;
	cin>>a>>menge;
	for(int i=0;i<menge;i++){
		cin>>b;
		num[b]=1;
	}
	for(int i=a ,j=a;true;i++,j--){
		if(num[j]==0){
			cout<<j;
			return 0;
		}
		else if(num[i]==0){
			cout<<i;
			return 0;
		}
	}
	
return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

constexpr double eps=1e-9;
constexpr double PI=3.14159265358979323846264338327950;

inline int sgn(double x){
    if(x<-eps) return -1;
    if(x>eps) return 1;
    return 0;
}

inline bool EQ(double x, double y){
    return sgn(x-y)==0;
}

inline bool GE(double x, double y){
    return sgn(x-y)==1;
}

inline bool LE(double x, double y){
    return sgn(x-y)==-1;
}

inline bool GEQ(double x, double y){
    return sgn(x-y)>=0;
}

inline bool LEQ(double x, double y){
    return sgn(x-y)<=0;
}

int main(){
    int n, m = 256;
    while(scanf("%d", &n) && n){
        int I[n+1], O[n+1], R[n+1];
        rep(i, n) scanf("%d", &I[i+1]);
        double tmp = INF;
        int S, A, C;
        rep(s, 16)rep(a, 16)rep(c, 16){
            vector<int> cnt(256, 0);
            R[0] = s;
            rep(i, n) R[i+1] = (a * R[i] + c) % m;
            rep(i, n){
                O[i+1] = (R[i+1] + I[i+1]) % m;
                ++cnt[O[i+1]];
            }
            double H = 0;
            rep(i, 256)if(cnt[i]) H -= cnt[i] * log(1.0*cnt[i] / n);
            if(LE(H, tmp)){
                S = s, A = a, C = c;
                tmp = H;
            }
        }
        printf("%d %d %d\n", S, A, C);
    }
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;
constexpr int MAX = 2000200;
constexpr double EPS = 1E-11;

using namespace std;

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

	int a = 0;
	int b = 0;

	rep(i, n) {
		if (s[i] == 'R')a++;
		if (s[i] == 'B')b++;
	}
	if (a > b) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}




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

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


Measured memory_bytes: 3120
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,j,k)  for(register int i=(int)(j);i<=(int)(k);i++)
#define rrep(i,j,k) for(register int i=(int)(j);i>=(int)(k);i--)

ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}

string s;
vector<int> a,b;
bool dp[5050][16080];

int main(){
	cin>>s;int x=read(),y=read();s=s+'T';
	int cnt=0;int flag=1;
	for(int i=0;i<s.size();i++){
		if(s[i]=='T'){
			if(flag) a.pb(cnt); else b.pb(cnt);
			cnt=0;flag^=1;
		}
		else cnt++;
	}
	dp[1][a[0]+8010]=1;
	for(int i=1;i<a.size();i++){
		int nw=a[i];
		for(int j=0;j<16030;j++){
			if(dp[i][j]){
				if(j>=nw) dp[i+1][j-nw]=1;
				if(j+nw<=16020) dp[i+1][j+nw]=1;
			}
		}
	}
	bool ok=1;
	if(dp[a.size()][x+8010]) ok=1;else ok=0;
	memset(dp,0,sizeof(dp));
	dp[0][8010]=1;
	for(int i=0;i<b.size();i++){
		int nw=b[i];
		for(int j=0;j<16030;j++){
			if(dp[i][j]){
				if(j>=nw) dp[i+1][j-nw]=1;
				if(j+nw<=16020) dp[i+1][j+nw]=1;
			}
		}
	}
	if(dp[b.size()][y+8010]); else ok=0;
	if(ok)puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 79616
#include <stdio.h>
int main()
{
	int a[10001], b[10001], i, k;
	i = 1;
	while (1) {
		scanf("%d %d", &a[i], &b[i]);
		if (a[i] == 0 && b[i] == 0) { break; }
		else { if (a[i] >= b[i]) { printf("%d %d\n", b[i], a[i]); }
		else { printf("%d %d\n", a[i], b[i]); } }
	}

	return 0;
}



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

int main(void)
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while (1) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
}


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



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

	int N;
	cin >> N;
	char* S = new char[N];
	cin >> S;

	set<int> Sr;
	set<int> Sg;
	set<int> Sb;

	for (int i = 0; i < N; i++) {
		if (S[i] == 'R') Sr.insert(i +1);
		if (S[i] == 'G') Sg.insert(i+1);
		if (S[i] == 'B') Sb.insert(i+1);
	}

	ll maxC = Sr.size() * Sg.size() * Sb.size();
	set<tuple<int, int, int> > c;
	for (auto it = Sr.begin(); it != Sr.end(); it++) {
		for (auto jt = Sg.begin(); jt != Sg.end(); jt++) {
			int a = *it < *jt ? *it : *jt;
			int b = *it < *jt ? *jt : *it;
			int i = 2 * a - b;
			int j = (((a + b) % 2) == 1) ? 0 : (a + b) / 2;
			int k = 2 * b - a;
//			std::cout << "(" << a << ", " << b << ") : ";
			if (Sb.find(i) != Sb.end()) {
				c.insert(tuple<int,int,int>(i,a,b));
//				std::cout << "find i = " << i << ", "; 
			}
			if (Sb.find(j) != Sb.end()) {
				c.insert(tuple<int, int, int>(a, j, b));
//				std::cout << "find j = " << j << "(" << a << "," << b << "), "; 
			}
			if (Sb.find(k) != Sb.end()) {
				c.insert(tuple<int, int, int>(a, b, k));
//				std::cout << "find k = " << k << ", "; 
			}
//			std::cout << endl;
 		}
	}
//	std::cout << maxC << "," << c.size() << endl;
	std::cout << maxC - c.size() << endl;

//	for (auto it = c.begin(); it != c.end(); it++) {
//		cout << "(" << std::get<0>(*it) << "," << std::get<1>(*it) << "," << std::get<2>(*it) << endl;
//	}
}


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

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    while ( x != NIL ) {
        y = x;
        if ( z->key < x->key ) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if ( y == NIL ) {
        root = z;
    } else {
        if ( z->key < y->key ) {
            y->left = z;
        } else {
            y->right = z;
        }   
    }
}

void inorder (Node *u) {
    if ( u == NIL ) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}
void preorder (Node *u) {
    if ( u == NIL ) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n, i, x;
    string com;

    scanf("%d", &n);

    for (i = 0; i<n; i++ ) {
        cin >> com;
        if (com == "insert" ) {
            scanf("%d", &x);
            insert(x);
        } else if ( com == "print" ) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
return 0;
}



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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  int cnt = 0;
  while(true){
    for(int i = 0; i < n; i++){
      if(a[i] % 2 != 0){
        cout << cnt << endl;
        return 0;
      }
    }
    for(int i = 0; i < n; i++){
      a[i] /= 2;
    }
    cnt++;
  }
}

Measured memory_bytes: 3636
import math

def calc(a,b,x):
    return math.floor(a*x/b) - a*math.floor(x/b)
    
def main():
    A,B,N = [int(x) for x in input().split()]
    if N < B:
        print(calc(A,B,N))
    else:
        print(calc(A,B,B-1))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
#include <stdio.h>

int main(){
  int N,K,Q,T;
  int A[100002]={};
  scanf("%d %d %d",&N,&K,&Q);
  for(int i=1;i<=N;i++)
    A[i]=0;
  for(int i=1;i<=Q;i++){
    scanf("%d",&T);
    A[T]++;
  }
  for(int i=1;i<=N;i++){
    if(Q-A[i]<K) printf("Yes\n");
    else printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 2020
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
        int N = Integer.parseInt(br.readLine());
        String[] heightStrings = br.readLine().split(" ");
        int[] h = new int[N+1];
        h[0] = 0;
        for(int i=1;i<N+1;++i)
            h[i] = Integer.parseInt(heightStrings[i-1]);

        heightStrings = null;

        System.out.println(solution(N, h));
    }

    public static int solution(int N, int[] heights) {
        int[] A = new int[N+1];
        A[0] = 0;
        A[1] = heights[1-1];
        A[2] = Math.abs(heights[2] - heights[1]);

        for(int i=3;i<N+1;++i) {
            A[i] = Math.min(
                Math.abs(heights[i] - heights[i-1]) + A[i-1], 
                Math.abs(heights[i]-heights[i-2]) + A[i-2]
            );
        }

        return A[N];
    }
}

Measured memory_bytes: 34140
#include<iostream>
#include<string>
int main() {

	int output = 0;
	std::string cinput;
	std::cin >> cinput;
	for (int cnti = 0; cnti < cinput.size(); cnti++) {
		if (cinput[cnti] == '+') output++;
		if (cinput[cnti] == '-') output--;
	}
	std::cout << output << std::endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using static System.Console;

namespace ABC129B
{
    static class Program
    {
        static void Main(string[] args)
        {
            var n = ReadLine().TryParse<int>();

            var line = ReadLine().SplitTryParseToList<int>();

            var sum1 = line.Sum();
            int sum2 = 0;

            var list = new List<int>();;

            for (int i = 0; i < line.Count; i++)
            {
                sum2 += line[i];
                sum1 -= line[i];

                list.Add(Math.Abs(sum2 - sum1));
            }

            WriteLine(list.Min());

        }

        public static T TryParse<T>(this String input)
        {
            try
            {
                var converter = TypeDescriptor.GetConverter(typeof(T));
                if (converter != null)
                {
                    return (T)converter.ConvertFromString(input);
                }
                else
                {
                    throw new InvalidCastException("");
                }
            }
            catch
            {
                throw new InvalidCastException(typeof(T) + " is not supported.");
            }
        }

        public static List<T> SplitTryParseToList<T>(this String input)
        {
            return input.Split().Select(n => n.TryParse<T>()).ToList();
        }

        public static List<T> ListSwap<T>(this List<T> list, Int32 index1, Int32 index2)
        {
            var t = list[index1];
            list[index1] = list[index2];
            list[index2] = t;
            return list;
        }

        public static List<Tuple<T, int>> DuplicateCount<T>(this IEnumerable<T> list)
        {
            return list
                .GroupBy(i => i)
                .Where(g => g.Any())
                .Select(g => Tuple.Create(g.Key, g.Count()))
                .ToList();
        }
        public static List<Tuple<T, int>> DuplicateSort<T>(this IEnumerable<Tuple<T, int>> list)
        {
            return list.OrderByDescending((x) => x.Item2).ToList();
        }
        public static List<T> ReadLineOne<T>(int n)
        {
            var list = new List<T>();
            foreach (var i in Enumerable.Range(1, n))
            {
                list.Add(Console.ReadLine().TryParse<T>());
            }
            return list;
        }
        public static void PrintAll<T>(this IEnumerable<T> list)
        {
            foreach (var i in list)
            {
                Console.Write($"{i} ");
            }

            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 13408
#include <cstdio>

int a, b, c;
bool f;

int main(){
	scanf("%d %d %d", &a, &b, &c);
	for(int i=1; i<=b; ++i)
		if(a*i%b == c) f = true;
	if(f) printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 128