akhauriyash/Code-Regression huggingface dataset:
import java.io.*
import java.util.*
import java.lang.Math.*


fun main() {
    val N = rd.readInt()
    val A = rd.readIntArray()
    assert(A.size == N)

    var prod = 0
    for (i in 0 until N) {
        prod = prod xor A[i]
    }

    val X = IntArray(N)
    for (i in 0 until N) {
        X[i] = prod xor A[i]
    }

    println(X.joinToString(" "))
}


//val rd = debug.Reader("abc", "171", "e", "sample-1")
val rd = Reader()
fun main(args: Array<String>) {
    Thread(null, MainThread(), "mainThread", 128 * 1024 * 1024).start()
}


const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
const val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
class MainThread : Runnable {
    override fun run() { main() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 67812
//AT2583
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if ((a*100+b*10+c)%4==0)
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}
	return 0;
}

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

using namespace std;

const int maxn = 1e5 + 5;
int N, C, K, Sta[maxn], top, Ans;

int main() {
  scanf("%d%d%d", &N, &C, &K);
  for (int i = 1; i <= N; i++) scanf("%d", &Sta[++top]);
  sort(Sta + 1, Sta + N + 1), reverse(Sta + 1, Sta + N + 1);
  while (top) {
    int now = Sta[top], lim = top;
    while (lim > 1 && top - (lim - 1) + 1 <= C && Sta[lim - 1] - now <= K)
      lim--;
    top = lim - 1, Ans++;
  }
  printf("%d\n", Ans);
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define FOR(I,a,b) for(int I=a;I<b;I++)
#define FORit(it,a) for(auto it=a.begin();it!=a.end();it++)
#define ROF(I,a,b) for(int I=a;I>=b;I--)
#define vec vector
#define vi vec<int>
#define vll vec<ll>
#define pb push_back
#define pp pop_back
#define all(x) x.begin(),x.end()
#define testcases ll t;cin>>t;while(t--)
#define mem(a,k) memset(a,k,sizeof(a))
#define FF first
#define SS second
#define MP(x,y) make_pair(x,y)
#define rt return
#define br break
#define ct continue
#define elif else if
#define ii pair<int,int>
#define vecin(a,n,index) for(int I=index;I<n;I++)cin>>a[I]
#define vecout(a,n,index) for(int I=index;I<n;I++)cout<<a[I]<<" ";cout<<endl;
//ll mod = 1000000007;
int n, m;
vi ad[1000001];
int visited[1000001] = {0};
void dfs(int v) {
	if (visited[v])rt;
	visited[v] = 1;
	for (auto i : ad[v]) {
		if (visited[i] == 0)dfs(i);
	}

}
void solve() {
	cin >> n >> m;
	while (m--) {
		int a, b;
		cin >> a >> b;
		ad[a].pb(b);
		ad[b].pb(a);
	}
	int root = 1;
	dfs(root);
	int ans = 0;
	FOR(i, 1, n + 1) {
		if (!visited[i]) {dfs(i); ans++;}
	}
	cout << ans << endl;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	// START FROM HERE :)
	solve();
}

Measured memory_bytes: 31092
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define MOD 1000000007
#define pb push_back
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define ll long long int
#define ff first
#define ss second
#define INF 1000000000
#define HINF 1000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define deb(x) cout<<#x<<'='<<x<<endl
const double pi = 3.14159265358979323846;

ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}


void solve()
{

	ll i=0,j=0,k=0,m,n,p,sum=0,cnt=1;
	cin>>n;
	m=n;
	i=1;
	while(j+i*26<n)
	{
	    j=j+i*26;
	    i*=26;
	    cnt++;
	    m-=i;
	}
	ll arr[cnt];
	m--;
	for(k=0;k<cnt;k++)
	{
	    arr[cnt-1-k]=m%26;
	    m/=26;
	}
	for(k=0;k<cnt;k++)
	{
	    cout<<(char)(arr[k]+97);
	}
    
}
int main() {
    fast
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w+", stdout);
    //test
    {
        
        solve();
		
		      
    }
    return 0;
}
  

Measured memory_bytes: 3564
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	S := nextBytes()
	T := nextBytes()

	c := 0

	for i := 0; i < 3; i++ {
		if S[i] == T[i] {
			c++
		}
	}
	fmt.Println(c)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


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

int f(int x){
int y;
y=x*x;
return y;}
int main(){
int d,e,ans;
while(cin>>d){
ans=0;
e=600/d;
for(int i=0;i<e;i++){
ans+=f(i*d)*d;}
cout<<ans<<endl;}}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <vector>

using namespace std;

