akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int dy[] = {-1,-1,-1,0,0,0,1,1,1};
int dx[] = {-1,0,1,-1,0,1,-1,0,1};

int main() {
	ll H, W, N;
	cin >> H >> W >> N;
	map<pair<ll,ll>,ll> mp;
	for(int i=0;i<N;i++) {
		ll a, b;
		cin >> a >> b;
		a--, b--;
		for(int j=0;j<9;j++) {
			ll y = a + dy[j];
			ll x = b + dx[j];
			if(1 <= y and y <= H-2 and 1 <= x and x <= W-2) {
				mp[make_pair(y,x)]++;
			}
		}
	}
	vector<ll> ans(10, 0);
	for(auto &tmp : mp) {
		if(tmp.second > 0) {
			ans[tmp.second]++;
		}
	}
	ans[0] = (H - 2) * (W - 2) - accumulate(ans.begin(), ans.end(), 0);

	for(int i=0;i<10;i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 56448
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

const double EPS=(1e-10);
typedef long long ll;
typedef pair<int,int> pii;
bool EQ(double a,double b){
  return abs((a)-(b))<EPS;
}
void fast_stream(){
	std::ios_base::sync_with_stdio(0);
}

int n;
int a[1001];
int k;
void solve(){
    while(cin>>n>>k&&(n|k)){
        for(int i=0;i<n;i++)cin>>a[i];
        int maxt=0;
        for(int i=0;i+k<=n;i++){
            int tmp=1;
            for(int j=0;j<k;j++)tmp*=a[i+j];
            maxt=max(maxt,tmp);
        }
        int maxs=0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                swap(a[i],a[j]);
                for(int l=0;l+k<=n;l++){
                    int tmp=1;
                    for(int m=0;m<k;m++)tmp*=a[l+m];
                    maxs=max(maxs,tmp);
                }
                swap(a[i],a[j]);
            }
        }
        if(maxt>maxs)cout<<"NO GAME"<<endl;
        else cout<<maxs-maxt<<endl;
    }
}
int main(){

    solve();

    return 0;
}

Measured memory_bytes: 868
N, M = (int(ai) for ai in input().split(' '))
cakes = [[int(cake) for cake in input().split(' ')] for _ in range(N)]
signs = [[(-1)**i, (-1)**j, (-1)**k]
         for i in range(2) for j in range(2) for k in range(2)]
answer = 0
for sign in signs:
    values = [sum([cake[i] * sign[i] for i in range(3)]) for cake in cakes]
    answer = max(sum(sorted(values, reverse=True)[:M]), answer)
print(answer)

Measured memory_bytes: 3332
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	ll n;
	cin >> n;
	vector<ll> h(n);
	rep(i, n) cin >> h[i];

	ll ans = 0;
	ll cnt = 0;
	rep(i, n-1) {
		if (h[i] >= h[i + 1]) {
			cnt++;
		}
		else {
			cnt = 0;
		}
		ans = max(ans, cnt);
	}

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


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

int func(int x, vector<vector<int>> &graph, vector<int> &flag, vector<int> &dp) {
  if (flag[x])
    return dp[x];
  
  // flag[x] == 1 bugの原因
  flag[x] = 1;
  int check = 0;
  for (auto i : graph[x]) {
    check = max(check, func(i, graph, flag, dp) + 1);
  }
  dp[x] = check;
  return dp[x];
}

int main() {  
  
  int N, M;
  cin >> N >> M;
  vector<int> flag(N + 1, 0);
  vector<int> dp(N + 1, 0);
  vector<vector<int>> graph(N + 1);
  int x, y;
  for (int i = 0; i < M; i++) {
      cin >> x >> y;
      graph[x].push_back(y);
  }
  // 各nodeをdfsで探索
  int ans = 0;
  for (int i = 1; i < N + 1; i++) {
      ans = max(ans, func(i, graph, flag, dp));
  }
  cout << ans << endl;
}

Measured memory_bytes: 12944
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ').map(Number);
  buildMaxHeap(arr);
  console.log(arr.reduce((s, e) => s += ' ' + e, ''));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest, tmp;
    left = 2 * i + 1;
    right = 2 * i + 2;
    if (left < n && arr[left] > arr[i]) largest = left;
    else largest = i;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
        tmp = arr[i];
        arr[i] = arr[largest];
        arr[largest] = tmp;
    //   arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
}



Measured memory_bytes: 143548
import re

def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

N = int(input())

MOD = int(1e9) + 7

acgt = ["A", "C", "G", "T"]
changed = list(map(lambda pat: re.compile(pat), [r".*AGC", r".*GAC", r".*ACG", r".*A.GC", r".*AG.C"]))
abcl = [ a+b+c for a in acgt for b in acgt for c in acgt]

dp = {}
for now in abcl:
    if any(map(lambda ch: ch.match(now), changed)):
        dp[now] = 0
    else:
        dp[now] = 1

N -= 3

while N > 0:
    dpNow = {}
    for abc in abcl:
        abc = abc[:min(N, 3)]
        dpNow[abc] = 0
        for key, value in dp.items():
            now = key + abc
            if not any(map(lambda ch: ch.match(now), changed)):
                dpNow[abc] += value
                dpNow[abc] %= MOD
    dp = dpNow
    N -= 3

ans = 0
for v in dp.values():
    ans += v
    ans %= MOD

print(ans)


Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 1e6;
int A[N];

