akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;


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

  int N;
  cin >> N;
  int ans = 0;
  for(int i=N;i<=1000000;i++){
    bool ok = true;
    for(int j=2;j*j<=i;j++){
      if(i % j == 0){
        ok = false;
        break;
      }
    }
    if(ok){
      ans = i;
      break;
    }
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <memory>
#include <algorithm>
#include <cstring>

using namespace std;

int n, zero;
vector<int> pos, neg;

int sol;
vector<pair<int, int>> moves;

void printsol() {
    cout << sol << endl;
    for (int i = 0; i < moves.size(); ++i)
        cout << moves[i].first << " " << moves[i].second << endl;
}

int main() {
    cin >> n;
    pos.reserve(n);
    neg.reserve(n);
    zero = 0;
    for (int i = 0; i < n; ++i) {
        int t;
        cin >> t;
        if (!t) zero++;
        else if (t < 0)
            neg.push_back(t);
        else pos.push_back(t);
    }

    if (zero) {
        if (pos.empty()) {
            pos.push_back(0);
            zero--;
        }
        for (int i = 0; i < zero; ++i)
            neg.push_back(0);
    }
    std::sort(pos.begin(), pos.end(), std::less<int>());
    std::sort(neg.begin(), neg.end(), std::less<int>());

    if (pos.size() == 0) {
        if (neg.size() == 2) {
            moves.push_back({neg[1], neg[0]});
            sol = neg[1] - neg[0];
            printsol();
            return 0;
        }
        pos.push_back(neg[neg.size() - 1] - neg[neg.size() - 2]);
        moves.push_back({neg[neg.size() - 1],  neg[neg.size() - 2]});
        neg.pop_back();
        neg.pop_back();
    } else if (neg.size() == 0) {
        if (pos.size() == 2) {
            moves.push_back({pos[1], pos[0]});
            sol = pos[1] - pos[0];
            printsol();
            return 0;
        }
        neg.push_back(pos[0] - pos[1]);
        moves.push_back({pos[0],  pos[1]});
        pos.erase(pos.begin(), pos.begin() + 2);
    }

    int ppos = 0, npos = 0;
    for (; ppos < pos.size() - 1 && npos < neg.size(); ++ppos) {
        moves.push_back({neg[npos], pos[ppos]});
        neg[npos] = neg[npos] - pos[ppos];
    }
    for (; npos < neg.size() && ppos < pos.size(); ++npos) {
        moves.push_back({pos[ppos], neg[npos]});
        pos[ppos] = pos[ppos] - neg[npos];
    }
    sol = pos[ppos];
    printsol();
    return 0;
}


Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    ll a,b,x;
    cin >> a >> b >> x;
    if(a == 0){
        cout << b / x + 1 << endl;
    }else {
        cout << b / x - (a - 1) / x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
// 091-B
// hapdap
#include<stdio.h>
#include<string.h>

int main(void){
	int N, i;
	scanf("%d", &N);

  char s[N][11];

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

  int M, j;
	scanf("%d", &M);

  char t[M][11];

  for(j=0; j<M; j++){
    scanf("%s", t[j]);
  }

  int score, highscore=0;

  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      //sで一致したら+1点
      if(strcmp(s[i],s[j])==0){
        score+=1;
      }
    }
    for(j=0; j<M; j++){
      //tで一致したら-1点
      if(strcmp(s[i],t[j])==0 && score>0){
        score-=1;
      }
    }

    if(score>highscore){
      highscore=score;
    }
    score=0;
  }

  printf("%d\n", highscore);

	return 0;
}


Measured memory_bytes: 128
# ?????????????????????????????????????§???????????????????????????????
# @param [Array]   g Edge ?????????????????§??¨???????????°??????
# @param [Integer] s ????§????????????????
# @return [Array]  ?????????????????§???????¨?????????????????´????????????????
# g ??????????????????????????§?????????
# g_i ?????? i ???????????????????????????????????¨??????????????????????????¨??????????´?????????????
def dijkstra(g, s)
  def enq(pq, val)
    pq << val
    cd = pq.size
    pr = cd / 2
    until pr.zero? || (pq[pr - 1] <=> pq[cd - 1]) < 0
      pq[pr - 1], pq[cd - 1] = pq[cd - 1], pq[pr - 1]
      cd = pr
      pr = cd / 2
    end
  end

  def deq(pq)
    rs = pq[0]
    pq[0] = pq[-1]
    pq.delete_at(-1)
    unless pq.empty?
      pr = 1
      cd = [pr * 2, pr * 2 + 1].select { |i| pq[i - 1] }.min_by { |i| pq[i - 1] }
      until cd.nil? || (pq[pr - 1] <=> pq[cd - 1]) < 0
        pq[pr - 1], pq[cd - 1] = pq[cd - 1], pq[pr - 1]
        pr = cd
        cd = [pr * 2, pr * 2 + 1].select { |i| pq[i - 1] }.min_by { |i| pq[i - 1] }
      end
    end
    rs
  end

  pq = []
  d = Array.new(g.size) { Float::INFINITY }
  d[s] = 0
  enq(pq, [0, s])

  until pq.empty?
    v_cost, v = deq(pq)
    next if d[v] < v_cost
    g[v].each do |e|
      if d[e.to] > d[v] + e.cost
        d[e.to] = d[v] + e.cost
        enq(pq, [d[e.to], e.to])
      end
    end
  end

  d