int main(){
	uint16_t R, G, B, N;
	cin >> R >> G >> B >> N;
	uint32_t res = 0;
	for(uint16_t r = 0;r <= N / R;++r){
		for(uint16_t g = 0;g <= (N - (R * r)) / G;++g){
			if(((N - (R*r)) - (G*g)) % B == 0)
				++res;
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <vector>
using namespace std;
int main() {
    int a,b,c,k,i;
    vector<int> vec;
    cin >> a >> b >> k;
    c=a;
    if( a>b ) c=b;
    for(i=1; i<=c; i++)
        if( a%i==0 && b%i==0 )
            vec.push_back(i);
    cout << vec[vec.size()-k] << endl;
}


Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;
public class Main {
	static int anotherSide(int[] map,int x){//baseと同じ高さを持つ一番近いｘ座標を返す
		for(int i=x+1;i<map.length;i++){
			if(map[x]==map[i]) return i;
		}
		return -1;
	}
	static double crossProduct(int x1,int y1,int x2,int y2){
		return x1*y2-y1*x2;
	}
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		String data=scan.next();
		int N=data.length()+1;
		int[] map=new int[N];
		int height=0;
		for(int i=0;i<N;i++ ){
			map[i]=height;
			if(i==N-1){
				break;
			}else{
				if(data.charAt(i)=='\\'){
					height--;
				}else if(data.charAt(i)=='/'){
					height++;
				}else{
					//何もしない。高さが変わらない。
				}
			}
		}
		int base=0;
		int area=0;
		int All=0;
		int nextbase;
		boolean sign=false;
		LinkedList<Integer> answer=new LinkedList<Integer>();
		while(true){
			if(base==N-1) break;
			while(!(map[base]>map[base+1])){
				base++;
				if(base==N-1){
					sign=true;
					break;
				}
			}
			if(sign) break;
			nextbase=anotherSide(map,base);
			if(nextbase==-1){//見つからなかった。
				base++;
				continue;
			}else{//水たまりができる。
				//外積
				for(int i=base;i<nextbase;i++){
					area+=crossProduct(i,map[i],i+1,map[i+1]);
				}
				area+=crossProduct(nextbase,map[nextbase],base,map[base]);//面積が求まった
				area/=2;
				area=Math.abs(area);
				All+=area;
				answer.addLast(area);
				area=0;
				base=nextbase;
			}
		}
		System.out.println(All);
		System.out.print(answer.size());
		while(!answer.isEmpty()){
			System.out.print(" "+answer.poll());
		}
		System.out.println();
		scan.close();
	}
}

Measured memory_bytes: 25488
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
int main(){

  priority_queue <int> a;
  int tmp1;
  char tmp2[10];

  while(scanf("%s",tmp2),tmp2[2]!='d'){
    if(tmp2[0]=='i'){
      scanf("%d",&tmp1);
      a.push(tmp1);
    }
    else{
      printf("%d\n",a.top());
      a.pop();
    }
  }
  return 0;

}

Measured memory_bytes: 7028
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;

int main() {
    string S,T,U;
    cin >> S >> T;
    ll a, b;
    cin >> a >> b;
    cin >> U;
    if (U == S) {
        a --;
    } else {
        b --;
    }
    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
s_list = list()
ans = [0 for i in range(N)]
flag = True
for i in range(M):
    s,c = map(int,input().split())
    
    if s==1 and c==0 and N!=1:
        flag = False
        
    if s in s_list:
        if ans[s-1] != c:
            flag = False
    else:
        s_list.append(s)
        ans[s-1] = c
if flag ==False:
    print(-1)
else:
    if N != 1 and ans[0]==0:
        ans[0] = 1
    ans = [str(i) for i in ans]
    print(''.join(ans))


Measured memory_bytes: 38384
k, n = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

distance = (k - a[n-1]) + a[0]

for i in range(n-1):
    if distance < a[i+1] - a[i]:
        distance = a[i+1] - a[i]

print(k - distance)

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

int main(){
  int N;
  const int64_t mod=1e9+7;
  cin >> N;
  map<int,int> m;
  for(int i=2;i<=N;i++){
    int n=i;
    int a=2;
    while(a*a<=n){
      if(n%a==0){
        n/=a;
        if(m.count(a)){
          m.at(a)++;
        }else{
          m[a]=1;
        }
      }else{
        a++;
      }
    }
    if(m.count(n)){
      m.at(n)++;
    }else{
      m[n]=1;
    }
  }
  int64_t ans=1;
  for(auto p:m){
    ans*=(p.second+1);
    ans%=mod;
  }
  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 < (n); ++i)
typedef float fl;
typedef long long ll;

vector<int> A;
int n, m, q; 
int a[50], b[50], c[50], d[50];
ll ans;

ll score(vector<int> &A) {
    ll ans = 0;
    rep(i,q) if(A[b[i]] - A[a[i]] == c[i]) ans += d[i];
    return ans;
}

ll dfs(vector<int> &A) {
    if(A.size() == n) return score(A);

    int prev_last = (A.empty()? 1 : A.back());
    for(int add = prev_last; add <= m; ++add) {
        A.push_back(add); 
        ans = max(ans, dfs(A));
        A.pop_back();
    }

    return ans;
}

int main(){
    cin >> n >> m >> q;
    rep(i,q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i], --b[i];
    }
    cout << dfs(A) << endl;
    return 0;
}

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

int main(){
    int h1, m1, h2, m2, k;
    cin >>h1>>m1>>h2>>m2>>k;

    int time1=h1*60+m1;
    int time2=h2*60+m2;

    int time=time2-time1;

    if(time>=k){
        cout << time-k <<endl;
    }
    else {
        cout<<0<<endl;
    }
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

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

template<typename T,typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int r;
    cin >> r;
    cout << 3*r*r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

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

    int N; cin >> N;
    ll data[N]; F0R(i, N) cin >> data[i];

    ll ans[N];
    ans[0] = 0; F0R(i, N) {
        ans[0] += data[i]; if (i % 2 == 1) ans[0] -= 2*data[i];
    }

    ans[0] = ans[0] / 2;
    FOR(i, 1, N) {
        ans[i] = data[i-1] - ans[i-1];
    }

    F0R(i, N) {
        cout << ans[i] * 2 << " ";
    }

    cout << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 2944
def readinput():
    n=int(input())
    a=list(map(int,input().split()))
    return (n,a)

def main(n,a):
    a.sort(reverse=True)
    nloop=n//2
    apoint=0
    bpoint=0
    l=0
    while(l<nloop):
        apoint+=a[l*2]
        bpoint+=a[l*2+1]
        l+=1
    if(n%2==1):
        apoint+=a[n-1]
    return apoint-bpoint


if __name__=='__main__':
    n,a = readinput()
    ans=main(n,a)
    print(ans)


Measured memory_bytes: 3064
s=input()
sl=len(s)
ans=0
for i in range(2**(sl-1)):
    bit=bin(i)[2:].zfill(sl-1)
    now=0
    for j in range(len(s)-1):
        if int(bit[j]):
            ans+=int(s[now:j+1])
            now=j+1
    ans+=int(s[now:])
print(ans)

Measured memory_bytes: 9140
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        int lmax = 0, rmin = Integer.MAX_VALUE;
        int res;
        for(int i = 0; i < m; i++) {
            int l = Integer.parseInt(sc.next()), r = Integer.parseInt(sc.next());
            lmax = Math.max(lmax, l);
            rmin = Math.min(rmin, r);
        }
        res = Math.max(0, rmin - lmax + 1);
        System.out.println(res);
    }
}


Measured memory_bytes: 48436
from math import factorial

# 入力
N, A, B = map(int, input().split())
v = list(map(int, input().split()))

u = sorted(v, reverse=True)
m = sum(x == u[A - 1] for x in v)


# 非負の整数n, k について、二項係数nCkを返す関数
def c(n, k):
    return factorial(n) // (factorial(n - k) * factorial(k))


# 平均の最大値は価値の高いものから順にA個選んだときの平均値
# そのような選び方は二項係数を用いて求める
ans = '{}\n{}'.format(
    sum(u[:A]) / A,
    (
        c(
            m,
            A - sum(x > u[A - 1] for x in v)
        ) if u[A - 1] < u[0] else
        sum(
            c(m, k)
            for k in range(A, min(m + 1, B + 1))
        )
    )
)

# 出力
print(ans)


Measured memory_bytes: 3064
def insertionSort(a, g):
    global cnt
    for i in range(g, len(a)):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j - g
            cnt += 1
            a[j+g] = v


def shellSort(a):
    global cnt
    cnt = 0
    g = []
    h = 1
    while h <= len(a):
        g.append(h)
        h = 3*h+1
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str, g)))
    for i in range(m):
        insertionSort(a, g[i])


