akhauriyash/Code-Regression huggingface dataset:
# abc148_c.py
# https://atcoder.jp/contests/abc148/tasks/abc148_c

# C - Snack /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点: 300点

# 問題文
# 高橋君はパーティを企画しています。
# パーティーでは参加者に 1人 1個以上のお菓子を配る予定です。
# 高橋君は参加者の人数が A人か B人のどちらかになるだろうという予想を立てました。
# どちらの場合でも均等に配りきることができるようなお菓子の個数の最小値を求めてください。
# ただし、 1個のお菓子を分割して複数人で分けることはできないものとします。

# 制約
#     1≤A,B≤105
#     A≠B入力はすべて整数

# 入力
# 入力は以下の形式で標準入力から与えられる。
# A B

# 出力
# 参加者の人数が A人の場合でも B人の場合でも均等に配りきることができるようなお菓子の個数の最小値を出力せよ。

# 入力例 1
# 2 3

# 出力例 1
# 6

# 6個のお菓子があるとき、参加者が 2 人の場合は 3 個ずつ、 3 人の場合は 2個ずつ配ることができます。

# 入力例 2
# 123 456

# 出力例 2
# 18696

# 入力例 3
# 100000 99999

# 出力例 3
# 9999900000


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    A, B = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    import math
    result = (A*B) / math.gcd(A, B)
    result = int(result)
    
    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['2 3']
        lines_export = [6]
    if pattern == 2:
        lines_input = ['123 456']
        lines_export = [18696]
    if pattern == 3:
        lines_input = ['100000 99999']
        lines_export = [9999900000]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9204
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
int main() {
  int n, m, a, b;
  cin >> n >> m;
  vector<int> p(n + 1);
  vector<vector<int> > v(n + 1);
  queue<int> q;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (int i = 2; i <= n; i++) {
    p[i] = -1;
  }
  p[1] = 1;
  q.push(1);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = 0; i < v[x].size(); i++) {
      if (p[v[x][i]] == -1) {
        p[v[x][i]] = x;
        q.push(v[x][i]);
      }
    }
  }
  cout << "Yes" << endl;
  for (int i = 2; i <= n; i++) {
    cout << p[i] << endl;
  }
}

Measured memory_bytes: 10248
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N = I()
A = LI()

ns = [0] * N
for a in A:
    ns[a-1] += 1

PL(ns)


Measured memory_bytes: 92512
#include <iostream>

using namespace std;

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

    int T, A;
    long long t_min = 1, a_min = 1, ans;
    for (int i = 0; i < N; i++) {
    	cin >> T >> A;

    	t_min = (((t_min - 1) / T) + 1) * T;
    	a_min = (((a_min - 1) / A) + 1) * A;

    	if (t_min / T * A < a_min) {
    		t_min = a_min / A * T;
    	} else {
    		a_min = t_min / T * A;
    	}
    }

    ans = t_min + a_min;

    cout << ans << endl;

    return 0;
}

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

using namespace std;
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
#define debug(_x)		cerr << #_x << '=' << (_x) << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << (_x) << ' ' << #_y << '=' << (_y) << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << (_x+1) << ' '; cerr << endl;

#define HERE debug(__LINE__);

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;

#define pow5(x) ((x)*(x)*(x)*(x)*(x))