end

Edge = Struct.new('Edge', :to, :cost)

v, e, r = gets.split.map(&:to_i)
g = Array.new(v) { [] }
e.times do
  s, t, d = gets.split.map(&:to_i)
  g[s] << Edge.new(t, d)
end

dijkstra(g, r).each do |sum|
  puts (sum == Float::INFINITY ? 'INF' : sum)
end

Measured memory_bytes: 62480
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

ll add(ll x, ll y) {ll res=x+y; return(res>=MOD?res-MOD:res);}
ll mul(ll x, ll y) {ll res=x*y; return(res>=MOD?res%MOD:res);}
ll sub(ll x, ll y) {ll res=x-y; return(res<0?res+MOD:res);}
ll lcm(ll x, ll y) {ll res=(x*y)/__gcd(x,y); return res;}
ll power(ll x, ll y) {ll res=1; x%=MOD; while(y){if(y&1)res=mul(res,x); y>>=1; x=mul(x,x);} return res;}

const int MAX = 5e5 + 5;
ll fact[MAX], invf[MAX];
ll nCr(ll n, ll r){if(n<r||n<0||r<0)return 0; return mul(fact[n],mul(invf[n - r],invf[r]));}
void preprocess()
{
	fact[0] = 1;
	invf[0] = 1;
	for(ll i = 1; i < MAX; i++){
		fact[i] = mul(fact[i - 1], i);
		invf[i] = power(fact[i], MOD - 2);
	}
}
int main()
{
	boost;
	preprocess();
	ll n, m;
	cin >> n >> m;
	
	ll res = mul(nCr(m, n), fact[n]);
	ll ans = 0;
	for(int i = 0; i <= n; i++) {
		if(i & 1) ans = sub(ans, mul(nCr(n, i), mul(nCr(m - i, n - i), fact[n - i])));
		else ans = add(ans, mul(nCr(n, i), mul(nCr(m - i, n - i), fact[n - i])));
	}
	ans = mul(res, ans);
	cout << ans;
}


Measured memory_bytes: 11448
#include<iostream>                                        
#include<cstdio>                                          
#include<cstring>                                         
using namespace std;                                      
                                                          
int main(){                                               
  char number[1001];                                      
  int i;                                                  
  int num;                                                
  while(1){                                               
    scanf("%s",number);                                   
    if(number[0] == '0') break;                           
    int sum = 0;                                          
    for(i=0;i<strlen(number);i++){                        
      num = number[i] - '0';                              
      sum += num;                                         
    }                                                     
    printf("%d\n",sum);                                   
  }                                                       
                                                          
  return 0;                                               
}

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

int main(){
  int A, B, C; cin >> A >> B >> C;
  int a=A;
  int b=B;
  int c=C;
  int ans=0;
  while(true){
    if(a%2==1 || b%2==1 || c%2==1){
      break;
    }
    if(a==b && b==c){
      cout << -1 << endl;
      return 0;
    }
    a=(B+C)/2;
    b=(A+C)/2;
    c=(A+B)/2;
    A=a;
    B=b;
    C=c;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 764
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		if (i%3==0)
		{
			cout << " " << i;
		}
		else if (i % 10 == 3|| i / 10 == 3 || (i / 10) % 10 == 3 || i / 100 == 3 || (i / 100) % 10 == 3 || i / 1000 == 3 || (i / 1000) % 10 == 3)
		{
			cout << " " << i;
		}
	}
	cout << "\n";
	return 0;
}


Measured memory_bytes: 3072
import collections

n, *a = map(int, open(0).read().split())
c = collections.Counter(a)
cnt = 0
for s in c.keys():
    s_num = c[s]
    if s < s_num:
        cnt += s_num - s
    elif s > s_num:
        cnt += s_num
print(cnt)

Measured memory_bytes: 18728
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>

using namespace std;

