akhauriyash/Code-Regression huggingface dataset:
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int comp(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return (*(int*)a<*(int*)b)-(*(int*)a>*(int*)b);}

#define putchar(c) putc_unlocked((c), stdout);
uint32_t nextpint(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint64_t nextplong(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint32_t nextstr(char *s){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getc_unlocked(stdin); } *s='\0'; return len; }
uint32_t nextstrln(char *s){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); uint32_t len=0; while(c!='\n'){ *s++=c; len++; c=getc_unlocked(stdin); } *s='\0'; return len; }

void printint(int x){ if(x<0){x=-x; putc_unlocked('-', stdout);}else if(x==0){putc_unlocked('0', stdout);} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putc_unlocked(s[i], stdout); putc_unlocked('\n', stdout); }
void printlong(long x){ if(x<0){x=-x; putc_unlocked('-', stdout);}else if(x==0){putc_unlocked('0', stdout);} int d=0; char s[20]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putc_unlocked(s[i], stdout); }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}
inline int abs2(const int a){return a>=0?a:-a;}

int a[100000][2];
int main(void){
	int n=nextpint();
	for(int i=0; i<n; i++){
		a[i][0]=nextpint();
		a[i][1]=i;
	}
	qsort(a, n, 8, comp);
	int ans=0;
	for(int i=0; i<n; i++){
		if((i&1)!=(a[i][1]&1)) ans++;
	}
	printf("%d\n", ans>>1);
}


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll n,w;cin>>n>>w>>w;
  vector<ll> a(n+1);rep(i,n)cin>>a[i+1];
  a[0]=a[1];
  cout<<max(abs(a[n]-w),abs(a[n-1]-a[n]))<<endl;
  return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int A, B; cin >> A >> B;
    int W = 100, H = 100;

    vs s(H);
    REP(i, H / 2) s[i] = string(W, '.');
    FOR(i, H / 2, H) s[i] = string(W, '#');

    int cnt = 1;
    bool ok = false;
    for(int i= 0; i<H/2; i+=2) {
        for(int j=0; j<W; j+=2){
            if (cnt >= B) {
                ok = true;
                break;
            }
            s[i][j] = '#';
            cnt++;
        }
        if (ok) break;
    }

    cnt = 1;
    ok = false;
    for(int i= H/2+1; i<H; i+=2) {
        for(int j=0; j<W; j+=2){
            if (cnt >= A) {
                ok = true;
                break;
            }
            s[i][j] = '.';
            cnt++;
        }
        if (ok) break;
    }

    cout << H << " " << W << endl;
    REP(i,H) {
        cout << s[i] << endl;
    }

    return 0;
}

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

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}


int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll pow(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x); x=((x)*(x));n=n/2;}return result;}

string p="abcdefghijklmnopqrstuvwxyz";
int a[20];
int sum[20];

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    string ans="";
    while(n){
        n--;
        ans+=p[n%26];
        n/=26;
    }
    reverse(all(ans));
    cout << ans;
    return 0;
}

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

using namespace std;

/*

    bottom up.

*/

const int N = 1000 + 5;
const int mod = 1e9 + 7;

int numberOfWays[N][N];
char a[N][N];
int W , H;