a = [int(input()) for i in range(int(input()))]
shellSort(a)
print(cnt)
for e in a:
    print(e)



Measured memory_bytes: 45512
#include <bits/stdc++.h>
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%I64d", &(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("%I64d\n", (n))
#define pii pair<int, int>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
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;
using namespace std;
ll a[MAXN];

int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    if (a[0] != 0)
        return !printf("-1\n");
    ll ans = 0;
    for (int i = 1; i < n; i++)
    {
        if (a[i] - a[i - 1] > 1)
        {
            cout << "-1\n";
            return 0;
        }
        int j = i + 1;
        while (j < n && a[j] - a[j - 1] == 1)
            j++;
        j--;
        ans += (ll) a[j];
        i = j;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int sosu_high_min(int n);
int sosu_small_max(int n);

int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		int high=0,min;
		if(n<3||50000<n)
		{
		}
		else
		{
			high=sosu_small_max((n-1));
			min=sosu_high_min((n+1));
			printf("%d %d\n",high,min);
		}
	}
}

int sosu_small_max(int n)
{
	int t;
	for(n;;n--)
	{
		for(t=2;t<=n;t++)
		{
			if(t==n)
			{
				return n;
			}
			else if(n%t==0)
			{
				break;
			}
		}
	}
}
int sosu_high_min(int n)
{
	int t;
	for(n;;n++)
	{
		for(t=2;t<=n;t++)
		{
			if(t==n)
			{
				return t;
			}
			else if(n%t==0)
			{
				break;
			}
		}
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
using namespace std;
using ll=long long;
using R=double;

ll nC2(ll n){
	ll res = n*(n-1) / 2;
	return res;
}

int main(){
	ll A,B,C;
	ll K;
	cin >> A >> B >> C >> K;

	ll result;

	if(K%2 == 0){
		result = A-B;
	}else{
		result = B-A;
	}

	if(abs(result) > pow(10,18)){
		puts("Unfair");
		return 0;
	}

	cout << result << endl;

}


Measured memory_bytes: 256
import java.util.*;
import java.util.regex.*;
import static java.lang.Math.*;
import static java.lang.System.out;

// AOJ
public class Main {
	final Scanner sc=new Scanner(System.in);
	final int[] vx={0,1,0,-1}, vy={-1,0,1,0};
	final int[] vvx={0,1,0,-1,-1,1,1,-1}, vvy={-1,0,1,0,-1,-1,1,1};
	static class Point{
		int x, y;
		Point(int x, int y){	this.x=x;	this.y=y;}
		Point(){	this.x=0; this.y=0;}
		@Override public String toString(){	return "("+this.x+","+this.y+")";}
		static boolean ok(int x,int y,int X,int Y,int min){	return (min<=x&&x<X)&&(min<=y&&y<Y);}
		static boolean ok(int x,int y,int X,int Y){	return ok(x,y,X,Y,0);}
	}
	public static void main(String[] args) {
		new Main().AOJ1159();
	}
	
	void AOJ1160(){
		while(sc.hasNext()){
			int W=sc.nextInt(),H=sc.nextInt();
			if((W|H)==0)	break;
			boolean[][] b=new boolean[W][H];
			for(int y=0; y<H; y++){
				for(int x=0; x<W; x++)	b[x][y]=(sc.nextInt()==1);
			}
			boolean[][] close=new boolean[W][H];
			LinkedList<Point> open=new LinkedList<Point>();
			int ans=0;
			for(int x=0; x<W; x++){
				for(int y=0; y<H; y++){
					if(b[x][y]&&!close[x][y]){
						open.add(new Point(x,y));
						ans++;
						while(!open.isEmpty()){
							Point now=open.poll();
							for(int i=0; i<8; i++){
								int xx=now.x+vvx[i],yy=now.y+vvy[i];
								if(!Point.ok(xx, yy, W, H))	continue;
								if(!b[xx][yy])	continue;
								if(close[xx][yy])	continue;
								open.add(new Point(xx,yy));
								close[xx][yy]=true;
							}
						}
					}
				}
			}
			out.println(ans);
		}
	}
	
	void AOJ1159(){
		while(true){
			int n = sc.nextInt();
			int q = sc.nextInt();
			if(n == 0 && q == 0) break;
			int [] data = new int[n];
			//int num = 0;
			for(int i = 0; i < 1000000; i++){
				if(q == 0){
					q += data[i%n];
					data[i%n] = 0;
				}
				else{
					data[i%n]++;
					q--;
					//System.out.println(q + " " + data[i%n]);
					if(q == 0){
						boolean flg = true;
						for(int j = 0; j < n; j++){
							if((i % n) == j) continue;
							if(data[j] != 0){
								flg = false;
								break;
							}
						}
						if(flg == true){
							System.out.println(i%n);
							break;
						}
					}
					
				}
			}
		}
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;

import static java.lang.Math.max;

public class Main
{
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long k = scanner.nextLong();
        if (k == 0) {
            System.out.println(n * n);
            return;
        }

        long count = 0;
        for (long b = 2; b <= n; b++) {
            count += (n / b) * max(b - k, 0) + max(n % b - k + 1, 0);
        }
        System.out.println(count);
    }
}



Measured memory_bytes: 23764
def solve(n):

    if n == 0:
        return 2
    elif n == 1:
        return 1
    else:
        l0 = 2
        l1 = 1
        for i in range(2,n+1):
            l = l1 + l0
            l0 = l1
            l1 = l
        return l

if __name__ == "__main__":
    n = int(input())
    print(solve(n))


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

int main(){
	int x,n; cin>>x>>n;
	if(n==0){cout << x << endl; return 0;}
	vector<int> v(102);
	for(int i=0; i<n; i++){
		int p; cin>>p;
		v[p]=p;
	}
	int ans1=0; int ans2=0; int p1, p2;
	for(int i=x; i>-1; i--){
		if(v[i]==0){ans1=abs(x-i); p1=i; break;}
	}
	for(int i=x-1; i<=101; i++){
		if(v[i]==0){ans2=abs(x-i); p2=i; break;}
	}
	cout << (ans1<=ans2?p1:p2) <<endl;	
}

Measured memory_bytes: 3652
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j, k;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  
  for(j=2; j<=n;j++)
    {
      k=A[j];
      i=j-1;
  while(i>0 && A[i]>k)
    {
      A[i+1] = A[i];
      i--;
      A[i+1] = k;
    }
  trace(A, n);
    }
return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;

int main(){
	int ans = 0,n;
	cin >> n;
	int a[n];
	for(int i = 0;i < n;i++) cin >> a[i];
	vector<int> v;
	for(int i = 0;i < n;i += 2) v.push_back(a[i]);
	sort(a,a + n);
	multiset<int> s;
	for(int i = 0;i < n;i += 2) s.insert(a[i]);
	for(int i = 0;i < v.size();i++){
		if(s.count(v[i])) s.erase(s.find(v[i]));
		else ans++;
	}
	cout << ans << endl;
}

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

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


int main(){
    int A,B,C,K;
    int S;

    cin >> A >> B >> C >> K;

    if(A>=K){
        cout << K << endl;
    }else if(A+B>=K){
        cout << A << endl;
    }else if(A+B<K){
        cout << A - (K-A-B) << endl;
    }
    


    
    
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll       long long
#define DS       pair<ll, ll>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 1005;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int h, a, c = 0;
    cin >> h >> a;
    while (h > 0) {
        h -= a;
        c++;
    }
    cout << c << endl;
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> d(N);
	for (int i = 0; i < N; i++) {
		cin >> d.at(i);
	}
	sort(d.begin(), d.end());

	int ans = 1;
	int tmp = d.at(0);
	for (int i = 1; i < N; i++) {
		if (d.at(i) > tmp) {
			ans++;
			tmp = d.at(i);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
N, WM = map(int, input().split())
W = []
V = []
dp = [[0] * (WM + 1) for _ in range(N + 1)]

for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)

for i in range(N):
    for w in range(WM + 1):
        if w - W[i] >= 0:
            dp[i + 1][w] = max(dp[i + 1][w], dp[i][w - W[i]] + V[i])
        dp[i + 1][w] = max(dp[i + 1][w], dp[i][w])

print(dp[N][WM])


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

int main(){
  
  int n;
  cin >> n;
  
  vector<int> vx(n);
  vector<int> vy(n);
  
  rep(i,n){
    int x,y;
    cin >> x >> y;
    vx[i] = x+y;
    vy[i] = x-y;
  }
  
  int xmax = *max_element(all(vx))-*min_element(all(vx));
  int ymax = *max_element(all(vy))-*min_element(all(vy));
  
  cout << max(xmax,ymax) << endl;
}


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

int main() {
    int N, K; cin >> N >> K;
    vector<int> p(N);
    for (int i = 0; i < N; i++) {
        cin >> p.at(i);
    }
    double M = 0, sum = 0;
    for(int i = 0; i < N - K + 1; i++) {
        if (i == 0) {
            for (int j = 0; j < K; j++) {
                sum += p.at(j);
                M = sum;
            }
        }
        else {
            sum += p.at(i + K - 1) - p.at(i - 1);
            M = max(M, sum);
        }
    }
    cout << fixed << setprecision(7);
    cout << (K + M) / 2 << endl;
}

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


int main() {
  int W, H, x, y, r;

  cin >> W >> H >> x >> y >> r;

  int right, left, top, bottom;

  right = x + r;
  left = x - r;
  top = y + r;
  bottom = y - r;

  if (right <= W && left >= 0 && top <= H && bottom >= 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }




}



Measured memory_bytes: 3100
/*
Original problem: 
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)


#define PII pair<int,int>
#define PLL pair<ll,ll>

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;

const int mod = 1e9+7;

namespace SOLVE {
    int H, W;

    int valid(int i, int j) {
        return (0 <= i && i < H && 0 <= j && j < W);
    }

	void main() {
		// 2D dp
        
        cin >> H >> W;

        vector<string> grid(H);
        REP(i,0,H) {
            cin >> grid[i];
        }
        vector<VLL> dp(H, VLL(W));
        dp[0][0] = 1;
        REP(i,0,H) {
            REP(j,0,W) {
                
                dp[i][j] += (valid(i-1,j) && grid[i-1][j] == '.') ? dp[i-1][j] : 0;
                dp[i][j] += (valid(i,j-1) && grid[i][j-1] == '.') ? dp[i][j-1] : 0;
                dp[i][j] %= mod;
                
            }
        }

        cout << dp[H-1][W-1] << endl;

	}
}


signed main() {
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

Measured memory_bytes: 9216
def merge(A,left,mid,right):
    global cnt
    n1 = mid - left
    n2 = right - mid
    cnt += n1+n2
    L = [A[left+i] for i in range(n1)]
    R = [A[mid+i] for i in range(n2)]
    L.append(float("inf"))
    R.append(float("inf"))
    i = 0
    j = 0
    for k in range(left,right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergesort(A,left,right):
    if left +1 < right:
        mid = int((left+right)/2)
        mergesort(A,left,mid)
        mergesort(A,mid,right)
        merge(A,left,mid,right)

n = int(input())
A = list(map(int,input().split()))
cnt = 0
mergesort(A,0,n)
print(" ".join(map(str,A)))
print(cnt)


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

int main() {
    int N;
    cin>>N;
    map<char, int>Smap;
    int ans = 0;
    char tmp;
    for(int i=0;i<N;++i){
        cin>>tmp;
        if(Smap[tmp]==0)ans++;
        Smap[tmp]++;
    }
    if(ans==3)cout<<"Three"<<endl;
    else cout<<"Four"<<endl;
}


Measured memory_bytes: 256
def comb(n, r, p):
    x, y = 1, 1
    for i in range(n, n - r, -1):
        x *= i
        y *= i + r - n
        x %= p
        y %= p
    return pow(y, p - 2, p) * x % p

n, m, k = map(int, input().split())
mod = 998244353
all = pow(n, m, mod)
x, y = [0] * (k + 1), [0] * (k + 1)
x[0] = (m * pow(m - 1, n - k - 1, mod)) % mod
y[0] = 1
for i in range(1, k + 1):
    x[i] = (x[i - 1] * (m - 1)) % mod
    y[i] = (pow(i, mod - 2, mod) * y[i - 1] * (n - i)) % mod
y.reverse()
ans = 0
for i in range(k + 1):
    ans += x[i] * y[i]
    ans %= mod
print(ans)

Measured memory_bytes: 88664
#include <iostream>

using namespace std;

int func(int a)
{
	int count = 0;
	
	// 100でちょうど割り切る
	while (a % 100 == 0)
	{
		a /= 100;
		count++;
	}
	
	return count;
}

int main()
{
	int D, N;
	cin >> D >> N;
	
	int num = 0;
	int answer = 0;
	
	// N番目になるまで
	while(num < N)
	{
		answer++;
		// 現在の数字が何回で割り切れたかのカウント
		int count = func(answer);
		
		//  ちょうどD回
		if (count == D) {
			num++;
		}
	}
	
	cout << answer << endl;
	
	return 0;
}

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

int main()
{
    char x; cin >> x;
    int tmp = x - 65;

    if(tmp <= 25) cout << "A" << endl;
    else cout << "a" << endl;
}

Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main{
    public static void main(String args[]){
	String str;
	try{
	    InputStreamReader is = new InputStreamReader(System.in);
	    BufferedReader br = new BufferedReader(is);
	    String[] strary = new String[3];
	    int[] len = new int[3];
	    int temp;
	    str = br.readLine();
	    int count = Integer.parseInt(str);
	    while((count--) != 0){
		str = br.readLine();
		strary = str.split(" ");
		for(int i=0;i<3;i++){
		    len[i] = Integer.parseInt(strary[i]);
		}
		if(len[0] > len[1]){
		    temp = len[0];
		    len[0] = len[1];
		    len[1] = temp;
		}
		if(len[1] > len[2]){
		    temp = len[1];
		    len[1] = len[2];
		    len[2] = temp;
		}
		if((len[0]*len[0] + len[1]*len[1]) == (len[2]*len[2]))
		    System.out.println("YES");
		else
		    System.out.println("NO");
	    }
	}
	catch(Exception e){
	    System.exit(0);
	}
    }
}

Measured memory_bytes: 20164
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

n,m,k = map(int,input().split())
uf=UnionFind(n)

F=[set() for _ in range(n)]
for i in range(m):
   a,b=map(int,input().split())
   uf.union(a-1,b-1)
   F[a-1].add(b-1)
   F[b-1].add(a-1)

B=[0 for _ in range(n)]
for i in range(k):
    c,d=map(int,input().split())
    if uf.same(c-1,d-1):
        B[c-1]-=1
        B[d-1]-=1
A=[]
for i in range(n):
    A.append(uf.size(i)-len(F[i])+B[i]-1)
print(*A)

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

int main(){

    int n,m;
    cin >> n >> m;
    int l=1,r=n;
    rep(i,m){
        int s,t;
        cin >> s >> t;
        l=max(l,s);
        r=min(r,t);
    }

    cout << max(0,r-l+1) << endl;

    return 0;
}

Measured memory_bytes: 256
/**
  @file a.cpp
  @title A - Weather Prediction
  @url https://atcoder.jp/contests/abc141/tasks/abc141_a
**/

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

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

  vector<string> v = {"Sunny", "Cloudy", "Rainy"};

  if (S == v[0]) {
    cout << v[1] << endl;
  } else if (S == v[1]) {
    cout << v[2] << endl;
  } else if (S == v[2]) {
    cout << v[0] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    long long N, A[100001], i, odd=0, even=0;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> A[i];

        if(A[i]%2==1){
            odd++;
        }

        else{
            even++;
        }
    }

    if(odd % 2 == 0){
        cout << "YES" << endl;
    }

    else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <string>
#include <deque>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <assert.h>
typedef long long ll;
#define pi pair<int, int>
#define pii pair<pi, pi>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
#define vlll vector<vll>
using namespace std;

long long INF = 1LL << 50;
int main() {
	int R, C, K;
	cin >> R >> C >> K;
	vll grid(R, vl(C));
	vlll dp(R + 1, vll(C + 1, vl(4, -INF)));
	for (int i = 0; i < K; i++) {
		int r, c;
		long long v;
		cin >> r >> c >> v;
		grid[--r][--c] = v;
	}
	for (int i = 0; i <= R; i++) {
		dp[i][0][0] = 0;
	}
	for (int i = 0; i <= C; i++) {
		dp[0][i][0] = 0;
	}
	for (int i = 1; i <= R; i++) {
		for (int j = 1; j <= C; j++) {
			for (int k = 0; k < 4; k++) {
				dp[i][j][k] = dp[i][j - 1][k];
			}
			for (int k = 0; k < 4; k++) {
				dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][k]);
				if (grid[i - 1][j - 1]) {
					dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j][k] + grid[i - 1][j - 1]);
				}
			}
			if (grid[i - 1][j - 1]) {
				dp[i][j][1] = max(dp[i][j][1], dp[i][j - 1][0] + grid[i - 1][j - 1]);
				dp[i][j][2] = max(dp[i][j][2], dp[i][j - 1][1] + grid[i - 1][j - 1]);
				dp[i][j][3] = max(dp[i][j][3], dp[i][j - 1][2] + grid[i - 1][j - 1]);
			}
		}
	}
	long long ans = 0;
	for (int k = 0; k < 4; k++) {
		ans = max(ans, dp[R][C][k]);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 707308
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main(){
  int N,P;
  cin >> N >> P;
  vector<int> a(N);
  for(int i = 0; i< N; i++){
    cin >> a.at(i);
  }
  bool b = true;
  for(int i = 0; i<N; i++){
    if(a.at(i) %2 != 0){
      b = false;
    }
  }
  long long ans;
  if(b){
    if(P == 0){
      ans =pow(2,N);
    }
    else{
      ans = 0;
    }
  }
  else{
    ans = pow(2,N-1);
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n;
ll ans=1e12+4;
int main() {
	scanf("%lld",&n);
	for (register ll i=1;i*i<=n;++i) {
		if (n%i==0) {
			ll j=n/i;
			ans=min(ans,-2ll+j+i);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int jiang,mod;
long long dp[3001][3001];
long long c[3001][3001];
inline long long quick_pow(long long x,int p,int mod){
	long long result=1;
	while(p){
		if(p&1){
			result*=x;
			result%=mod;
		}
		p>>=1;
		x*=x;
		x%=mod;
	}
	return result;
}
int main(){
	scanf("%d%d",&jiang,&mod);
	for(register int i=0;i<=jiang;i++){
		c[i][0]=dp[i][0]=1;
		for(register int j=1;j<=i;j++){
			dp[i][j]=(dp[i-1][j-1]+(j+1)*dp[i-1][j]%mod)%mod;
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
		}
	}
	register long long ans=0;
	for(register int i=0;i<=jiang;i++){
		register long long can=quick_pow(2,quick_pow(2,jiang-i,mod-1),mod);
		register long long num=quick_pow(2,jiang-i,mod);
		register long long sum=0;
		register long long coef=1;
		for(register int j=0;j<=i;j++){
			sum+=dp[i][j]*coef;
			sum%=mod;
			coef*=num;
			coef%=mod;
		}
		ans+=sum*(can*(i&1?mod-c[jiang][i]:c[jiang][i])%mod)%mod;
		ans%=mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 96064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	length, _ := strconv.Atoi(input())
	x := float64(length) / 3
	fmt.Println(x * x * x)
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll a,b,x;
  cin >> a >> b >> x;

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


Measured memory_bytes: 384
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve() { 
    priority_queue<int,vector<int>,greater<int>> pq;
    int n,m; cin>>n>>m; 
    for (int i=0;i<n;i++){
        int a; cin>>a;
        pq.push(a);
    }
    vector <pii> v(m);
    for (int i=0;i<m;i++) 
        cin>>v[i].ss>>v[i].ff; 
    sort(v.rbegin(), v.rend()); 
    for (int i=0;i<m;i++){
        int j=0;
        while (j<v[i].ss and v[i].ff>pq.top()){
            pq.pop(); pq.push(v[i].ff); j++;
        }
    }
    int sum=0; 
    while (pq.size()){
        sum += pq.top();
        pq.pop();
    }
    cout << sum << endl; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

int main(){
	string num;
	while(1){
		cin >> num;
		if(num[0]=='0') break;
		int sum = 0;
		for(int i=0;i < num.length();i++){
			sum += num[i] - '0';
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;
int main()
{
	ll X,A,B;
	cin>>X;
	A=X/100;
	B=X%100;
	if(A*5>=B)cout<<1<<endl;
	else cout<<0<<endl;
}

Measured memory_bytes: 888
#include <iostream>

void call( int n )
{
  int i = 1 ;

  for ( ; i <= n ; ++i ) {
    int x = i ;
    
    bool bMatch = ( x % 3 == 0 ) ;
    for ( ; x && !bMatch ; x /= 10 ) {
      bMatch = ( x % 10 == 3 ) ;
    }
    if ( bMatch )
      std::cout << " " << i ;
  }
  std::cout << std::endl ;
}

int main()
{
  int num ;
  std::cin >> num ;

  call( num ) ;

  return 0 ;
}

Measured memory_bytes: 3064
SA = list(input())
SB = list(input())
SC = list(input())
gameflag = 1
flag = "a"
while gameflag == 1:
    if flag == "a":
        if SA == []:
            break
        else:
            flag = SA.pop(0)
    if flag == "b":
        if SB == []:
            break
        else:
            flag = SB.pop(0)
    if flag == "c":
        if SC == []:
            break
        else:
            flag = SC.pop(0)
print(str.upper(flag))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
struct LCA {
    vector<vector<int>> par;
    vector<int> d;
    int n;
    LCA(vector<vector<int>> graph, int root) {
        n = graph.size();
        par.resize(n, vector<int>(30));
        d.resize(n, 0);
        function<void(int, int, int)> dfs = [&](int c, int p, int depth) {
            d[c] = depth;
            par[c][0] = p;
            for (auto ch : graph[c]) {
                if (ch != p) dfs(ch, c, depth + 1);
            }
        };
        dfs(0, 0, 0);
        for (int j = 1; j < 30; j++) {
            REP(i, n) { par[i][j] = par[par[i][j - 1]][j - 1]; }
        }
    }
    int getdistance(int u, int v) { return (d[u] + d[v]) - 2 * (d[query(u, v)]); }
    int query(int u, int v) {
        if (d[u] > d[v]) {
            swap(u, v);
        }
        for (int i = 29; 0 <= i; i--) {
            if (d[u] <= d[par[v][i]]) {
                v = par[v][i];
            }
        }
        /* LCA */
        for (int i = 29; 0 <= i; i--) {
            if (par[v][i] != par[u][i]) {
                v = par[v][i];
                u = par[u][i];
            }
        }
        if (u == v) {
            return u;
        } else {
            return par[v][0];
        }
    }
};

struct UnionFind {
    vector<int> parent, size;
    UnionFind(int n) {
        parent.resize(n, -1);
        size.resize(n, 1);
    }
    void unite(int x, int y) {
        if (same(x, y)) {
            return;
        }
        x = root(x);
        y = root(y);
        if (size[x] <= size[y]) {
            swap(x, y);
        }
        parent[y] = x;
        size[x] += size[y];
    }
    bool same(int x, int y) { return (root(x) == root(y)); }
    int root(int x) {
        while (parent[x] != -1) {
            x = parent[x];
        }
        return x;
    }
    int getsize(int x) { return size[root(x)]; }
};
void aoj(vector<int> bs) {
    REP(i, bs.size() - 1) { cout << bs[i] << " "; }
    cout << bs[bs.size() - 1] << endl;
}

signed main() {
    int n;
    cin >> n;
    vector<int> as(n);
    REP(i, n) { cin >> as[i]; }
    int q;
    cin >> q;
    vector<int> k(q);
    REP(i, q) { cin >> k[i]; }
    // find an index of minimum value >= 5;
    // set limits
    REP(i, q) { cout << lower_bound(as.begin(), as.end(), k[i]) - as.begin() << endl; }
}


Measured memory_bytes: 4108
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>
#include <map>

using namespace std;

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

    map<int, int> cnt;

    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        cnt[a]++;
        cnt[a - 1]++;
        cnt[a + 1]++;
    }

    int out = -1;

    for(auto& it: cnt)
        out = max(out, it.second);

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b;
    cin >> a >> b;
    ll x;
    cin >> x;
    if (a==0){
        cout << b/x+1 << endl;
    }
    else
    {
        cout << b/x - (a-1)/x << endl;
    }
}


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

using namespace std;

int main(void){
  int a,b;
  cin>>a>>b;
  if(a==b) cout<<"Draw";
  else if(a==1||b==1){
    if(a==1) cout<<"Alice";
    else cout<<"Bob";
  }
  else if(a>b) cout<<"Alice";
  else if(b>a) cout<<"Bob";

  cout<<endl;
  return 0;
}

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

using namespace std;

const long long MD = 1e9 + 7;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    vector<int> dat(1001,0);
    for(int i = 1; i <= n; i++){
        int f = i;
        for(int pf = 2; pf <= f; pf++){
            while(f % pf == 0){
                f /= pf;
                dat[pf]++;
            }
        }
    }
    long long ans = 1;
    for(int i : dat) if(i != 0)ans = (ans * (i+1)) % MD;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256