int main() {
    ios :: sync_with_stdio(false);
    int n, q;
    int a[100001], t;

    cin>>n;
    for(int i=0; i<n; ++i) {
        cin>>a[i];
    }
    cin>>q;
    for(int i=0; i<q; ++i) {
        cin>>t;
        cout<<binary_search(a, a+n, t)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
#define ll long long int
#define st string
#define con continue
#define br break
#define rt return 0
#define fr first
#define sec second
using namespace std;
int main(){
//ll tc; cin>>tc; while(tc--){
ll n,m,i,x,j,mx=0,t,k,b=0,a=0,ans=0,c=0; 
ll mn;    
 st s,str; char strn;
cin>>n; //a=n; n-=1; 
    mn=n-1;
ll ara[n+1],bra[n+1],taj[n+1];
//memset(ara,0,sizeof(ara));
//for(i=1;i<=n;i++) cin>>ara[i]; 
      // cout<<k<<endl;  
  for(i=1;i<=sqrt(n);i++)
   {
     if(n%i==0)
     {
        b++;
      //ara[++a]=i;
     // bra[++b]=n/i;  
      ans=((n/i)+i)-2;
      mn=min(mn,ans);                   
     }
   }      
// t=ara[a]-1;
// k=bra[b]-1; 
  if(!b)cout<<n-1;     
 else cout<<mn<<endl;
    
 
    rt;
}


Measured memory_bytes: 3676
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
def inputS(): return input().rstrip().decode()
readlines = sys.stdin.buffer.readlines 

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

ans = 0
mi = 1<<60
for i in range(N):
  mi = min(mi, A[i])
  if A[i] <= mi:
    ans += 1    
print(ans)    
  

Measured memory_bytes: 20348
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
const int R = 1e4 + 10;
int n;
long long a[R], b[R];
unsigned long long as, bs;
int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for(int i = 1; i <= n; i++) {
		cin >> b[i];
	}
	for(int i = 1; i <= n; i++) {
		if(a[i] > b[i]) as += a[i] - b[i];
		else bs += (b[i] - a[i]) / 2;
	}
	if(as <= bs) cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 384
import sys
from collections import Counter
from collections import deque
import math
import fractions
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=input()
n=len(s)
c0=0
c1=0
for i in range(n):
    if s[i]=="0":
        c0+=1
    else:
        c1+=1
print(2*min(c0,c1))

Measured memory_bytes: 67564
#include<iostream>
using namespace std;
int p[12000000], n, m;
int main() {
	while (true) {
		for (int i = 0; i < 1200000; i++)p[i] = -1;
		cin >> n >> m; int G = n;
		if (n + m == 0)break;
		int cnt = 0;
		while (true) {
			if (p[G] >= 0) {
				if (G == 0)cnt = p[G];
				cout << p[G] << ' ' << cnt - p[G] << endl; break;
			}
			p[G] = cnt; cnt++; G *= 10; G %= m;
		}
	}
	return 0;
}

Measured memory_bytes: 7300
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
 
public class Main {
 
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        // TODO Auto-generated method stub
      int N = sc.nextInt();
      int K = sc.nextInt();
      int odd = ((N%2)==0) ? 0:1;
      int max = ((N - (N%2)) / 2) + odd;
      //System.out.println(max);
      if( K <= max){
        System.out.println("YES");
      }else{
        System.out.println("NO");
      }
    }
 
}

Measured memory_bytes: 22740
n = int(input())
A = list(map(int, input().split()))

if A[0] != 0:
    ans1 = 0
    sum = A[0]
else:
    ans1 = 1
    sum = 1
# A[0]=0 のときは1にする。下で-1にするパターンも試している。なお0は不可。

for a in A[1:]:
    if (sum + a) * sum < 0:
        sum += a
    else:
        nextsum = 1 if sum < 0 else -1
        # fugo = sum // abs(sum) 割り算のときは0に気をつけろ！
        a_should_be = nextsum - sum
        dif = abs(a_should_be - a)
        sum = nextsum
        ans1 += dif

#A[0]を反転したほうがいいパターンの処理
ans2 = abs(A[0]) + 1
sum = 1 if A[0] < 0 else -1
#ある意味、ここでA[0]=0のときに-1にすることもやっている

for a in A[1:]:
    if (sum + a) * sum < 0:
        sum += a
    else:
        nextsum = 1 if sum < 0 else -1
        a_should_be = nextsum - sum
        dif = abs(a_should_be - a)
        sum = nextsum
        ans2 += dif
        
print(min(ans1, ans2))


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

int main(){
  int n; cin >> n;
  vector<string> s(n);
  for(int i=0; i<n; ++i) cin >> s[i];
  sort(s.begin(), s.end());
  int cnt = 1, maxcnt = 0;
  for(int i=0; i<n-1; ++i){
    if(s[i] == s[i+1]) ++cnt;
    else{
      if(maxcnt < cnt) maxcnt = cnt;
      cnt = 1;
    }
    if(i == n-2 && maxcnt < cnt) maxcnt = cnt;
  }
  cnt = 1;
  for(int i=0; i<n-1; ++i){
    if(s[i] == s[i+1]) ++cnt;
    else{
      if(cnt == maxcnt) cout << s[i] << endl;
      cnt = 1;
    }
    if(i == n-2 && cnt == maxcnt) cout << s[i+1] << endl;
  }
  return 0;
}


Measured memory_bytes: 14208
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
using namespace std;
int n,k,m,ans;
int a[111111];
string s[111111];
signed main(){
    cin>>n>>k;
    rep(i,k){
    	cin>>a[i]>>s[i];
    	a[i]--;
    }
    int pen=0,sei=0,flag[111111]={0},cnt[111111]={0};
    rep(i,k){
    	if(s[i]=="AC"){
    		if(!flag[a[i]])sei++;
    		flag[a[i]]=1;
    	}
    	else{
    		if(flag[a[i]])continue;
    		cnt[a[i]]++;
    	}
    	//cout<<sei<<" "<<pen<<endl;
    }
    rep(i,n){
    	if(flag[i])pen+=cnt[i];
    }
    cout<<sei<<" "<<pen<<endl;
}


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

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1000000007
#define PI 3.14159265
#define endl '\n'
#define MAX 501

using namespace std;

void quick () {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);/*//*/
}

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

