akhauriyash/Code-Regression huggingface dataset:
open System
open System.Collections.Generic
open System.Linq

let [|h; w|] = stdin.ReadLine().Split(' ') |> Array.map int
let s = Array.create h ""
for i = 0 to h - 1 do
  s.[i] <- stdin.ReadLine().Trim()
let dw = new List<List<int>>()
let dh = new List<List<int>>()
for i = 0 to h - 1 do
  let cw = new List<int>()
  let mutable count = 0
  for j = 0 to w - 1 do
    if s.[i].[j] = '#' then
      cw.Add(0)
    elif (j = 0 || s.[i].[j - 1] = '#') then
      count <- let rec loop1 i k w (s : string []) count =
                 if k > w - 1 || s.[i].[k] <> '.' then
                   count
                 else
                   loop1 i (k + 1) w s (count + 1)
               in loop1 i j w s 0
      cw.Add(count)
    else
      cw.Add(count)
  dw.Add(cw)
for j = 0 to w - 1 do
  let ch = new List<int>()
  let mutable count = 0
  for i = 0 to h - 1 do
    if s.[i].[j] = '#' then
      ch.Add(0)
    elif (i = 0 || s.[i - 1].[j] = '#') then
      count <- let rec loop2 k j h (s : string []) count =
                 if k > h - 1 || s.[k].[j] <> '.' then
                   count
                 else
                   loop2 (k + 1) j h s (count + 1)
               in loop2 i j h s 0
      ch.Add(count)
    else
      ch.Add(count)
  dh.Add(ch)
let mutable max = 0
for i = 0 to h - 1 do
  for j = 0 to w - 1 do
    let sum = dw.[i].[j] + dh.[j].[i]
    if max < sum then
      max <- sum
Console.WriteLine(max - 1)

Measured memory_bytes: 78716
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k,ans=0; cin>>n>>k;
    string s; cin>>s;
    
    vector <int> nums;
    int now = 1;
    int cnt = 0;
    for(int i=0;i<n;i++){
        if(s[i]==char('0' + now)) cnt++;
        else{
            nums.push_back(cnt);
            cnt = 1;
            now = 1 - now;
        }
    }
    if(cnt != 0) nums.push_back(cnt);
    if(s.back() == '0') nums.push_back(0);
    vector <int> sums(nums.size() + 1 ,0);
    for(int i=0;i<nums.size();i++){
        sums[i+1]= sums[i] + nums[i];
    }
    int right = 0, left = 0, tmp = 0;
    for(int i=0;i<nums.size();i+=2){
        left = i;
        right = min(i+(2*k)+1, (int)sums.size()-1 );
        tmp = sums[right] - sums[left];
        ans = max(ans, tmp);
    }
    cout<<ans<<endl;
}


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