int32_t main() {
	FAST_IO;
	
	int x;
	cin >> x;

	for (int i = -1000; i <= 1000; i++) {
		int b = pow5(i);
		int need = x+b;
		int l = -1000, r = 1001;
		while (l < r) {
			int mid = (l+r)>>1;
			
			if (pow5(mid) < need) {
				l = mid+1;
			} else {
				r = mid;
			}
		}
		
//		cout << l << ' ' << i << endl;
		if (pow5(l)-b == x) {
			cout << l << ' ' << i << endl;
			break;
		}
	}
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    string S, T;
    cin >> S >> T;
    int N = S.size(), M = T.size();
    //[0,i)
    int sa[N+1], sb[N+1], ta[M+1], tb[M+1];
    sa[0] = sb[0] = ta[0] = tb[0] = 0;
    rep(i, N){
        sa[i+1] = sa[i], sb[i+1] = sb[i];
        if(S[i] == 'A') sa[i+1]++;
        else sb[i+1]++;
    }
    rep(i, M){
        ta[i+1] = ta[i], tb[i+1] = tb[i];
        if(T[i] == 'A') ta[i+1]++;
        else tb[i+1]++;
    }
    int Q;
    cin >> Q;
    rep(i, Q){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int s = (sa[b]-sa[a-1])+2*(sb[b]-sb[a-1]);
        int t = (ta[d]-ta[c-1])+2*(tb[d]-tb[c-1]);
        if(s%3 == t%3) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

int main()
{
  int n,k;
  int h[100000];
  int dp[100000] = {};
  cin >> n >> k;
  REP(i,n) {
    cin >> h[i];
  }

  REP(i,n) {
    int result = 1110001110;
    FOR(j, 1, k+1) {
      if (i <= k) {
        result = abs(h[i] - h[0]);
        break;
      }

      result = min(result, dp[i - j] + abs(h[i] - h[i-j]));
    }
    dp[i] = result;
  }

  cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
char a[1001][1001];
int m[1001][1001];
int h,w;
const int MOD = 1e9 + 7;

int f(int i, int j){
    if (i < 1  || j < 1  || a[i][j] == '#') return 0;
    if(m[i][j] != -1) return m[i][j];
    return m[i][j] = (f(i-1,j)+f(i,j-1)) % MOD;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> h >> w;
    for(int i = 1; i<=h; i++){
        for(int j = 1; j<=w; j++){
            cin >> a[i][j];
            m[i][j] = -1;
        }
    }
    m[1][1] = 1;
    f(h,w);
    cout << f(h,w) << endl;

    return 0;
}



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

using namespace std;

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


Measured memory_bytes: 3516
//#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	//freopen("input.txt", "rt", stdin);
	int n;

	cin >> n;
	
	vector<vector<long long>> dp(n, vector<long long>(3, 0));

	for (int i = 0; i < n; i++) {
		if (i == 0)
		{
			cin >> dp[0][0] >> dp[0][1] >> dp[0][2];
			continue;
		}
		vector<long long> a(3);
		cin >> a[0] >> a[1] >> a[2];
		for (int j = 0; j < 3; j++) {
			dp[i][j] = max(dp[i - 1][(j + 1) % 3] + a[j], dp[i - 1][(j + 2) % 3] + a[j]);
		}
	}

	cout << *max_element(dp[n - 1].begin(), dp[n - 1].end());

	return 0;
}

Measured memory_bytes: 7808
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque

N,Q = map(int,readline().split())
ki = []
for i in range(N-1):
    ki.append(list(map(int,readline().split())))
co = []
for i in range(Q):
    co.append(list(map(int,readline().split())))
 
ki.sort(key=lambda x: x[1])

kid = deque(ki)
ver = []
check = []
for i in range(N):
    ver.append(0)
    check.append(False)
 
for c in co:
    ver[c[0]-1] += c[1]

check[0] = True

kid2 = deque()

while len(kid) != 0:
    k = kid.popleft()
    if check[k[0]-1] == True:
        ver[k[1]-1] += ver[k[0]-1]
        check[k[1]-1] = True
    elif check[k[1]-1] == True:
        ver[k[0]-1] += ver[k[1]-1]
        check[k[0]-1] = True
    else:
        kid2.append(k)

while len(kid2) != 0:
    k = kid2.pop()
    if check[k[0]-1] == True:
        ver[k[1]-1] += ver[k[0]-1]
        check[k[1]-1] = True
    elif check[k[1]-1] == True:
        ver[k[0]-1] += ver[k[1]-1]
        check[k[0]-1] = True
    else:
        kid2.appendleft(k)


print(' '.join(map(str,ver)))


Measured memory_bytes: 129824
N,M=map(int,input().split())
A=[]
for j in range(N):
    A.append([int(i) for i in input().split()])
    A[j].pop(0)
ans=0

for i in range(1,M+1):
    for j in range(N):
        if not i in A[j]:
            break
        if j==N-1 and i in A[j]:
            ans+=1

print(ans)

Measured memory_bytes: 3064
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

ll gcd(ll a,ll b){
    if ( b == 0 ) return a ;
    return gcd(b,a%b);
}

int main(){
    int n ;
    cin >> n ;
    vector<int> v(n) ;
    for(int &x : v){
        cin >> x ;
    }
    vector<int> left(n+1) ;
    vector<int> right(n+1) ;
    left[0] = 0 ;
    right[n] = 0 ;
    for(int i=0;i<n;i++){
        left[i+1] = gcd(left[i],v[i]);
    }
    for(int i=n-1;i>=0;i--){
        right[i] = gcd(right[i+1],v[i]);
    }
    debug() << imie(left) ;
    debug() << imie(right) ;
    int nax = right[0] ;
    debug() << imie(nax) ;
    for(int i=1;i<=n;i++){
        int ans = gcd(left[i-1],right[i]);
        nax = max(nax,ans);
        debug() << imie(nax) ;
    }
    cout << nax << endl;
    return 0 ;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	string str;
	string longstr;
	string maxwordstr;
	int maxword=0;
	map<string, int> words;
	while (cin >> str) {
		if (str.size() > longstr.size()) {
			longstr = str;
		}
		auto itr = words.find(str);
		if (itr != words.end()) {
			words[str]++;
		}
		else {
			words[str] = 1;
		}
		if (maxword < words[str]) {
			maxword = words[str];
			maxwordstr = str;
		}
	}
	cout << maxwordstr << " " << longstr<<endl;
	return 0;
}

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

m = {}
for i in range(10):
    has_num = False
    for d in D:
        if d == i:
            has_num = True
            break
    if has_num:
        m[i] = True
    else:
        m[i] = False

min_cost = N
while(True):
    min_cost_list = list(str(min_cost))
    num_list = [int(i) for i in min_cost_list]
    has_num = False
    for n in num_list:
        if m[n]:
            has_num = True
    if has_num:
        min_cost += 1
        continue
    else:
        break
print(min_cost)


Measured memory_bytes: 3064
#include <stdio.h>
 
int main(void){
    int i,j,k,n,a,b,dice[7],
        side[5] = {2,3,5,4,2};
    char order[7][3] = {"","","N","W","E","S","NN"};
     
    for(i=1;i<7;i++)
        scanf("%d", &dice[i]);
     
    scanf("%d", &n);

    for(i=0;i<n;i++){
        scanf("%d%d",&a,&b);
     
        for(j=1;dice[j]!=a;j++);
 
     
        for(k=0;order[j][k]!='\0';k++){
         
            dice[0] = dice[1];
         
            switch(order[j][k]){
                 
                case 'E':
                    dice[1] = dice[4];
                    dice[4] = dice[6];
                    dice[6] = dice[3];
                    dice[3] = dice[0]; 
                    break;
             
                case 'N':
                    dice[1] = dice[2];
                    dice[2] = dice[6];
                    dice[6] = dice[5];
                    dice[5] = dice[0]; 
                    break;
             
                case 'S':
                    dice[1] = dice[5];
                    dice[5] = dice[6];
                    dice[6] = dice[2];
                    dice[2] = dice[0]; 
                    break;
                 
                case 'W':
                    dice[1] = dice[3];
                    dice[3] = dice[6];
                    dice[6] = dice[4];
                    dice[4] = dice[0]; 
                    break;
 
            }
        }
         
        for(j=0;b!=dice[side[j]];j++);
         
        printf("%d\n",dice[side[j+1]]);
         
    }
     
    return 0;
}


Measured memory_bytes: 2052
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>

#define in std::cin
#define out std::cout

int32_t N;
int32_t num[100000];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N;
	for (int32_t i = 0; i < N; ++i)
	{
		in >> num[i];
	}
	int64_t count = 0;
	bool rem = false;
	for (int32_t i = 0; i < N; ++i)
	{
		if (rem)++num[i];
		count += num[i]/2;
		rem = (num[i] / 2) && (num[i] & 1);
	}

	out << count << endl;
	return 0;
}
#endif


Measured memory_bytes: 640
# https://atcoder.jp/contests/abc084/tasks/abc084_c

N = int(input())    # N個の駅
C_list = []         # 駅iからi+1に向かうまでにかかる時間
S_list = []         # 最初の列車が開通式開始後S秒後に駅iを出発
F_list = []         # F秒おきに発車

for n in range(N - 1):
    C, S, F = map(int, input().split())
    C_list.append(C)
    S_list.append(S)
    F_list.append(F)


for i in range(N - 1):

    t = 0
    for j in range(i, N - 1):
        
        # 時刻tにj番目の駅にいる
        # t <= Sなら時刻Sにjを出発して、S + C秒で次の駅に到着する
        if t <= S_list[j]:
            t = S_list[j] + C_list[j]
        
        # そうではなく、t % F == 0なら時刻tにjを出発する
        elif t % F_list[j] == 0:
            t += C_list[j]

        # そうでないなら、開通式開始 t + Fj − (t ％ Fj ) 秒後にjを出発する
        else:
            t += F_list[j] - (t % F_list[j]) + C_list[j]

    print(t)

print(0)

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

void solve()
{
    int n;
    cin>>n;
    
    for(int i=1;i<=9;i++)
    for(int j=1;j<=9;j++)
    if(i*j==n)
    {
        cout<<"Yes";
        return;
    }
    
    cout<<"No";
    return;
}

int main()
{
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <math.h>


//using ll = long long;
int ASC( void *a,  void *b) {
	return strcmp(*(const char **)a, *(const char **)b);//降順
}
int GCD(int a, int b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main(void)
{
	char s[4];
	scanf("%s",s);
	if (s[1] == 'B')
		printf("ARC");
	else
		printf("ABC");
	return 0;
}

Measured memory_bytes: 1676
import sys
input = sys.stdin.readline
N, W = list(map(int, input().split()))
WV = [list(map(int, input().split())) for _ in range(N)]

DP = [[float("inf")] * (10**5+1)]
for _ in range(N):
    DP.append([float("inf")] * (10**5+1))

DP[0][0] = 0

for n in range(N):
    for v in range(10 ** 5 + 1):
        if v - WV[n][1] >= 0:
            DP[n+1][v] = min(DP[n+1][v], DP[n][v - WV[n][1]] + WV[n][0])
        DP[n+1][v] = min(DP[n+1][v], DP[n][v])

ans = 0
for v in range(10 ** 5 + 1):
    if DP[N][v] <= W:
        ans = v

print(ans)


Measured memory_bytes: 312632
#include <bits/stdc++.h>
using namespace std;
using llong = long long;

void fnInput(int& rnLeft, int& rnRigt)
{
  cin >> rnLeft >> rnRigt;
}
  
int fnMinRemain2019(int nLeft, int nRigt)
{
  if (nLeft + 2018 <= nRigt) return 0;         // nLeft～nRigtまでの数に
                                               // 2019 で割り切れる数が存在
  int nMinRem2019 = 2018;

  for (int i = nLeft; i < nRigt; i++)
    for (int j = i + 1; j < nRigt + 1; j++)
    {
      int nRem2019 = (llong)i * j % 2019;
      nMinRem2019 = min(nMinRem2019, nRem2019);
    }

  return nMinRem2019;
}
  
int main()
{
  int nLeft, nRigt;
  fnInput(nLeft, nRigt);
  cout << fnMinRemain2019(nLeft, nRigt) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int N, K;
    cin >> N >> K;
    cout << (N - K + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,sse,sse2,ssse3,sse4.1,sse4.2,tune=native,popcnt")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
const int maxn = 303030;
using vi = vector<int>;
using ll = long long;
int mat[1030][1030];
vector<vi> a;
int n, m;
ll check() {
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			mat[i+1][j+1] = a[i][j] ^ mat[i][j+1];
		}
	}
	ll ans = 0;
	for(int i = 0; i <= n; i++)
		for(int j = 0; j < i; j++) {
			int o = 0, e = 0, pref = 0;
			for(int a = 0; a <= m; a++) 
					((pref ^= mat[i][a]^mat[j][a])?o:e)++;
			ans += o*1ll*e;
		}
	return ans;
}
void print() {
	for(auto i : a) {
		for(auto j : i) cout << j;
		cout << '\n';
	}
	exit(0);
}
void solve(int lx, int rx, int ly, int ry) {
	if(lx == rx && ly == ry) {
		a[lx][ly] = 1;
		return;
	}
	if(rx-lx > ry-ly) {
		int mx = (lx+rx)/2;
		for(int i = ly; i <= ry; i++)
			a[mx][i] ^= 1;
		solve(lx, mx-1, ly, ry);
		solve(mx+1, rx, ly, ry);
		return;
	}
	if(rx-lx < ry-ly) {
		int my = (ly+ry)/2;
		for(int i = lx; i <= rx; i++)
			a[i][my] ^= 1;
		solve(lx, rx, ly, my-1);
		solve(lx, rx, my+1, ry);
		return;
	}
	int mx = (lx+rx)/2;
	for(int i = ly; i <= ry; i++)
		a[mx][i] ^= 1;
	int my = (ly+ry)/2;
	for(int i = lx; i <= rx; i++)
		a[i][my] ^= 1;
	solve(lx, mx-1, ly, my-1);
	solve(lx, mx-1, my+1, ry);
	solve(mx+1, rx, ly, my-1);
	solve(mx+1, rx, my+1, ry);
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m;
	//assert(n==m);
	n = (1<<n)-1, m = (1<<m)-1;
	a= vector<vi>(n, vi(m, 0));
	solve(0, n-1, 0, m-1);
	//cout << check() << '\n';
	print();
}
//1835008:
//2064384
//1572864:


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

int main()
{
    ll n,i;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++) arr[i]=i+1;
    ll sum=0;
    for(i=0;i<n;i++)
    {
        if(arr[i]%5==0 || arr[i]%3==0) arr[i]=0;
    }
    for(i=0;i<n;i++) sum+=arr[i];
    cout<<sum;
}

Measured memory_bytes: 11360
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] tansaku = new int[7368792];
		while(true) {
			int m = sc.nextInt();
			int n = sc.nextInt();
			if(m==0&&n==0) break;
			for(int i=0;i<7368791;++i) {
				tansaku[i]=0;
			}
			for(int i=0;i<n;++i) {
				for(int j=m;j<=7368791;j+=m) tansaku[j]=1;
				while(tansaku[m]==1) m++;
			}
			System.out.println(m);
		}
	}
}



