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

int main(){
    using namespace std;
    unsigned long N, K;
    cin >> N >> K;
    string s;
    cin >> s;

    s = '1' + s + '1';
    vector<unsigned long> kyokai({0});
    for(unsigned long i = 0; i <= N; ++i)if(s[i] != s[i + 1])kyokai.push_back(i);
    kyokai.push_back(N);

    auto M = kyokai.size();
    unsigned long ans{M <= 2 * K + 1 ? kyokai.back() - kyokai.front() : 0};
    for(unsigned long i = 0; i + 2 * K + 1 < M; i += 2)ans = max(ans, kyokai[i + 2 * K + 1] - kyokai[i]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1524
#include <stdio.h>

int main()
{
    int a, b, c, tmp;

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

    if(a > b){
        tmp = a;
        a = b;
        b = tmp;
    }
    if(b > c){
        tmp = b;
        b = c;
        c = tmp;
    }
    if(a > b){
        tmp = a;
        a = b;
        b = tmp;
    }

    printf("%d %d %d\n", a, b, c);

    return 0;
}



Measured memory_bytes: 2060
# import math
# import statistics
a=input()
#b,c=int(input()),int(input())
c=[]
for i in a:
    c.append(i)
#e1,e2 = map(int,input().split())
# f = list(map(int,input().split()))
#g = [input() for _ in range(a)]
# h = []
# for i in range(e1):
#     h.append(list(map(int,input().split())))
se=set(c)
c.sort()
count=1
res=[]
for i in range(len(c)-1):
    if c[i]==c[i+1]:
        count+=1
    else:
        if count%2==0:
            res.append(c[i])
        count=1
if count%2==0:
    res.append(c[-1])
if len(res)==len(se):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 8984
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <random>
#include <complex>


using namespace std;
typedef long long ll;

ll solve(ll x) {
	if (x == 1) { return 1; }
	else {
		return solve(x / 2) * 2 + 1LL;
	}
}
int main() {
	ll H; cin >> H;
	cout << solve(H) << endl;
	return 0;
}

Measured memory_bytes: 256
// AOJ Volume 1 Problem 0110

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

int check_0(char *form)
{
	int i;
	
	if (form[0] == 'X' && ('0' <= form[1] && form[1] <= '9' || form[1] == 'X')){
		return (1);
	}
	
	i = 1;
	while (form[i] != '\0'){
		if (form[i] == 'X' && 
		    ('0' <= form[i + 1] && form[i + 1] <= '9' || form[i + 1] == 'X') &&
			(form[i - 1] == '+' || form[i - 1] == '=')){
			return (1);
		}
		i++;
	}
	
	return (0);
}

void replace(char *form, int i)
{
	while (*form != '\0'){
		if (*form == 'X'){
			*form = i + '0';
		}
		form++;
	}
}


int get_rval(char *form)
{
	int num;

	while (*form++ != '=');

	num = 0;
	while ('0' <= *form && *form <= '9'){
		num = num * 10 + *form++ - '0';
	}
	
	return (num);
}

int get_num(char **form)
{
	int num;
	
	num = 0;
	while ('0' <= **form && **form <= '9'){
		num = num * 10 + **form - '0';
		(*form)++;
	}
	return (num);
}

int get_lval(char *form)
{
	int n;
	
	n = get_num(&form);
	
	while (*form != '='){
		form++;
		n += get_num(&form);
	}
	return (n);
}

int main(void)
{
	char form_org[128], form[128];
	int i, j;
	int lval, rval;
	int n;

	while (scanf("%s", form_org) != EOF){
		for (i = check_0(form_org); i <= 9; i++){
			strcpy(form, form_org);
			replace(form, i);
			
			lval = get_lval(form);
			rval = get_rval(form);
			
//			printf("[%s]%d=%d\n", form, lval, rval);
			
			if (lval == rval){
				break;
			}
		}
		if (lval == rval){
			printf("%d\n", i);
		}
		else {
			printf("NA\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	long long N, K, S,x=0; cin >> N >> K >> S;
	for (int i = 0; i < N; i++) {
		if (K != 0) {
			cout << S << " ";
			K--;
		}
		else {
			if (S == 1000000000)cout << S - 1 << " ";
			else cout << S + 1 << " ";
		}
	}
	
}





Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3024
#include <stdio.h>
int main()
{int n,p[100],i,s;
while(~scanf("%d",&n))
{s=0;
for(i=0;i<n;i++)
  scanf("%d",&p[i]);
  for(i=1;i<n-1;i++)
  if(p[i]>p[i-1]&&p[i]<p[i+1]||p[i]>p[i+1]&&p[i]<p[i-1])
    s++;
    printf("%d\n",s);
}
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    return (x*y);
}

#define WA printf("WA\n");
int main()
{
    ss s,t;
    cin >> s >> t;

    //ll min = M,max=0;
    vll sn(SIZE(s)),tn(SIZE(t));
    rep(i,SIZE(s))sn[i] = (ll)s[i];
    rep(i,SIZE(t))tn[i] = (ll)t[i];
    
    sort(all(sn));
    sort(all(tn));

    ss ans;
    if(sn[0] < tn[SIZE(t)-1])ans = "Yes";
    else if(SIZE(s) < SIZE(t)){
        ll count = 0;
        rep(i,SIZE(s)){
            if(sn[i] == tn[i])count++;
        }
        if(count == SIZE(s))ans = "Yes";
        else ans = "No";
    }
    else ans = "No";

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


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

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(int i = f; i < (int)l; ++i)
#define repit(it, t) for(__typeof((t).begin()) it = (t).begin(); it != (t).end(); it++)
#define endl "\n"
#define pb emplace_back
#define lb lower_bound
#define int long long
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second
#define DBG0(x) { cout << #x << ": " << x << "\t"; }
#define DBG(x) {DBG0(x); cout << endl;}
#define DBG2(x, y) {DBG0(x); DBG(y);}
#define DBG3(x, y, z) {DBG0(x); DBG2(y, z);}
#define DBG4(w, x, y, z) {DBG0(w); DBG3(x, y, z);}

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;

signed main(void){
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    cout << ((a == b && b == c) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 764
#include<iostream>
using namespace std;
 
int main(){
int a,b,c,d,A,B,C,D,S,T;
cin>>a>>b>>c>>d;
cin>>A>>B>>C>>D;
S=a+b+c+d;
T=A+B+C+D;
if(S>T) cout<<S<<"\n";
else cout<<T<<"\n";
return 0;
}

Measured memory_bytes: 1164
#include <iostream>

using namespace std;

int main() {
	int a;
	while (cin >> a) {
		if (a == 0) {
			break;
		}
	a = 1000 - a;
	int counter = 0;
	if (a >= 500) {
		counter += a/500;
		a %= 500;
	}
	if (a >= 100) {
		counter += a/100;
		a %= 100;
	}
	if (a >= 50) {
		counter += a/50;
		a %= 50;
	}
	if (a >= 10) {
		counter += a/10;
		a %= 10;
	}
	if (a >= 5) {
		counter += a/5;
		a %= 5;
	}
	if (a >= 1) {
		counter += a;
	}
	cout << counter << endl;
	}
	return 0;
}

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

signed main() {
	int n, m;
	cin >> n >> m;
	vector<pair<ll, ll>> p(n);
	ll cnt = 0;

	for (int i = 0; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		p[i] = make_pair(a, b);
	}

	sort(p.begin(), p.end());

	for (int i = 0; i < n; ++i) {
		ll a = p[i].first;
		ll b = p[i].second;

		if (m >= b) {
			cnt += a * b;
			m -= b;
		}
		else {
			cnt += a * m;
			break;
		}
	}

	cout << cnt << endl;
}


Measured memory_bytes: 1792
import numpy as np

A, B, H, M = input().split(" ")

A = int(A)
B = int(B)
H = int(H)
M = int(M)

minute = 60*H + M
theta_A = 2*np.pi * (minute/720)
theta_B = 2*np.pi * (M/60)

jisin = np.array([A*np.sin(theta_A), A*np.cos(theta_A)])
hunsin = np.array([B*np.sin(theta_B), B*np.cos(theta_B)])

kyori = np.sqrt(np.sum((jisin-hunsin)**2))

print(kyori)

Measured memory_bytes: 27252
fun main(args: Array<String>) {
    val (a,b) = readLine()!!.split(" ").map(String::toLong)
    val x = gcd(a,b)
    val list = decom(x)
    println(list.size + 1)
}

fun decom(x: Long) : MutableList<Long> {
    var value = x
    val list: MutableList<Long> = mutableListOf()
    if (value % 2L == 0L) {
        list.add(2L)
        while (value % 2L == 0L) {
            value /= 2L
        }
    }
    var i = 3L
    while (i * i <= value) {
        if ( value % i == 0L) {
            list.add(i)
            while (value % i == 0L) {
                value /= i
            }
        }
        i += 2L
    }
    if (value > 1L) {
        list.add(value)
    }
    return list
}

fun gcd(a : Long, b : Long) : Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

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

int main(){
	int k,n;
	cin>>k>>n;
	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	int a1=arr[0];
	for(int i=0;i<n-1;i++){
		arr[i]=arr[i+1]-arr[i];
	}
	arr[n-1]=k-arr[n-1]+a1;
	int max=0;
	int sum=0;
	for(int i=0;i<n;i++){
		if(arr[i]>max){
			max=arr[i];
		}
		sum+=arr[i];
	}
	sum-=max;
	cout<<sum;
	return 0;
}

Measured memory_bytes: 1024
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.length();
    int a = 0;
    int b = 0;
    int ans = 0;
    for (int i=0; i<n; ++i){
        if(s[i] == '0'){
            a++;
        }
        else {
            b++;
        }
    }
    ans = min(a * 2, b * 2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1144
n = int(input())
a = list(map(int,input().split()))
s = len(bin(max(a)))-2

box = [0] * s
bbbox = [] * n
for i in range(n):
    bbbox.append(format(a[i],'b').zfill(s))
    for j in range(s):
        box[j] += int(bbbox[-1][-j-1])


ans = [0] * n
for i in range(s):
    for j in range(n):
        if box[i] % 2 == 0:
            if bbbox[j][-1-i] == '1':
                ans[j] += 2 ** i
        else:
            if bbbox[j][-1-i] == '0':
                ans[j] += 2 ** i
print(*ans)

Measured memory_bytes: 123720
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] s = new int[m];
		char[] c = new char[m];
		for (int i=0; i<m; i++ ) {
			s[i] = sc.nextInt()-1;
			String cs = sc.next();
			c[i] = cs.charAt(0);
		}

		int g = -1;
		int mx = (int)Math.pow(10,n);
lb1:		for (int i=0; i<mx; i++ ) {
			String is = String.valueOf(i);
			if ( is.length() != n ) {
				continue;
			}
			int f = 1;
			for ( int j=0; j<m; j++ ) {
				if ( is.charAt(s[j])!=c[j] ) f = 0;
			}
			if ( f == 1 ) {
				g = i;
				break lb1;
			}
		}
		System.out.println(g);
		}
}

Measured memory_bytes: 23508
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N,M;
int monster[100000];

int calc(int X){

	int left = 0,right = 0,ret = 0,pre_diff;
	int calc_left = 0,calc_right = N-1,m = (calc_left+calc_right)/2;
	int LEVEL = 1;

	while(right < N-1){
		ret++;

		while(calc_left <= calc_right){

			if(monster[m] < LEVEL+X){
				right = m;
				calc_left = m+1;
			}else{
				calc_right = m-1;
			}
			m = (calc_left+calc_right)/2;
		}

		pre_diff = abs(LEVEL-monster[left]);

		while(left < right && abs(LEVEL-monster[left+1]) < pre_diff){
			left += 1;
			pre_diff = abs(LEVEL-monster[left]);
		}
		LEVEL += max(1,X-abs(LEVEL-monster[left]));

		calc_left = right;
		calc_right = N-1;
		m = (calc_left+calc_right)/2;
	}
	return ret;
}

void func(){

	for(int i = 0; i < N; i++)scanf("%d",&monster[i]);

	int ans = -1;

	int left,right,m;

	left = monster[0],right = monster[N-1],m = (left+right)/2;

	while(left <= right){

		if(calc(m) >= M){
			ans = m;
			left = m+1;
		}else{
			right = m-1;
		}
		m = (left+right)/2;
	}

	printf("%d\n",ans);
}

int main(){

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
int a,b,k;
bool x=false;
cin>>k>>a>>b;
for (int i = a; i <= b; i++)
{
    if (i%k==0)
    {x=true;
        cout<<"OK"<<endl;
        break;
    }
   
}
if (x==false)
{
       cout<<"NG"<<endl;
}

    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int ans = 0;
    for (int i = 0; i < k; ++i)
    {
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}


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

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

int N;
int A[200010];
int mem[30][50];

signed main()
{
    cin >> N;
    rep(i, N)
    {
        double d;
        cin >> d;
        A[i] = llround(d * 1e9);
    }

    int ans = 0;
    rep(i, N)
    {
        int cnt2 = 0, cnt5 = 0;
        int a = A[i];
        while(a % 2 == 0)
        {
            a /= 2;
            cnt2++;
        }
        while(a % 5 == 0)
        {
            a /= 5;
            cnt5++;
        }

        for(int j = 18 - cnt5; j < 30; j++)for(int k = 18 - cnt2; k < 50; k++)ans += mem[j][k];
        mem[cnt5][cnt2]++;
    }

    cout << ans <<endl;

    return 0;
}


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

typedef long long ll;

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

ll lcm(ll a,ll b ) {
  return a*(b/gcd(a,b));

}
int main() {
  int N; cin >> N;
  ll T[101];
  for ( int i = 0; i < N; i++ ) cin >> T[i];
  ll ans = T[0];
  for ( int  i = 1; i < N; i++ ) {
    ans = lcm(ans,T[i]);
    // cout << ans << endl;
  }

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


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def warshall_floyd(g):
    d = defaultdict(dict)
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v))
    V = set(V)
    for i in V:
        for j in V:
            if i in g and j in g[i]:
                d[i][j] = g[i][j]
            else:
                d[i][j] = sys.maxsize
    for k in g:
        for i in g:
            for j in g:
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]

    return d


@mt
def slv(N, A):
    g = defaultdict(dict)
    for i, r in enumerate(A):
        for j, c in enumerate(r):
            g[i][j] = c
            g[j][i] = c

    d = warshall_floyd(g)

    for i in range(N):
        for j in range(N):
            if A[i][j] != d[i][j]:
                return -1
    ans = 0
    for i in range(N):
        for j in range(i, N):
            for k in range(N):
                if A[i][k] == 0:
                    continue
                if j != k and A[i][k] + A[k][j] == A[i][j]:
                    break
            else:
                ans += A[i][j]
    return ans


def main():
    N = read_int()
    A = [read_int_n() for _ in range(N)]
    # N = 200
    # A = [[random.randint(1, 10000) for _ in range(N)] for __ in range(N)]
    # for i in range(N):
    #     A[i][i] = 0
    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 77544
#include <bits/stdc++.h>
using namespace std;
#define maxn 100010
#define ll long long
#define db double
#define vi vector<int>
#define pb push_back
#define mod 998244353
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
// head
char inp[maxn];
int fl[4];
int main() {
	scanf("%s", inp);
	int n = strlen(inp);
	for (int i = 0; i < n; i++) {
		if (inp[i] == 'N') fl[0] = 1;
		else if (inp[i] == 'S') fl[1] = 1;
		else if (inp[i] == 'W') fl[2] = 1;
		else fl[3] = 1;
	}
	if (fl[0] ^ fl[1]) cout << "No" << endl;
	else if (fl[2] ^ fl[3]) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    tmp = input.split("\n");
    N = tmp[0];
    p = tmp.slice(1, N+1);
    p = p.map(Number);
    M = Math.max.apply(null,p);
    answer=0;
    for(i=0; i<N; i++){
        answer += p[i];
        
    }

    console.log(Number(answer) - 0.5*M);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

int main() {
	ll N;
	cin >> N;
	ll tmp = N;
	ll check = 0;
	map<ll,ll> m;
	if (N == 1) {

		cout << 0;
		return 0;
	}
	for (int i = 2; i <=tmp;i++) {

		while (1) {
			if (N % i == 0) {
				N = N / i;
				m[i]++;
				check = 1;
			}
			else {
				break;
			}
		}
		if (N == 1) {
			break;
		}
		if (pow(tmp, 0.5) < i) {
			check = 1;
			m[100000000000]++;
			break;
		}
	}
	if (check==0) {
		cout << 1;
		return 0;
	}
	ll ans=0;
	for (auto i : m) {
		for (int j = 1; j <= i.second; j++) {
			if (i.second >= (j + 1) * j / 2 && i.second < (j + 1) * (j + 2) / 2) {
				ans += j;
				break;
			}
		}
	}
	cout << ans;
}




Measured memory_bytes: 4108
#include <cstdlib>
#include <iostream>


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

  int x1, y1, x2, y2;
  std::cin >> x1 >> y1 >> x2 >> y2;
  auto dx = x2 - x1;
  auto dy = y2 - y1;

  auto x3 = x2 - dy;
  auto y3 = y2 + dx;
  auto x4 = x1 - dy;
  auto y4 = y1 + dx;
  std::cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << std::endl;

  return EXIT_SUCCESS;
}


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

def souwa(num):
    if num % 2 == 0:
        return int((num+1) * (num/2))
    else:
        return int((num+1) * (num//2)) + ((num//2)+1)

ans = 0
buf1 = 0
buf2 = 0
for i in range(N):
    buf1 += sum(A[i] > A[j] for j in range(i+1, N))
    buf2 += sum(A[i] > a for a in A)

ans = (buf1 * K) + (buf2 * (K*(K-1)//2))
print(ans % (10**9+7))

Measured memory_bytes: 3188
N,M=gets.split.map(&:to_i)
l=Array.new(N){[]}
M.times{
    a,b=gets.split.map{|i|i.to_i-1}
    l[a] << b
    l[b] << a
}
#l.map!{|i|i.uniq}
#warn l.inspect
comp=Array.new(N)
closed=Array.new(N){false}
s=[]
count=Hash.new{0}
max=0
N.times{|i|
    next if closed[i]
    s.push(i)
    until s.empty?
        v=s.pop
        next if closed[v]
        closed[v]=true
        comp[v]=i
        count[i]+=1
        if max<count[i]
            max=count[i]
        end
        l[v].each{|n|
            next if closed[n]
            s.push(n)
        }
    end
}
puts max


Measured memory_bytes: 38652
int p[10001];
main(i,j,r){
  p[0]=p[1]=1;
  for(i=2;i<10001;i++)
    if(!p[i])
      for(j=i*2;j<10001;j+=i)p[j]=1;
  for(;~scanf("%d",&j);printf("%d\n",r))
    for(r=0,i=2;i<=j;i++)
      if(!p[i]&&!p[j-i+1])r++;
  return 0;
}

Measured memory_bytes: 632
N=io.read"*n"
io.read()
a={}
for i=1,N do
	S=io.read()
	if(a[S])then a[S]=a[S]+1
	else a[S]=1 end
end
n=0 r={}
for k,v in pairs(a)do
	if(v>n)then r={k} n=v
	elseif(v==n)then table.insert(r,k)
	end
end
table.sort(r)
for _,v in ipairs(r)do print(v)end

Measured memory_bytes: 18460
#include <iostream>
#include <bits/stdc++.h>
#define lld long long int 
using namespace std;
int h,w,ans=0;
char a[1500][1500];
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> h >> w;
    int dp[h][w];
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin >> a[i][j];
            dp[i][j]=0;
        }
    }
    for(int i=0;i<w;i++)
    {
     if(a[0][i] == '.')
     {
         dp[0][i]=1;
     }
     else
     {
         break;
     }
    }
    
    for(int i=0;i<h;i++)
    {
     if(a[i][0] == '.')
     {
         dp[i][0]=1;
     }
     else
     {
         break;
     }
    }
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(i == 0 && j == 0)
            {
                continue;
            }
            if(a[i][j] == '#')
            {
                continue;
            }
            if(i > 0&& j >0)
            {
                dp[i][j]=((dp[i-1][j]%1000000007)+(dp[i][j-1]%1000000007))%1000000007;
            }
        }
    }
    cout<<(dp[h-1][w-1])%1000000007<<endl;
	return 0;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


signed main(){
    int H, A;
    cin >> H >> A;
    PRINT((H + A - 1) / A);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
using namespace std;
int main(){
    int N;
    cin>>N;
    ll p, sum = 0, ans = 0;
    while(N--){
        cin>>p;
        ans+=(p*sum);
        ans%=mod;
        sum+=p;
        sum%=mod;
    }
    cout<<ans%mod;
}


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

  const int MOD = 1000000007;

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

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

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }



int main(){
  string S;
  cin >> S;
  int N = S.length();
  ll ans = 0;
  for(int i = 0; i < (1 << (N - 1)); i++){
    string now = "";
    now += S[0];
    for(int j = 0; j < N - 1; j++){
      if(i & (1 << j)) now +='+';
      now += S[j + 1];
    }
    ll sum = 0;
    int pos = 0;
    while(now.find('+', pos) != string::npos){
        int nextpos = now.find('+', pos);
        sum += stoll(now.substr(pos, nextpos - pos));
        pos = nextpos + 1;
    }
    sum += stoll(now.substr(pos));
    ans += sum;
  }
  print(ans);
}


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

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

	string ret = "Yes";
	string s;
	set<string> ss;
	cin >> s;
	ss.insert(s);
	char prev = s.back();
	for (int i = 1; i < n; ++i) {
		cin >> s;
		if (prev != s.front() || ss.find(s) != ss.end()) {
			ret = "No";
		}
		ss.insert(s);
		prev = s.back();
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

cards = []
for _ in range(m):
    b, c = map(int, input().split())
    cards.append([c, b])

cards.sort()
ans = 0
for i, num in enumerate(a):
    if not cards:
        break
    c, b = cards.pop()
    if c > num:
        a[i] = c
        b -= 1
    else:
        break

    if b:
        cards.append([c, b])

print(sum(a))



Measured memory_bytes: 24008
#include <cstdio>
#include <queue>
using namespace std;
struct st{int l, r, x, y;};
int n, a[200005], m[200005][20];
priority_queue<st> pq;
bool operator < (st p, st q) {return a[p.x]>a[q.x];}
 
int mn(int p, int q) {return a[p]<a[q] ? p:q;}
 
int f(int l, int r) {
	int j=0;
	while(1<<(j+1) <= r-l+1) j++;
	return mn(m[l][j], m[r-(1<<j)+1][j]);
}
 
void add(int l, int r) {
	int x, y;
	if(l>r) return;
	x = f(l, r);
	y = x+1==r ? r : mn(f(x+1, r-1), r);
	pq.push({l,r,x,y});
}
 
int main() {
	int i, j, k;
	scanf("%d", &n);
	for(i=0; i<n; i++) scanf("%d", a+i), m[i][1] = i;
	for(j=2; ; j++) {
		k = 1<<j;
		if(k>n) break;
		for(i=0; i+k<=n; i++) m[i][j] = mn(m[i][j-1], m[i+k/2][j-1]);
	}
	for(add(0, n-1); !pq.empty(); ) {
		st t = pq.top(); pq.pop();
		printf("%d %d ", a[t.x], a[t.y]);
		add(t.l, t.x-1);
		add(t.x+1, t.y-1);
		add(t.y+1, t.r);
	}
	return 0;
}

Measured memory_bytes: 18676
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N,ans=0;
	cin >> N;
	vector<int> A(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> A.at(i);
	}
	if (A.at(0)==1)
	{
		A.at(0) = A.at(0);
		A.at(1) = 1;
		
		ans++;
	}
	for (size_t i = 1; i < N-1; i++)
	{
		if (A.at(i)==i+1)
		{
			A.at(i + 1) = i+1;
			ans++;
		}
	}
	if (A.at(N-1)==N)
	{
		ans++;
	}
	cout << ans;
}

Measured memory_bytes: 640
n,m=map(int,input().split())
judge=[0 for i in range(n+1)]
for i in range(m):
        a=int(input())
        judge[a]=1
dp=[0]*(n+2)
dp[n]=1
mod=10**9+7
for i in range(n-1,-1,-1):
        if judge[i]:
                dp[i]=0
                continue
        dp[i]=(dp[i+1]+dp[i+2])%mod
print(dp[0])

Measured memory_bytes: 7832
def resolve():
    '''
    code here
    '''
    import math
    import collections

    N = int(input())

    def mk_factor(num):
        max_divisor = int(math.sqrt(num))+1
        divisor = 2
        factor_list = [1]

        while divisor <= max_divisor:
            if num % divisor == 0:
                factor_list.append(divisor)
                num //= divisor
            else:
                divisor += 1

        factor_list.append(num)
        return factor_list


    fact_dic = dict(collections.Counter(mk_factor(N)))

    fact_dic.pop(1)

    cnt = 0
    for i in range(1, int(math.sqrt(N))+1):
        for j in fact_dic.keys():
            if fact_dic[j] >= i:
                cnt += 1
            fact_dic[j] -= i


    print(cnt)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9488
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s1,s2;
  cin>>s1;
  for(int i=0;i<s1.size();i++){
    if(s1.at(i)=='0') 
      
       s2+='0';
    if(s1.at(i)=='1') 
     
       s2+='1';
    if(s1.at(i)=='B')
      if(s2.size()!=0) s2.erase(s2.size()-1);
  }
  cout<<s2<<endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i, loop;
    long int max, min, sum;
    scanf("%d", &loop);
    scanf("%ld", &max);
    min = max; sum = max;

    for(i = 0; i < loop - 1; i++){
        long int n;
        scanf("%ld", &n);
        
        if(n > max)max = n;
        else if(n < min)min = n;

        sum += n;
    }

    printf("%ld %ld %ld\n", min, max, sum);
}


Measured memory_bytes: 2140
fun main() {
    val (n,k) = readLine()!!.split(" ").map(String::toInt)

    val a = Array(k){
        readLine()!!
        readLine()!!.split(" ").map(String::toInt)
    }

    var sum = 0

    for(i in 1 .. n){

        if( !a.any { it.any { it == i } }){
            sum += 1;
        }

    }

    println("$sum")

}

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

bool is_prime(int x) {
    if(x<=1) return false;
    for(int i=2;i*i<=x;i++) {
        if(x%i==0) return false;
    }
    return true;
}

int main() {
    int x;
    cin >> x;
    int p = x;
    while(!is_prime(p)) p++;

    cout << p << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n, r; cin >> n >> r;
    if (n >= 10) cout << r << endl;
    else cout << r + 100 * (10 - n) << endl;
    return 0;
}

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

int gcd(int x, int y);    //最大公約数　ユークリッドの互除法
int lcm(int x, int y, int gcd);    //最小公倍数  lcm(x,y)=xy/gcd(x,y)

int main(){
    int x, y;
    int g_res;
    long l_res;
    while(cin >> x >> y){
        g_res = gcd(x,y);
        l_res = lcm(x,y,g_res);
        cout << g_res << " " << l_res << "\n";
    }
    return 0;
}


int gcd(int x, int y){
    if(y==0)  return x;
    else      return gcd(y, x%y);
}

int lcm(int x, int y, int gcd){
    return x/gcd*y;
}  

Measured memory_bytes: 1160
def abc054c_one_stroke_path():
    import itertools
    n, m = map(int, input().split())
    e = [set() for _ in range(n + 1)]
    for _ in range(m):
        a, b = map(int, input().split())
        e[a].add(b)
        e[b].add(a)
    pattern = itertools.permutations(range(2, n + 1))
    cnt = 0
    for p in pattern:
        p_m = [1] + list(p)
        for i in range(n - 1):
            if p_m[i+1] not in e[p_m[i]]:
                break
        else:
            cnt += 1
    print(cnt)


abc054c_one_stroke_path()

Measured memory_bytes: 9212
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
    for(;;){
    int n;
    cin >> n;
    if(n==0){
      break;
    }
    int t[2*n], h[2*n], j;
    for(int i=0; i<2*n; i++){
      t[i] = 0;
      h[i] = 1;
    }
    for(int i=0; i<n; i++){
      cin >> j;
      t[j-1] = 1;
      h[j-1] = 0;
    }
    int tp = n;
    int hp = n;
    int stage = 0;
    bool f;
    while(tp>0 && hp>0){

        f=true;
        for(int i=stage; i<2*n; i++){
          if(t[i]==1){
            t[i] = 0;
            stage = i;
            tp--;
            f=false;
            break;
          }
        }
        if(tp==0){
          break;
        }

        if(f){
          stage=0;
        }

        f=true;
        for(int i=stage; i<2*n; i++){
          if(h[i]==1){
            h[i] = 0;
            stage = i;
            hp--;
            f=false;
            break;
          }

        }
        if(hp==0){
          break;
        }
        if(f){
          stage=0;
        }
      
    }
    cout << hp << endl << tp << endl;

  }
}


Measured memory_bytes: 3040
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;

int main() {
	int n; ni(n);
	if (!(n & (n-1)))
		return !printf("No\n");
	printf("Yes\n1 2\n");
	for (int i = 2; i < n; i += 2) {
		printf("%d %d\n", i, i+1);
		printf("%d %d\n", i+1, n+1);
		printf("%d %d\n", n+1, n+i);
		printf("%d %d\n", n+i, n+i+1);
	}
	if (!(n & 1)) {
		int a = 1;
		while (2*a < n) a *= 2;
		printf("%d %d\n", n, n+a);
		printf("%d %d\n", 2*n, n^a^1);
	}
    return 0;
}


Measured memory_bytes: 2816
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main {

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		Scanner scan = new Scanner(System.in);

		String str1 =scan.nextLine();

		String str2;

		int count =0;

		while (true) {

				str2 = scan.nextLine();

				/*System.out.print(str2);*/
				if (str2.equals("END_OF_TEXT")) {
					break;
				}
				Scanner sb = new Scanner(str2);
					while(sb.hasNext()){


/*					System.out.println(sb.next());
*/					if(sb.next().equalsIgnoreCase(str1)){
						count++;

					}
					}
		}

		System.out.println(count);
 }

}

Measured memory_bytes: 26268
N = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
time = [a, b, c, d, e]
#print(min(time))
#if N/min(time)==1:
 # print(int(N/min(time))+4)
#else:
 # print(int(N/min(time))+5)
print(int((N-1)/min(time))+5)

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

int main()
{
  string sa, sb, sc;
  char now;
  int status; // 誰のターンか
  cin >> sa >> sb >> sc;
  now = sa[0];
  sa = sa.erase(0, 1);
  while (true)
  {
    if (now == 'a')
    {
      now = sa[0];
      sa = sa.erase(0, 1);
      status = 0;
    }
    else if (now == 'b')
    {
      now = sb[0];
      sb = sb.erase(0, 1);
      status = 1;
    }
    else if (now == 'c')
    {
      now = sc[0];
      sc = sc.erase(0, 1);
      status = 2;
    }
    else if (sa == "" or sb == "" or sc == "")
    {
      break;
    }
  }
  if (status == 0)
    cout << "A" << endl;
  if (status == 1)
    cout << "B" << endl;
  if (status == 2)
    cout << "C" << endl;
}

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

using namespace std;

#define rep(i,x) for(int i=0;i<x;++i)
#define all(a) begin(a),end(a)

int J[1010][1010], O[1010][1010], I[1010][1010];

signed main()
{
    int M, N; cin >> M >> N;
    int K; cin >> K;

    rep(i, M) rep(j, N) {
        char C; cin >> C;

        if (C == 'J') J[i+1][j+1]++;
        if (C == 'O') O[i+1][j+1]++;
        if (C == 'I') I[i+1][j+1]++;
    }

    for (int i = 1; i <= 1000; ++i) {
        for (int j = 1; j <= 1000; ++j) {
            J[i][j] += J[i - 1][j] + J[i][j - 1] - J[i - 1][j - 1];
            O[i][j] += O[i - 1][j] + O[i][j - 1] - O[i - 1][j - 1];
            I[i][j] += I[i - 1][j] + I[i][j - 1] - I[i - 1][j - 1];
        }
    }

    rep(_, K) {
        int a, b, c, d; cin >> a >> b >> c >> d;

        int j = J[c][d] - J[a - 1][d] - J[c][b - 1] + J[a - 1][b - 1];
        int o = O[c][d] - O[a - 1][d] - O[c][b - 1] + O[a - 1][b - 1];
        int i = I[c][d] - I[a - 1][d] - I[c][b - 1] + I[a - 1][b - 1];

        cout << j << ' ' << o << ' ' << i << endl;
    }
}

Measured memory_bytes: 14900
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int n;cin>>n;
vector <pair< pair<string,int>,int> > v(n);
for(int i=0;i<n;i++){
    string s;int a;
    cin>>s>>a;
    v[i]=make_pair(make_pair(s,-a),i);
}
sort(v.begin(),v.end());
for(int i=0;i<n;i++){
    cout<<v[i].second+1<<endl;
}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename T> class Dinic {
public:
    struct edge{
        int to;
        T cap;
        int rev;
    };
    vector<vector<edge> > G;
    vector<int> level,iter;
    int n;
    Dinic(int node_size){
        n = node_size;
        G.resize(node_size),level.resize(node_size),iter.resize(node_size);
    }
    //辺を張る
    void add_edge(int from,int to,T cap)
    {
    	G[from].push_back((edge){to,cap,(int)G[to].size()});
    	G[to].push_back((edge){from,(T)0,(int)G[from].size()-1});
    }
    void bfs(int s)
    {
    	fill(level.begin(),level.end(),-1);
    	queue<int> que;
    	level[s] = 0;
    	que.push(s);
    	while(!que.empty()){
    		int v = que.front();
    		que.pop();
    		for(auto& e : G[v]){
    			if(e.cap > 0 && level[e.to] < 0){
    				level[e.to] = level[v] + 1;
    				que.push(e.to);
    			}
    		}
    	}
    }
    T dfs(int v,int t,T f)
    {
    	if(v==t){
    		return f;
    	}
    	for(int &i = iter[v];i<(int)G[v].size();i++){
    		edge &e = G[v][i];
    		if(e.cap > 0 && level[v] < level[e.to]){
    			T d = dfs(e.to,t,min(f,e.cap));
    			if(d>0){
    				e.cap -= d;
    				G[e.to][e.rev].cap += d;
    				return d;
    			}
    		}
    	}
    	return 0;
    }
    //最大流を計算
    T solve(int s,int t)
    {
    	T flow = 0;
    	for(;;){
    		bfs(s);
    		if(level[t]<0){
    			return flow;
    		}
    		fill(iter.begin(),iter.end(),0);
    		T f;
    		while((f=dfs(s,t,numeric_limits<T>::max())) > 0){
    			flow += f;
    		}
    	}
    }
};


int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n)cin >> s[i];
    
    for(int i=0;i<26;i++){
        Dinic<int> dc(30);
        int cnt = 0;
        bool flag = 0;
        for(int j=0;j<n;j++){
            char a,b;
            a = s[j][0];
            b = s[j][s[j].size()-1];
            if(s[j][0]=='a'+i){
                if(b=='a'+i){
                    flag = 1;
                }else{
                    cnt++;
                    dc.add_edge(0,b-'a',1);
                }
            }else{
                if(b=='a'+i){
                    flag = 1;
                    dc.add_edge(a-'a',27,1);
                }else{
                    dc.add_edge(a-'a',b-'a',1);
                }
            }
        }
        int ans = dc.solve(0,27);
        if(!flag){
            continue;
        }
        if(ans>=cnt){
            cout << (char)('a'+i) << endl;
        }else{
            continue;
        }
    }

    return 0;
}


