akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

lint inv_mod(lint a,lint b,lint p){
  if(b==0)return 1;
  if(b%2==0){
    lint d=inv_mod(a,b/2,p);
    return (d*d)%p;
  }else{
    return (a*inv_mod(a,b-1,p))%p;
  }
}

int main(){
  int N,M;
  cin>>N>>M;
  int K=31625;
  // int K=10;
  lint p=1000*1000*1000+7;
  lint ans=1;
  int s[K]={0};
  FOR(i,2,K){
    while(M%i==0){
      if(M==1)break;
      M/=i;
      s[i]+=1;
    }
    if(M==1)break;
  }
  if(M>1)ans*=N;
  FOR(i,2,K){
    if(s[i]==0)continue;
    lint a=1;
    FOR(j,N,N+s[i]){
      a*=j;
      a%=p;
    }
    lint b=1;
    FOR(j,1,s[i]+1){
      b*=j;
      b%=p;
    }
    // cout<<s[i]<<a<<b<<endl;
    ans*=a;
    ans%=p;
    ans*=inv_mod(b,p-2,p);
    ans%=p;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = int(input())
ab = [readints() for _ in range(n)]
# print(ab)
ab2 = sorted(ab, key=lambda x: x[1])
# print(ab2)
tmp = 0
cnt = 0
for i in range(n):

    tmp += ab2[i][0]
    if tmp <= ab2[i][1]:
        cnt += 1
if cnt == n:
    print('Yes')
    exit()
print('No')


Measured memory_bytes: 90200
n,k = map(int,input().split())
mod = 10**9+7
C=[[0] * (k+1) for i in range(n+1)]
for i in range(1,n+1):
    C[i][1] = i
    for j in range(2,k+1):
        C[i][j] = (C[i-1][j-1] + C[i-1][j])%mod
print(n-k+1)
for i in range(1,k):
    if n-k < i or k-1 < i:
        print(0)
        continue
    print((C[n-k+1][i+1] * C[k-1][i])%mod)
    # print(C[n-k+1][i] , C[k-1][i-1])


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

int main()
{
	char c1, c2, c3, c4;
	cin >> c1 >> c2 >> c3 >> c4;
	if ((c1 == c2 && c2 == c3)||(c2==c3&&c3==c4)) {
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
s=input()

res=0
for i in range(len(s)+1):
    for j in range(i+1,len(s)+1):
        cnt=0
        for x in s[i:j]:
            if x not in ['A','G','C','T']:
                break
            cnt+=1
        if res<cnt:
            res=cnt

print(res)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string S;
    cin >> S;

    if (S.back() == '3' ) 
        cout << "bon" << endl;
    else if (S.back() == '0' || S.back() == '1' || S.back() == '6' || S.back() == '8') 
        cout << "pon" << endl;
    else 
        cout << "hon" << endl;
    return 0;
}

Measured memory_bytes: 3592
n = int(raw_input())

for i in range(n):

    t = list(raw_input())

    t.sort()
    #print t
    lo = int("".join(map(str,t)))

    t.reverse()
    he = int("".join(map(str,t)))                                                                                                                                                                            
    #print he

    print he-lo

Measured memory_bytes: 4216
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 16,mo=1e9+7;
int n,m,a[N+3],f[1<<N|3],g[1<<N|3],fac[1<<N|3],ifac[1<<N|3];
int power(int a, int n){
	int res=1;
	while(n){
		if(n&1)res=1LL*res*a%mo;
		a=1LL*a*a%mo;n>>=1;
	}
	return res;
}
int C(int n, int m){return m>=0&&m<=n?1LL*fac[n]*ifac[m]%mo*ifac[n-m]%mo:0;}
void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}
int main() {
	read(n);read(m);rep(i,1,m)read(a[i]);int all=(1<<max(n,m))-1;
	fac[0]=1;rep(i,1,all)fac[i]=1LL*fac[i-1]*i%mo;
	ifac[all]=power(fac[all],mo-2);per(i,all-1,0)ifac[i]=1LL*ifac[i+1]*(i+1)%mo;
	f[0]=1;per(i,m,1){
		memset(g,0,sizeof(g));
		rep(j,0,all)if(f[j])rep(k,0,n-1)if(!(j>>k&1))
			add(g[j|1<<k],1LL*f[j]*C((1<<n)-a[i]-j,(1<<k)-1)%mo*fac[1<<k]%mo);
		rep(i,0,all)add(f[i],g[i]);
	}
	ll res=0;
	rep(i,0,all)if(f[i]){
	//	printf("%d:%d %d\n",i,f[i],f[i]*fac[n-1-i]);
		int cnt=1;rep(j,0,n-1)if(i>>j&1)cnt*=-1;
		res+=1LL*f[i]*fac[(1<<n)-1-i]%mo*cnt;
	}
	res=(res%mo+mo)%mo;res=(res<<n)%mo;//rep(i,0,n-1)res=res*fac[1<<i]%mo;
	printf("%lld",res);
	return 0;
}


Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
        Map<String, Integer> word = new HashMap<>();
        int longest = 0, mostFrequent = 0;
        String longestStr = "", mostFrequentStr = "";
        try {
            while (true) {
                String input = br.readLine();
                if (input == null) break;
                String[] line = input.split(" ");
                for (String str : line) {
                    if (word.get(str) == null) {
                        word.put(str, 1);
                    } else {
                        word.put(str, word.get(str) + 1);
                    }
                    if (str.length() > longest) {
                        longest = str.length();
                        longestStr = str;
                    }
                    if (word.get(str) > mostFrequent) {
                        mostFrequent = word.get(str);
                        mostFrequentStr = str;
                    }
                }
            }
        } finally {
            br.close();
        }
        System.out.println(mostFrequentStr + " " + longestStr);
    }
}