main(){

    scanf("%d %d" , &H , &W);

    for(int i = 0 ; i < H ; i ++){
            scanf("%s" , a[i]);
    }

    for(int i = 0 ; i < H ; i ++){
            for(int j = 0 ; j < W ; j ++){
                    numberOfWays[i][j] = 0;
            }
    }
    numberOfWays[0][0] = 1;

    for(int i = 0 ; i < H ; i ++){
            for(int j = 0 ; j < W ; j ++){
                    if(i + 1 < H && a[i+1][j] != '#'){
                            numberOfWays[i+1][j] = (numberOfWays[i+1][j]%mod + numberOfWays[i][j]%mod) %mod;
                    }

                    if(j + 1 < W && a[i][j+1] != '#'){
                            numberOfWays[i][j+1] = (numberOfWays[i][j+1]%mod + numberOfWays[i][j]%mod) %mod;
                    }
            }
    }

    printf("%d\n" , numberOfWays[H-1][W-1]);

    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>



int main(int argc, char* argv[])
{
	using std::cin;
	using std::cout;
	std::ios::sync_with_stdio(false);
	cin.tie(nullptr);

	std::string S;
	cin >> S;

	char prev = 'z';
	for (char c : S)
	{
		if (c == prev)
		{
			cout << "Bad" << std::endl;
			return 0;
		}
		prev = c;
	}

	cout << "Good" << std::endl;

	return 0;
}


Measured memory_bytes: 256
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
ans = 0
for _ in range(n):
    a = list(map(int,input().split()))
    res = c
    for i in range(m):
        res += b[i]*a[i]
    if res > 0:
        ans += 1
print(ans)

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			int n = stdIn.nextInt();
			if(n==0){
				return;
			}
			String[] l = new String[n];
			double[] eft = new double[n];
			for(int i=0;i<n;i++){
				l[i] = stdIn.next();
				int p = stdIn.nextInt();
				int ac = stdIn.nextInt();
				ac += stdIn.nextInt();
				ac += stdIn.nextInt();
				int d = stdIn.nextInt();
				int e = stdIn.nextInt();
				int f = stdIn.nextInt();
				int s = stdIn.nextInt();
				int m = stdIn.nextInt();
				double sell = f*s*m-p;
				int time = ac+(d+e)*m;
				eft[i] = sell/time;
			}
			for(int i=0;i<n;i++){
				int max = i;
				for(int j=i+1;j<n;j++){
					if(Math.abs(eft[max]-eft[j])<0.0000000001){
						if(l[max].compareTo(l[j])>0){
							max = j;
						}
					}
					else if(eft[max]<eft[j]){
						max = j;
					}
				}
				double tmp1 = eft[i];
				eft[i] = eft[max];
				eft[max] = tmp1;
				String tmp2 = l[i];
				l[i] = l[max];
				l[max] = tmp2;
			}
			for(int i=0;i<n;i++){
				System.out.println(l[i]);
			}
			System.out.println("#");
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const ll INF = +10010010000;

typedef pair<ll,ll> P;
const ll MO = 1000000007;


int main(){
    int w,h,n;
    cin >> w >> h >> n;
    vector<int> white(4,0);
    white[1] = w;
    white[3] = h;
    rep(i,n){
        int x,y,a;
        cin >> x >> y >> a;
        --a;
        
        if(a==0){
            white[a] = max(white[a],x);
        }else if(a==1){
            white[a] = min(white[a],x);
        }else if(a==2){
            white[a] = max(white[a],y);
        }else{
            white[a] = min(white[a],y);
        }
    }
    ll ans = 0;
    // rep(i,4)cout << white[i] << " ";
    // cout << endl;
    if(white[1]-white[0]<=0||white[3]-white[2]<=0)ans = 0;
    else ans = (white[1]-white[0]) * (white[3]-white[2]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	private	static	BufferedReader br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		double[][]	aVector = null;

		while((aVector = parseVector()) != null) {
			result(aVector);
		}
	}

	private static double[][] parseVector() {
		double[][]	aVector = null;
		String[]	as      = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					aVector        = new double[2][2];	
					as             = line.split(" ");
					aVector[0][0]  = Double.parseDouble(as[2]) - Double.parseDouble(as[0]);
					aVector[0][1]  = Double.parseDouble(as[3]) - Double.parseDouble(as[1]);
					aVector[1][0]  = Double.parseDouble(as[6]) - Double.parseDouble(as[4]);
					aVector[1][1]  = Double.parseDouble(as[7]) - Double.parseDouble(as[5]);
				}
			}
		}
		catch (NumberFormatException e) {}
		catch (IOException e) {}

		return aVector;
	}

	private static void result(double[][] aVector) {
		if (aVector[0][0] * aVector[1][0] + aVector[0][1] * aVector[1][1] == 0.0) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
	}
}

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

using namespace std;

typedef long long ll;

signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto& x : a)
        cin >> x;
    sort(a.begin(), a.end());
    cout << accumulate(a.begin(), a.end(), 0LL) - (a.back() / 2) << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int d;
vector<int> c(26,0),last(26,-1);
vector<vector<int>> s;

int score(vector<int> &t){
    int ans=0;
    rep(i,d){
        ans+=s[i][t[i]];
        last[t[i]]=i;
        rep(j,26) ans-=c[j]*(i-last[j]);
        //cout<<ans<<endl;
    }
    return ans;
}