int main(void){
    int H,W,i,j;
    while(1){
        scanf("%d%d",&H,&W);
        if(H==0 && W==0)
            break;
        for(i=0;i<H;i++){
            for(j=0;j<W;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
n = int(input())
h = [int(i) for i in input().split()]

flag = 1
temp = h[0]
for i in range(len(h)-1):
    if(temp<h[i]):
        temp = h[i]
    if(temp-h[i+1]>=2):
        print("No")
        flag=0
        break
            
if(flag==1):
    print("Yes")

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

int main()
{
    int N, K;
    cin >> N >> K;
    
    vector<int> H = vector<int>(N, 0);
    
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    
    sort(H.begin(), H.end());
    
    long long sum = 0;
    for (int i = 0; i < (N - K); i++) {
        sum += H[i];
    }
    
    cout << sum;

    return 0;
}

Measured memory_bytes: 1656
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int k, n;
  cin >> k >> n;
  vector<int> v;
  int count, a;
  cin >> a;
  v.push_back(a);
  count = a;
  for(int i=1; i<n; i++){
    cin >> a;
    v.push_back(a-count);
    count+=a-count;
  }
  v[0]+=k-count;
  sort(v.begin(), v.end());
  cout << k-v[v.size()-1];
  return 0;
}

Measured memory_bytes: 1528
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) < *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

int main(void) {
	size_t N, H, W;

	scanf("%zu\n%zu\n%zu", &N, &H, &W);

	printf("%zu\n", (N - H + 1) * (N - W + 1));

	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n;
ll c[200010];
ll dp[200010];
ll dif[200010];
vector<ll> idx[200010];

ll dfs(ll i){
  if(i==n)return 1;
  if(dp[i]!=-1)return dp[i];
  ll res=dfs(dif[i]);
  ll nxt=lower_bound(all(idx[c[i]]),dif[i])-idx[c[i]].begin();
  if(nxt<idx[c[i]].size())(res+=dfs(idx[c[i]][nxt]))%=mod;
  return dp[i]=res;
}

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

  cin>>n;
  rep(i,n){
    cin>>c[i];
    c[i]--;
    idx[c[i]].push_back(i);
  }
  dif[n-1]=n;
  for(ll i=n-2;i>=0;i--){
    if(c[i]==c[i+1])dif[i]=dif[i+1];
    else dif[i]=i+1;
  }
  rep(i,200000)sort(all(idx[i]));

  memset(dp,-1,sizeof(dp));
  cout<<dfs(0)<<endl;

  return 0;
}


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

int main(){
    int count[26] = {};
    char c;
    while(scanf("%c",&c) != EOF){
        if(isalpha(c)){
            count[tolower(c)-'a']++;
        }
    }
    for(int i=0;i<26;++i){
        printf("%c : %d\n", 'a'+i, count[i]);
    }
    return 0;
}



Measured memory_bytes: 3216
import java.io.PrintWriter
import java.util.*

var n: Int = 0
var s: Array<String> = Array(0){""}

fun main(args: Array<String>) = IO().exec {
    n = int()
    s = Array(n){string()}
    println((0 until n).map { isSyn(it) }.count { it } * n)
}

fun isSyn(sx: Int): Boolean {
    for (y in 0 until n) for (x in 0 until n)
        if (s[y][(x + sx) % n] != s[x][(sx + y) % n]) return false
    return true
}

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = PrintWriter(System.out)
    fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = System.`in`.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }
    fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else return -1
    }
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun string(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun long(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun double(): Double {
        return string().toDouble()
    }
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}

Measured memory_bytes: 34092
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>

#define INF 100000000
#define ll long long


using namespace std;

int main() {
	ll n, m;
	cin >> n >> m;
	ll ans = (1900 * m + 100 * (n - m)) * pow(2, m);
	cout << ans << endl;
	return 0;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ep emplace_back

using namespace std;

const int  mod = 1e9 + 7;
const int e = 2e5 + 69;
const int base = 311;

ll g[e], r[e], cll[e];

int main()
{
   int x, y, a, b, c;
   cin >> x >> y >> a >> b >> c;
   for(int i=1; i<=a; i++) cin >> r[i];
   for(int i=1; i<=b; i++) cin >> g[i];
   vector<ll>cur;
   for(int i=1; i<=c; i++)
   {
       ll k;
       cin >> k;
       cur.pb(k);
   }
   sort(r+1, r+a+1, greater<ll>());
   sort(g+1, g+b+1, greater<ll>());
   for(int i=1; i<=x; i++)
   {
       cur.pb(r[i]);
   }
   for(int i=1; i<=y; i++)
   {
       cur.pb(g[i]);
   }
   sort(cur.rbegin(), cur.rend());
   ll s= 0;
   for(int i=0; i<x+y; i++)
   {
       s += cur[i];
   }
   cout << s;
}


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

int main()
{
    long long int a, b, c, d;
    cin>> a >> b >> c >> d;

    vector<long long int>ans;
    ans.push_back(a*c);
    ans.push_back(a*d);
    ans.push_back(b*c);
    ans.push_back(b*d);
    sort(ans.begin(),ans.end());
    cout<< ans[3];
    return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int n;
    cin >> n;
    int pw = 1;
    repk(i, 1, n + 1) {
        pw *= i % MOD;
        pw %= MOD;
    }
    cout << pw << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

const intMax = 2147483647

func main() {
	var h int
	_, _ = fmt.Scan(&h)

	if h == 1{
		fmt.Println(1)
		return
	}

	cnt := 0
	for {
		h /= 2
		cnt++
		if h <= 1 {
			break
		}
	}

	res := 1
	a := 2
	for i := 0; i < cnt; i++ {
		res += a
		a *= 2
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
import math

n=int(input())
s=input()

minuscount=0
for i in range(n-2):
    a=i+1
    for j in range(i+1,math.floor(n/2 + a/2)):
        b=j+1
        a1=s[i]
        a2=s[j]
        a3=s[2*b-a-1]
        if a1!=a2 and a2!=a3 and a1!=a3:
            minuscount+=1

rcount=s.count("R")
gcount=s.count("G")
bcount=s.count("B")

print(rcount*gcount*bcount-minuscount)
        

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e8
typedef long long ll;
typedef long double ld;

int main() {
    int h, n;
    cin >> h >> n;
    int sum = 0;
    rep(i, n){
        int t;
        cin >> t;
        sum += t;
    }
    if(sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val n = Integer.parseInt(readNext())
    val s = readNext().split(" ").map { Integer.parseInt(it) }

    var max = 0
    var nou = 0
    var next = 0
    var tmp = 0
    for (i in 0..n - 1){
        if (i == n-1) {

            if ( max >= tmp) {

            } else {
                max = tmp
            }
            tmp = 0
            break
        }
        nou = s[i]
        next = s[i + 1]
        if (nou >= next) {
            tmp++
        } else {
            if ( max >= tmp) {

            } else {
                max = tmp
            }
            tmp = 0
        }
    }
    println(max)
}

    fun readNext(): String {
        return readLine()!!
    }


Measured memory_bytes: 57732
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1001001001;

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

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

const int MAX = 1001000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();
    ll x, y;
    cin >> x >> y;
    ll h = max(x, y);
    ll l = min(x, y);
    ll thCnt = 0;
    while(h - l < l and x > 2 and y > 2) {
        x -= 3;
        y -= 3;
        h = max(x, y);
        l = min(x, y);
        thCnt += 1;
    }
    h = max(x, y);
    l = min(x, y);
    if(h - l == l) {
        ll ans = COM(2*thCnt + l, thCnt);
        cout << ans << endl;
    } else {
        cout << 0 << endl;
    }
}

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

int dp[1005][1005];

int lcs(string x, string y){
    for (int i = 1; i <= x.size(); i++){
        for (int j = 1; j <= y.size(); j++)
        {
            if(x[i-1] != y[j-1])
                dp[i][j] = dp[i-1][j] > dp[i][j-1] ? dp[i-1][j] : dp[i][j-1];
            else
                dp[i][j] = dp[i-1][j-1] + 1;
        }
    }
    return dp[x.size()][y.size()];
}

int main()
{
    int n; cin >>n;
    string x, y;
    
    for (int i = 0; i < n; i++)
    {
        cin >> x >> y;
        cout << lcs(x, y) << endl;
    }
}


Measured memory_bytes: 6992
use proconio::input;
use std::cmp::min;

fn main() {
    input! {
        n: usize,
        a: [i32; n],
    }

    let mut min_cost = std::i32::MAX;

    for i in -100..=100 {
        let sum = a.iter().fold(0, |sum, x| sum + (x - i) * (x - i));
        min_cost = min(min_cost, sum);
    }

    println!("{}", min_cost);
}

Measured memory_bytes: 2180
from itertools import combinations as co
n=int(input())
A=[[] for _ in range(n+1)]
for i in range(1,n+1):
    for _ in range(int(input())):
        A[i].append(list(map(int,input().split())))
for i in range(n+1,0,-1):
    for a in co(range(1,n+1),i):
        b=1
        B=[0]*(n+1)
        for b in a:
            B[b]=1
        for k,v in enumerate(B):
            if v==1:
                for x,y in A[k]:
                    if B[x]!=y:
                        b=0;break
        if b:
            print(i)
            exit()
print(0)

Measured memory_bytes: 3064
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
    auto X = readln.split[0].to!(long);
    foreach (A; 0 .. 10^^3+1) foreach (B; 0 .. A) {
        if (A^^5 - B^^5 == X) { writeln (A, " ", B); return; }
        if (A^^5 + B^^5 == X) { writeln (A, " ", -B); return; }
    }
    assert(0);
}



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

int main(void){
    int L, R, d, ans;
    
    cin >> L >> R >> d;
    
    if(L%d == 0){
        ans = (R / d) - (L / d) + 1;
    }
    else{
        ans = (R / d) - (L / d);
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>

int main()
{
	int a, b, sum = 0, counts = 0;
	while(scanf("%d %d", &a, &b) != EOF)
	{
		counts = 0;
		sum = a + b;
		while(sum != 0)
		{
			sum /= 10;
			counts++;
		}
		printf("%d\n", counts);
	}
	return 0;
}


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

int main() {
	int N, M;
	cin >> N >> M;
	int arr[N]={};
	int x;
	for (int i=0; i<M*2; i++){
		cin>>x;
		arr[x-1] += 1;
	}
	for (int i=0; i<N; i++){
		cout<< arr[i] << '\n';
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <sstream>
#include <climits>
//#include <fstream>

using namespace std;

int hex2dec (char c)
{
	if (isdigit(c) ){
		return (c - '0');
	} // end if
	return (c - 'a' + 10 );
}

int main()
{
	const string color[] = {
"black",//	 00	 00	 00
"blue",//	 00	 00	 ff
"lime",//	 00	 ff	 00
"aqua",//	 00	 ff	 ff
"red",//	 ff	 00	 00
"fuchsia",// ff	 00	 ff
"yellow",//	 ff	 ff	 00
"white"//	 ff	 ff	 ff
};
	const int code[][3] = {
/* black */	 {0x00, 0x00, 0x00 },
/* blue */	 {0x00, 0x00,	0xff },
/* lime */	 {0x00, 0xff,	0x00 },
/* aqua */	 {0x00, 0xff,	0xff },
/* red	*/	 {0xff, 0x00,	0x00 },
/* fuchsia */  {0xff, 0x00,	0xff },
/* yellow */	 {0xff, 0xff,	0x00 },
/* white */	 {0xff, 0xff,	0xff }
};

//	cut here before submit 
//	freopen ("testcase.whatcolor", "r", stdin );
	string str = "";

	while (getline (cin, str ) ){
		int len = str.length();

		if (len == 1 && str[0] == '0'){
			break;
		} // end if

		vector <int> C (3, 0 ); // Red, Green, Blue order
		int i,j;

		for (i = 0; i < 3; ++i){
			C[i] = hex2dec(str[2*i+1])*16 + hex2dec(str[2*i+2]);
		} // end for

		int minV = INT_MAX;
		int res = -1;
		for (i = 0; i	< sizeof (color)/sizeof(color[0] ); ++i){
			int dd = 0;
			for (j = 0; j < 3; ++j){
				dd += (code[i][j] - C[j])*(code[i][j] - C[j]);
			} // end for
			
			if (minV > dd ){
				minV = dd;
				res = i;
			} // end if
		} // end for
		
		cout << color[res] << endl;

	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll x,a,b; cin >> x >> a >> b;
  if(abs(x-a)>abs(x-b)) cout << "B" << endl;
  else cout << "A" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>L(N);
  for(int X=0;X<N;X++){
    cin>>L[X];
  }
  sort(L.begin(),L.end());long long V=0;
  for(int X=0;X<N-2;X++){
    for(int Y=X+1;Y<N-1;Y++){
      for(int Z=Y+1;Z<N;Z++){
        if(L[X]+L[Y]>L[Z])V++;
        else break;
      }
    }
  }
  cout<<V<<endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265358979
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using Graphi = vector<vi>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
struct edge {
    int to; 
    int weight;
    edge(int t, int w) : to(t),weight(w) {}
};

vector<ll> a;
int n;

ll culc(){

    ll ans = 0;
    ll loop = 1;

    rep(i,60){
        if(i != 0){
            loop *= 2;
            loop %= mod;
        }
        ll cnt_one = 0;
        ll cnt_zero = 0;
        rep(j,n){
            if(a.at(j) >> i & 1) cnt_one++;
            else cnt_zero++;
        }
        ll temp = (cnt_one * cnt_zero)%mod;
        temp = (temp*loop)%mod;
       
        ans += temp;
        ans %= mod;
    }

    return ans;

}

int main(){

    cin >> n;
    a.resize(n);
    rep(i,n) cin >> a.at(i);

    cout << culc() << endl;
    return 0;

}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>
#define INF 100000000
using namespace std;
int N,A,B,C,l;
vector<int> L;

int dfs(int depth,int a,int b,int c){
 int ret0,ret1,ret2,ret3,ret4;
 if(depth==N){
  if(a!=0 && b!=0 && c!=0)return abs(A-a)+abs(B-b)+abs(C-c)-30;
  else return INF;
 }

 ret0=dfs(depth+1,a,b,c);
 ret1=dfs(depth+1,a+L[depth],b,c)+10;
 ret2=dfs(depth+1,a,b+L[depth],c)+10;
 ret3=dfs(depth+1,a,b,c+L[depth])+10;

 return min({ret0,ret1,ret2,ret3});
}

int main(void){

 cin>>N>>A>>B>>C;

 for(int i=0; i<N; i++){
  cin>>l;
  L.push_back(l);
 }
 cout<<dfs(0,0,0,0)<<endl;

 return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<cstring>
#include<string>
using namespace std;
int main(){
	long long a,ans=2;
    scanf("%lld",&a);
    for(int i=1;i<=a;i++)ans=(ans+1)*2;
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
int ask[100010];
int main (){
  int No,Q;
  cin>>No>>Q;
  string N;
  cin>>N;
  int anal=0;
  for(int i=1;i<N.length();i++){
    if(N[i-1]=='A' and N[i]=='C'){
      anal++;
    }
    ask[i]=anal;
  }
  ask[N.length()]=ask[N.length()-1];
 rep(i,Q){
    int x,y;
    cin>>x>>y;
    cout<<ask[y-1]-ask[x-1]<<endl;
  }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, n) for(int i = n-1; i >= 0; i--)
#define rep4(i, x, n) for(int i = x; i > n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    int H, W;
    cin >> H >> W;
    string S[H];
    ll cnt[H][W];
    rep(i, H){
        rep(j, W) cnt[i][j] = INF;
    }
    queue<P> que;
    rep(i, H){
        cin >> S[i];
        rep(j, W){
            if(S[i][j] == '#'){
                cnt[i][j] = 0;
                que.push(P(i, j));
            }
        }
    }
    while(!que.empty()){
        P p = que.front();
        que.pop();
        int i = p.first;
        int j = p.second;
        if(0 <= i-1){
            if(cnt[i-1][j] > cnt[i][j]+1){
                cnt[i-1][j] = cnt[i][j]+1;
                que.push(P(i-1, j));
            }
        }
        if(i+1 < H){
            if(cnt[i+1][j] > cnt[i][j]+1){
                cnt[i+1][j] = cnt[i][j]+1;
                que.push(P(i+1, j));
            }
        }
        if(0 <= j-1){
            if(cnt[i][j-1] > cnt[i][j]+1){
                cnt[i][j-1] = cnt[i][j]+1;
                que.push(P(i, j-1));
            }
        }
        if(j+1 < W){
            if(cnt[i][j+1] > cnt[i][j]+1){
                cnt[i][j+1] = cnt[i][j]+1;
                que.push(P(i, j+1));
            }
        }
    }
    ll ans = 0;
    rep(i, H){
        rep(j, W) ans = max(ans, cnt[i][j]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 25524
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
#define int long long 
const int INF = 1e9;
#define put(n) cout<<(n)<<endl
#define rep(i,N) for(int(i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>=(0);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define pb(n) push_back(n)

int H,W;
int ans = 1e9;

void bar(int& S, int& s, int& h){
    int MAX = max(h * W ,max(s , S - s));
    int MIN = min(h * W ,min(s , S - s));
    ans = min(ans , MAX - MIN);
}

signed main(){

    cin >> H >> W;

    rep(j,2){
        for(int h = 1; h < H; ++h){
            int S = (H-h) * W;
            int s = (H-h) * (W/2);
            int s1 = W * ((H-h) / 2);
            bar(S,s,h);
            bar(S,s1,h);              
        }
        swap(H,W);
    }
    cout << ans << endl;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  ll aSum = 0, bSum = 0;
  rep(i, n) {
    cin >> a[i];
    aSum += a[i];
  }
  rep(i, n) {
    cin >> b[i];
    bSum += b[i];
  }

  if (aSum < bSum) {
    cout << "-1" << endl;
    return 0;
  }

  vector<int> minus, plus;
  rep(i, n) {
    if (a[i] < b[i]) {
      minus.eb(b[i] - a[i]);
    }
    if (a[i] > b[i]) {
      plus.eb(a[i] - b[i]);
    }
  }

  sort(rall(plus));

  int idx = 0;
  rep(i, sz(minus)) {
    while (1) {
      if (plus[idx] == 0) idx++;
      int t = min(minus[i], plus[idx]);
      minus[i] -= t;
      plus[idx] -= t;
      if (minus[i] == 0) break;
    }
  }

  int ans = sz(minus);
  if (ans > 0) ans += idx + 1;

  cout << ans << endl;
}


Measured memory_bytes: 1660
n,m=list(map(int,input().split()))
x=sorted(list(map(int,input().split())))
y=[0]*(m-1)
for i in range(m-1):
  y[i]=x[i+1]-x[i]
y=sorted(y)
if n==1:
  print(sum(y))
else:
  print(sum(y[:-(n-1)]))

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

int main() {
    int x = 0;
    int N;
    cin >> N;
    char S[N];
    cin >> S;
    int max = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'I') {
            ++x;
        }
        if (S[i] == 'D') {
            --x;
        }
        if (x > max) {
            max = x;
        }
    }
    cout << max;
}

Measured memory_bytes: 256
import sys

import numba as nb
import numpy as np

input = sys.stdin.readline


@nb.njit("i8(i8,i8,i8[:,:])", cache=True)
def solve(H, N, AB):
    INF = 10 ** 18
    dp = [INF] * (H + 1)
    dp[0] = 0
    for i in range(N):
        A, B = AB[i]
        for d in range(H + 1):
            if d < A:
                dp[d] = min(dp[d], B)
            else:
                dp[d] = min(dp[d], dp[d - A] + B)

    ans = dp[-1]
    return ans


def main():
    H, N = map(int, input().split())
    AB = np.zeros(shape=(N, 2), dtype=np.int64)
    for i in range(N):
        AB[i] = input().split()

    ans = solve(H, N, AB)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 106600
n = input()
a_array = input().split(' ')

seki = 1
end = False

if "0" in a_array:
    print(0)
else:
    for a in a_array:
        a = int(a)
        seki *= a

        if seki > 10**18:
            print(-1)
            end = True
            break

    if end == False:
        print(seki)

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

#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int  long long

int32_t main()
{
    IOS
    int n;
    cin >> n;
    char a[26];
    for(int i = 0; i <= 25; i++) a[i] = i + 'a';
    string ans;
    while(n)
    {
    	n--;
    	int r = n % 26;
    	ans += (a[r]);
    	n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=8000;
const long INF=1e9;
int main(){
	long N;cin>>N;
	long temp=1;
	for(long i=1;i*i<=N;i++){
		if(N%i==0) temp=i;
	}cout<<temp+N/temp-2<<endl;
}

Measured memory_bytes: 384
n=int(input())
ans=0

def cnt_divisors(n):
    divisor=[]
    for i in range(1,int(n**0.5)+1):
        if n%i ==0:
            divisor.append(i)
            if i != n//i:
                divisor.append(n//i)
    return len(divisor)
    
for i in range(1,n+1,2):
    if cnt_divisors(i)==8:
        ans+=1
        
print(ans)

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define FOR(i, a, b) for (int i = a; i <= (int)(b); i++)
#define FORD(i, a, b) for (int i = a; i >= (int)(b); i--)

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
using Lint = long long;
#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define PB push_back
#define MP make_pair
using P=pair<int, int>;
using V=vector<int>;
using M=map<int, int>;
using S=set<int>;

#define COUT(x) cout << (x) << endl
#define SCOUT(x) cout << (x) << " "

#define DUMP(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
template <class T>bool chmax(T &a, const T &b){if (a < b){a = b;return 1;}return 0;}
template <class T>bool chmin(T &a, const T &b){if (b < a){a = b;return 1;}return 0;}
/* vector<T>のイテレータはvector<T>::iterator型
vector<int>::iterator it = vc.begin();  // begin()はvectorの最初の要素を指すイテレータを返す。
vector<int>::iterator endIt = vc.end(); // end()はvectorの終端位置を指すイテレータを返す。
while (it != endIt)
{
  cout << *it << '\n'; // イテレータの指す要素は、ポインタのように*演算子でアクセスします。
  it++;                // インクリメントすることで次の要素を指します。
}
}*/
int main()
{
  
  string s="No";
  int h,l,tmp,k,t;
  cin>>h>>l;
   k=h;
  t=0;
  while(k>=0){
     tmp=4*k+2*t;
  if(tmp==l){s="Yes";break;}
  
    t++;
    k--;
  }
  COUT(s); 
}

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i ++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i --)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {T a; K b;};

int main( void ){
	initialize();
	ll N;
	cin >> N;
	map<string, int> mp;
	int mx = 0;
	rep(i,0, N){
		string S; cin >> S;
		// sort(S.begin(), S.end());
		mp[S]++;
		mx = max(mx, mp[S]);
	}
	for(auto m:mp){
		if (m.second == mx)
		cout << m.first <<endl;
	}
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
	// cin.tie( 0 );
	// ios::sync_with_stdio( false );
}


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

int main() {
	char s[4]; scanf("%s", s);
	int a1 = s[0] - '0', a2 = s[1] - '0', a3 = s[2] - '0', a4 = s[3] - '0';
	int ans = a1;
	char anss[10];
	anss[0] = s[0]; anss[2] = s[1];
	anss[4] = s[2]; anss[6] = s[3]; 
	anss[7] = '=';  anss[8] = '7'; anss[9] = '\0';
	for (int a = 0; a < 2; a ++) {
		anss[2] = s[1];
		ans = a1;
		if (a == 0) { ans += a2; anss[1] = '+';}
		else { ans -= a2; anss[1] = '-'; }
		int tmp = ans;
		for (int b = 0; b < 2; b ++) {
			if (b == 0) { ans = tmp + a3; anss[3] = '+'; }
			else { ans = tmp - a3; anss[3] = '-'; }
			int tmp1 = ans;
			for (int c = 0; c < 2; c ++) {
				if (c == 0) { ans = tmp1 + a4; anss[5] = '+'; }
				else { ans = tmp1 - a4; anss[5] = '-'; }
				if (ans == 7) { cout << anss << endl; return 0; }
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInts(n)

	sort.Ints(a)

	b, c := 0, 0
	for i := n - 2; i >= 0; i-- {
		if a[i] == a[i+1] {
			b = a[i]
			a = a[:i]
			break
		}
	}
	for i := len(a) - 2; i >= 0; i-- {
		if a[i] == a[i+1] {
			c = a[i]
			break
		}
	}
	fmt.Fprintln(wr, b*c)
}


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

#define int long long

signed main() {
	int n; cin >> n;
	vector<double> v;
	for(int i = 0; i < n; i++) {
		int y; cin >> y;
		v.push_back((double)y);
	}
	double x = 2.0;
	sort(v.begin(),v.end());
	vector<double>::iterator itr;
	itr = v.begin();
	while(v.size()>1) {
		double z = (v[0]+v[1])/x;
		v.erase(itr);
		v.erase(itr);
		v.push_back(z);
		sort(v.begin(),v.end());
	}
	cout << v[0] << endl;
	return 0;
}

Measured memory_bytes: 256
def mizuyari2(row):
    cnt = 0
    _min = min(row)
    cnt += _min
    row2 = [i - _min for i in row]

    res = [[]]
    for e in row2:
        if e != 0:
            res[-1].append(e)
        else:
            res.append([])

    return cnt, res


def mizuyari(ll):
    cnt = 0

    for l in ll:
        if l:
            cnt2, hs = mizuyari2(l)
            # print(cnt2, hs)
            cnt += cnt2
            cnt += mizuyari(hs)
    return cnt


def main2():
    n = int(input())
    hs = [int(i) for i in input().split()]
    hs = [hs]
    cnt = mizuyari(hs)
    print(cnt)


if __name__ == '__main__':
    main2()


Measured memory_bytes: 3064
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE MultiWayIf #-}

import Control.Monad
import Control.Monad.ST
import Control.Monad.State
import Control.Monad.Primitive
import Control.Applicative
import Control.Arrow
import Data.List
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Data.Maybe
import Data.Bits
import Data.Ord
import Data.Ratio
import Data.Int
import Data.Char
import qualified Data.ByteString.Char8 as BS
import qualified Data.Set as Set
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Data.Tuple
import Data.Function
import Text.Printf
import Debug.Trace
import Numeric

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

listToTuple2 [a,b] = (a,b)
listToTuple3 [a,b,c] = (a,b,c)
listToTuple4 [a,b,c,d] = (a,b,c,d)
listToTuple5 [a,b,c,d,e] = (a,b,c,d,e)

readIntBS = fst . fromJust . BS.readInt

for = flip map

infixr 1 ?
(?) :: Bool -> (a,a) -> a
(?) b t = (if b then fst else snd) t

main :: IO ()
main = do
  [x1,y1,x2,y2] <- map read . words <$> getLine :: IO [Int]
  let
    dy = y2 - y1
    dx = x2 - x1

  --print (dx,dy)
  printf "%d %d %d %d\n" (x2 - dy) (y2 + dx) (x1 - dy) (y1 + dx)

  

  
  


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

using namespace std;
using ll = long long;

#define ist istream_iterator
#define ost ostream_iterator

ll const inf = 100 * 1000;
int const N = (1 << 17) + 16;


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

  int n;
  ll k;
  cin >> n >> k;
  vector<ll> a(100*1000+16);
  while(n--) {
    int x, y;
    cin >> x >> y;
    a[x] += y;
  }

  partial_sum(a.begin(), a.end(), a.begin());
  cout << lower_bound(a.begin(), a.end(), k)-a.begin() << endl;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main(){
  int x[10010];
  int i;

  for(i=0;i<10010;i++){
    cin >> x[i];
    if(x[i]==0)
      break;
  }

  for(i=0;x[i]!=0;i++)
    cout << "Case " << i+1 << ": " << x[i] << endl;
  
}

Measured memory_bytes: 3096
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int a[100000];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		a[i]--;
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (a[a[i]] == i) ans++;
	}
	cout << ans / 2 << endl;
}

Measured memory_bytes: 640
k = int(input())

lunlun = [1, 2, 3, 4, 5, 6, 7, 8, 9]
n = 0

def generate_lunlun(n):
    last = n % 10
    if last - 1 >= 0:
        yield n * 10 + last - 1
    yield n * 10 + last
    if last + 1 < 10:
        yield n * 10 + last + 1

while len(lunlun) < k:
    for new_lunlun in generate_lunlun(lunlun[n]):
        lunlun.append(new_lunlun)
    n += 1

print(lunlun[k-1])

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

int main() {
  int n,k,q;
  int l;

  cin >> n >> k >> q;

  int score[n] = {};

  for(int i=0;i<q;i++) {
    cin >> l;
    score[l-1]++;
  }

  for(int i=0;i<n;i++) {
    if(q-k < score[i]) {cout << "Yes" << endl;}
    else if(q-k >= score[i]) {cout << "No" << endl;}
  }

  return 0;
}


Measured memory_bytes: 1024
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

const int MOD = 1e9+7;

signed main() {
	int n,m;
	std::cin >> n >> m;

	std::vector<int> s(n);
	std::vector<int> t(m);
	rep(i,n) std::cin >> s[i];
	rep(i,m) std::cin >> t[i];

	std::vector<std::vector<int> > sum(n+1,std::vector<int>(m+1,0));
	std::vector<std::vector<int> > dp(n+1,std::vector<int>(m+1,0));
	dp[0][0] = 1;
	rep(i,n+1) sum[i][0] = 1;
	rep(i,m+1) sum[0][i] = 1;

	rep(i,n) rep(j,m) {
		if(s[i]==t[j]) {
			dp[i+1][j+1] = sum[i][j] % MOD;
		}
		sum[i+1][j+1]  = (dp[i+1][j+1] + sum[i][j+1] + sum[i+1][j] - sum[i][j] + MOD) % MOD;
	}
	print(sum[n][m]);
		
	return 0;
}


Measured memory_bytes: 62976
n, a, b, c, d = map(int, raw_input().split())
t = n - 1
for i in xrange(t + 1):
    l, r = a + c * i, a + d * i
    l, r = l - d * (t - i), r - c * (t - i)
    if l <= b <= r:
        print "YES"
        break
else:
    print "NO"


Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end());
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vdouble = vector<double>;


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

int main(){
	ll N,K;
	cin>>N>>K;
	vdouble p(N),sum(N+1);
	REP(i,N) {
	    double A;
		cin>>A;
		p[i]=(A+1)/2;
	}
	sum[0]=0.0;
	sum[1]=p[0];
	REP(i,N-1){
		sum[i+2]=sum[i+1]+p[i+1];
	}

	double ans=0;
	REP(i,N-K+1){
		ans=max(ans,(sum[K+i]-sum[i]));
	}
	cout<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ld long double
#define ll long long
ll dp[3005][3005];
using namespace std;

ll dequeue(ll a[],ll s,ll e){
	if(dp[s][e]!=-1){
		return dp[s][e];
	}
	if(s > e){
		return 0;
	}
	if(s == e){
		return a[s];
	}

	return dp[s][e] = max(dequeue(a,s,s) - dequeue(a,s+1,e) , dequeue(a,e,e) - dequeue(a,s,e-1));
	 
}

int main(){
	for(int i=0;i<3005;i++){
		for(int j = 0;j <= 3005;j++){
			dp[i][j] = -1;
		}
	}
	int n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
 	ll ans = 0;
 	int flag = 0;
	ans = dequeue(a,0,n-1);
	cout<<ans<<endl;
	// ll dp[N][2];
}

Measured memory_bytes: 71040
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])
c = 0
f = m
for i in range(n+1):
    if a[i]>k:
        break
    while a[i]+b[f]>k:
        f-=1
    c = max(c, i+f)
print(c)


Measured memory_bytes: 134140
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int H, W, K; cin >> H >> W >> K;
    vector<string> chocolate(H); rep(i, H)cin >> chocolate[i];

    int res = INF;

    for (int bit = 0; bit < (1 << H-1); bit++) {
        vector<int> is_divide(10); int divide_cnt = 0;
        for (int i = 0; i < H-1; i++) {
            if (bit & (1 << i)){
                //縦i列目の直下で割る
                is_divide[i] = true;
                divide_cnt++;
            }
        }
        // 探索後の処理
        vector<int> Counter(10); bool ng = false;
        rep(w, W){
            vector<int> cnt(10);
            int index = 0;
            rep(h, H){
                if(chocolate[h][w]=='1')cnt[index]++;
                if(is_divide[h])index++;
            }
            bool is_over = false;
            rep(i, 10) if(Counter[i] + cnt[i] > K)is_over = true;
            if(is_over){
                if(w==0)ng = true;
                else{
                    divide_cnt++;
                    rep(i, 10)Counter[i] = cnt[i];
                }
            }else{
                rep(i, 10)Counter[i] += cnt[i];
            }
            if(ng)break;
        }
        if(!ng)chmin(res, divide_cnt);
    }
    cout << res << ln;
}


Measured memory_bytes: 3556
/**
 *      ABC 83 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-02 04:10:33
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int A, B, C, D; cin >> A >> B >> C >> D;

    if (A + B > C + D){
        cout << "Left";
    }
    else if (A + B == C + D){
        cout << "Balanced";
    }
    else {
        cout << "Right";
    }
    return 0;
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Comparator;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScan in = new MyScan(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, MyScan in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            int[][] data = new int[m][];
            for (int i = 0; i < m; i++) {
                data[i] = in.na(2);
            }
            Arrays.sort(data, Comparator.<int[]>comparingInt(l -> l[0]).thenComparing(Comparator.comparingInt(o -> o[1])));


            int next = 1000_000_000;

            int res = 0;
            for (int[] s : data) {
                if (s[0] >= next) {
                    next = s[1];
                    res++;
                }
                next = Math.min(s[1], next);
            }
            out.println(res + 1);


        }

    }

    static class MyScan {
        private final InputStream in;
        private byte[] inbuf = new byte[1024];
        public int lenbuf = 0;
        public int ptrbuf = 0;

        public MyScan(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (lenbuf == -1) throw new InputMismatchException();
            if (ptrbuf >= lenbuf) {
                ptrbuf = 0;
                try {
                    lenbuf = in.read(inbuf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0) return -1;
            }
            return inbuf[ptrbuf++];
        }

        public int[] na(int n) {
            int[] k = new int[n];
            for (int i = 0; i < n; i++) {
                k[i] = nextInt();
            }
            return k;
        }

        public int nextInt() {
            int num = 0, b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = num * 10 + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 31644