Measured memory_bytes: 55908
#include<bits/stdc++.h>
using namespace std;
//define
typedef pair<int,int>pi;
#define int long long
#define elif else if
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define Rep(x,y) for(int k=x;k<y;k++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define vint vector<int>
#define vvint vector<vector<int>>
#define vtr vector<string>
#define vvtr vector<vector<string>>
#define vhar vector<char>
#define vvhar vector<vector<char>>
#define mod 100000007
#define elif else if
#define str string
int digitsum(int a){
  int b=0;
  while(a){
    b+=a%10;
    a/=10;
  }
  return b;
}
signed main(){
  int N,M,O,P=0,c=0,co=0,cou=0,minN=mod;
  double D,Do;
  char C,Ca;
  str S,T;
  cin>>N;
  vint A(N);
  rep(0,N)cin>>A[i];
  rep(0,N){
    if(A[i]%2==0){
      if(A[i]%3==0||A[i]%5==0)co++;
      else c++;
    }
  }
  c>0?cout<<"DENIED"<<endl:cout<<"APPROVED"<<endl;
}


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

const int nm = 1e5;
int n, m, a[nm], tn = 0;
vector<int> g[nm];
bool b[nm];

priority_queue<int, vector<int>> q;

int minDfs(int v, int p) {

	b[v] = 1;
	int rv = a[v];
	for (int nv : g[v]) {
		if (nv == p)
			continue;
		int minNext = minDfs(nv, v);
		if (minNext < rv)
			swap(rv, minNext);
		q.push(minNext);
		if ((int) q.size() > n - m - 2)
			q.pop();
	}
	return rv;
}
long long ans = 0;

int main() {
	cin >> n >> m;
	if (m == n - 1) {
		cout << 0 << endl;
		return 0;
	}
	if ((n - m - 1) * 2 > n) {
		cout << "Impossible" << endl;
		return 0;
	}
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0, x, y; i < m; i++) {
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	for (int i = 0; i < n; i++) {
		if (!b[i])
			ans += minDfs(i, -1);
	}
	while (!q.empty()) {
		ans += q.top();
		q.pop();
	}
	cout << ans << endl;
}


Measured memory_bytes: 6272
import numpy as np

n,m = map(int, input().split())
h = np.array(list(map(int, input().split())))

high = np.array([True]*n)
cnt = np.array([False]*n)

for _ in range(m):
    a,b = map(int, input().split())
    if h[a-1] < h[b-1]:
        high[a-1] = False
    
    elif h[a-1] > h[b-1]:
        high[b-1] = False
    
    else:
        high[a-1] = False
        high[b-1] = False

ans = np.count_nonzero(high==True)

print(ans)

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

using namespace std;
typedef long long ll;

int main () {
    int N, M, C;  cin >> N >> M >> C;
    vector<int> B(M);
    for (int i = 0; i < M; ++i) cin >> B[i];
    int A[N][M];
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < M; ++j) {
            cin >> A[i][j];
        }
    }

    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        int sum = C;
        for (int j = 0; j < M; ++j) {
            sum += A[i][j] * B[j];
        }

        if (sum > 0) cnt++;
    }

    cout << cnt << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <map>