Measured memory_bytes: 24200
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define eb emplace_back
#define precision(n) cout << fixed << setprecision(n);
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{
    fast;
    int a[100001];
    int n;
    cin>>n;
    int cnt=0;
    int f=0;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(int i=0; i<n; i++)
    {
        if(a[i]%2==0)
        {
            cnt++;
        }
    }
    for(int i=0; i<n; i++)
    {
        if(a[i]%2==0)
        {
            if(a[i]%5==0||a[i]%3==0)
            {
                f++;
            }
        }
    }
    if(f==cnt)
    {
        cout<<"APPROVED"<<endl;
    }
    else
        cout<<"DENIED"<<endl;


        return 0;
    }


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

int main()
{
  char s[10];
  scanf("%s", s);
  if (strcmp(s, "Sunny") == 0)
    puts("Cloudy");
  if (strcmp(s, "Cloudy") == 0)
    puts("Rainy");
  if (strcmp(s, "Rainy") == 0)
    puts("Sunny");
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int r = sc.nextInt();
			if (n == 0 && r == 0)
				break;
			int[] card = new int[n];
			for (int i = 0; i < n; i++)
				card[i] = n - i;
			for (int i = 0; i < r; i++) {
				int p = sc.nextInt();
				int c = sc.nextInt();
				int[] tcard = new int[p - 1];
				for (int j = 0; j < p - 1; j++)
					tcard[j] = card[j];
				for (int j = 0; j < c; j++)
					card[j] = card[j + p - 1];
				for (int j = 0; j < p - 1; j++)
					card[j + c] = tcard[j];
			}
			System.out.println(card[0]);
		}
		sc.close();
	}
}

Measured memory_bytes: 30324
#include <iostream>
#include <string>

using namespace std;