int main() {
    ios_base::sync_with_stdio(0);
    int a,b,n,T,cas=0;
    cin>>n;
    for(int i=0;i<n-1;++i) {
        cin>>a;
        A[a]++;
    }
    for(int i=1;i<=n;++i) {
        cout<<A[i]<<endl;
    }
    return 0;
}

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

int DP[100][20];
int main()
{
	int n,m;
	while(cin >> m >> n){
		if(!m && !n)
			break;
		for(int i=0;i<n;i++){
			int book;
			cin >> book;
			if(i==0)
				for(int j=0;j<m;j++){
					DP[i][j] = book;
				}
			else{
				DP[i][0] = DP[i-1][0]+book;
			}
		}
		
		for(int i=1;i<=n;i++){
			for(int j=1;j<m;j++){
				DP[i][j] = max(DP[i][0]-DP[i-1][0],DP[i-1][j-1]);
				for(int k=i-2;k>=0;k--){
					if(DP[i][0]-DP[k][0] >= DP[k][j-1]){
						DP[i][j] = min(DP[i][j],DP[i][0]-DP[k][0]);
						break;
					}else{
						DP[i][j] = min(DP[i][j],DP[k][j-1]);
					}
				}
			}
		}
		
		cout << DP[n-1][m-1] << endl;
	}
	return 0;
}

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

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))
#define INF (1<<28)
#define pb push_back
#define fs first
#define sc second

const char dx[]={0,1,0,-1},dy[]={1,0,-1,0};
template<class T>
ostream &operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()) out << v[i] << ", " ;
	return out << "}" << endl;
}
template<class S,class T>
ostream &operator<<(ostream &out, const pair<S,T> p){
	return out << "(" << p.fs << ", " << p.sc << ")";
}
int main(){
	int n;
	cin >> n;
	string s;
	vi v(26,50);
	rep(i,n){
		cin >> s;
		vi vv(26,0);
		rep(j,s.length()){
			vv[s[j]-'a']++;
		}
		rep(j,26) v[j] = min(v[j],vv[j]);
	}
	rep(i,26){
		char c = 'a' + i;
		rep(j,v[i])
			cout << c;
	}
	cout << endl;
	return 0;
}


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

int H[200000];

int Cmp(const void *a, const void *b){
  return *(int *)b - *(int *)a;
}

void Do(int N, int K){
  int i;
  long long S;
  for(i = 0;i < N;i++) scanf("%d", &H[i]);
  qsort(H, N, sizeof(int), Cmp);
  S = 0;
  for(i = K;i < N;i++) S += H[i];
  printf("%lld\n", S);
}