#include <utility>
#define _GLIBCXX_DEBUG
using namespace std;

int main()
{
    string s;
    cin >> s;
    if (s == "ABC")
    {
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
    
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define MN 100
char s[MN+5][MN+5];
int main()
{
	int n,m,i,j;
	scanf("%d%d",&n,&m);
	for(i=0;i<100;++i)for(j=0;j<100;++j)s[i][j]=i<50?'.':'#';
	for(i=1;i<m;++i)s[i/50*2][i%50*2]='#';
	for(i=1;i<n;++i)s[99-i/50*2][99-i%50*2]='.';
	puts("100 100");
	for(i=0;i<100;++i)puts(s[i]);
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
    	long r, D, x;
    	
        void solve(InputReader in, PrintWriter out) {
            // write your code here
        	r = in.nextLong();
        	D = in.nextLong();
        	x = in.nextLong();
        	
        	for (int i = 0; i < 10; ++i) {
        		x = r*x - D;
        		out.println(x);
        	}
        }
        
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}


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

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i,N) cin >> d[i];
    ll sum = 0;
    rep(i,N) {
        for(int j = i+1; j < N; ++j) {
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool visted[200010];
vector<int> vt[200010];
vector<int> v[200010];
ll n , m ;
ll numberOfConnectedComponent;
void dfs(int index) {
    if(!visted[index]) {
        visted[index] = true;
        vt[numberOfConnectedComponent].push_back(index);
        for(int i=0;i<v[index].size(); i++) {
            dfs(v[index][i]);
        }
    } else {
        return;
    }
}
int main() {
    cin>>n>>m;

    for(int i=0;i<m;i++) {
        int c1 , c2;
        cin>>c1>>c2;
        v[c1-1].push_back(c2-1);
        v[c2-1].push_back(c1-1);
    }
    if(m == 0) {
        cout<<1<<endl;
        return 0 ;
    }
    int maxx = INT_MIN;
    for(int i=0; i<n; i++) {
        if(!visted[i]) {
            dfs(i);
            int tempSize = vt[numberOfConnectedComponent].size();
            maxx = max(maxx, tempSize);
            numberOfConnectedComponent++;
        }
    }
    /*bool haveSinglGrpupe = false;
    for(int i=0;i<n;i++) {
        if(v[i].size() == 0) {
            haveSinglGrpupe = true;
            break;
        }
    }*/
    /*if(haveSinglGrpupe) {
        cout<<maxx-1<<endl;
    }
    else {
        cout<<maxx;
    }*/
    cout<<maxx<<endl;
}


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> x;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        if(a == 1) x.push_back(b);
        if(b == n) x.push_back(a);
    }
    int l = x.size();
    set<int> y(x.begin(),x.end());
    if(l == y.size()) cout << "IMPOSSIBLE" << endl;
    else cout << "POSSIBLE" << endl;
}

Measured memory_bytes: 10356
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(0); cin.tie(); cout.tie()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define endl '\n'
#define len(a) a.length()
#define TIME cout << endl << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
#define f first
#define s second

#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

typedef long long ll;

const long long inf = 1e18;
const double eps = 1e-6;
const long long mod = 1e9 + 7;

int32_t main()
{
    boost;
    int n; cin >> n;
    vector <int> a (n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    sort(all(a), greater<int>());

    ll ans = 0;
    ans += a[0];
    for (int i = 2; i < n; i++) {
        ans += a[i / 2];
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 4028
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
  
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;

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

  int a,b;
  cin>>a>>b;

  rep(i,max(a,b)){
    cout<<min(a,b);
  }
  cout<<'\n';
  return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = 13;
int pw3[maxN];
vector < int > events[729];
string t;
int pos[729];
int mvR[729];
int mvBig[729];
int cur[729];
int ans[729 * 729];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
    pw3[0] = 1;
    for (int i = 1; i <= n; i++) {
        pw3[i] = 3 * pw3[i - 1];
    }
    int small = (n + 1) / 2;
    int big = n - small;

    for (int j = 0; j < pw3[small]; j++) {
        mvR[j] = 0;
        for (int p = 0; p < small; p++) {
            int bit = (j / pw3[p]) % 3;
            if (bit != 0) {
                bit = 3 - bit;
            }
            mvR[j] += bit * pw3[p];
        }
    }
    for (int j = 0; j < pw3[big]; j++) {
        mvBig[j] = 0;
        for (int p = 0; p < big; p++) {
            int bit = (j / pw3[p]) % 3;
            if (bit != 0) {
                bit = 3 - bit;
            }
            mvBig[j] += bit * pw3[p];
        }
    }
    cin >> t;
    for (int i = 0; i < pw3[small]; i++) {
        for (int j = 0; j < pw3[big]; j++) {
            pos[j] = j;
            cur[j] = 0;
        }
        int cur_res = 0;
        int their_res = i;
        for (int j = 0; j < t.size(); j++) {
            if (t[j] == 'S') {
                cur_res ^= 1;
                their_res = mvR[their_res];
            }
            else {
                if (their_res == pw3[small] - 1) {
                    their_res = 0;
                    for (int c = 0; c < pw3[big]; c++) {
                        int t = cur_res ^ cur[c];
                        if (t) {
                            pos[c] = mvBig[pos[c]];
                        }
                        pos[c]++;
                        if (pos[c] == pw3[big]) pos[c] = 0;
                        cur[c] = cur_res;
                    }
                }
                else {
                    their_res++;
                }
            }
        }
        for (int j = 0; j < pw3[big]; j++) {
            if (cur[j] ^ cur_res) {
                pos[j] = mvBig[pos[j]];
            }
            ans[j * pw3[small] + i] = pos[j] * pw3[small] + their_res;
        }
    }
    for (int j = 0; j < pw3[n]; j++) {
        cout << ans[j] << " ";
    }

    return 0;
}

Measured memory_bytes: 6412
// ABC159D - Banned K

#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.at(i);
	}

	map<int, int> T;
	for (int i = 0; i < N; i++) {
		T[A.at(i)]++;
	}

	long long answer = 0;
	for (map<int, int>::iterator it = T.begin(); it != T.end(); it++) {
		pair<int, int> temp = *it;
		if (temp.second > 1) {
			answer += (long long)temp.second * ((long long)temp.second - 1) / 2;
		}
	}

	for (int i = 0; i < N; i++) {
		long long int temp_answer;
		if (T[A.at(i)] <= 1) {
			temp_answer = 0;
		} else {
			temp_answer = (long long)T[A.at(i)] - 1;
		}
		cout << answer - temp_answer << endl;
	}

	return 0;
}


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

int main() {
	int N;
	cin >> N;
	
	map<string, int> value;
	string s[100];
	int strSize = 0;
	for (int i = 0; i < N; ++i) {
		string str;
		cin >> str;
		auto iter = value.find(str);
		if (iter != end(value)) {
			value[str]++;
		}
		else {
			value[str] = 1;
			s[strSize++] = str;
		}
	}

	int M;
	cin >> M;
	for (int i = 0; i < M; ++i) {
		string str;
		cin >> str;
		auto iter = value.find(str);
		if (iter != end(value)) value[str]--;
	}

	int max = 0;
	for (int i = 0; i < strSize; ++i) {
		if (max < value.at(s[i])) max = value.at(s[i]);
	}

	cout << max << endl;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int a; string s;
    cin>>a>>s;
    if (a>=3200) cout << s << endl;
    else cout << "red" << endl; 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

#define ll long long int

using namespace std;

int main() {
  ll mod = 1000000007;
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<ll> probs(n);
  probs[0] = 0;
  for (int i = 1; i < n; i++) {
    ll tmp = mod - 2;
    probs[i] = 1;
    ll base = i + 1;
    while (tmp > 0) {
      if (tmp & 1) probs[i] = (probs[i] * base) % mod;
      base = (base * base) % mod;
      tmp >>= 1;
    }
  }

  vector<ll> sumprobs(n);
  sumprobs[0] = 0;
  for (int i = 1; i < n; i++) {
    sumprobs[i] = (probs[i] + sumprobs[i - 1]) % mod;
  }
  
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ll b = (a[i] * sumprobs[i]) % mod;
    b = (b + a[i] * sumprobs[n - 1 - i]) % mod;
    b = (b + a[i]) % mod;
    ans = (ans + b) % mod;
  }

  for (int i = 0; i < n; i++) {
    ans = (ans * (i + 1)) % mod;
  }
  cout << ans;
}


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

int main()
{
	int n, m, bmax = 0, s = 0;
	int a[1000], b[1000];

	cin >> n >> m;

	for (int i = 0; i < m; i++)
		cin >> a[i] >> b[i];

	for (int i = 0; i < m; i++) {
		if (b[i] > n) {
			if (bmax < b[i])
				bmax = b[i];
			s += b[i] - n;
		}
	}

	cout << s - bmax + n << endl;

	return 0;
}


Measured memory_bytes: 3088
#[allow(unused_imports)]
use std::io::{stdin, Read, StdinLock};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::{HashSet, HashMap, BinaryHeap, VecDeque};
#[allow(unused_imports)]
use std::vec::Vec;

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;
#[allow(dead_code)]
const EPS: f64 = 1.0e-10;
#[allow(dead_code)]
const MOD: i32 = 1000_000_007;
#[allow(dead_code)]
const MODLL: i64 = 1000_000_007;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: String = sc.read();
    let n: Vec<char> = n.chars().collect();
    let ans1 = n.iter().fold(0, |sum, c| sum + c.to_digit(10).unwrap());
    let ans2 = n[0].to_digit(10).unwrap() - 1 + 9 * (n.len() - 1) as u32;
    println!("{}", max(ans1, ans2));
}

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