int main(){
    cin>>d;
    vector<set<int>> st(26);
    rep(i,26){
        st[i].insert(-1);
        st[i].insert(d);
    }
    vector<int> t(d,0);
    rep(i,26) cin>>c[i];
    s.assign(d,vector<int>(26,0));
    rep(i,d)rep(j,26){
        cin>>s[i][j];
    }
    rep(i,d){
        cin>>t[i];
        t[i]--;
        st[t[i]].insert(i);
    }
    int ans=score(t);
    //cout<<ans<<endl;
    
    int m; cin>>m;
    rep(i,m){
        int p,di,q; cin>>di>>q;
        di--; q--;
        p=t[di];
        ans+=s[di][q]-s[di][p];
        t[di]=q;
        st[p].erase(di);
        int dd=*st[p].upper_bound(di)-di;
        int du=di-*(--st[p].upper_bound(di));
        ans-=du*dd*c[p];
        dd=*st[q].upper_bound(di)-di;
        du=di-*(--st[q].upper_bound(di));
        st[q].insert(di);
        ans+=du*dd*c[q];
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
const long long p = 1000000007;

long long powmod(long long b, long long e){
    long long t = 1;
    while(e){
        if (e & 1) t = (t * b) % p;
        b = (b * b) % p;
        e >>= 1;
    }
    return t;
}

int main(){
    int x, y, z;
    cin >> x >> y;
    z = x + y;
    if (z % 3) cout << 0 << '\n';
    else{
        z /= 3;
        x -= z;
        y -= z;
        if ((x < 0) || (y < 0)) cout << 0 << '\n';
        else if ((x == 0) || (y == 0)) cout << 1 << '\n';
        else{
            long long fact = 1, factx, facty;

            for (long long i = 1; i <= x + y; i++){
                fact = (fact * i) % p;
                if (i == x) factx = fact;
                if (i == y) facty = fact;
            }
            factx = powmod(factx, p-2);
            facty = powmod(facty, p-2);
            fact = (fact * factx) % p;
            fact = (fact * facty) % p;
            cout << fact << '\n';
        }
    }
}


Measured memory_bytes: 256
package main

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

func main() {
	N, Y := ReadInt(), ReadInt()/1000

	for i := 0; i <= Min(N, Y/10); i++ {
		for j := 0; j <= Min(N-i, (Y-10*i)/5); j++ {
			k := N - i - j
			if 10*i+5*j+k == Y {
				fmt.Println(i, j, k)
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 1868
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if( N == 1){
    cout << "Hello World" << endl;
  }
  if( N == 2){
    int A,B;
    cin >> A >> B;
    cout << A+B << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
ll nCr(int n,int k){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;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;
  }
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
int main(void){
  int n;
  scanf("%d",&n);
  char s[n+1],t[n+1];
  scanf("%s %s",s,t);
  FOR(n)printf("%c%c",s[i],t[i]);
  PRS("");
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;

int main() {
	string str;

	cin >> str;
	str[3] = '8';
	cout << str;
	return 0;
}

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

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;

ll gcd(ll a, ll b) {
    if (a < b) {
        swap(a, b);
    }

    /* ユークリッドの互除法 */
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

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

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int64_t t = __pow_mod(n, p / 2, mod);
        return (t * t) % mod;
    }
    return (n * (__pow_mod(n, p - 1, mod) % mod)) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    int64_t res = __pow_mod(n, p, mod);
    if (res == 0) {
        res = mod;
    }
    return res;
}

void solve(std::string S, std::string T, long long A, long long B,
           std::string U) {

    if (U == S) {
        A--;
    } else {
        B--;
    }
    cout << A << " " << B << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    long long A;
    std::cin >> A;
    long long B;
    std::cin >> B;
    std::string U;
    std::cin >> U;
    solve(S, T, A, B, U);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define inl(a) cin >> a
#define prl(a) cout << a << " "
#define outl(a) cout << a << endl
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
#define tddd tuple<double,double,double>
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<int,pair<int,int> > >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define N 3002
typedef long long int ll;
int vis[N][N];
ll dp[N][N];
ll v[N];
ll fun(int a,int b)
{
    if(a==b)
        return v[a];
    if(vis[a][b])
        return dp[a][b];
    vis[a][b]=1;
    dp[a][b]=max(v[a]-fun(a+1,b),v[b]-fun(a,b-1));
    return dp[a][b];
}
int main()
{
    int n,i;
    in(n);
    rep(i,n)
        inl(v[i]);
    outl(fun(0,n-1));
}






Measured memory_bytes: 105216
//package com.atcoder.contest173.a;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int sum = 0;
        while(sum < n){
            sum += 1000;
        }
        System.out.println(sum-n);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

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

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

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


Measured memory_bytes: 32588
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
int main(){

	int n,m,a;
	// a,bÌcüÉ©©é¡üÌ³Ìê
	set<int> rightLine[101];
	set<int> leftLine[101];
	while(cin>>n>>m>>a&&!(n==0&&m==0&&a==0)){
		for(int i = 0; i < 101; i++){
			rightLine[i].clear();
			leftLine[i].clear();
		}
		for(int i = 0; i < m; i++){
			int h,p,q;
			cin>>h>>p>>q;
			rightLine[p].insert(-h);
			leftLine[q].insert(-h);
		}
		int ch=-1002;
		int ct=a;
		// S[·éÜÅV~[g
		while(1){
			int t=1;
			int s=1;
			// ©gÌEÆ¶ð`FbN
			if(ct!=1){
				set<int>::iterator it=leftLine[ct].upper_bound(ch);
				if(it!=leftLine[ct].end())
					t=*it;
			}
			if(ct!=n){
				set<int>::iterator it=rightLine[ct].upper_bound(ch);
				if(it!=rightLine[ct].end())
					s=*it;
			}
			if(t==1&&s==1)
				break;
			else if(t==1){
				ch=s;
				ct++;
			}
			else if(s==1){
				ch=t;
				ct--;
			}
			else{
				if(s>t){
					ch=t;
					ct--;
				}
				else{
					ch=s;
					ct++;
				}
			}
		}
		cout<<ct<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
N,M=map(int,input().split())
def divisor(n):
    divisors=[]
    for i in range(1,int(n**0.5+1)):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
a=divisor(M)
ans=1
for i in a:
    if i *N<=M:
        ans=i
print(ans)


Measured memory_bytes: 38640
/** Author: Dwai
 *  Omae wa mou shindeiru!
**/

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

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define all(a) (a).begin(),(a).end()
#define fr(i,a,b) for (i = a; i <= b; i++)
#define frr(i,a,b) for (i = a; i >= b; i--)
#define rep(i,n) for (i = 0 ; i < n; i++)
#define repr(i,n) for (i = n - 1; i >= 0; i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define flushinput   cin.ignore(numeric_limits<streamsize>::max(),'\n');

void debug_out() { cerr << endl; }

void clock_out(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}

void fileio(){
  freopen("/home/dwai/Desktop/cp/input.txt","r", stdin);
  freopen("/home/dwai/Desktop/cp/output.txt", "w", stdout);
  freopen("/home/dwai/Desktop/cp/debug.txt", "w", stderr);
}

void ofileio(){
  freopen("input.txt","r", stdin);
  freopen("output.txt", "w", stdout); 
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define fio() fileio()
#define ofio() fileio()
#define clock() clock_out()
#else
#define debug(...) 42
#define fio() 42
#define ofio() ofileio()
#define clock() 42
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef map<ll,ll> mll;

int IT_MAX = 1 << 20;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;



void solve()
{
	ll N,W;
	cin>>N>>W;
	ll w[N],v[N];

	ll dp[W+1][N+1];

	memset(dp,0,sizeof(dp));

	ll i,j;

	rep(i,N)
		cin>>w[i]>>v[i];

	fr(j,1,N)
	{
		fr(i,1,W)
		{
			dp[i][j]=dp[i][j-1];

			if(i-w[j-1]>=0)
			{
				dp[i][j]=max(dp[i][j],dp[i-w[j-1]][j-1]+v[j-1]);
			}
		}
	}

	ll ans=0;
	fr(i,1,W)
	{
		ans=max(ans,dp[i][N]);
	}

	cout<<ans;

}

int main()
{
	//fio();
	fast
	ll t=1;
	//cin>>t;

	while(t--){
		solve();
	}
	return 0;
}

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

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

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

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

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

  return gcd(b, a%b);
}

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

  ll n, m;
  cin >> n >> m;
  string s,t;
  cin >> s >> t;
  ll l = n*m/gcd(n, m);


  bool flag = true;
  map<ll, char> x;
  REP(i, n)
    x[i*l/n] = s[i];
  REP(i, m){
    if(x[i*l/m] != 0 && x[i*l/m] != t[i])
      flag = false;
  }

  if(flag)
    cout << l << endl;
  else
    cout << -1 << endl;


}



Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  ll res = 1;
  for (int i = 1; i <= 3; i++) {
    res *= n;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let w: i32 = sc.read();
    let h: i32 = sc.read();
    let x: i32 = sc.read();
    let y: i32 = sc.read();
    let r: i32 = sc.read();
    if x - r >= 0 && y - r >= 0 && x + r <= w && y + r <= h {
        println!("Yes");
    }else {
        println!("No");
    }
}

use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
 
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


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

int main(){
  long n;
  cin >> n;
  string res;
  
  while(n>0){
  
  if(n%26==1){
    res += 'a';
    n -= 1;
    n/=26;
  }
  else if(n%26==2){
    res += 'b';
    n -= 2;
    n/=26;
  }
  else if(n%26==3){
    res += 'c';
    n -=3;
    n/=26;
  }
  else if(n%26==4){
    res += 'd';
    n -=4;
    n/=26;
  }
  else if(n%26==5){
    res += 'e';
    n -=5;
    n/=26;
  }
  else if(n%26==6){
    res += 'f';
    n-=6;
    n/=26;
  }
  else if(n%26==7){
    res += 'g';
    n-=7;
    n/=26;
  }
  else if(n%26==8){
    res += 'h';
    n-=8;
    n/=26;
  }
  else if(n%26==9){
    res += 'i';
    n-=9;
    n/=26;
  }
  else if(n%26==10){
    res += 'j';
    n-=10;
    n/=26;
  }
  else if(n%26==11){
    res += 'k';
    n-=11;
    n/=26;
  }
  else if(n%26==12){
    res += 'l';
    n-=12;
    n/=26;
  }
  else if(n%26==13){
    res += 'm';
    n-=13;
    n/=26;
  }
  else if(n%26==14){
    res += 'n';
    n-=14;
    n/=26;
  }
  else if(n%26==15){
    res += 'o';
    n-=15;
    n/=26;
  }
  else if(n%26==16){
    res += 'p';
    n-=16;
    n/=26;
  }
  else if(n%26==17){
    res += 'q';
    n-=17;
    n/=26;
  }
  else if(n%26==18){
    res += 'r';
    n-=18;
    n/=26;
  }
  else if(n%26==19){
    res += 's';
    n-=19;
    n/=26;
  }
  else if(n%26==20){
    res += 't';
    n-=20;
    n/=26;
  }
  else if(n%26==21){
    res += 'u';
    n-=21;
    n/=26;
  }
  else if(n%26==22){
    res += 'v';
    n-=22;
    n/=26;
  }
  else if(n%26==23){
    res += 'w';
    n-=23;
    n/=26;
  }
  else if(n%26==24){
    res += 'x';
    n-=24;
    n/=26;
  }
  else if(n%26==25){
    res += 'y';
    n-=25;
    n/=26;
  }
  else{
    res += 'z';
    n-=26;
    n/=26;
  }
}
  
  reverse(res.begin(),res.end());
  cout << res << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 1e5 + 5;
int N, K, Ans, Sum[2][2005][2005], Mp[2][2005][2005];
inline int getVal0(int X1, int Y1, int X2, int Y2)
{
	if(X1 > X2 || Y1 > Y2)return 0;
	return Sum[0][X2][Y2] - Sum[0][X1 - 1][Y2] - Sum[0][X2][Y1 - 1] + Sum[0][X1 - 1][Y1 - 1];
}
inline int getVal1(int X1, int Y1, int X2, int Y2)
{
	if(X1 > X2 || Y1 > Y2)return 0;
	return Sum[1][X2][Y2] - Sum[1][X1 - 1][Y2] - Sum[1][X2][Y1 - 1] + Sum[1][X1 - 1][Y1 - 1];
}
int main()
{
	scanf("%d%d", &N, &K);
	char S[3];
	for(int I = 1, X, Y, C; I <= N; ++I){
		scanf("%d%d%s", &X, &Y, S);
		X = X % (2 * K) + 1;
		Y = Y % (2 * K) + 1;
		if(S[0] == 'B')C = 1;
		else C = 0;
		++Mp[C][X][Y];
	}
	for(int I = 1; I <= 2 * K; ++I)
		for(int J = 1; J <= 2 * K; ++J)
			for(int Col = 0; Col < 2; ++Col)
				Sum[Col][I][J] = Sum[Col][I - 1][J] + Sum[Col][I][J - 1] + Mp[Col][I][J] - Sum[Col][I - 1][J - 1];
    for(int X = 1; X <= K; ++X)
		for(int Y = 1; Y <= K; ++Y){
			int Now = 0;
			Now += Sum[0][X][Y] + getVal0(X + 1, Y + 1, X + K, Y + K) + getVal0(X + K + 1, Y + K + 1, 2 * K, 2 * K) + getVal0(1, Y + K + 1, X, 2 * K) + getVal0(X + K + 1, 1, 2 * K, Y);
			Now += getVal1(1, Y + 1, X, Y + K) + getVal1(X + 1, 1, X + K, Y) + getVal1(X + 1, Y + K + 1, X + K, 2 * K) + getVal1(X + K + 1, Y + 1, 2 * K, Y + K);
			Ans = max(Ans, max(Now, N - Now));
		}
	cout << Ans << endl;
	return 0;
}


Measured memory_bytes: 62976
def prob(point, p, K):
    if point >= K:
        return p
    else:
        return prob(point * 2, p * 0.5, K)

N, K = list(map(int, input().split()))

p_arr = []
for i in range(N):
    dice = i + 1
    p_arr.append(prob(dice, 1/N, K))

print(sum(p_arr))



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

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

int main() {
	int n = nxt();
	string s;
	cin >> s;
	if (s == string(1 << n, '1')) {
		cout << "Possible\n";
		cout << "0\n0 0\n";
		return 0;
	}
	if (s[0] == '0') {
		cout << "Impossible\n";
		return 0;
	}
	const int N = 1 << n;
	vector<char> base(N);
	for (int i = 0; i < N; ++i) {
		if (s[i] == '0') {
			base[i] = 1;
			for (int j = i; j > 0; j = (j - 1) & i) {
				if (s[i ^ j] == '0') {
					base[i] = 0;
				}
			}
			continue;
		}
		for (int j = i; j > 0; j = (j - 1) & i) {
			if (s[i ^ j] == '0') {
				cout << "Impossible\n";
				return 0;
			}
		}
	}

	vector<int> ans;
	function<void(int, bool, bool)> add = [&](int mask, bool rev, bool flip) {
		assert(mask);
		if (__builtin_popcount(mask) == 1) {
			ans.push_back(flip ? -__builtin_ctz(mask) - 1 : __builtin_ctz(mask) + 1);
			return;
		}
		int nm = mask ^ (1 << (__builtin_ctz(mask)));
		if (rev) {
			ans.push_back(flip ? -__builtin_ctz(mask) - 1 : __builtin_ctz(mask) + 1);
			add(nm, false, !flip);
			ans.push_back(!flip ? -__builtin_ctz(mask) - 1 : __builtin_ctz(mask) + 1);
			add(nm, true, flip);
		} else {
			add(nm, false, flip);
			ans.push_back(!flip ? -__builtin_ctz(mask) - 1 : __builtin_ctz(mask) + 1);
			add(nm, true, !flip);
			ans.push_back(flip ? -__builtin_ctz(mask) - 1 : __builtin_ctz(mask) + 1);
		}
	};
	for (int mask = 0; mask < N; ++mask) {
		if (base[mask]) {
			add(mask, false, false);
		}
	}
	int y = 0;
	vector<pair<int, int>> answer = {{0, y}};
	auto go = [&](int c) {
		while (y < c) {
			y += 1;
			answer.push_back({0, y});
		}
		while (y > c) {
			y -= 1;
			answer.push_back({0, y});
		}
	};

	for (int i : ans) {
		// cerr << i << " ";
		if (i < 0) {
			go(-i - 1);
			answer.push_back({1, y});
			answer.push_back({1, y + 1});
			answer.push_back({0, y + 1});
			y += 1;
		} else {
			go(i);
			answer.push_back({1, y});
			answer.push_back({1, y - 1});
			answer.push_back({0, y - 1});
			y -= 1;
		}
	}
	// cerr << "\n";
	go(0);
	cout << "Possible\n";
	cout << (int)answer.size() - 1 << "\n";
	for (const auto& p : answer) {
		cout << p.second << " " << p.first << "\n";
	}

	return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 998244353;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = 200001;


	void doIt() {
		System.out.println((sc.nextInt()<=sc.nextInt())?"unsafe":"safe");
	}

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


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

const int mod = 1e9 + 7;

int main() {
    int n; cin >> n;
    vector<long long> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    long long ans = 0;
    for(int i=0; i<60; i++){
        long long x = 0;
        for(int j=0; j<n; j++){
            if(a[j]>>i&1) x++;
        }
        long long now = x*(n-x) % mod;
        for(int j=0; j<i; j++){
            now = now * 2 % mod;
        }
        ans += now;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

int main()
{
    int N;
    cin >> N;
    vector<long long> A(N);
    rep(i, N)
    {
        cin >> A[i];
    }
    vector<long long> ans(N, 0);
    rep(i, N)
    {
        if (i % 2 == 0)
            ans[0] += A[i];
        else
            ans[0] -= A[i];
    }
    rep(i, N - 1)
    {
        ans[i + 1] = 2 * A[i] - ans[i];
    }
    rep(i, N)
    {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int main(){
	while(1){
		int n;
		cin>>n;
		if(!n)break;
		string w[n];
		rep(i,n)cin>>w[i];
		int a[]={5,7,5,7,7};
		int c,s;
		rep(i,n){
			c=s=0;
			REP(j,i,n){
				s+=w[j].length();
				if(s>a[c])break;
				if(s==a[c]){
					s=0;
					c++;
				}
				if(c==5){
					cout<<i+1<<endl;
					goto END;
				}
			}
		}
		END:;
	}
	return 0;
}


Measured memory_bytes: 3164
fun main(args: Array<String>) {
    abc151e()
}

fun abc151e() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val aList = readLine()!!.split(' ').map { it.toLong() }.sorted().toLongArray()

    var answer = 0L
    
    for (i in 0 until n) {
        answer -= aList[i] * nCk(n - i - 1, k - 1) % MOD
        answer += aList[i] * nCk(i, k - 1) % MOD
        answer %= MOD
    }


    println(answer)
}

private const val MOD = (1e9 + 7).toLong()

private const val MAX = 1000000
private val fac = LongArray(MAX)
private val fInv = LongArray(MAX)
private val inv = LongArray(MAX)
private var isNCkInit = false

private fun nCk(n: Int, k: Int): Long {
    if (!isNCkInit) {
        isNCkInit = true
        fac[0] = 1
        fac[1] = 1
        fInv[0] = 1
        fInv[1] = 1
        inv[1] = 1
        for (i in 2 until MAX) {
            fac[i] = fac[i - 1] * i % MOD
            inv[i] = MOD - inv[(MOD % i).toInt()] * (MOD / i) % MOD
            fInv[i] = fInv[i - 1] * inv[i] % MOD
        }
    }
    if (n < k) return 0
    if (n < 0 || k < 0) return 0
    return fac[n] * (fInv[k] * fInv[n - k] % MOD) % MOD
}


Measured memory_bytes: 97036
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

ll k;

int main(int argc, char **argv) {
	cin >> k;
	ll n = 50;
	ll x = k / n, y = k % n;
	cout << n << endl;
	REP(i, n) {
		if (i != 0) cout << ' ';
		cout << (n - 1 + x - y + (i >= n - y ? n + 1 : 0));
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
h=[int(i) for i in input().split()]
i=1
old=h[0]
a=[old]
b=[]
while i<n:
    if h[i-1]>=h[i]:
        a.append(h[i])
    else:
        b.append(a)
        a=[h[i]]
    old=h[i]
    i+=1
b.append(a)
print(max( len(i) for i in b)-1 )

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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

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

    int n, k, q;
    cin >> n >> k >> q;
    vi scores(n, 0);

    int base = q - k;

    while (q-- > 0) {
        int x;
        cin >> x;
        --x;
        ++scores[x];
    }

    // allowed to get at most k - 1 wrong
    // k - 1 + correct = q
    // correct = q - (k - 1)
    for (int i = 0; i < n; ++i) {
        if (scores[i] > base) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>

int main() {
	int n, p[101], m[101][101];
	std::cin >> n;
	for (int i = 1; i <= n; i++) {
		std::cin >> p[i - 1] >> p[i];
	}

	for (int i = 1; i <= n; i++) m[i][i] = 0;
	for (int l = 2; l <= n; l++) {
		for (int i = 1; i <= n - l + 1; i++) {
			int j = i + l - 1;
			m[i][j] = (1 << 21);
			for (int k = i; k <= j - 1; k++) {
				m[i][j] = std::min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
			}
		}
	}
	std::cout << m[1][n] << std::endl;
	return 0;
}

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

int main(){
int h, w, d; scanf("%d%d%d", &h, &w, &d);
if(d & 1){ for(int i = 0; i < h; i++, puts("")) for(int j = 0; j < w; j++) putchar("RB"[(i + j) & 1]); }
else{ for(int i = 0; i < h; i++, puts("")){ for(int j = 0; j < w; j++){ int k = min(i % d, d - i % d); int p = j % d; int l = j / d + i / d; l &= 1; int q = (i % d > d / 2); putchar("RGBY"[l ^ (p < k ? 2 : p >= d - k ? 3 : q)]); } }}
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,N) for(int i = 0; i<(int)(N); i++)
#define REP(i,k,N) for(int i = k; i<(int)(N); i++)
typedef long long ll;
using namespace std;
int d[101][10001];
int main(){
        ll N,W;
        ll v[101]={},w[101]={};
        cin >> N >> W;
        REP(i,1,N+1) cin>>v[i]>>w[i];

        REP(y,1,N+1) REP(x,1,W+1){
                if((x - w[y]) < 0) d[y][x] = d[y-1][x];
                else d[y][x] = max<ll>(d[y-1][x], d[y-1][x - w[y]] + v[y]);
        }

        cout << d[N][W] << endl;
        return 0;
}



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

// #undef LOCAL
#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

const ll MAX = 1e12;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  int N;
  cin >> N;
  ll K;
  cin >> K;
  vector<ll> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int B = 40;
  dumpv(N, K, B, a);
  vector<int> c0(B), c1(B);
  for (int i = 0; i < B; i++) {
    ll bit = 1LL << i;
    for (int j = 0; j < N; j++) {
      if (a[j] & bit)
        c1[i]++;
      else
        c0[i]++;
    }
  }
  dumpv(c0);
  dumpv(c1);
  ll x = 0;
  for (int i = B - 1; 0 <= i; i--) {
    ll bit = 1LL << i;
    if (bit <= K) {
      if (c1[i] < c0[i]) {
        x |= bit;
        K -= bit;
      }
    }
  }
  dump(x);
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ans += (a[i] ^ x);
  }
  cout << ans << endl;
  return 0;
}

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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vll>;
df data(n, vll(m));
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/range/algorithm.hpp> // boost::sort(arr)
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
using boost::algorithm::join; // string s = join(arr, "");
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

#include <boost/range/algorithm.hpp> // boost::sort(arr)

int main() {
  int a, b, c;
  vector<int> arr(3);
  rep(i, 3) cin >> arr[i];
  boost::sort(arr);
  cout << arr[2] - arr[0] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;cin>>n>>m;
  vector<int> q(m);
  vector<string> ac(m);
  for(int i=0;i<m;i++)
    cin>>q[i]>>ac[i];
  vector<bool> cor(n+1,false);
  vector<int> inc(n+1,0);
  for(int i=0;i<m;i++)
    if(ac[i]=="AC")
      cor[q[i]]=true;
  	else if(!cor[q[i]])
      inc[q[i]]++;
  int a=0,w=0;
  for(int i=1;i<=n;i++)
    if(cor[i])
    {
      a++;
      w+=inc[i];
    }
  cout<<a<<" "<<w<<endl;
  return 0;
}
  

Measured memory_bytes: 6528
import java.util.Scanner;
import java.util.stream.Stream;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
//		int[] S = Stream.of(sc.nextLine().split("")).mapToInt(Integer::parseInt).toArray();
		String[] S = sc.nextLine().split("");
		
		int v_mae   = Integer.parseInt(S[0]+S[1]);
		int v_usiro = Integer.parseInt(S[2]+S[3]);
		boolean yymm_flg = false;
		boolean mmyy_flg = false;
		
		if(0 <= v_mae && v_mae <= 99 && 1 <= v_usiro && v_usiro <= 12 ) {
			yymm_flg=true;
		}
		if(0 <= v_usiro && v_usiro <= 99 && 1 <= v_mae && v_mae <= 12 ) {
			mmyy_flg=true;
		}
		
		if(yymm_flg && !mmyy_flg) {
			System.out.print("YYMM");
		}
		else if(!yymm_flg && mmyy_flg) {
			System.out.print("MMYY");
		}
		else if(yymm_flg && mmyy_flg) {
			System.out.print("AMBIGUOUS");
		}
		else {
			System.out.print("NA");
		}
	}
}

Measured memory_bytes: 21716
N, K = map(int, input().split())
s = input()
  
group = []
if s[0] == '0' :
  group = [0]
sign = s[0]
curr = 0
for i in range(N):
  curr += 1
  if s[i] != sign: 
    group += [curr-1]
    curr = 1
    sign = s[i]
else:group += [curr]
if s[-1] == '0':
  group += [0]

m = len(group)//2
if K >= m:
  print(N)
else:
  score = [sum(group[:2*K+1])]
  for i in range(m-K):
    score += [score[-1] - group[2*i]  - group[2*i+1] + group[2*i+2*K+1]+group[2*i+2*K+2]]
  
  print(max(score))

Measured memory_bytes: 5432
#include <bits/stdc++.h>
#define pq priority_queue
using namespace std;
constexpr long long gcd(long long a, long long b){return b ? gcd(b, a % b) : a;}
constexpr long long lcm(long long a, long long b){return a / gcd(a, b) * b;}
constexpr int INF = 1e9, MOD = INF + 7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
constexpr int mod_pow(long long x, long long n, const int mod){long long ret=1;while(n){if(n&1)(ret*=x)%=mod;(x*=x)%=mod;n>>=1;}return ret;}
template<int n> struct Prime{bool arr[n+1];constexpr bool operator[](int k){return arr[k];}constexpr Prime():arr(){for(int i=2;i<n;i++){arr[i]=true;for(int j=2;j*j<=i;j++){if(!(i%j))arr[i]=false;}}}};
template<int n> struct Factorial{long long arr[n+1],ary[n+1];constexpr Factorial():arr(),ary(){arr[0]=1;ary[0]=1;for(int i=0;i<n;i++){arr[i+1]=arr[i]*(i+1)%MOD;ary[i+1]=mod_pow(arr[i+1],MOD-2,MOD);}}};
constexpr Factorial<1010> fact; constexpr Prime<10> prime;
constexpr long long comb(int a, int b){if(a < b) return 0LL;if(!a or !b) return 1LL; long long pos = fact.arr[a], pot = fact.ary[a - b], por = fact.ary[b]; return pos * pot % MOD * por % MOD;}
template<int n> struct Bernoulli{long long arr[n+1];constexpr Bernoulli():arr(){arr[0]=1;for(int i=1;i<=n;i++){long long sum=0;for(int j=0;j<i;j++){(sum+=comb(i+1,j)*arr[j]%MOD)%=MOD;}arr[i]=(MOD-mod_pow(i+1,MOD-2,MOD))%MOD*sum%MOD;}}};
constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
constexpr long double PI = abs(acos(-1));
constexpr int sqrtN = 512, logN = 32;
constexpr long long LINF=1e18;

int main(){
	long long n, s; cin >> n >> s;
	if(n == s){
		cout << n + 1 << endl;
		return 0;
	}
	
	if(n < s){
		cout << -1 << endl;
		return 0;
	}
	
	for(long long i = 2; i * i <= n; i++){
		long long c = 0, pos = n;
		
		while(pos){
			c += pos % i;
			pos /= i;
		}
		
		if(c == s){
			cout << i << endl;
			return 0;
		}
	}
	
	long long mi = LINF;
	for(long long i = 1; i * i <= n; i++){
		long long p = i;
		long long q = s - p;
		
		if((n - q) % p) continue;
		long long b = (n - q) / p;
		
		long long c = 0, pos = n;
		while(pos){
			c += pos % b;
			pos /= b;
		}
		
		if(c == s) mi = min(mi, b);
	}
	
	if(mi == LINF) cout << -1 << endl;
	else cout << mi << endl;
	return 0;
}


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

int w,h;
int f[51][51];
int d[3] = {0,-1,1};

void dfs(int x, int y) {
    int i,j,nx,ny;
    f[x][y] = 0;
    for(i=0; i<3; i++)
        for(j=0; j<3; j++) {
            if(i+j == 0)
                continue;
            nx=x+d[i], ny=y+d[j];
            if(nx<0 || nx>=h || ny<0 || ny>=w)
                continue;
            if(f[nx][ny] == 1)
                dfs(nx,ny);
        }
}

int main() {
    int i,j,r;
    while(1) {
        r=0;
        cin >> w >> h;
        if(w+h == 0)
            break;

        for(i=0; i<h; i++)
            for(j=0; j<w; j++)
                cin >> f[i][j];
        
        for(i=0; i<h; i++)
            for(j=0; j<w; j++)
                if(f[i][j] == 1) {
                    dfs(i, j);
                    r++;
                }
        cout << r << endl;
    }
}


Measured memory_bytes: 3148