int diva (int n) {
    int counter = 0;
    for (int i = 1 ; i <= n ;i++){
        if (n%i==0)counter++;
    }
    return counter;
}

void readFromText(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif // ONLINE_JUDGE
}

int main()
{
    quick();
//    readFromText();
    int n ;
    cin >> n ;
    cout << n*(n+1)/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define max(a,b) (((a) > (b)) ? (a) : (b))
using namespace std;
int A,B,C,D,E,F,water,sugar=0,o=10;
int main(){
  std::cin >> A >> B >> C >> D >> E >> F;
  A*=100; B*=100;
  water = min(A,B);
  for(int a = 0; (a<100*o)&&((a*A)<=F); a++)
    for(int b = 0; (b<100*o)&&((a*A+b*B)<=F); b++)
      for(int c = 0; (c<100*o)&&((a*A+b*B+c*C)<=F); c++)
        for(int d = 0; (d<100*o)&&((a*A+b*B+c*C+d*D)<=F); d++){
          if(!(a+b)||!(c+d)) continue;
          int cwater = a*A+b*B, csugar = c*C+d*D;
          if(!(cwater+csugar <= F) || !(100*csugar<=(E*cwater))) continue;
          if((1.0*csugar/(1.0*cwater+1.0*csugar))>(1.0*sugar/(1.0*water+1.0*sugar)))
            sugar = csugar, water = cwater;
        }
  std::cout << water+sugar << ' ' << sugar << '\n';
}


Measured memory_bytes: 256
def main():
    N,K=map(int,input().split())
    a_ls=list(map(int,input().split()))
    f_ls=list(map(int,input().split()))
    
    a_ls.sort()
    f_ls.sort()
    f_ls.reverse()
    
    def can_eat_by(x):
        cost_after_training=list(map(lambda item: x//item, f_ls))
        sum=0
        for i in range(N):
            if a_ls[i]>cost_after_training[i]:
                sum+=a_ls[i]-cost_after_training[i]
        return sum<=K
    
    left=-1
    right=10**12
    while left + 1 < right:
        next_x=(right+left)//2
        if can_eat_by(next_x):
            answer=next_x
            right=next_x
        else:
            left=next_x
    print(right)

    '''
    while left + 1 < right:
      mid = (left+right)//2
      if can_eat(mid):
        right = mid
      else:
        left = mid
     
    answer = right
    print(answer)
    '''
    
main()

Measured memory_bytes: 136684
#include<bits/stdc++.h>
#include <bitset>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dcm(a) setprecision(a)<<fixed
#define MOD 1000000007
#define clr(memo, a) memset(memo,a,sizeof(memo))
#define PI acos(-1)

void solve()
{
int n;
cin>>n;
vector<double> dp(n+5);
dp[0]=1;
for(int i=0;i<n;i++){
    double p;
    cin>>p;
    for(int j=i;j>=0;--j)
    {
      dp[j+1]+=dp[j]*p;
      dp[j]=dp[j]*(1-p);
    }

}
  double ans=0;
    for(int i=0;i<=n;i++)
        if(i>(n-i))
        ans+=dp[i];
    cout<<setprecision(11)<<ans<<endl;
}
int main()
{
    fast;
    solve();

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll N,K,Q; cin >> N >> K >> Q;
    vector<ll> SCORE(N, K - Q);
    rep(i,Q) {
        ll A; cin >> A;
        SCORE[A-1]++;
    }
    rep(i,N) {
        if (SCORE[i] > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = int64_t; using ull = uint64_t; const ll INF = 9e18;
void print() { cout << endl; }
template<typename Head,typename... Tail> void print(Head head,Tail... tail){cout<<head;if(sizeof...(Tail)>0)cout<<" ";print(tail...);}
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<head;print0(tail...);}
// clang-format on

int main() {
    ll N, X, Y;
    cin >> N >> X >> Y;
    // vector<vector<ll>> disttable(2002, vector<ll>(2002, INF));
    vector<ll> distcnt(2002, 0);
    for (ll i = 1; i <= N; i++) {
        for (ll j = i + 1; j <= N; j++) {
            ll dist = min(j - i, abs(i - X) + abs(j - Y) + 1);
            distcnt[dist]++;
        }
    }
    for (ll k = 1; k <= N - 1; k++) {
        print(distcnt[k]);
    }
}


Measured memory_bytes: 3632
n,m,k=gets.split.map(&:to_i)
c=0
(n+1).times do |i|
  c=i*m
  (m+1).times do |j|
    c-=i*2-n if j>0
    if c==k
      puts "Yes"
      exit
    end
  end
end
puts "No"

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long
#define pii pair<int,int>

void test_case()
{
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n,greater<ll>());
    ll ans=a[0];
    if(n&1) {
        for(int i=1;i<n/2;i++) {
            ans+=2*a[i];
        }
        ans+=a[n/2];
    } else {
        for(int i=1;i<n/2;i++)
            ans+=2*a[i];
    }
    cout << ans;
}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}


Measured memory_bytes: 5220
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>

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

using namespace std;
int main(){
	int n, ans;
	cin >> n;
	ans = n * 800 - (n / 15 * 200);

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int a,b,c;
  int k;
  
  scanf("%d %d",&a,&b);
  
  if(a>b)
  {
    c=a;
    a=b;
    b=c;
  }
  if((a+b)%2==1)
    printf("IMPOSSIBLE");
  else
    printf("%d",(a+b)/2);
  return 0;
}

Measured memory_bytes: 128
from math import ceil

DEBT = 100000
DIGITS = 1000
INTEREST_RATE = 1.05

def calc_debt(n):
    d = DEBT // DIGITS
    while n > 0:
        d = ceil(d * INTEREST_RATE)  # 借金の小数点以下を切り捨て
        n  -= 1
    return d * DIGITS

n = int(input())
print(calc_debt(n))



Measured memory_bytes: 5664
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
	int64_t N;
	vector<int64_t> A(100010, 0);
	vector<int64_t> B(100010, 0);
	cin >> N;
	for(int i = 0; i < N+1; i++) cin >> A[i];
	for(int i = 0; i < N; i++) cin >> B[i];

	int64_t cnt = 0;
	int64_t pnt = 0;
	for(int i = 0; i < N; i++)
	{
		if(A[i] <= pnt)
		{
			cnt += A[i];
			A[i] = 0;
		}
		else
		{
			cnt += pnt;
			A[i] -= pnt;
		}
		pnt = 0;

		if(A[i] <= B[i])
		{
			cnt += A[i];
			pnt = B[i] - A[i];
		}
		else
		{
			cnt += B[i];
		}
	}

	//A_N+1
	if(A[N] <= pnt)
	{
		cnt += A[N];
	}
	else
	{
		cnt += pnt;
	}


	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int x[] = new int[N];
        int y[] = new int[N];
        for(int i=0;i<N;i++){
        	x[i]= sc.nextInt();
        	y[i]= sc.nextInt();
        }
        int n = N*(N-1)/2;
        double distance = 0;
        
        for(int i=0;i<N-1;i++) {
            for(int j=i+1;j<N;j++) {
            	distance += Math.sqrt(Math.pow(x[j]-x[i], 2) + Math.pow(y[j]-y[i], 2));
            }
        }
        
        double aveDistance = distance * (N-1) / n;
        
        
        System.out.print(aveDistance);
        
	}
	
        
        
}







Measured memory_bytes: 23636
#include <stdio.h>
#include <malloc.h>

int main(void)
{
    int N;
    int *value, *cost, gain;
    int max_gain = 0;
    int i;

    scanf("%d", &N);

    value = (int *)malloc(N * sizeof(int));
    cost = (int *)malloc(N * sizeof(int));

    for (i = 0; i < N; i++)
    {
        scanf("%d", &value[i]);
    }

    for (i = 0; i < N; i++)
    {
        scanf("%d", &cost[i]);
    }

    for (i = 0; i < N; i++)
    {
        gain = value[i] - cost[i];
        if (gain > 0)
        {
            max_gain += gain;
        }
    }

    printf("%d\n", max_gain);

    free(value);
    free(cost);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
  int n;
  cin >> n;
  int x[110];
  for (int i=0; i<n; i++) cin >> x[i];
  sort(x, x+n);
  long int res = 10000000000000;
  for (int i=x[0]; i<=x[n-1]; i++) {
    int sum = 0;
    for (int j=0; j<n; j++) {
       sum += pow(abs(i - x[j]), 2);
    }
    if (res > sum) res = sum;
  }
  cout <<  res << endl;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  cin >> n;
  map<string, bool> t;
  rep(i, n) {
    string s;
    cin >> s;
    t[s] = true;
  }
  int m;
  cin >> m;
  bool d = false;
  rep(i, m) {
    string s;
    cin >> s;
    if (t.count(s)) {
      d ^= 1;
      cout << (d ? "Opened" : "Closed") << " by " << s << endl;
    } else {
      cout << "Unknown " << s << endl;
    }
  }
}

Measured memory_bytes: 3196
nums = input()

for i in range(8):
    sum = int(nums[0])
    S = nums[0]
    for j in range(3):
        if ((i>>j) & 1):
            sum += int(nums[j+1])
            S += '+' + nums[j+1]
        else:
            sum -= int(nums[j+1])
            S += '-' + nums[j+1]
    if sum == 7:
        print(S+'=7')
        break


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define clr(a,v) memset((a),(v),sizeof(a))

int gx, gy;
int p;
int t;
bool mat[16][16][16][16];
int dp[16][16];

int main()
{
  scanf( "%d", &t );

  while( t-- )
  {
    clr( mat, false );
    clr( dp, 0 );
    scanf( "%d%d%d", &gx, &gy, &p );

    rep( i, p )
    {
      int x1, y1, x2, y2;
      scanf( "%d%d%d%d", &x1, &y1, &x2, &y2 );
      mat[y1][x1][y2][x2] = mat[y2][x2][y1][x1] = true;
    }

    dp[0][0] = 1;
    repi( i, 1, gy+1 )
    {
      if( mat[i-1][0][i][0] )
        break;

      dp[i][0] = 1;
    }
    repi( j, 1, gx+1 )
    {
      if( mat[0][j-1][0][j] )
        break;

      dp[0][j] = 1;
    }

    repi( i, 1, gy+1 ) repi( j, 1, gx+1 )
      dp[i][j] = (!mat[i-1][j][i][j] ? dp[i-1][j] : 0) + (!mat[i][j-1][i][j] ? dp[i][j-1] : 0);

    if( !dp[gy][gx] )
      puts( "Miserable Hokusai!" );
    else
      printf( "%d\n", dp[gy][gx] );
  }

  return 0;
}

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

using namespace std;

int main(){
    int N,L,sum=0;
    cin>>N>>L;

    vector<int> s(N);
    for(int i=0;i<N;i++){
        s[i] = L + i;
        sum += s[i];
    }

    int ans = 1e9;
    for(int i=0;i<N;i++){
        int t = sum - s[i];
            if(abs(sum-t)<abs(ans - sum))
                ans = t;
    }
    cout<<ans;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;



int main() {
    ios_base::sync_with_stdio(false); 

    int h,w,d;
    cin >> h >> w >> d;
    int dd=(h*w)/d+1;
    vector<vector<P>> p(d,vector<P>(dd));
    rep(i,h) {
        rep(j,w) {
            int a;
            cin >> a;
            p[a%d][a/d]={i,j};
        }
    }
    vector<vector<ll>> g(d,vector<ll>(dd));
    rep(i,d) {
        rep(j,dd-1) {
            g[i][j+1]=g[i][j]+abs(p[i][j+1].first-p[i][j].first)+abs(p[i][j+1].second-p[i][j].second);
        }
    }
    int q;
    cin >> q;
    rep(i,q) {
        int l,r;
        cin >> l >> r;
        cout << g[r%d][r/d]-g[l%d][l/d] << endl;
    }

    return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> namespace mp = boost::multiprecision; //mp::cpp_intで宣言
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////

struct ant{
    ll x;
    ll w;
    ll num;
};
bool comp(ant a,ant b){
    if(a.x<b.x)return true;
    else return false;
}

int main(){
    ll n,l,t;cin>>n>>l>>t;
    ant an[n];
    rep(i,0,n-1){
        cin>>an[i].x>>an[i].w;
        an[i].num=i;
    }
    vector<ant>v;
    rep(i,0,n-1){
        ll c;
        if(an[i].w==1){
            c=(an[i].x+t)%l;
        }else{
            c=(100000*l+an[i].x-t)%l;
            if(c<0)c+=l;
        }
        ant a;a.x=c;a.w=an[i].w;a.num=i;
        v.pb(a);
    }
    sort(v.begin(),v.end(),comp);
    
    ll count=0;
    ll pos;
    rep(i,0,n-1){
        if(v[i].num==0)pos=i;
    }
    ll init=-1;
    if(an[0].w==1){
        rep(i,1,n-1){
            if(an[i].w==2){
                ll q=2*t-(an[i].x-an[0].x);
                if(q<0)continue;
                else{
                    ll c=(q-1)/l;
                    count+=c+1;
                }
            }
        }
        init=(pos-count+n*1000000)%n;
        if(init<0)init+=n;
    }else{
        rep(i,1,n-1){
            if(an[i].w==1){
                ll q=2*t-(-an[i].x+l+an[0].x);
                if(q<0)continue;
                else{
                    ll c=q/l;
                    count+=c+1;
                }
            }
        }
        init=(pos+count+n*5)%n;
        if(init<0)init+=n;
    }
    //cout<<pos<<" "<<count<<" "<<init<<endl;
    rep(i,init,n-1){
        cout<<v[i].x<<endl;
    }
    rep(i,0,init-1){
        cout<<v[i].x<<endl;
    }
    return 0;
}


Measured memory_bytes: 6900
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 1e9 + 7
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    int n, k;
    ll *a;
    ll cnt = 1, before = 1;
    cin >> n >> k;
    a = new ll[n];
    for (int i = 0; i < n; i++)
        scanf("%lld", &a[i]);
    REP(i, n - k)
    {
        cnt = a[i + k];
        before = a[i];
        if (before < cnt)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 5284
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-02-17 07:21:21
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  string s; cin >> s;
  int cnt = 0;
  int n = s.size();
  for (int i = 0; i < n - 1; ++i) {
    cnt += s[i] != s[i + 1];
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }

int main()
{
    ll n,k,q,x;
    cin>>n>>k>>q;
    ll a[n]={0};
    rep(i,q) cin>>x,a[x-1]++;
    rep(i,n) yn(k+a[i]-q>0);
    return 0;
}


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

using namespace std;

using ll = long long;

const ll INF = 1e10;

// Longest Increasing Subsequence at A=a_1...a_n
// O(nlogn)
// DPL_1_D: verified
int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++) cin >> a[i];
    vector<ll> dp(n + 1);  // the last(maximum) value of LIS length i+1
    // (if not exist then INF)
    fill(dp.begin(), dp.end(), INF);
    for(ll i=0;i<n;i++){
        // lower_bound(k) returns min pointer a_i >= k
        *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
    }
    cout << ll(lower_bound(dp.begin(), dp.end(), INF) - dp.begin()) << endl;
}



Measured memory_bytes: 4428
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    sumA = [0] * (N + 1)
    for i, a in enumerate(A): sumA[i+1] = sumA[i] + A[i]
    Ans = 100000000000000000
    for i in range(N - 1):
        Ans = min(Ans, abs(sumA[i + 1] - (sumA[N] - sumA[i + 1])))
    print(Ans)


    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 24920
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define PR pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define int ll

// Programming contest

const int MAX=1e5+10;

signed main(){
  int N,R,L;
  cin>>N>>R>>L;
  
  set<PR> teams;
  int score[MAX];
  int tele[MAX];
  for(int i=0; i<N; i++){
    teams.insert(mk(0,i+1));
    score[i+1]=0;
    tele[i+1]=0;
  }
  
  int now_time=0;
  for(int i=0; i<R; i++){
    int team,time,s;
    cin>>team>>time>>s;
    PR M=*(teams.begin());
    tele[M.second]+=time-now_time;
    teams.erase(mk(-score[team],team));
    teams.insert(mk(-score[team]-s,team));
    score[team]+=s;
    now_time=time;
  }
  PR M=*(teams.begin());
  tele[M.second]+=L-now_time;

  PR ans=mk(0,0);
  for(int i=1; i<=N; i++){
    if(ans.first<tele[i]){
      ans.second=i;
      ans.first=tele[i];
    }
  }
  cout<<ans.second<<en
}



Measured memory_bytes: 10892
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    vector<pair<double,int>> a(n);
    double sum = 0;
    rep(i,n){
        cin >> a[i].first;
        sum += a[i].first;
        a[i].second = i;
    }
    sum/= n;
    double dis = 1e18;
    int ans = 0;
    rep(i,n){
        if(dis > abs(sum-a[i].first)){
            dis = abs(sum-a[i].first);
            ans = a[i].second;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int n;
int a[100010];
int count;
int max;
int main(void)
{
	scanf("%d", &n);
	for(int i = 0 ; i < n ; i++)
	{
		scanf("%d", &a[i]);
	}
	for(int i = 1 ; i < n ; i++)
	{	
		if(count > max)
			max = count;
		if(a[i] <= a[i - 1])
		{
			count++;
		}
		else
		{	
			count = 0;
		}
	}
	if(count > max)
		max = count;
	printf("%d", max);
	return 0;
}


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

int main() {
  string s,t;
  cin >> s >> t;
  
  int ans = s.size();
  int count = 0;
  
  string sd = s;
  
  for(int i=0; i<=s.size() - t.size(); i++){
    for(int j=i; j<i + t.size(); j++){
      sd[j] = t[j-i];
    }
    
    for(int j=0; j<s.size(); j++){
      if(sd[j] != s[j]) count++;
    }
    
    if(count <= ans) ans = count;
    
    count = 0;
    sd = s;
  }

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


Measured memory_bytes: 3628
# E
N, D = map(int, input().split())
dv = list(map(int, input().split()))
Q = int(input())
qv = list(map(int, input().split()))

# trace of Alice
dist_alice = D
dist_alice_list = [D]
for i in range(N):
    if dist_alice >= dv[i]:
        dist_alice -= dv[i]
    elif 2*dist_alice >= dv[i]:
        dist_alice = dv[i] - dist_alice
    dist_alice_list.append(dist_alice)

sol_min = [1]
sol_min_ = 1 
for i in range(N-1, -1, -1):
    if 2 * sol_min_ > dv[i]:
        sol_min_ += dv[i]
    sol_min.append(sol_min_)

for i in range(Q):
    if dist_alice_list[qv[i]-1] >= sol_min[N-qv[i]]:
        print("YES")
    else:
        print("NO")
        


Measured memory_bytes: 78484
use proconio::input;

fn main() {
    input!{
        n: usize,
        a: [i32; n],
    }
    
    let mut a = a;
    a.sort_by(|x, y| x.cmp(y).reverse());
    let mut alice = 0;
    let mut bob = 0;

    for (i, &x) in a.iter().enumerate() {
        if i % 2 == 0 {
            alice += x;
        } else {
            bob += x;
        }
    }

    println!("{}", alice - bob);
}


Measured memory_bytes: 2160
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort(reverse=True)
    print('Yes'if L[0] < sum(L[1:]) else 'No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; 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;
}

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

// -------------------------------------------------------

int N;

int main() {
  //
  cin >> N;
  int ans = (1000 - N % 1000);
  if (ans == 1000) {
    cout << 0;
  } else {
    cout << ans;
  }
}


Measured memory_bytes: 3632
#include<stdio.h>
 
struct dice
{
    int n[6] ;
};
struct dice dice1 ;
 
 
int east()
{
    int mem = 0 ;
    mem = dice1.n[0] ;
    dice1.n[0] = dice1.n[3] ;
    dice1.n[3] = dice1.n[5] ;
    dice1.n[5] = dice1.n[2] ;
    dice1.n[2] = mem ;
}
 
int west()
{
    int mem = 0 ;
    mem = dice1.n[0] ;
    dice1.n[0] = dice1.n[2] ;
    dice1.n[2] = dice1.n[5] ;
    dice1.n[5] = dice1.n[3] ;
    dice1.n[3] = mem ;
}
 
int south()
{
    int mem = 0 ;
    mem = dice1.n[0] ;
    dice1.n[0] = dice1.n[4] ;
    dice1.n[4] = dice1.n[5] ;
    dice1.n[5] = dice1.n[1] ;
    dice1.n[1] = mem ;
}
 
int north()
{
    int mem = 0 ;
    mem = dice1.n[0] ;
    dice1.n[0] = dice1.n[1] ;
    dice1.n[1] = dice1.n[5] ;
    dice1.n[5] = dice1.n[4] ;
    dice1.n[4] = mem ;
}
 
int main()
{
    int i=0 ;
    int cmp=0 ;
 
    char a[101] = {0} ;
 
    for (i=0 ;i < 6 ;i++)
    {
        scanf("%d" ,&cmp) ;
 
        dice1.n[i] = cmp ;
 
    }
    scanf("%s" ,a) ;
 
    for (i=0 ;i < 101 ;i++)
    {
        if (a[i] == '\0') break ;
 
        if (a[i] == 'E') east() ;
        if (a[i] == 'W') west() ;
        if (a[i] == 'S') south() ;
        if (a[i] == 'N') north() ;
 
    }
 
    printf ("%d\n" ,dice1.n[0]) ;
    return 0 ;
}


Measured memory_bytes: 2108
#include <stdio.h>

void printarray(int array[],int n){
	int i;
	for(i=0;i<n;++i){
		if(i)printf(" ");
		printf("%d",array[i]);
	}
	printf("\n");
}

int main(void){
	int n,i,j,key;
	int array[100];
	scanf("%d",&n);
	
	for(i=0;i<n;++i)
		scanf("%d",&array[i]);
  printarray(array,n);		
	for(i=1;i<n;++i){
		key = array[i];
		j=i-1;
		while(j>=0&&array[j]>key){
			array[j+1] = array[j];
			j--;
		}
		array[j+1] = key;
		printarray(array,n);
	}
	return 0;
}

Measured memory_bytes: 1760
#include <cstdio>

int main()
{
    int N;
    scanf("%d", &N);
    int H[N];
    for(int i=0; i<N; i++)
        scanf("%d", &H[i]);
    
    int max_height = H[0];
    int count = 1;
    for(int i=1; i<N; i++){
        if(H[i] >= max_height){
            count++;
            max_height = H[i];
        }
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

struct mint{
	ll x;
	mint(ll x=0):x((x%mod+mod)%mod){}
	friend ostream &operator<<(ostream& os,const mint& a){
		return os<<a.x;
	}
	friend istream &operator>>(istream& is,mint& a){
		ll t;
		is>>t;
		a=mint(t);
		return (is);
	}
	mint& operator+=(const mint a){
		if((x+=a.x)>=mod) x-=mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x+=mod-a.x)>=mod)x-=mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x*=a.x)%=mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if (!t) return 1;
		mint a=pow(t>>1);
		a*=a;
		if(t&1) a*=*this;
		return a;
	}
	// for prime mod
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this)*=a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
};

struct combination{
  vector<mint> fact,ifact;
  combination(int n):fact(n+1),ifact(n+1){
	assert(n<mod);
	fact[0]=1;
	for(int i=1;i<=n;i++) fact[i]=fact[i-1]*i;
	ifact[n]=fact[n].inv();
	for(int i=n;i>=1;i--) ifact[i-1]=ifact[i]*i;
  }
  mint operator()(int n,int k){
	if (k<0 || k>n) return 0;
	return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	mint ans=0;
	vector<mint> cnt(k+1);
	for(int i=k;i>=1;i--){
		mint dif=0;
		mint now=1;
		for(int j=2*i;j<=k;j+=i){
			dif+=cnt[j];
			now+=1;
		}
		cnt[i]=now.pow(n)-dif;
		ans+=cnt[i]*i;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4000
import java.lang.Math;
import java.util.ArrayList;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        int a = sn.nextInt();
        int b = sn.nextInt();
        if (a == b) {
            System.out.println("a == b");
        } else {
            System.out.println(a > b ? "a > b" : "a < b");
        }
    }
}

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

int main(){
	while(1){
		long e, ans=1000000;
		
		scanf(" %ld", &e);
		if(e==0) break;
		
		for(long z=0; z*z*z<=e; ++z){
			long p=z*z*z;
			
			for(long y=0; p+y*y<=e; ++y){
				long q=y*y;
				long x=e-p-q;
				long tmp=x+y+z;	
				
				if(tmp<ans) ans=tmp;
				//printf("(%ld,%ld,%ld),%ld\n",x,y,z, tmp);	
			}
		}
		printf("%ld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1188