#include <atcoder/all>

// #LIB#

using namespace std;
using namespace atcoder;
using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#ifdef ONLINE_JUDGE
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');
#endif

int main() {
  ll n, k, q;
  cin >> n >> k;
  vector<ll> x(n);
  rep(i, n) cin >> x[i];
  const ll PM = 24;
  vector<vector<ll>> x_l(n + 1, vector<ll>(PM, 0)), x_r(n + 1, vector<ll>(PM, n));
  vector<vector<ll>> x_ls(n + 1, vector<ll>(PM)), x_rs(n + 1, vector<ll>(PM));
  rep(i, n) {
    x_l[i + 1][0] = upper_bound(x.begin(), x.end(), x[i] - k) - x.begin();
    x_r[i][0] = lower_bound(x.begin(), x.end(), x[i] + k) - x.begin();
    x_ls[i + 1][0] = i;
    x_rs[i][0] = i;
  }
  rep(i, PM - 1) {
    rep(j, n + 1) {
      x_l[j][i + 1] = x_l[x_l[j][i]][i];
      x_r[j][i + 1] = x_r[x_r[j][i]][i];
      x_ls[j][i + 1] = x_ls[j][i] + x_ls[x_l[j][i]][i];
      x_rs[j][i + 1] = x_rs[j][i] + x_rs[x_r[j][i]][i];
    }
  }
  auto D = [](const vector<vector<ll>>& v, const vector<vector<ll>>& vs, int p, int n) {
    ll sum = 0;
    int i = 0;
    while (n > 0) {
      if (n & 1) {
        sum += vs[p][i];
        p = v[p][i];
      }
      n >>= 1;
      ++i;
    }
    return pair(p, sum);
  };
  cin >> q;
  rep(qi, q) {
    ll l, r;
    cin >> l >> r;
    --l;
    ll low = 0, high = n;
    while (high - low > 1) {
      ll middle = (low + high) / 2;
      bool cond = D(x_r, x_rs, l, middle).first < r;
      (cond ? low : high) = middle;
    }
    ll len = low + 1;
    ll sumR = D(x_r, x_rs, l, len).second;
    ll sumL = D(x_l, x_ls, r, len).second;
    cout << sumL - sumR + len << endl;
  }
  // rep(i, n) cout << x_rs[i][0] << " ";
  // cout << endl;
  // rep(i, n) cout << x_rs[i][1] << " ";
  // cout << endl;
}