int main(void){
  int N, K;
  scanf("%d %d", &N, &K);
  Do(N, K);
  return 0;
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
int main() {
    string s, t;
    cin >> s >> t;
    int ls = s.size(), lt = t.size(), r = lt;
    for (int i = 0; i + lt - 1 < ls; ++i) {
        int pr = 0;
        for (int j = 0; j < lt; ++j) {
            if (s[i + j] != t[j]) ++pr;
        }
        r = min(r, pr);
    }
    cout << r;
}

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

int main() {
  int n;
  cin >> n;
  vector<pair<string, int>> l(n);
  for (auto& e : l) cin >> e.first >> e.second;
  string x;
  cin >> x;
  rep(i, n) {
    if (l[i].first == x) {
      int ans = 0;
      for (int j = i + 1; j < n; j++) ans += l[j].second;
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <iomanip>
#include <string.h>
#include <sstream>
#include <map>
#include <set>

#define N 100000
#define mod 1000000007
#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

long long sqr(const long long& x){return x * x;}

long long solve(int* a, int n, long long C){
//	cout << a[0] << " " << n << endl;

}

int a[111],ans[111111];

int main(int argc, char const *argv[]){
	int n,k; cin>>n>>k;

	for(int i=0; i<n; i++)
	cin>>a[i];

	for(int i=0; i<=100000; i++)
		for(int j=0; j<n; j++)
		{
			if(a[j]+i>100000)continue;
			ans[i+a[j]]|=!ans[i];
		}

	cout<<(ans[k]?"First":"Second");
}



















Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long int
#define ld long double
#define pb push_back
#define pf push_front
#define ft first
#define sc second
#define all(v) v.begin(), v.end()
using namespace std;
const int maxn = 3010, mod = 998244353;
signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    ld ans = 2 * 3.14159 * n;
    cout.precision(16);
    cout << ans;
}


Measured memory_bytes: 3800
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	class P {
		Double x;
		Double y;

		P() {
		};

		P(Double x, Double y) {
			this.x = x;
			this.y = y;
		}

		P sub(P p) {
			return new P(this.x - p.x, this.y - p.y);
		}

		P right() {
			return new P(-this.y, this.x);
		}

		Double dot(P p) {
			return this.x * p.x + this.y * p.y;
		}
	}

	void run() {
		for (;;) {
			if(!sc.hasNextInt()){
				break;
			}
			P[] p = new P[4];
			for (int i = 0; i < 4; i++) {
				p[i] = new P();
				p[i].x = sc.nextDouble();
				p[i].y = sc.nextDouble();
			}
			boolean ret = true;
			for (int i = 0; i < 3; i++) {
				P line = p[(i + 1) % 3].sub(p[i]);
				P odd = p[(i + 2) % 3].sub(p[i]);
				P tar = p[3].sub(p[i]);
				if (line.right().dot(tar) * line.right().dot(odd) <= 0) {
					ret = false;
				}
			}
			System.out.println(ret ? "YES" : "NO");
		}
	}

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

Measured memory_bytes: 12000
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
const long LMIN=-9223372036854775808l;
struct TAG{long* array;int size,head,tail,count;};
typedef struct TAG* DEQUE;
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline long IN(void)
{
  long x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(long a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
static inline long Max(const long x,const long y){return x<y?y:x;}
static inline void* xmalloc(size_t size){void* p=malloc(size);if(p==NULL){exit(EXIT_FAILURE);}return p;}
static inline DEQUE CREATE(void)
{
  const int size=10000;
  struct TAG* deque=(DEQUE)xmalloc(sizeof(struct TAG));
  deque->array=(long*)xmalloc(sizeof(long)*size);
  deque->size=size;deque->head=deque->tail=deque->count=0;return deque;
}
static inline void DELETE(DEQUE deque){free(deque->array);free(deque);}
static inline int PREV(DEQUE deque,int index){return(!index)?deque->size-1:index-1;}
static inline int NEXT(DEQUE deque,int index){return(index+1)%deque->size;}
static inline void PUSH(DEQUE deque,long value,int back)
{
  //front=0,back=1;
  if(deque->count==deque->size){exit(EXIT_FAILURE);}
  if(back)deque->tail=NEXT(deque,deque->tail);else deque->head=PREV(deque,deque->head);
  deque->array[(back)?deque->tail:deque->head]=value;
  deque->count++;
  if(deque->count==1){if(back)deque->head=deque->tail;else deque->tail=deque->head;}
}
static inline long POP(DEQUE deque,int back)
{
  if(!deque->count){exit(EXIT_FAILURE);}
  long value=deque->array[(back)?deque->tail:deque->head];
  if(back)deque->tail=PREV(deque,deque->tail);else deque->head=NEXT(deque,deque->head);
  deque->count--;
  return value;
}
int main(void)
{
  int N=IN(),K=IN(),C[5000],P[5000],vis[5000]={0};
  long score=LMIN,vector[15000];
  rep(i,N){P[i]=IN()-1;}rep(i,N){C[i]=IN();score=Max(score,C[i]);}
  if(score<0){return OUT(score),0;}
  rep(i,N)
  {
    if(vis[i]){continue;}
    int len=0,now=K,sz=0,x=P[i];long high=LMIN,temp=0,y=1l*C[x];vis[i]=1;
    vector[sz++]=0,vector[sz++]=y;
    while(!vis[x]){vis[x]=1;x=P[x];y+=1l*C[x];vector[sz++]=1l*C[x];}
    if(y>0)
    {
      temp+=1l*Max(1l*now/(sz-1l)-1l,0l)*y;
      if(now>sz-1){now%=sz-1;now+=1l*sz-1l;}
    }len=sz;
    rep(j,len-1){vector[sz++]=1l*vector[j+1];}
    rep(j,len-1){vector[sz++]=1l*vector[j+1];}
    rep(j,sz-2){vector[j+2]+=1l*vector[j+1];}
    DEQUE dq=CREATE();
    PUSH(dq,0,0);
    rep(j,sz-1)
    {
      while(dq->count&&vector[dq->array[dq->head]]>vector[j+1]){POP(dq,0);}
      PUSH(dq,j+1,0);
      while(dq->count&&j+1-dq->array[dq->tail]>now){POP(dq,1);}
      if((j+1)!=dq->array[dq->tail]){high=1l*Max(1l*high,1l*vector[j+1]-1l*vector[dq->array[dq->tail]]);}
    }
    temp+=1l*high;score=1l*Max(score,temp);
    DELETE(dq);
  }
  return OUT(score),0;
}

Measured memory_bytes: 1728
N, K = map(int, input().split())
        
    
import math

sum = 0
for i in range(N):
    X = math.log2(K/(i+1))
    X = math.floor(X) if X % 1 == 0 else math.floor(X+1)
    #print(X, i, K)
    X = X if X > 0 else 0
    sum += (1/N)*(1/2)**X
    
print(sum)

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

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String nums = reader.readLine();
        StringBuilder result = new StringBuilder();
        for(int i = 0; i<nums.length(); i++){
            String n = nums.charAt(i) == '1' ? "9" : "1";
            result.append(n);
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
#define lint long long
#define ll long long
static const int INF = 1 << 22;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
/*******source code below********/
#define M_MAX 100010
int main(void) {

	long long N; cin >> N;
	long long M; cin >> M;

	vector<ll> x(M),y(M), water(N);
	vector<bool> red(N);

	for (int i = 0; i < M; i++)
	{
		int X, Y; cin >> X >> Y;
		x[i] = --X;
		y[i] = --Y;

	}
	fill(all(water), 1);
	fill(all(red), false);
	red[0] = true;

	for (int i = 0; i < M; i++) {
		if (red[x[i]]) {
			red[y[i]] = true;
		}
		water[x[i]]--;
		water[y[i]]++;
		if (water[x[i]] == 0) red[x[i]] = false;
	}
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (red[i]) cnt++;
	}
	cout << cnt << endl;
	return 0;

}

Measured memory_bytes: 2560
#include<sstream>
#include<iostream>
#include<string>
#include<cstring>
#include <stdlib.h>
#include <cstdio>
#include <algorithm>
#define ll long long

using namespace std;

int main(){
    
    int i, j, a,sum=0,ar[100005];
    
    for (i=0;i<=2;i++){
        cin >> ar[i];
    }
    
    sort (ar,ar+3);
    reverse(ar,ar+3);
    
    for (i=0;i<2;i++){
        sum+=abs(ar[i]-ar[i+1]);
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    int ansa,ansb;
    ansa = c-a;
    ansb = d-b;
    printf("%d %d %d %d\n",c-ansb,d+ansa,a-ansb,b+ansa);
}

Measured memory_bytes: 128
N=int(input())
A=list(int(i)%4 for i in input().split())
b1=A.count(1)+A.count(3)
b2=A.count(2)
b4=A.count(0)
print('Yes' if ( (b2==0 and (b1<=b4+1)) or b1<=b4) else 'No')

Measured memory_bytes: 11100
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct Graph {
    static constexpr ll INF = 1LL << 60;
    struct VertexQ {
        bool operator<(const VertexQ &o) const {
            return c > o.c; // 逆
        }
        int i;
        ll c;
    };
    struct Vertex { int n; ll c; };
    struct Edge { int i, n, c; };
    Graph(int n, int m) : v(n, { -1, INF }), e(m), n(n), m(0) {}
    void add_edge(int i, int j, int c) {
        e[m] = { j, v[i].n, c };
        v[i].n = m;
        m++;
    }
    void dijkstra(int i) {
        for (int i = 0; i < n; i++) v[i].c = INF;
        priority_queue<VertexQ> q;
        q.push({ i, v[i].c = 0 });
        while (!q.empty()) {
            auto p = q.top(); q.pop();
            if (p.c > v[p.i].c) continue;
            for (int j = v[p.i].n; j >= 0; j = e[j].n) {
                Edge &o = e[j];
                ll c = p.c + o.c;
                if (c < v[o.i].c) q.push({ o.i, v[o.i].c = c });
            }
        }
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
};

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

    int n, m, s;
    cin >> n >> m >> s;

    int t = 2501;//持ってる銀貨の枚数の最大+1
    Graph g(n * t, m * t * 2 + n * t);
    for (int i = 0; i < m; i++) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;

        for (int j = a; j < t; j++) {
            g.add_edge(t * u + j, t * v + j - a, b);
            g.add_edge(t * v + j, t * u + j - a, b);
        }
    }

    for (int v = 0; v < n; v++) {
        int c, d;
        cin >> c >> d;

        for (int j = 0; j < t - 1; j++) {
            g.add_edge(t * v + j, t * v + min(j + c, t - 1), d);
        }
    }

    g.dijkstra(t * 0 + min(s, t - 1));

    for (int v = 1; v < n; v++) {
        ll r = Graph::INF;
        for (int j = 0; j < t; j++) {
            r = min(r, g.v[t * v + j].c);
        }
        cout << r << '\n';
    }

    //両替が必要か判定 必要ならどこの都市で両替するか全探索 50*50*50
    //必要な銀貨は高々5000枚 二分探索 違うな両替しながら進むこともある

    //銀貨を2500枚以上持ったら最短距離で目的地へ向かうのでそれ以上持つ意味はない
    //2500*50=125000を頂点数とする

    return 0;
}

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

int main()

{
   int x,k,d=0,p;
   int i,j,m,n,a[102];
   cin>>n;
   for(i=0;i<n;i++){
    cin>>a[i];
   }
   for(i=0;i<n-2;i++){
        for(p=i+1;p<n-1;p++){
           for(j=p+1;j<n;j++){
            if(a[i]!=a[p] && a[i]!=a[j] && a[p]!=a[j]){
            if(a[i]+a[p]>a[j] && a[i]+a[j]>a[p] && a[j]+a[p]>a[i]){
          d++;
        }
                }


        }

    }
   }
   cout<<d<<endl;

   return 0;


}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
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; }

string s;
ll dp[200020];
map<ll,ll>mp;

ll POW(ll x,ll n){
    ll res = 1;
    while(n>0){
        if(n&1)res=res*x%2019;
        x=x*x%2019;
        n>>=1;
    }
    return res;
}

ll solve(){
    int n = s.size();
    mp[0]++;
    dp[n]=0;
    for(int i=n-1;i>=0;i--){
        dp[i]=dp[i+1]+POW(10,n-i-1)*(s[i]-'0');
        dp[i]%=2019;
        mp[dp[i]]++;
    }
    ll ans = 0;
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        ll res = itr->second;
        res = res*(res-1)/2;
        ans += res;
    }
    return ans;
}

int main() {
    cin >> s;
    cout << solve() << endl;
    return 0;
}

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

int main () {
    long long ans= 0ll;
    int x, y, a, b, c;
    vector <int> p, q, r;
    cin >> x >> y >> a >> b >> c;
    p.resize(a);
    q.resize(b);
    r.resize(c);
    for (int& elem: p) cin >> elem;
    for (int& elem: q) cin >> elem;
    for (int& elem: r) cin >> elem;
    sort(begin(p), end(p));
    sort(begin(q), end(q));
    for (int i = 0; i < x; i++) {
        r.push_back(p[a - x + i]);
    }
    for (int i = 0; i < y; i++) {
        r.push_back(q[b - y + i]);
    }
    sort(begin(r), end(r));
    for (int i = 0; i < x + y; i++) {
        ans += r[c + i];
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 2552
#include<bits/stdc++.h>
using namespace std;
bool DFS(string q){
	if(q=="ABC")return 1;
	if(q.size()<5)return 0;
	string x="";char z='B';
	if(q.substr(0,3)=="ABC")z='A';
	if(q.substr(q.size()-3,3)=="ABC")z='C';
	int i=0;
	while(i<q.size()){
		if(q.substr(i,3)=="ABC"){x.push_back(z);i+=3;}
		else{if(q[i]==z)return 0;x.push_back(q[i]);i++;}
	}
	if(x.size()<q.size())return DFS(x);
	return 0;
}
int main(){
	string s;cin>>s;
	cout<<(DFS(s)?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 21952
#include<stdio.h>
int main ()
{
	int x,a,b;
	while(scanf("%d%d%d",&x,&a,&b)!=EOF)
	{
		if(b<=a)
			printf("delicious\n");
		else if(x>=(b-a))
			printf("safe\n");
		else
			printf("dangerous\n");
	}
} 

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct Node{
    int key;
    struct Node* per;
    struct Node* l;
    struct Node* r;
};
typedef struct Node node;
node* insert(node* px,int k);
void printI(node* x);
void printP(node* x);
node* find(node* px,int k);
void delete(node* px,int k);
node* next(node* px);

int main(void){
    int i;
    int n,k;
    node* x=NULL;
    char com[10];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",&com);
        if(strcmp(com,"insert")==0){
            scanf("%d",&k);
            x=insert(x,k);
        }else if(strcmp(com,"print")==0){
            printI(x);
            printf("\n");
            printP(x);
            printf("\n");
        }else if(strcmp(com,"find")==0){
            scanf("%d",&k);
            if(find(x,k)==NULL){
                printf("no\n");
            }else{
                printf("yes\n");
            }
        }else{
            scanf("%d",&k);
            delete(x,k);
        }
    }
    return 0;
}

node* insert(node* px,int k){
    node* x=px;
    node* y=NULL;
    node* z=(node*)malloc(sizeof(node));
    z->key=k;
    z->l=NULL;
    z->r=NULL;
    z->per=NULL;
    while(x!=NULL){
        y=x;
        if(z->key<x->key){
            x=x->l;
        }else{
            x=x->r;
        }
    }
    z->per=y;
    if(y==NULL){
        px=z;
    }else if(z->key<y->key){
        y->l=z;
    }else{
        y->r=z;
    }
    return px;
}

void printI(node* x){
    if(x->l != NULL){
        printI(x->l);
    }
    printf(" %d",x->key);
    if(x->r != NULL){
        printI(x->r);
    }
}

void printP(node* x){
    printf(" %d",x->key);
    if(x->l != NULL){
        printP(x->l);
    }
    if(x->r != NULL){
        printP(x->r);
    }
}

node* find(node* px,int k){
    while(1){
        if(px==NULL){
            return NULL;
        }
        if(px->key==k){
            return px;
        }
        if(px->key>k){
            px=px->l;
        }else{
            px=px->r;
        }
    }
}

void delete(node* px,int k){
    node* del;
    node* temp;
    int tk;
    del=find(px,k);
    if(del->l==NULL&&del->r==NULL){
        if(del->per->l==del){
            del->per->l=NULL;
        }else{
            del->per->r=NULL;
        }
        free(del);
    }else if(del->l!=NULL&&del->r==NULL){
        if(del->per->l==del){
            del->per->l=del->l;
            del->l->per=del->per;
        }else{
            del->per->r=del->l;
            del->l->per=del->per;
        }
        free(del);
    }else if(del->l==NULL&&del->r!=NULL){
        if(del->per->l==del){
            del->per->l=del->r;
            del->r->per=del->per;
        }else{
            del->per->r=del->r;
            del->r->per=del->per;
        }
        free(del);
    }else{
        tk=next(del)->key;
        delete(px,tk);
        del->key=tk;
    }
}

node* next(node* px){
    node* x;
    if(px->r!=NULL){
        px=px->r;
        while(px->l!=NULL){
            px=px->l;
        }
        return px;
    }
    x=px->per;
    while(x!=NULL&&px==x->r){
        px=x;
        x=x->per;
    }
    return x;
}

Measured memory_bytes: 19364
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
using namespace std;
using namespace __gnu_pbds;
int inf = 2e9, mod = 1e9 + 7;

typedef tree<
ii,
null_type,
less<ii>,
rb_tree_tag,
tree_order_statistics_node_update> ST;

int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(0);
    int n, k; cin >> n >> k;
    ST st;
    int sum = 0, res = 0;
    for(int i=0,a;i<=n;i++){
        if(i != 0) cin >> a;
        else a = 0;
        sum+=a;
        a = sum - (i) * k;
        res += st.order_of_key(ii(a,i));
        st.insert({a, i});
    }
    cout << res<<endl;
    return 0;
}


Measured memory_bytes: 12928
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

int main() {
    int N;
    cin >> N;
    vector<int> A(N+1, 0);
    for (int i = 0; i < N; i++) cin >> A[i];
    ll money = 1000;
    ll have = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] <= money) {
            ll buy = money/A[i];
            have += buy;
            money -= buy*A[i];
        }
        if (A[i] > A[i+1]) {
            money += have*A[i];
            have = 0;
        }
    }
    cout << money << endl;
    return 0;
}


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

ll mod = 1e9 + 7;

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

  vector<int> v(N, 0);
  rep(i, N) {
    int a;
    cin >> a;
    v[a]++;
  }

  if (N % 2 != 0 && v[0] != 1) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 1;
  for (int i = 1; i < N; i++) {
    if (v[i] == 0)
      continue;
    if (v[i] != 2) {
      ans = 0;
      break;
    }
    ans = 2 * ans % mod;
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
import collections


def solve(n, m, arr):
    totalVotes = sum(arr)

    arr.sort(reverse=True)

    for i in range(m):
        if arr[i] < (totalVotes / (4 * m)):
            return False

    return True


[n, m] = list(map(int, input().strip().split()))
arr = list(map(int, input().strip().split()))

print("Yes" if solve(n, m, arr) else "No")


Measured memory_bytes: 3316
//
// Created by Huang,Zhiqiang on 2018/6/26.
//

//
// Created by Huang,Zhiqiang on 2018/6/26.
//

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

const int max_arr = 300005;
int west[max_arr];
int east[max_arr];
int n;
string s;

int main() {
    cin >> n;
    cin >> s;
    for (int i = 0; i <= n + 1; i++) {
        west[i] = 0;
        east[i] = 0;
    }
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'W') {
            west[i + 1] = west[i] + 1;
        } else {
            west[i + 1] = west[i];
        }
    }
    for (int i = s.size() - 1; i >= 0; i--) {
        if (s[i] == 'E') {
            east[i + 1] = east[i + 2] + 1;
        } else {
            east[i + 1] = east[i + 2];
        }
    }
    int ans = INT32_MAX;
    for (int i = 1; i <= n; i++) {
        ans = min(ans, west[i] - 1 + east[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>


using namespace std;
typedef long long ll;

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; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }


constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

struct mint {
	long long x;
	mint(long long x = 0) :x((x% mod + mod) % mod) {}
	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;
	}
};

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	ll n; cin >> n;
	vector<ll> a(n); for (int i = 0; i < n; i++) cin >> a[i];
	vector<mint> sum(n + 1); for (int i = 0; i < n; i++) sum[i + 1] = sum[i] + a[i];
	mint res = 0;
	for (int i = 0; i + 1< n; i++) {
		res += (sum.back() - sum[i + 1]) * a[i];
	}
	cout << res.x << endl;
	return 0;
}

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

#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output14.txt", "w", stdout);
#endif
	//fast_cin();
	int k; cin >> k;
	int num = 0;
	for (int i = 1; i <= k; ++i) {
		num = num * 10 + 7;
		num %= k;
		//out << num << "\n";
		if (num == 0) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 3624
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

vector<string> A;
int H,W,K;

void dfs(string s){
    if(s.size()==W-1){
        A.pb(s);
        return;
    }
    dfs(s+'0');
    if(s.size()==0||s[s.size()-1]=='0'){
        dfs(s+'1');
    }
    return;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int ans=0;
    for(int i=2;i<s.size();i+=2){
        bool b=true;
        rep(j,i/2){
            if(s[j]!=s[i/2+j]){
                b=false;
            }
        }
        if(b){
            chmax(ans,i);
        }
    }
    cout << ans << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}

int main() {
    int i,n,m,k,c=0,sum=0;
    c_p_c();
    cin>>n;
    int a[n];
    fo(i,n) cin>>a[i];
    sort(a,a+n);
    for (int i = 0; i < n-1; ++i)
    {
    	/* code */
    	sum+=a[i];
    }
    sum+=a[n-1]/2;
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3624
//
//  main.cpp
//  Code Festival Relay ProblemH Akashic Records
//
//  Created by 范泽玥 on 2018/7/1.
//  Copyright © 2018年 范泽玥. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
using namespace std;
int n;
int X[320],Y[320];
int pri[7]={2,3,5,7,11,13,17};
int num[7]={9,6,4,3,3,3,3};
int cnt[7];
int  w[320];
int ans;
void dfs(int x){
    if (x==7){
        memset(w,0,sizeof(w));
        int cur=0;
        for (int i=1;i<=n;i++){
            bool flag=true;
            int u=X[i];
            int v=Y[i];
            for (int j=0;j<7;j++){
                for (int k=0;k<cnt[j];k++){
                    if (u%pri[j]==0){
                        u/=pri[j];
                    }
                    else{
                        break;
                    }
                }
                if (u%pri[j]==0){
                    flag=false;
                    break;
                }
            }
            if (!flag){
                continue;
            }
            w[u]+=v;
        }
        cur=w[1];
        for (int i=2;i<=300;i++){
            if (w[i]>0){
                cur+=w[i];
            }
        }
        ans=max(ans,cur);
    }
    else{
        for (cnt[x]=0;cnt[x]<num[x];cnt[x]++){
            dfs(x+1);
        }
    }
}
int main() {
    cin>>n;
    for (int i=1;i<=n;i++){
        cin>>X[i]>>Y[i];
    }
    dfs(0);
    cout<<ans;
    return 0;
}
/*
5
56 114834
72 -149861
100 190757
192 -132693
240 133108
*/


Measured memory_bytes: 256
# import math


def gcd(a, b):
    a = abs(a)
    b = abs(b)
    if b > a:
        return gcd(b, a)
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)

# print(make_divisor_list(24))


N, X = [int(x) for x in input().split()]
xlist = [int(x) for x in input().split()]

# print(xlist)

shiftedX = [x - X for x in xlist]

# print(shiftedX)

maxDivisor = shiftedX[0]
for n in shiftedX:
    maxDivisor = gcd(maxDivisor, n)

print(maxDivisor)


Measured memory_bytes: 14224
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

int main(){
    int n;
    cin>>n;
    int ans[100005];
    for (int i = 0;i < n; i++){
        cin>>ans[i];
    }
    int result = ans[0]-1;
    for (int i = 1;i < n;i++){
        if (result > ans[i]){
            printf("No\n");
            return 0;
        }
        else if(result != ans[i]){
            ans[i] -= 1;
        }
        result = ans[i];
    }
    printf("Yes\n");
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
signed main(){
	int N;
	cin >> N;
	if(N < 3){
		cout << 0 << endl;
		return 0;
	}
	vector<ll> L(N);
	for(int i = 0; i < N; i++){
		cin >> L.at(i);
	}
	ll count = 0;
	for(int i = 0; i < N; i++){
		for(int j = i+1; j < N; j++){
			if(L.at(i) == L.at(j))
				continue;
			for(int k = j+1; k < N; k++){
				if(L.at(j) == L.at(k) || L.at(i) == L.at(k))
					continue;
				ll sum = L.at(i)+L.at(j)+L.at(k);
				ll mx = max(L.at(i), max(L.at(j), L.at(k)));
				if(mx < sum-mx){
					count++;
				}
			}
		}
	}
 	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3628
package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	abc := strings.Split(stdin.Text(), " ")
	a, _ := strconv.Atoi(abc[0])
	b, _ := strconv.Atoi(abc[1])
	c, _ := strconv.Atoi(abc[2])

	if a < b && b < c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



Measured memory_bytes: 1088
import sys
S=list((input()))
K=(input())


if S[0]!='1':
    print(S[0])
    sys.exit()

first_non1=1
count=0
find=0
for i in range (len(S)):
    if S[i]!='1' and find==0:
        first_non1=S[i]
        count=i
        find+=1
        
if int(K)<count+1:
    print(1)
else:
    print(int(first_non1))

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

int main() {
	int n; cin >> n;
	vector<string> s(n); rep(i, 0, n) cin >> s[i];
	int m; cin >> m;
	vector<string> t(m); rep(i, 0, m) cin >> t[i];

	map<string, int> mp;
	rep(i, 0, n) mp[s[i]]++;
	rep(i, 0, m) mp[t[i]]--;
	int ans = 0;
	for (auto& x : mp) ans = max(ans, x.second);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define unique(a)  (a).erase(unique((a).begin(), (a).end()),(a).end())
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define mod 1000000007
typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
inline LL add(LL x, LL y) { x += y; if (x >= mod) x -= mod; return x; }
inline LL moduloMultiplication(LL x, LL y) {
	return (x%mod * 1LL * y%mod) %

		mod;
}
inline LL power(LL a, LL b) {
	LL x = 1 % mod;
	while (b) {
		if (b & 1) x = moduloMultiplication(x, a);
		a = moduloMultiplication(a, a);
		b >>= 1;
	}
	return x % mod;
}
inline LL inv(LL a) { return power(a, mod - 2) % mod; }
LL gcd(LL a, LL b)
{
	if (!a)
		return b % mod;
	return gcd(b%a, a) % mod;
}
int main()
{
	
	int n, k;
	cin >> n >> k;
	if (n >= 10) {
		cout << k << endl;
	}
	else
	{
		cout << k + 100 * (10 - n) << endl;
	}


}




Measured memory_bytes: 256
N = int(input())
a = tuple(int(x) for x in input().split())

def hoge(n, r):
 return n * (min(n-r, r))

n = max(a)
ans = (n, a[0]) if n != a[0] else (n, a[1])
for i in a:
 if n == i: continue
 ans = (n, i) if hoge(*ans) < hoge(n, i) else ans
print(*ans)


Measured memory_bytes: 14180
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int g = sc.nextInt();
    int b = sc.nextInt();
    int K = sc.nextInt();
    
    for(int i=0;i<K;i++){
      if(r>=g){
        g+=g;
      } else if(g>=b){
        b+=b;
      } else if(r<g && g<b){
        break;
      }
    }
    
    if(r<g && g<b){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35728
#![allow(unused_imports)]
#![allow(non_snake_case)]
#![allow(dead_code)]
use proconio::{input, fastout};
use proconio::marker::{Chars, Bytes, Usize1};

struct FenwikTree {
    size: usize,
    depth: usize,
    tree: Vec<i64>
}

impl FenwikTree {
    fn new(n: usize) -> Self {
        let size = n;
        let mut v = size;
        let mut tmp = 0;
        while v > 0 {
            tmp += 1;
            v >>= 1
        }
        let depth = tmp;
        let tree = vec![0; size + 1];

        FenwikTree {
            size, depth, tree
        }
    }

    fn _bitsum(&self, mut i: usize) -> i64 {
        let mut ret = 0;
        while i > 0 {
            ret += self.tree[i];
            i ^= i & (1 + !i);
        }
        ret
    }

    fn bitsum(&self, l:usize, r:usize) -> i64 {
        self._bitsum(r) - self._bitsum(l)
    }

    fn bitadd(&mut self, mut i:usize, x:i64) {
        i += 1;
        while i <= self.size {
            self.tree[i] += x;
            i += i & (1 + !i);
        }
    }

    fn lower_bound(&self, x:i64) -> usize {
        let mut _sum: i64 = 0;
        let mut pos: usize = 0;
        let mut v: usize = 1 << self.depth;
        for _ in (0..self.depth).rev() {
            let k = pos + v;
            if k <= self.size && _sum + self.tree[k] < x {
                _sum += self.tree[k];
                pos = k;
            }
            v >>= 1;
        }
        pos + 1
    }
}

#[fastout]
fn main() {
    input!{
        n: usize, q:usize,
        c: [Usize1; n],
        query: [(usize, usize); q]
    }
    let mut last = vec![n; n];
    let mut g = query.iter().enumerate().collect::<Vec<_>>();
    g.sort_by_cached_key(|(_, &(_, z))| z);
    let mut idx = 0;
    let mut ans = vec![0; q];
    let mut bit = FenwikTree::new(n);
    for &(i, &(l, r)) in &g {
        // println!("{} {} {}", i, l, r);
        while idx < r {
            if last[c[idx]] < n {
                bit.bitadd(last[c[idx]], -1);
            }
            last[c[idx]] = idx;
            bit.bitadd(idx, 1);
            idx += 1;
        }
        ans[i] = bit.bitsum(l-1, r);
    }
    println!("{}", ans.iter().map(|x| x.to_string()).collect::<Vec<_>>().join("\n"));
}


Measured memory_bytes: 75520
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <cassert>
#include <map>
using namespace std;
#define ll long long
#define ui unsigned int
const double EPS = 1e-10;

bool asc(ui left,ui right) {
    return left > right;
}


int main(){
  ll n,ans;
  ans=0;
  cin>>n;
  vector<ui> a(n,0);
  for(ll i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end(),asc);
  vector<int> b(n,0);
  map<ui,vector<int>> mp;
  int q,w;
  for(int i=0;i<n;i++){
    vector<int>v;
    v.push_back(i);
    for(q=1;q+i<n&&a[i+q]==a[i];q++){
      v.push_back(i+q);
    }
    reverse(v.begin(),v.end());
    mp.insert(make_pair(a[i],v));
    i+=q-1;
  }
  for(ll i=0;i<n;i++){
    if(b[i]==1) continue;
    b[i]=1;
    mp.find(a[i])->second.pop_back();
    int j;
    for(j=30;j>=0;j--){
      if(a[i]&(1<<j)) break;
    }
    ui x=(1<<(j+1))-a[i];
    auto itr=mp.find(x);
    if(itr!=mp.end()&&itr->second.size()>0){
      b[itr->second[itr->second.size()-1]]=1;
      itr->second.pop_back();
      ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 23680
n = int(input())
L = sorted(list(map(int, input().split())))
def isOK(target,a,b):
  return target < a+b

def bin_search(a,b):
  left = 1
  right = n
  while abs(right-left)>1:
    mid = (left+right)//2
    if isOK(L[mid],a,b):
      left = mid
    else:
      right = mid
  return left
ans = 0
for i in range(n-2):
  for j in range(i+1,n):
    a,b = L[i],L[j]
    ans += max(0, bin_search(a,b) - j)
      
print(ans)



Measured memory_bytes: 48236
from bisect import bisect_left
from collections import Counter
from sys import stdin
N = int(stdin.readline().rstrip())
S = [int(_) for _ in stdin.readline().rstrip().split()]
S.sort()
Q = int(stdin.readline().rstrip())
T = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0

def bisect_search(l, x):
    i = bisect_left(l, x)
    if i != len(l) and l[i] == x:
        return True
    return False

for i in T:
    if bisect_search(S, i):
        ans += 1
print(ans)


Measured memory_bytes: 16592
/******************************************
* AUTHOR : AMAN SAXENA *
* "There's some good in this world, and it's worth fighting for." *
* INSTITUTION : KIET Group of Institutions *
******************************************/
#include <bits/stdc++.h>

const long long MODULO=1000000007;
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define FOR1(i,a,n) for(int i=a;i<=n;i++)
#define FOR2(i,a,n) for(int i=a;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ll long long 
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pi 3.14159265359

using namespace std;

template <typename TYPE> void in(TYPE &x){cin>>x;}

void solve()
{
    ll n;
    cin >> n;
    ll c = 1000;
    while(c<n)
    {
        c += 1000;
    }
    cout <<  c-n << '\n';
}

void test()
{
    int t;
    cin>>t;
    while(t--) //for(int j=1;j<=t;j++) cout << "Case #" << j << ": ";
    {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    // test();
    solve();
    
    return 0;
}

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

int main(){
	int n,num[10001]={0};
	while(cin >> n && n){
		for(int i=0;i<n;i++){
			cin >> num[i];
		}
		int ans = 0;
		for(int i=0;i<n;i++){
			for(int j=1;j<=3;j++){
				int sum=0;
				if(num[i]!=j){
					int cou = 1;
					int head=i-1;
					while(head >= 0 && num[head] == j){
						cou++; head--;
					}
					int tail=i+1;
					while(tail < n && num[tail] == j){
						cou++; tail++;
					}
					if(cou >= 4){
						sum += cou;
						bool flg = true;
						while(flg && head >= 0 && tail < n && num[head] == num[tail]){
							int co = num[head];
							int cnt = 2;
							head--; tail++;
							while(head >= 0 && num[head] == co){
								cnt++; head--;
							}
							while(tail < n && num[tail] == co){
								cnt++; tail++;
							}
							if(cnt >= 4) sum += cnt;
							else flg = false;
						}
					}
					ans = max(ans,sum);
				}
			}
		}
		cout << n-ans << endl;
	}
}

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

int main(){
  int a,b;
  cin >> a >> b;
  int n;
  int count=0;
  if(b<=9){
    n=10*a+b;
  }
  else if (b<=99){
    n=100*a+b;
  }
  else{
    n=1000*a+b;
  }
  for(int i=1;i<1000;i++){
    if(i*i==n){
      count++;
    }
  }
  if(count==1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256