Measured memory_bytes: 5176
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){ll ans=1;rrp(i,n-r+1,n+1){ans*=i;ans%=mod;}return ans/=fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
double ans=0;
////////////////////////////////////////////////////////////
int main(){
 char s[200000];
 sc(s);
 ll len=strlen(s);
 deque<char>deque(s,s+len);
 ll sm=0,q,t,r;char c;
 sc(t);
 rep(i,0,t){
  sc(q);
  if(q==1)sm++;
  if(q==2){
   sc(r);sc(c);
   if(r==1){
    if(sm%2==1)deque.push_back(c);
    else deque.push_front(c);
   }
   if(r==2){
    if(sm%2==0)deque.push_back(c);
    else deque.push_front(c);
   }
  }
 }
 if(sm%2==1)reverse(all(deque));
 for(auto itr=deque.begin();itr!=deque.end();++itr){
  cout<<*itr;
 }
 pnn;

return 0;}


Measured memory_bytes: 3868
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    ll ans = A[0];
    for (ll i = 1; i < N; i++) {
        ans = gcd(ans, A[i]);
    }
    cout << ans << endl;
}

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

int main(){
  int i,am[9],pm[9];
  string name[9];
  for(i=0;i<9;i++){
    cin >> name[i] >> am[i] >> pm[i];
  }

  for(i=0;i<9;i++){
    cout << name[i] << ' '<< am[i] + pm[i] << ' '<< am[i] * 200 + pm[i] * 300 << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int h, w;
int dy[] = {1, 0, -1}, dx[] = {1, 0, -1};
bool in(int y, int x) { return 0 < y && y < h - 1 && 0 < x && x < w - 1; }

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

    int n;
    cin >> h >> w >> n;
    map<P, int> mp;
    int ans[10] = {};
    ans[0] = (h - 2) * (w - 2);
    rep(i, n)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        rep(j, 3) rep(k, 3)
        {
            int y = a + dy[j], x = b + dx[k];
            if (in(y, x))
            {
                int cnt = mp[P(y, x)];
                ans[cnt]--;
                mp[P(y, x)]++;
                ans[cnt + 1]++;
            }
        }
    }
    rep(i, 10) cout << ans[i] << endl;
}

Measured memory_bytes: 56576