Measured memory_bytes: 186088
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    map <int,int,greater<int> > s;
    vector <int> v(n);
    for(int i=0;i<n;i++)
    {
        int x=nxt();
        s[x]+=1;
        v[i]=x;
    }

    for(int i=0;i<n;i++)
    {
        s[v[i]]-=1;
        if(s[v[i]]==0)
            s.erase(v[i]);
        cout<<(s.begin())->first<<endl;
        s[v[i]]+=1;
    }
    
    
    
    return 0;   
}


 
 


Measured memory_bytes: 7936
from collections import defaultdict
dic = defaultdict(int)
MOD = 998244353
N = int(input())
A = list(map(int,input().split()))
MAX = max(A)
store = [0 for _ in range(MAX+1)]

for x in A:
  store[x] += 1

if A[0] != 0 or store[0] != 1:
  print(0)
  exit()

ans = 1
for i in range(MAX):
  ans = ans*pow(store[i],store[i+1],MOD)
print(ans%MOD)

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

int main(){
	vector<int> data(3);
    cin>>data.at(0)>>data.at(1)>>data.at(2);
  
    sort(data.begin(),data.end());
  
  	if((data.at(0)+data.at(1))==data.at(2)){
    	cout<<"Yes"<<endl;
    }else{
    	cout<<"No"<<endl;
    }
  
  
}    

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

  ll inf = 1000000000000001;

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

    int n,q; ll sum=0;
    cin >> n;
    int v[n];
    unordered_map<int, int> mp;
    for(int i=0;i<n;i++) {
      cin >> v[i];
      sum+=v[i];
      mp[v[i]]++;
    }
    cin >> q;
    while(q--) {
      int b,c;
      cin >> b >> c;
      ll d=0;
      if(mp.find(b)!=mp.end()) {
        d = mp[b]*(c-b);
        mp[c] += mp[b];
        mp[b]=0;
      }
      ll ans = sum + d;
      sum=ans;
      cout << ans << "\n";
    }

    return 0;
  }