class A {
	string s;
public:
	void solve()
	{
		for (int i{ 0 }; i < 3; i++)
		{
			cin >> s;
			cout << s[i];
		}

		cout << endl;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

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

int main() {
    string S;
    cin >> S;
    unordered_set<string> m{"01", "02", "03", "04", "05", "06",
                            "07", "08", "09", "10", "11", "12"};
    bool h = false, t = false;
    if (m.count(S.substr(0, 2)) > 0) h = true;
    if (m.count(S.substr(2, 2)) > 0) t = true;
    if (h && t)
        cout << "AMBIGUOUS" << endl;
    else if (h)
        cout << "MMYY" << endl;
    else if (t)
        cout << "YYMM" << endl;
    else
        cout << "NA" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans = 0;
int N;
vi A;
map<ll, ll> mp;

void solve(){
    rep(i, N){
        mp[A[i]+i]++;
    }

    rep(i, N){
        if(i - A[i] <= 0) continue;
        else {
            ans += mp[i-A[i]];
        }
    }

    cout << ans << endl;
}

int main(){
    cin >>N;
    A.resize(N);
    rep(i, N) cin >> A[i];

    solve();
}


Measured memory_bytes: 17716
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
 
 
int main(){
	long int n, k, i,j,c;
	double z=0;
	cin >> n >> k;
	
 
	for (i = 1; i <= n; i++) {
		c = 1;
		j = i;
		while (j < k) {
			j = 2*j;
			c = c * 2;
		}
		z =z+ (1 / double(n*c));
	
	}
	
	
	
	
	
	
	
	cout <<setprecision(12) << z;
 
	return 0;
	}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
void solve()
{
    vector < long > inp(n);
    int i;
    long ans=0;
    for (i=0;i<n;i++)
        cin>>inp[i];
    while(true)
    {
        int tag=0;
        for (i=0;i<n;i++)
            if (inp[i]%2==0) ;
            else tag=1;
        if (!tag)
        {
            for (i=0;i<n;i++)
                inp[i]/=2;
            ans++;
        }
        else break;
    }
    cout<<ans<<endl;
}
int main()
{
    while(cin>>n)
        solve();
}

Measured memory_bytes: 256
import sys
import math
def input():
    return sys.stdin.readline()[:-1]

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def trial_division(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    if n!=1:
        factor.append(n)
    return factor

n,m=map(int,input().split())
mod=10**9+7
if m==1:
    print(1)
    quit()
li=trial_division(m)
tmp=li[0]
countli=[]
count=1
for i in range(1,len(li)):
    if tmp!=li[i]:
        countli.append(count)
        count=1
    else:
        count+=1
    tmp=li[i]
countli.append(count)
ans=1
for i in range(len(countli)):
    ans*=combinations_count(countli[i]+n-1,countli[i])
print(ans%mod)

Measured memory_bytes: 115164
import kotlin.math.abs

fun main() = Thread(null, ::abc173e, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc173e() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val aList = readLine()!!.split(' ').map { it.toLong() }

    if (k == n) return println(aList.fold(Mint(1), Mint::times))

    val (positives, negatives) = aList
        .sortedByDescending { abs(it) }.partition { it > 0 }.toList().map { ArrayDeque(it) }

    var answer = Mint(1)

    if (k % 2 != 0) {
        if (positives.isEmpty()) return println(negatives.takeLast(k).fold(Mint(1), Mint::times))
        else answer *= positives.removeFirst()
    }

    repeat(k / 2) {
        when {
            positives.size >= 2 && negatives.size >= 2 -> {
                val pos = positives.take(2).reduce(Long::times)
                val neg = negatives.take(2).reduce(Long::times)
                if (pos > neg) {
                    answer *= pos
                    repeat(2) { positives.removeFirst() }
                } else {
                    answer *= neg
                    repeat(2) { negatives.removeFirst() }
                }
            }
            positives.size >= 2 -> answer *= positives.removeFirst() * positives.removeFirst()
            negatives.size >= 2 -> answer *= negatives.removeFirst() * negatives.removeFirst()
            else -> error("なんで？")
        }
    }

    println(answer)
}

private const val MOD = 1_000_000_007L

@Suppress("unused")
private class Mint(value: Long = 0L) {
    constructor(other: Mint) : this(other.value)

    private val value = (value % MOD).let { if (it < 0) it + MOD else it }
    operator fun unaryPlus() = this
    operator fun unaryMinus() = Mint(MOD - this.value)
    operator fun inc() = this.plus(1)
    operator fun dec() = this.minus(1)
    operator fun plus(other: Long) = Mint(this.value + other)
    operator fun plus(other: Mint) = this.plus(other.value)
    operator fun minus(other: Long) = Mint(this.value - other)
    operator fun minus(other: Mint) = this.plus(-other)
    operator fun times(other: Long) = Mint(this.value * Mint(other).value)
    operator fun times(other: Mint) = this.times(other.value)
    operator fun div(other: Long) = this.times(modPow(other, MOD - 2))
    operator fun div(other: Mint) = this.div(other.value)
    fun mod(mod: Long) = Mint(this.value % mod)
    fun modPow(other: Long) = Mint(modPow(this.value, other))
    fun toLong() = this.value
    override fun toString() = this.value.toString()
    override fun hashCode() = value.hashCode()
    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false
        other as Mint
        return value == other.value
    }

    companion object {
        private fun modPow(n: Long, p: Long): Long {
            var x = n % MOD
            var y = p
            var result = 1L
            while (y > 0) {
                if (y % 2 == 1L) result = (result * x) % MOD
                y = y shr 1
                x = (x * x) % MOD
            }
            return result
        }
    }
}


Measured memory_bytes: 79064
N, K = map(int, input().split())
foods = [[] for _ in range(N)]
for _ in range(K):
    d = int(input())
    food = list(map(int, input().split()))
    for human in food:
        foods[human - 1].append(d)

count = 0
for food in foods:
    if len(food) == 0:
        count += 1

print(count)


Measured memory_bytes: 67940
N,H = map(int,input().split())
A = []; B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a); B.append(b)
max_a = max(A)
B.sort(reverse=True)
cnt = 0
for b in B:
    if b > max_a:
        H -= b
        cnt += 1
    else:
        break
    if H <= 0:
        print(cnt)
        exit()
cnt += -(- H // max_a)
print(cnt)

Measured memory_bytes: 11336
fun main(args: Array<String>) {
    agc004a()
}

fun agc004a() {
    val (a, b, c) = readLine()!!.split(' ').map { it.toLong() }

    val answer = if (a % 2 == 0L || b % 2 == 0L || c % 2 == 0L) 0 else {
        Math.min(Math.min(a * b, a * c), b * c)
    }

    println(answer)
}


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

#define pb push_back
#define mp make_pair
#define M 1000000007
int main()
{
	float r;
	cin >> r;
	float ans = 2*3.14*r;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3788
import java.util.*;
import java.io.*;

public class Main {
   static int calc(int x) {
	   int ret = 0; 
	   while(x%100 == 0) {
		   x /= 100;
		   ret++;  
	   }
	  return ret; 
   }
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int d = in.readInt();
		int n = in.readInt();
		int cnt = 0,val = 0; 
		while(cnt < n) {
			val++; 
			if(calc(val) == d)
				cnt++;
		}
		System.out.println(val);
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


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

using namespace std;


#define int long long




int n,m;
vector<vector<int> > g; 
vector<int> dn,up,pref,suff;
void dfs1(int cur, int par){
	dn[cur] = 1;
	for(int son : g[cur]){
		if(son==par) continue;
		dfs1(son,cur);
		dn[cur] = (1ll*(dn[cur] * (1+dn[son])))%m;
	}
}

void dfs2(int cur, int par){
	int k = g[cur].size();
	for(int i = 0; i < k; i++){
		pref[i] = suff[i] = 1;
	}
	for(int i = 0; i < k; i++){
		if(par == g[cur][i]){
			if(i!=0) pref[i] = pref[i-1]%m;
			continue;
		}
		if(i==0) pref[i] = (1+dn[g[cur][i]])%m;
		else     pref[i] = 1ll*(pref[i-1] * (1+dn[g[cur][i]]))%m ;
	}
	for(int i = k-1; i >= 0; i--){
		if(par == g[cur][i]){
			if(i!=k-1) suff[i] = suff[i+1]%m;
			continue;
		}
		if(i==k-1) suff[i] = (1+dn[g[cur][i]])%m;
		else       suff[i] = 1ll*(suff[i+1] * (1+dn[g[cur][i]]) )%m;
	}
	//debug(cur,par,pref);
	//debug(cur,par,suff);
	for(int i = 0; i < k; i++){
		if(par == g[cur][i]) continue;
		int res = 1;
		if(i!=0) res = pref[i-1]%m;
		if(i!=k-1) res = 1ll * res * suff[i+1] % m;
		up[g[cur][i]] = 1ll * (1 + 1ll * up[cur] * res) % m;
	}
	for(int x : g[cur]){
		if(x == par) continue;
		dfs2(x,cur);
	}
}


 main(){
	cin >> n >> m;
	g.resize(n+1);
	dn.resize(n+1);
	up.resize(n+1);
	pref.resize(n+1);
	suff.resize(n+1);
	
	for(int i = 1; i < n; i++){
		int x,y; cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs1(1,0);
	up[1] = 1;
	dfs2(1,0);
	for(int i = 1; i <= n; i++){
		cout  << 1ll * dn[i]*up[i]%m << "\n";
	}
	return 0;
}


Measured memory_bytes: 15488
#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << (x) << std::endl
using ll = long long;
using ld = long double;
constexpr ll MOD = 1000000007LL;
template <typename T>
constexpr T INF() { return std::numeric_limits<T>::max() / 16; }
std::mt19937 mt{std::random_device{}()};
int main()
{
    int N;
    std::cin >> N;
    ll D;
    std::cin >> D;
    std::vector<ll> d(N);
    for (int i = 0; i < N; i++) { std::cin >> d[i]; }
    std::vector<ll> pos(N + 1, 0);
    for (int i = 0; i < N; i++) {
        const ll aft = pos[i] + (pos[i] <= D ? d[i] : -d[i]);
        if (std::abs(aft - D) < std::abs(D - pos[i])) {
            pos[i + 1] = aft;
        } else {
            pos[i + 1] = pos[i];
        }
    }
    std::vector<ll> ok(N + 1, 0);
    for (int i = N - 1; i >= 0; i--) {
        if (2 * ok[i + 1] < d[i] - 1) {
            ok[i] = ok[i + 1];
        } else {
            ok[i] = ok[i + 1] + d[i];
        }
    }
    int Q;
    std::cin >> Q;
    for (int i = 0, q; i < Q; i++) { std::cin >> q, q--, std::cout << (ok[q + 1] >= std::abs(pos[q] - D) ? "NO" : "YES") << std::endl; }
    return 0;
}


Measured memory_bytes: 15360
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const ll INF = 10e16;
const int maxN = 2010;
const int maxD = 400;
const int maxH = 100; 
const int MOD = 1000000007;
char wd[maxN];
char b[maxN];
char a[5];

int main()
{
	int x,a,b;
	scanf("%d%d%d",&x,&a,&b);
	int xa = abs(x-a);
	int xb = abs(x-b);
	if(xa < xb)
		puts("A");
	else
		puts("B");
	return 0;
}  

Measured memory_bytes: 256
import java.util.*

fun main(vararg args: String) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val arr = IntArray(n)
    repeat(n) {
        arr[it] = scanner.nextInt()
    }
    // 1 7 4 5 6 2 9
    val indexes = LinkedList<Int>()
    var p = 0
    for (i in 0 until n) {
        val a = arr[i]
        if (a < p) {
            if (indexes.isEmpty()) {
                indexes.add(i - 1)
            } else {
                indexes.add(i)
            }
        }
        p = a
    }
    if (indexes.isEmpty()) {
        println("YES")
        return
    }
    if (indexes.size != 2) {
        println("NO")
        return
    }
    val left = arr[indexes[0]]
    val leftSmaller = arr.getOrElse(indexes[0] - 1) { 0 }
    val leftBigger = arr.getOrElse(indexes[0] + 1) { 51 }
    val right = arr[indexes[1]]
    val rightSmaller = arr.getOrElse(indexes[1] - 1) { 0 }
    val rightBigger = arr.getOrElse(indexes[1] + 1) { 51 }
    if (right in leftSmaller..leftBigger && left in rightSmaller..rightBigger) {
        println("YES")
    } else {
//        println("NO, $right !in $leftSmaller..$leftBigger nor $left !in $rightSmaller..$rightBigger")
        println("NO")
    }
}


Measured memory_bytes: 35916
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int N;
	string s[10010];
	cin >> N;
	int a = 0, b = 0, ab = 0, ba = 0;
	for (int i = 1; i <= N; i++) {
		cin >> s[i];
		for (int j = 0; j <= s[i].length(); j++) {
			if (s[i][j] == 'A' && s[i][j + 1] == 'B')ab++;//ABが含まれる回数
		}
		if (s[i][0] == 'B') {
			if (s[i][0] == 'B' && s[i][s[i].length() - 1] == 'A')ba++;//B...Aの文
			else b++;//B...の文
		}
		if (s[i][s[i].length() - 1] == 'A') {
				if (s[i][0] == 'B' && s[i][s[i].length() - 1] == 'A')ba++;//B...Aの文
				else a++;//A...の文
		}
	}

	//B...Aを重複して数えてるので2で割る
	ba = ba / 2;
	if (ba == 0)cout << ab + min(a, b);
	else if (b == 0 && a == 0)cout << ab + ba - 1;
	else cout << ab + ba + min(a, b);
	
}

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

int main()
{
  long long a, b, c, k;
  cin >> a >> b >> c >> k;
  long long res = 0;
  res = min(a, k);
  k -= a;
  k -= b;
  if (0 < k) {
    res -= k;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3636
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal

INF = 1 << 50


def run():
    N, *L = map(int, read().split())
    ans = 0
    for i in range(N-2):
        x = L[i]
        for j in range(i+1, N-1):
            y = L[j]
            for k in range(j+1, N):
                z = L[k]
                if x != y and y != z and z != x and z < x+y and x < y+z and y < x+z:
                    ans += 1


    print(ans)

if __name__ == "__main__":
    run()

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    int c = 16-a-b;
    if(abs(a-b)<2+c) cout << "Yay!" << endl;
    else cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

signed main(void) {
    int K, S, ans=0; cin >> K >> S;
    REP(x, 0, K) {
        REP(y, 0, K) {
            if (0 <= (S-x-y) && (S-x-y) <= K) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Vector;

public class Main {
	static Vector<Integer> [] link;
	static int dp[];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		link = new Vector[n+1];
		for (int i=1;i<=n;i++)
			link[i] = new Vector();
		dp = new int[n+1];
		
		for (int i=0;i<m;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			link[a].add(b);
		}
		int ans = 0;
		for (int i=1;i<=n;i++) {
			int l = f(i);
			if (ans<l) ans = l;
		}
		System.out.println(ans);
		
	}
	private static int f(int i) {
		if (dp[i]>0) return dp[i];
		int ans = 0;
		for (int j : link[i]) {
			int l = f(j) + 1;
			if (ans<l) ans = l;
		}
		dp[i] = ans;
		return ans;
	}
}


Measured memory_bytes: 108188
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		if(N % 2 == 1){
			Console.WriteLine("No");
			return;
		}
		for(int i=0;i<N/2;i++){
			if(S[i] != S[i + N / 2]){
				Console.WriteLine("No");
				return;
			}
		}
		Console.WriteLine("Yes");
	}
	int N;
	String S;
	public Sol(){
		N = ri();
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Distinct or Not
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

/* global variables */

int as[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", as + i);
  sort(as, as + n);

  for (int i = 1; i < n; i++)
    if (as[i - 1] == as[i]) {
      puts("NO");
      return 0;
    }

  puts("YES");
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    
    
    //変数：デュードニー数に足す値「 a 」、指数「 n 」、上限の数「 m 」と置く
    int a, n, m, ans=0;
    
    //変数：右辺の答え「 rightAns 」、右辺の各桁の合計値「 rightDigitSum 」、左辺の合計値「 leftSum 」、と置く
    int rightAns = 0, rightDigitSum = 0, leftSum = 1;;

    //変数：左辺の合計値を求めるための仮の数「 rightSum 」と置く
    int rightSum;

    //入力：デュードニー数に足す値「 a 」、指数「 n 」、上限の数「 m 」を入力する
    cin >> a >> n >> m;

    while(pow(leftSum + a, n) <= m){
        //代入:右辺の答え「 rightAns 」に(y + a)^2の値を代入
        rightAns = pow(leftSum + a, n);
        rightSum = rightAns;
        rightDigitSum = 0;
        
        while(rightSum){
            rightDigitSum += (rightSum % 10);
            rightSum /= 10;
        }
        
        if(rightAns == pow(rightDigitSum + a, n)) ans++;
        
        leftSum++;
    }
    
    cout << ans << endl;
    
    
    return 0;
}



Measured memory_bytes: 3236
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

template <typename T>
bool uax(T& a, const T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T>
bool uin(T& a, const T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 60;
const int N = (int)1e6 + 7;
const int MAXN = (int)3e6 + 7;
const int MOD = (int)998244353;
const int INF = (int)1e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e17;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

/////////////////////////////////////////////////////////////////////

void solve() {
	set <string> st;
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		st.insert(s);
	}
	cout << size(st);
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

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

class UnionFind {
private:
  int sz;
  vector<int> par, size_;
public:
  UnionFind() {}
  UnionFind(int n) : sz(n), par(sz), size_(sz, 1) {
    iota(par.begin(), par.end(), 0);
  }
  int root(int x) {
    if (par.at(x) == x) return x;
    else return par.at(x) = root(par.at(x));
  }
  void unit(int x,int y) {
    x = root(x), y = root(y);
    if (x == y) return;
    if (size_.at(x) < size_.at(y)) swap(x, y);
    par.at(y) = x;
    size_.at(x) += size_.at(y);
  }
  int size(int x) {
    x = root(x);
    return size_.at(x);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
};

int main() {
  vector<vector<int>> G = {
    {1,3,5,7,8,10,12},
    {4,6,9,11},
    {2}
  };
  UnionFind UF(13);
  for (auto g : G) {
    for (int i = 0; i + 1 < (int)g.size(); i++) {
      UF.unit(g.at(i), g.at(i + 1));
    }
  }
  int x, y;
  cin >> x >> y;
  cout << ((UF.same(x, y)) ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		double ans = 0;
		int n = sc.nextInt();
		double[] a = new double[n];
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextDouble();
			ans += 1 / a[i];
		}
		ans = 1 / ans;
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 23252
#![allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let (x, y) = {
        let t: Vec<i32> = read_vec();
        (t[0], t[1])
    };
    println!("{}", if y % 2 == 0 && y / 2 - x >= 0 && 2 * x - y / 2 >= 0 { "Yes" } else { "No" });
}

Measured memory_bytes: 2112
#include<stdio.h>
    int main()
    {
        int a,b,c,d;
      
        // 整数の入力
        //scanf("%d", &a);
        // スペース区切りの整数の入力
        scanf("%d %d %d",&a,&c,&b);
        // 文字列の入力
	if(a != b && a == c){
	  d = b;
	}else if ( a == b && a != c){
	  d = c;
	}else{
	  d = a;
	}
        // 出力
        printf("%d",d);
        return 0;
    }


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

def input_one_number():
    return int(input())

def input_multiple_number():
    return map(int, input().split())

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


N,M,Q = input_multiple_number()

lists = []

for i in range(Q):
	lis = input_multiple_number_as_list()
	lists.append(lis)

ans = 0
for i in range(1,M+1):
	for i2 in range(i,M+1):
		for i3 in range(i2,M+1):
			for i4 in range(i3,M+1):
				for i5 in range(i4,M+1):
					for i6 in range(i5,M+1):
						for i7 in range(i6,M+1):
							for i8 in range(i7,M+1):
								for i9 in range(i8,M+1):
									for i10 in range(i9,M+1):
										score = 0
										for _q in lists:
											a = [i,i2,i3,i4,i5,i6,i7,i8,i9,i10]
											if (a[_q[1]-1]-a[_q[0]-1]) == _q[2]:
												score += _q[3]
										ans = max(ans,score)
										
print(ans)






Measured memory_bytes: 9236
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

const int INF = 1001001001;

int main() {
  string S;
  cin >> S;
  for (int i = S.size() - 2; i > 0; i -= 2) {
    string s = S.substr(0, i);
    int n = s.size();

    string s1 = s.substr(0, n / 2);
    string s2 = s.substr(n / 2, n);
    if (s1 == s2) {
      cout << n << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3620
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		// スペース区切りの整数の入力
		int sum=0;
for(int i=1;i<=N;i++){
	sum=sum+i;
}
		// 出力
		System.out.println(sum);
	}
}

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

int main()
{
    int N; ll K;
    scanf("%d %lld", &N, &K);
    ll a[N];
    for(int i = 0; i < N; ++i) scanf("%lld", &a[i]);
    sort(a, a + N);
    ll sm = 0;
    int res = N;
    for(int i = N-1; i >= 0; --i) {
        if(sm + a[i] < K) sm += a[i];
        else res = min(res, i);
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0) 
#define X first
#define Y second 
#define nl '\n'
#define AC return 0
#define mst(a,b) memset(a, b, sizeof a);
//#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
typedef pair <int, int> PII;
const int N = 1e5+10, mod = 1e9+7, inf = 0x3f3f3f;
int mm = 2e4;
int f[N];
bool v[200][200][200];

void dfs(int a, int b, int c)
{
	if(a*a+b*b+c*c > mm||v[a][b][c])
		return ;
	v[a][b][c] = 1;
	int s = (a*a+b*b+c*c)/2;
	f[s]++;
	dfs(a+1,b+1,c);
	dfs(a+1,b,c+1);
	dfs(a,b+1,c+1);
}

int main()
{
	dfs(2,2,2);
	int n;
	cin>>n;
	for(int i = 1; i <= n; i++)
	{
		cout<<f[i]<<nl;
	}
	
	AC;
} 

Measured memory_bytes: 5892
int z[999][999],d[999],n,m,a,b,i;
int D(c){
	if(d[c]>=0)return d[c];
	int i=0,x=0,y;
	for(;i<n;i++)if(z[i][c]){
		y=D(i)+z[i][c];
		if(x<y)x=y;
	}
	return d[c]=x;
}
main(x){
	for(scanf("%d%d",&n,&m);i<m;i++)scanf("%d%d%d",&a,&b,&x),z[a][b]=x;
	for(i=1;i<n;i++)d[i]=-1;
	printf("%d\n",D(n-1));exit(0);
}

Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
int a[15];

bool chk(int n)
{
    while (n) {
        int tmp = n % 10;
        if (a[tmp]) return true;
        n /= 10;
    }
    return false;
}

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

    int tmp;
    while (k--) {
        cin >> tmp;
        a[tmp]++;
    }

    while (chk(n)) {
        n++;
    }
    cout << n;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll a[100009];
int main()
{
    ll i,j,n,t,m;
    cin>>n>>m;
   t=m*2;
   j=n-t;
   if(j>0) cout<<j<<endl;
   else cout<<0<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    ll ans =  0;
    int n;
    ll h;
    cin>>n>>h;
    vector<pair<ll,ll>> v(n);
    rep(i,n){
        cin>>v[i].first>>v[i].second;
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    vector<ll> spe;
    if(v[0].second>=h){
        cout<<1<<endl;
        return 0;
    }
    for(int i=1;i<n;i++){
        spe.push_back(v[i].second);
    }
    sort(spe.begin(),spe.end());
    reverse(spe.begin(),spe.end());
    for(int i=0;i<spe.size();i++){
        if(v[0].second>=h){
        cout<<ans+1<<endl;
        return 0;
        }
        if(spe[i]>=v[0].first){
            ans++;
            h-=spe[i];
        }
        if(h<=0){
            cout<<ans<<endl;
        }
    }
    while(1){
        if(h-v[0].second<=0){
            cout<<ans+1<<endl;
            return 0;
        }
        h-=v[0].first;
        ans++;
        if(h<=0){
            cout<<ans<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 2936
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
int main(){
	int n;
	cin>>n;
	int a=(n-1)/111;
	if(a==0) cout<<111<<endl;
	else if(a==1) cout<<222<<endl;
	else if(a==2) cout<<333<<endl;
	else if(a==3) cout<<444<<endl;
	else if(a==4) cout<<555<<endl;
	else if(a==5) cout<<666<<endl;
	else if(a==6) cout<<777<<endl;
	else if(a==7) cout<<888<<endl;
	else if(a==8) cout<<999<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>

using namespace std;

long long int a,b,c;

int main(){
	cin >> a >> b;
	int aaa = a;
	int a4 = a;
	int bbb = b;
	int b4 = b;
	if (a-b>1 || a-b<-1) cout << 0 << endl;
	if (a-b == 0){
		c = 2;
		long long int aa = a;
		for(long long int i =0;i<aa;i++){
			c = (c*a)%1000000007;
			c = (c*a)%1000000007;
			a = a-1;
		}
		cout << c << endl;
	}
	else if (aaa-bbb == -1){
		c = bbb;
		long long int aa = aaa;
		long long int bb = bbb;
		for(long long int i =0;i<aa;i++){
			c = (c*aaa)%1000000007;
			c = (c*aaa)%1000000007;
			aaa = aaa-1;
		}
		cout << c << endl;
	}
	else if (a4-b4 == 1){
		c = a4;
		long long int aa = a4;
		long long int bb = b4;
		for(long long int i =0;i<bb;i++){
			c = (c*b4)%1000000007;
			c = (c*b4)%1000000007;
			b4 = b4-1;
		}
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//
// AGC012A: AtCoder Group Contest
//

#include <iostream>
#include <algorithm>
using namespace std;



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

	long long a[3*teams];
	for(int i=0; i<3*teams; i++) cin >> a[i];

	sort(a, a+3*teams, greater<long long>()); //降順にソート

	long long sum=0;
	for(int i=1; i<2*teams; i+=2) {
		sum += a[i];
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 2688
#include <iostream>

using namespace std;
long long n,a[5],sum = 0,mn = 10000000000000000;
int main(){
	int i;
	cin >> n;
	for(i=0;i<5;i++){
		cin >> a[i];
		mn = min(mn,a[i]);
	}
	cout << 4 + (n + mn - 1)/mn << endl; 
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
    int i, j, tmp;
    int arg[10];
     
    for(i=0; i<10; i++){
        scanf("%d", &arg[i]);
    }
     
    for(i=0; i<10; i++){
        for(j=i+1; j<10; j++){
            if(arg[j] > arg[i]){
                tmp = arg[i];
                arg[i] = arg[j];
                arg[j] = tmp;
            }
        }
    }
     
    for(i=0; i<3; i++){
        printf("%d\n", arg[i]);
    }
     
    return 0;
}

Measured memory_bytes: 1028
#!/usr/bin/ruby
N=gets.to_i
r=1.step(N-2,2).flat_map{|i|[[0,i]]}
r+=(N%2).step(N-1,2).flat_map{|i|[[N-1,i],[i,N-1]]}
1.step(N-2,3){|j|
	(1+j%2).step(N-2,2){|i|
		r<<[i,j]
	}
}
p r.size
puts r.map{|e|e*' '}

Measured memory_bytes: 52476
def resolve():
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    A = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    A = sorted(A)

    Cnt = [0] * 100002
    for a in A:
        Cnt[a] += 1
        Cnt[a+1] += 1
        Cnt[a+2] += 1

    print(max(Cnt))
resolve()

Measured memory_bytes: 52780
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

int main() {
  ll a,b;
  vl cd;
  cin >> a >> b;
  auto x = divisor(a);
  auto y = divisor(b);
  map<ll,int> cnt;
  for(auto i:x)cnt[i]++;
  for(auto i:y)cnt[i]++;
  for(auto it : cnt)if(it.se==2)cd.push_back(it.fi);
  ll ans = 0;
  for(auto x:cd){
    if(is_prime(x))ans++;
  }
  cout<<ans<<endl;
  return 0;
}

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

typedef long long ll;
const int NMAX = 1e7 + 10;
const int MOD = 1e9 + 7;
int fac[NMAX];

void init()
{
	for(register int i = 1;i < NMAX;i++)
		for(register int j = 1;j < NMAX && 1ll*i*j < NMAX;j++)
			fac[i*j]++;
}
int main(int argc, char const *argv[])
{
	int n;
	init();
	scanf("%d",&n);
	ll ans = 0;
	for(register int i = 1;i <= n;i++)	ans += 1ll*i*fac[i];
	printf("%lld\n",ans );
	return 0;
}

Measured memory_bytes: 42868
import java.util.*;
public class Main {
	//1140 start
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int K = sc.nextInt();
			if((n|m|K) == 0)break;
			long [][] dp = new long[n+1][n * m + 1];
			for(int i = 1; i < m+1; i++){
				dp[1][i] = 1;
			}
			
			for(int i = 1; i < n; i++){
				for(int j = 1;j <= i * m; j++){
					if(dp[i][j] == 0)continue;
					for(int k = 1; k <= m; k++){
						int next = j + k;
						dp[i+1][next] += dp[i][j];
					}
				}
			}
			
			double sum = 0;
			long mn = 1;
			for(int i = 0; i < n; i++){
				mn *= m;
			}
			
			for(int i = 1 ; i <= n * m; i++){
				int value = Math.max(i - K, 1);
				sum+= (double)dp[n][i] / mn * value;
			}
			System.out.println(sum);
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, x; cin >> N >> x;
	vector<int> a(N); rep(i, 0, N) {
		cin >> a[i];
	}
	int ans = INF;
	vector<int> m(N, INF);
	rep(k, 0, N) {
		int t = k*x;
		rep(i, 0, N) {
			chmin(m[i], a[(i + N - k) % N]);
			t += min(a[i], m[i]);
		}
		chmin(ans, t);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384