Measured memory_bytes: 7212
#include <stdio.h>

int main(void){

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

   if(a < b){
		  if(b<c){
	        printf("Yes\n");
      } else {
    	    printf("No\n");
     }
   }else {
	        printf("No\n");
      }
	return 0;
}

Measured memory_bytes: 580
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
     
      String S = sc.next();
      
      if(S.equals("ABC")){
      System.out.println("ARC");
      }
      else if(S.equals("ARC")){
      System.out.println("ABC");
      }
    }
}

Measured memory_bytes: 35716
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        List<Integer> numList = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            numList.add(Integer.parseInt(sc.next()));
        }
        numList.sort(Comparator.reverseOrder());
        int preNum = 0;
        List<Integer> removeList = new ArrayList<>();
        for (int i = 0; i < numList.size(); i++) {
            int n = numList.get(i).intValue();
            if (n == preNum) {
                removeList.add(i);
            } else {
                preNum = n;
            }
        }
        removeList.sort(Comparator.reverseOrder());
        for (Integer i:
             removeList) {
            numList.remove(i.intValue());
        }
        System.out.println(numList.size());
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll par[170000];
ll rank_[170000];
ll SIZEb[170000];
ll SIZEw[170000];
ll dx[4]={-1,0,1,0};
ll dy[4]={0,-1,0,1};
void init_uf(ll n_){
for(ll i=0;i<n_;i++){
par[i]=i;
  rank_[i]=0;
}
}
ll find(ll x){
if(x==par[x])
  return x;
  else
    return par[x]=find(par[x]);
}
void unite(ll x,ll y){
x=find(x);y=find(y);
  if(x==y)return ;
  if(rank_[x]<rank_[y]){
  par[x]=y;SIZEb[y]+=SIZEb[x];SIZEw[y]+=SIZEw[x];
  }else{
  par[y]=x;SIZEb[x]+=SIZEb[y];SIZEw[x]+=SIZEw[y];
    if(rank_[x]==rank_[y])rank_[x]++;
  }

}
ll H,W;
char field[405][405];
int main(){
  cin>>H>>W;
  for(ll i=0;i<H;i++){
    string s;cin>>s;
    for(ll j=0;j<W;j++)
      field[i][j]=s[j];
  }
  init_uf(H*W);
  for(ll i=0;i<H;i++)
    for(ll j=0;j<W;j++)
      if(field[i][j]=='#')
          SIZEb[W*i+j]=1;
  else
    SIZEw[W*i+j]=1;
  for(ll i=0;i<H;i++)
    for(ll j=0;j<W;j++)
    for(ll k=0;k<4;k++)
      if(0<=i+dx[k] && i+dx[k]<H && 0<=j+dy[k] && j+dy[k]<W){
     ll I=i+dx[k];ll J=j+dy[k];
        if(field[i][j]!=field[I][J]){
        ll a=i*W+j;ll b=I*W+J;
      unite(a,b);
        }
       }ll ans=0;
  for(ll i=0;i<H*W;i++)
    if(par[i]==i)ans+=(SIZEb[i]*SIZEw[i]);
  cout<<ans<<endl;
     return 0;
}

Measured memory_bytes: 8760