akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 1e5+5;
ll inp[lim],ans[lim];

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

	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>inp[i];

	ll sum = 0;
	for(int i=1;i<=n;i++) {
		if(i%2==1)
			sum += inp[i];
		else
			sum -= inp[i];
	}

	ans[1] = sum/2;
	for(int i=1;i<n;i++)
		ans[i+1] = inp[i]-ans[i];
	
	for(int i=1;i<=n;i++)
		cout<<2*ans[i]<<' ';

	return 0;
}

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

int n,t,m[1000],l[1000],k[1000];

bool check(int x){
  int c[1001]={},used[1000]={},cnt=0;
  for(int i=0;i<t;i++){
    x+=c[i];
    for(int j=0;j<n&&x;j++){
      if(used[j])continue;
      if(i+m[j]>t)return 0;
      if(i%(l[j]+k[j])<=l[j])c[i+m[j]]++,cnt++,used[j]=1,x--;
    }
  }
  return cnt==n;
}

int main(){
  while(scanf("%d%d",&n,&t),n){
    for(int i=0;i<n;i++)scanf("%d%d%d",&m[i],&l[i],&k[i]);
    int ans=0;
    for(int i=1;i<=n&&!ans;i++)if(check(i))ans=i;
    cout<<ans<<endl;
  }
  return 0;
}

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

int power(int x, int n){
  int64_t x_mod[32]; x_mod[0] = x%1000000007;
  rep(i, 31) x_mod[i+1] = (x_mod[i]*x_mod[i])%1000000007;
  bitset<32> bit(n);
  int64_t ans = 1;
  rep(i, 32) if(bit.test(i)) ans = (ans*x_mod[i])%1000000007;
  return ans;
}

int combination(int a, int b){
  int64_t m=1, n=1;
  rep(i, b) {
    m *= a-i; m %= 1000000007;
    n *= i+1; n %= 1000000007;
  }
  n = power(n, 1000000005);
  int ans = (m*n) % 1000000007;
  return ans;
}

int main(){
  int n, a, b; cin >> n >> a >> b;
  int64_t all, nCa, nCb;
  all = power(2, n) - 1; 
  nCa = combination(n, a);
  nCb = combination(n, b);
  int64_t ans = (all - nCa - nCb + 1000000007*2)%1000000007;
  cout << ans << endl;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    while(1){
        int h,w;
        cin>>h>>w;
        if(h==0&&w==0) break;
        cout<<'#';
            rep(j,w-2){
                cout<<"#";
            }
            cout<<'#';
            cout<<endl;
        rep(i,h-2){
            cout<<'#';
            rep(j,w-2){
                cout<<".";
            }
            cout<<'#';
            cout<<endl;
        }
        cout<<'#';
            rep(j,w-2){
                cout<<"#";
            }
            cout<<'#';
            cout<<endl;
        cout<<endl;
    }

}


Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
#include<stdio.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

bool isOK(int a[],int index,int key){
    if(a[index] >= key){
        return true;
    }else{
        return false;
    }
}

int binary_search(int a[],int n,int key){
    int left = -1;
    int right = n;

    while(right-left>1){
        int mid = left + (right - left)/2;
        if(isOK(a,mid,key)){
            right = mid;
        }else{
            left = mid;
        }
    }
    return right;
}



int main(void){
    int s,w;
    cin >> s >>w;
    if(s<=w){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Ti4 tuple<int, int, int, int>
#define Tlll tuple<ll, ll, ll>
#define PI 3.141592653589793

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) return 0;
        
        bool jew[21][21] = {};
        for (int i = 0; i < n; i++) {
            int x, y;  cin >> x >> y;
            jew[x][y] = 1;
        }
        int m, d[35];
        char c[35];
        cin >> m;
        for (int i = 0; i < m; i++) {
            cin >> c[i] >> d[i];
        }

        bool yes = 0;
        bool jew2[21][21] = {};
        int tx = 10, ty = 10, cnt = 0;
        if (jew[tx][ty] && !jew2[tx][ty]) {
            jew2[tx][ty] = 1;
            cnt++;
        }
        for (int i = 0; i < m; i++) {
            int dx = 0, dy = 0;
            bool ok = 1;
            if (c[i] == 'N') dy = 1;
            if (c[i] == 'E') dx = 1;
            if (c[i] == 'W') dx = -1;
            if (c[i] == 'S') dy = -1;

            for (int j = 0; j < d[i]; j++) {
                tx += dx;  ty += dy;
                if (jew[tx][ty] && !jew2[tx][ty]) {
                    jew2[tx][ty] = 1;
                    cnt++;
                }
            }
        }
        cout << (cnt == n ? "Yes" : "No") << endl;
    }
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << setprecision(16);
    int a,b,c,d; cin >> a >> b >> c >> d;
    int w = c-a, h = d-b;
    rep(i,h) cout << "U"; rep(i,w) cout << "R"; rep(i,h) cout << "D"; rep(i,w+1) cout << "L";
    rep(i,h+1) cout << "U"; rep(i,w+1) cout << "R";
    cout << "DR";
    rep(i,h+1) cout << "D"; rep(i,w+1) cout << "L";
    cout << "U" << endl;
    return 0;
}


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

struct P {
    ll X;
    ll L;

    bool operator<(const P &another) const {
        return X < another.X;
    };
};

int main() {
    ll N;
    cin >> N;
    vector<P> A(N);
    rep(i, N) cin >> A[i].X >> A[i].L;
    sort(all(A));

		// rep(i,N) cout << A[i].X << " " << A[i].L << endl;

    ll delc = 0;
    P b      = A[0];
    for (int i = 1; i < N; i++) {
        if (b.X + b.L > A[i].X - A[i].L) {
            delc++;
            if (b.X + b.L > A[i].X + A[i].L) {
                b = A[i];
            }
        } else {
					b = A[i];
				}
    }
    cout << N-delc << endl;
}

Measured memory_bytes: 1920
#include<stdio.h>
#include<assert.h>
#include<math.h>
#include<string.h>
int stack[110];
int top = 0;

void push(int v){ stack[top++] = v; }
int  pop(){ return stack[--top]; }
int getInt(char *s)
{
  int i,ret=0;
  int size = strlen(s);
  for(i=0;i<size;i++)
    {
      ret += (s[i]-'0')*pow(10,size-i-1);
    }
  return ret;
}

int main()
{
  char s[1000];
  while(scanf("%s",s)!=EOF)
    {
      if('0' <= s[0] && s[0] <= '9')
	{
	  int v = getInt(s);
	  push(v);
	  continue;
	}
	  int a,b;
	  b = pop();
	  a = pop();
	  if(s[0] == '+')
	      push(a+b);
	  else if(s[0] == '-')
	    push(a-b);
	  else if(s[0] == '*')
	    push(a*b);
	  else 
	    assert(0);
    }
  printf("%d\n",pop());
  return 0;
}



Measured memory_bytes: 2100
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var hw = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var a = Enumerable.Repeat(0, hw[0]).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
        List<int[]> ops = new List<int[]>();
        for (int i = 0; i < hw[0]; i++)
        {
            for (int j = 0; j < hw[1] - 1; j++)
            {
                if (a[i][j] % 2 == 1)
                {
                    ops.Add(new int[] { i + 1, j + 1, i + 1, j + 2 });
                    a[i][j]--;
                    a[i][j + 1]++;
                }
            }
            if (i != hw[0] - 1 && a[i][hw[1] - 1] % 2 == 1)
            {
                ops.Add(new int[] { i + 1, hw[1], i + 2, hw[1] });
                a[i][hw[1] - 1]--;
                a[i + 1][hw[1] - 1]++;
            }
        }
        Console.WriteLine(ops.Count);
        Console.WriteLine(string.Join("\n", ops.Select(x => string.Join(" ", x))));
    }
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  ll a[n], b[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  vector<ll> pl, mi;
  ll mii = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] > b[i]) {
      pl.push_back(a[i] - b[i]);
    }
    if (a[i] < b[i]) {
      mi.push_back(b[i] - a[i]);
      mii += b[i] - a[i];
    }
  }
  sort(pl.rbegin(), pl.rend());
  int ans = 0;
  for (int i = 0; i < pl.size(); i++) {
    if (mii <= 0) break;
    mii -= pl[i];
    ans++;
  }
  if (mii > 0) {
    cout << -1 << endl;
  } else {
    cout << ans + mi.size() << endl;
  }
  return 0;
}


Measured memory_bytes: 2812
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  string s;cin>>s;
  s+="./+*-";
  for(int i=0;i<s.size();i++){
    if(s[i]==s[i+1]){
      cout<<i+1<<" "<<i+2<<endl;
      return 0;
    }
    if(s[i]==s[i+2]){
      cout<<i+1<<" "<<i+3<<endl;
      return 0;
    }
  }
  cout<<-1<<" "<<-1<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, x;
  cin >> n >> x;
  int a[n], ans = 0;
  for(int i=0; i<n; ++i) cin >> a[i];
  sort(a, a+n);
  for(int i=0; i<n; ++i){
    if(x < a[i]) break;
    ++ans;
    x -= a[i];
  }
  if(ans == n && x) --ans;
  cout << ans << endl;
}

Measured memory_bytes: 3608
def main():
    from sys import exit

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

    result = 0
    q = [i for i in range(N) if B[i] != A[i]]
    while len(q) != 0:
        nq = []
        c = 0
        for i in q:
            if i == 0 or i == N - 1:
                j = B[(N + i - 1) % N] + B[(N + i + 1) % N]
            else:
                j = B[i - 1] + B[i + 1]
            if j > B[i] - A[i]:
                nq.append(i)
                continue
            c += 1
            k = (B[i] - A[i]) // j
            result += k
            B[i] -= j * k
            if A[i] != B[i]:
                nq.append(i)
        if c == 0 and len(nq) != 0:
            print(-1)
            exit()
        q = nq
    print(result)


main()


Measured memory_bytes: 33752
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<functional>
#include<string>
#include<stdlib.h>

using namespace std;
typedef pair<int, int> Pi;
typedef pair<int, Pi> Ti;
const int INF = 10000000;

int m, n, k, d;
int cake_cal[6];
vector<vector<Pi>> edge;
//home := 0 cake_shop := 1 ~ m landmark := m+1 ~ m+n city_holl := m+n+1

int djk(int s, int g) {
	int d[128][1 << 6];//d[i][j] i:= Node j:= Visited node's memo by bits 
	for (int i = 0; i < m + n + 2; i++)for (int j = 0; j < (1 << 6); j++)d[i][j] = INF;
	d[s][0] = 0;
	priority_queue<Ti, vector<Ti>, greater<Ti>> pq;//cost Node bit
	pq.push(make_pair(0, make_pair(s, 0)));
	while (pq.size()) {
		Ti tmp = pq.top(); pq.pop();
		int N = tmp.second.first, bit = tmp.second.second;
		if (d[N][bit] < tmp.first)continue;
		for (int i = 0; i < edge[N].size(); i++) {
			int to = edge[N][i].first, cost = edge[N][i].second;
			if (to >= 1 && to <= m) {
				//??±???????±?????????°
				if ((bit >> (to - 1)) & 1)continue;//?????§????????£??????????????°
				if (d[to][bit | 1 << (to - 1)] > d[N][bit] + cost - cake_cal[to - 1]) {
					//??????????????¨???????????????????????§??????????????§???????????????
					d[to][bit | 1 << (to - 1)] = d[N][bit] + cost - cake_cal[to - 1];
					pq.push(make_pair(d[to][bit | 1 << (to - 1)],
						make_pair(to, bit | 1 << (to - 1))
					));
				}
			}
			else {
				//??????????????????????????°
				if (d[to][bit] > d[N][bit] + cost) {
					d[to][bit] = d[N][bit] + cost;
					pq.push(make_pair(d[to][bit], make_pair(to, bit)));
				}
			}
		}
	}
	int res = INF;
	for (int i = 0; i < (1 << 6); i++)res = min(res, d[g][i]);
	return res;
}

int conv(const char *s1){
	if (s1[0] == 'H') return (0);
	if (s1[0] == 'D') return (m + n + 1);
	if (s1[0] == 'C') return (atoi(s1 + 1));
	return (atoi(s1 + 1) + m);
}


int main() {
	while (cin >> m >> n >> k >> d, m + m + k + d) {
		for (int i = 0; i < m; i++)cin >> cake_cal[i];
		edge.resize(2 + m + n);
		//??±?????????????????????????????????????????±???????±????????????????
		for (int i = 0; i < d; i++) {
			string s1, s2; int cost;
			cin >> s1 >> s2 >> cost;
			edge[conv(s1.c_str())].push_back(make_pair(conv(s2.c_str()), cost * k));
			edge[conv(s2.c_str())].push_back(make_pair(conv(s1.c_str()), cost * k));
		}
		cout << djk(0, m + n + 1) << endl;
		edge.clear();
	}
	return 0;
}

Measured memory_bytes: 3332
#include <bits/stdc++.h>
#include <iostream>
#include <vector>

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

using namespace std;

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

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

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<int>;
using vvi = vc<vi>;

using ll = long long;

int main() {
    cout << setprecision(20) << fixed;
    string str;
    long double x_1, y_1, x_2, y_2;
    cin >> x_1 >> y_1 >> x_2 >> y_2;

    cout << sqrt((x_1 - x_2) * (x_1 - x_2) + (y_1 - y_2) * (y_1 - y_2)) << "\n";
    return 0;
}



Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
int n,cnt=0,mn=1e9;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		mn=min(mn,x);
		if(mn>=x)
		{
			++cnt;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
	string s;
	cin >> s;

	if (s.length() % 2 == 1) {
		cout << "No";
		return 0;
	}

	for (int i = 0; i < s.length()-1; i+=2) {
		if (s[i] == 'h'&&s[i + 1] == 'i') {
		}
		else {
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";

	return 0;
}

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

ll inf=9223372036854775806,ans=0;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,m,x,i,a[101]={0},t,s1=0,s2=0;
	cin>>n>>m>>x;
	for (i=0;i<m;i++){
		cin>>t;
		a[t]++;
	}
	for (i=x;i<n;i++){
		s1+=a[i];
	}
	for (i=x;i>=0;i--){
		s2+=a[i];
	}
	cout<<min(s1,s2);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;


int main(){
 ll n,k; cin>>n>>k ;
 string s ;cin>>s ;
 ll cnt= 0;
 rep(i,n-1){
     if(s[i]!=s[i+1] ) cnt++ ;
 }
 cout<< min(n-1,n-1-cnt+2*k) <<endl ;
 return 0 ; 
}

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

int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i)
   {
     cin>>a[i];
   } 
   reverse(a.begin(), a.end());
   cout<<a[0];
   for (int i = 1; i < n; ++i)
   {
     cout<<" "<<a[i];
   }
   cout<<endl;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
int dp[105][4][2];
int main(){
    string s;cin >> s;
    int K;cin >> K;
    int n=s.size();
    for(int i=0; i<105; i++){
        for(int j=0; j<4; j++){
            for(int k=0; k<2; k++){
                dp[i][j][k]=0;
            }
        }
    }
    dp[0][0][0]=1;
    for(int i=0; i<n; i++){
        for(int j=0; j<=K; j++){
            for(int k=0; k<=1; k++){
                int nd=s[i]-'0';
                for(int d=0; d<10; d++){
                    int ni=i+1,nj=j,nk=k;
                    if(d!=0) nj++;
                    if(nj>K) continue;
                    if(k==0){
                        if(d>nd) continue;
                        if(d<nd) nk=1;
                    }
                    dp[ni][nj][nk]+=dp[i][j][k];
                }
            }
        }
    }
    int ans=dp[n][K][0]+dp[n][K][1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

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...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n, x, t; cin >> n >> x >> t;
	cout << ((n + x - 1) / x)*t;

	return 0;
}

Measured memory_bytes: 3152
//
// Created by 李青坪 on 2019/1/17.
//

#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>

#define MAXN 1400
#define NIL -1
using namespace std;

int H, W;
int c[MAXN][MAXN];
int s[MAXN][MAXN];

int square() {
    int maxS = 0;
    for (int i = 0; i < H; ++i) {
        s[i][0] = c[i][0] == 1 ? 0 : 1;
        if (c[i][0] == 0) maxS = 1;
    }
    for (int j = 0; j < W; ++j) {
        s[0][j] = c[0][j] == 1 ? 0 : 1;
        if (c[0][j] == 0) maxS = 1;
    }
    for (int i = 1; i < H; ++i) {
        for (int j = 1; j < W; ++j) {
            if (c[i][j] == 1){
                s[i][j] = 0;
            } else{
                s[i][j] = min(s[i-1][j-1], min(s[i-1][j], s[i][j-1])) + 1;
                maxS = max(maxS, s[i][j]);
            }
        }
    }
    return maxS * maxS;
}

int main() {
    scanf("%d %d", &H, &W);
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            scanf("%d", &c[i][j]);
        }
    }
    printf("%d\n", square());
}


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

int main(){
	int l,a,b,c,d;
	cin >> l >> a >> b >> c >> d;
	cout << l - max(ceil((double)a / (double)c),ceil((double)b / (double)d)) << endl;
	return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int man=100005;
const int MAXM= 15000005;
int n,m;
int a[505][505];
struct node
{
	int x,y,x1,y1;
	node(int x,int y,int a,int b):x(x),y(y),x1(a),y1(b) {
	}
};
vector<node> p;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin>>n>>m;
  for(int i=0;i<n;i++)
   for(int j=0;j<m;j++)
      cin>>a[i][j];
  for(int i=0;i<n-1;i++)
  {
  	  for(int j=0;j<m;j++)
  	  {
  	     if(a[i][j]&1)
		 {
		   	a[i][j]--;
		   	a[i+1][j]++;
		   	p.push_back(node(i+1,j+1,i+2,j+1));
		 } 
	  }
  }
  for(int i=0;i<m-1;i++)
  {
  	if(a[n-1][i]&1)
  	{
  		a[n-1][i]--;
  		a[n-1][i+1]++;
  		p.push_back(node(n,i+1,n,i+2));
	}
  }
  cout<<p.size()<<endl;
  for(int i=0;i<p.size();i++)
  {
  	cout<<p[i].x<<" "<<p[i].y<<" "<<p[i].x1<<" "<<p[i].y1<<endl;
  }
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  string b;
  cin >> a >> b;
  int c = a.size();
  int d = b.size();
  string m ="zzzzzzzzzzz" ;
  for(int i = 0;i < c-d+1;++i){
    string z = a;
    int x = 0;
    for(int j = 0;j < d ;++j){
      if(z.at(i+j) == '?'){z.at(i+j) = b.at(j);}
      if(z.at(i+j) != b.at(j)){x = 1;}
         }
         for(int j = 0;j < c;j++){
           if(z.at(j) == '?'){z.at(j) = 'a';}
         }
         if(z < m && x == 0){m = z;}
         }
         if(m == "zzzzzzzzzzz"){
           m ="UNRESTORABLE";}
         cout << m << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, i ;
	
	for (i=1; i<=3000; i++){
	
	scanf("%d%d",&a ,&b);
	if (a == 0 && b == 0) break;
	
	if (a < b) printf("%d %d\n", a, b);
	else printf("%d %d\n", b, a);
	
	
	}


	return 0;
	
}




Measured memory_bytes: 2020
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use proconio::marker::{Bytes, Chars};
use std::collections::*;

fn main() {
    input! {
        n:usize,
        a:[usize;n],
    }
    let ans = a
        .iter()
        .enumerate()
        .filter(|(i, &x)| (i + 1) % 2 == 1 && x % 2 == 1)
        .count();
    println!("{}", ans);
}

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

typedef long long ll;

int main(){
    ll N,K,ans;
    cin>>N>>K;

    if(N % K == 0) ans = 0;
    else if(2*N < K) ans = N;
    else{
        ll tmp = N/K+1;
        K *= tmp;
        ans = abs(K-N);
    }

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

Measured memory_bytes: 256
import sys
s = list(input())

if s[0] != "A":
    print("WA"); sys.exit()
else:
    s[0] = "a"
    
if "C" in s[2:-1]:
    s[s[2:-1].index("C") + 2] = "c"
else:
    print("WA"); sys.exit()

if all([i.islower() for i in s]):
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064
#include<bits/stdc++.h>//万能头文件
using namespace std;
int c[1000001];//字符数组
int main() 
{
    int k;
    cin>>k;//记录初始字符串的字符数量
    for(int i=1;i<=k;i++)cin>>c[i];//读入字符串
    sort(c+1,c+1+k);//去重之前必须排序
    int n=unique(c+1,c+1+k)-c-1;//去重，n记录去重后字符串的字符数量
    n==k ? cout<<"YES"<<endl : cout<<"NO"<<endl;//岛国题库输出要换行
    //判断去重后数组里的元素是否减少，没有输出yes，反之输出no，
    return 0;//结束
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define INF 0x7f7f7f7f
using namespace std;
int n,K,cnt,w[101010],l[101010],r[101010];
int nxt[202020],to[202020],fir[101010];
int d[100010];
void add(int x,int y)
{
	nxt[++cnt]=fir[x];fir[x]=cnt;
	to[cnt]=y;
}
void print()
{
	puts("No");
	exit(0);
}
void dfs(int x,int fa)
{
	if(w[x]!=-1) 
	{
		l[x]=max(l[x],w[x]),r[x]=min(r[x],w[x]);
		if(d[x]==-1||d[x]==(w[x]&1)) d[x]=(w[x]&1);
		else print();
	}
	for(int i=fir[x];i;i=nxt[i])
	if(to[i]!=fa)
	{
		if(r[x]!=INF)
		{
			l[to[i]]=max(l[to[i]],l[x]-1);
			r[to[i]]=min(r[to[i]],r[x]+1);
		}
		if(d[x]!=-1)
		{
			if(d[to[i]]==-1||d[to[i]]==(d[x]^1)) d[to[i]]=d[x]^1;
			else print();
		}
		dfs(to[i],x);
		if(r[to[i]]!=INF)
		{
			l[x]=max(l[to[i]]-1,l[x]);
			r[x]=min(r[to[i]]+1,r[x]);
			if(d[to[i]]!=-1)
			{
				if(d[x]==-1||d[x]==(d[to[i]]^1)) d[x]=(d[to[i]]^1);
				else print();
			}
		}
	}
	if(l[x]>r[x]) print();
}
int main()
{
	//freopen("1.in","r",stdin);
	//freopen("1.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);add(y,x);
	}
	memset(d,-1,sizeof(d));
	memset(w,-1,sizeof(w));
	memset(l,-0x7f,sizeof(l));
	memset(r,0x7f,sizeof(r));
	scanf("%d",&K);
	for(int i=1;i<=K;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		w[x]=y;
	}
	dfs(1,0);
	dfs(1,0);
	puts("Yes");
	for(int i=1;i<=n;i++)
	printf("%d\n",l[i]);
	return 0;
}

Measured memory_bytes: 9088
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n = sc.nextInt();
//        int k = sc.nextInt();
        int d[]=sc.nextIntArray(n);
        int mx=-1,ans=0;
        for (int i = 0; i < d.length; i++) {
        	if(mx<=d[i])ans++;
        	mx=max(mx,d[i]);
		}

               
        out.println(ans);
        out.flush();
    }

    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int id,T;
//    P(int id, int T) {
//        this.id=id;
//        this.T=T;
//    }
//    public int compareTo(P p){
//        return id-p.id; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long[] nextLongArray(int size) throws IOException{
    	long r[] = new long[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextLong(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

int main() {
    int N;
    cin >> N;
    vector<vector<int>>A(2,vector<int>(N));
    for (int i = 0; i < 2; i++) {
        for(int j = 0; j < N; j++) {
            cin >> A[i][j];
        }       
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int cnt = 0;
        for(int j = 0; j < N; j++) {
            if(i <= j) {
                cnt+=A[1][j];
            }
            if(i >= j) {
                cnt+=A[0][j];
            }
        }
        ans = max(ans,cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from collections import defaultdict as dd
x,n=map(int, input().split())
ar=list(map(int,input().split()))
d=dd(int)
for i in ar:
    d[i]=1
low,high=0,0
for i in range(x,-2,-1):
    if d[i]==0:
        low=i
        break
for i in range(x,102):
    if d[i]==0:
        high=i
        break    
if high-x<x-low: print(high)
else: print(low)


Measured memory_bytes: 64856
#include <bits/stdc++.h>
using namespace std;
template<class T> void chmax(T &a, T b) { if (a < b) a = b; }

int count_and_compress (vector<long long> &a) {
    vector<long long> b = a;
    sort(b.begin(), b.end());
    b.erase(unique(b.begin(), b.end()), b.end());
    for (auto& e : a) e = (lower_bound(b.begin(), b.end(), e) - b.begin());
    return b.size();
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<long long> t(n), d(n);
    for (int i = 0; i < n; i++) cin >> t[i] >> d[i];
    
    int sz = count_and_compress(t);
    vector<vector<long long>> g(sz);
    for (int i = 0; i < n; i++) g[t[i]].push_back(d[i]);
    for (auto &v : g) sort(v.begin(), v.end(), greater<long long>());
    
    vector<long long> f(1, 0), s(1, 0);
    for (int i = 0; i < sz; i++) {
        for (int j = 0; j < g[i].size(); j++) {
            if (j) s.emplace_back(g[i][j]);
            else  f.emplace_back(g[i][j]);
        }
    }
    
    long long ans = 0;
    int fs = f.size(), ss = s.size();
    sort(f.begin()+1, f.end(), greater<long long>());
    sort(s.begin()+1, s.end(), greater<long long>());
    for (int i = 0; i+1 < fs; i++) f[i+1] += f[i] + (2*i+1);
    for (int i = 0; i+1 < ss; i++) s[i+1] += s[i];
    
    for (int i = 1, j = k-1; i <= k; i++, j--) {
        if (i < fs and j < ss) chmax(ans, f[i]+s[j]);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9072
def ceil(x, y):
  return (x -1) // y + 1

N, H = map(int, input().split())
A = []
B = []
for _ in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)

maxA = max(A)

# max(打撃ダメージ) <= 投げるダメージ　はすべて投げる。
# そのあとはmax(打撃ダメージ)で何回攻撃するかを計算する。
cnt = 0
B.sort(reverse=True)
for i in B:
  if i >= maxA and H > 0:
    H -= i
    cnt += 1
  else:
    break
if H > 0:
  cnt += ceil(H, maxA)
print(cnt)


Measured memory_bytes: 11372
#include <bits/stdc++.h>
using namespace std;
int INF = 100000000;
vector<int> dy = {1, 0, -1, 0};
vector<int> dx = {0, 1, 0, -1};
int main(){
  int H, W;
  cin >> H >> W;
  int Ch, Cw;
  cin >> Ch >> Cw;
  Ch++;
  Cw++;
  int Dh, Dw;
  cin >> Dh >> Dw;
  Dh++;
  Dw++;
  vector<vector<char>> S(H + 4, vector<char>(W + 4, '#'));
  for (int i = 2; i <= H + 1; i++){
    for (int j = 2; j <= W + 1; j++){
      cin >> S[i][j];
    }
  }
  vector<vector<int>> d(H + 4, vector<int>(W + 4, INF));
  deque<tuple<int, int, int>> dq;
  dq.push_back(make_tuple(0, Ch, Cw));
  while (!dq.empty()){
    int c = get<0>(dq.front());
    int y = get<1>(dq.front());
    int x = get<2>(dq.front());
    dq.pop_front();
    if (d[y][x] == INF){
      d[y][x] = c;
      for (int i = 0; i < 4; i++){
        int y2 = y + dy[i];
        int x2 = x + dx[i];
        if (d[y2][x2] == INF && S[y2][x2] == '.'){
          dq.push_front(make_tuple(c, y2, x2));
        }
      }
      for (int y2 = y - 2; y2 <= y + 2; y2++){
        for (int x2 = x - 2; x2 <= x + 2; x2++){
          if (d[y2][x2] == INF && S[y2][x2] == '.'){
            dq.push_back(make_tuple(c + 1, y2, x2));
          }
        }
      }
    }
  }
  if (d[Dh][Dw] == INF){
    cout << -1 << endl;
  } else {
    cout << d[Dh][Dw] << endl;
  }
}

Measured memory_bytes: 8996
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
#include<list>

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

using namespace std;
typedef long long ll;

int d(ll num) { //桁を数える
	int cnt = 0; //0桁
	while (num > 0) {
		num /= 10;
		cnt++; //10で割れるなら+1桁
	}
	return cnt;
}

int main() {
	ll n;
	cin >> n;
	int ans = d(n); //桁の最大値
	for(ll a = 1LL; a * a <= n; a++) { //O(√n)
		if (n % a == 0) {
			ll b = n / a; //a*b=n
			int dma = max(d(a), d(b)); //桁が大きい方を返す
			ans = min(ans, dma); //f(a, b)で最小のもの
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io;
fn main() {
  let stdin = io::stdin();
  let mut buf = String::new();
  stdin
    .read_line(&mut buf)
    .expect("ERROR");
  let n: i64 = buf.trim().parse().unwrap();
  buf = String::new();
  stdin
    .read_line(&mut buf)
    .expect("ERROR");
  //println!("{}",buf);
  let k: i64 = buf.trim().parse().unwrap();

  let mut ans = 1;

  for i in 0..n {
    if ans > k {
      ans = ans + k;
    } else {
      ans = ans + ans;
    }
    //println!("{}",ans);
  }

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


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define endl enjoy_codeforces
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::string s;std::cin>>s;
    int k;std::cin>>k;
    for(char&c:s){
        if(c!='a'&&'z'<c+k)k-='z'-c+1,c='a';
    }
    s.back()=(s.back()-'a'+k)%26+'a';
    std::cout<<s<<'\n';
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
long long int n,a[200000],ans;
int main(){
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=1;i<n;i++)
		if(a[i]<a[i-1])
			ans+=a[i-1]-a[i],a[i]=a[i-1];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5136
#include <iostream>
#include <unordered_map>
#include <string>
using namespace std;
int solve(void){
    int N;
    string S;
    unordered_map<string,int> table;
    cin >> N >> S;
    int ans = 0;
    for(int num=0;num<=999;num++){
        string key = "";
        if(num < 10){
            key = "00";
        }
        else if(num < 100){
            key = "0";
        }
        key += to_string(num);
        int m = 0;
        bool OK;
        for(int i=0;i<3;i++){
            OK = false;
            for(int j=m;j<N;j++){
                if(S[m] == key[i]){
                    OK = true;
                    m++;
                    break;
                }
                m++;
            }
        }
        if(OK)ans++;
        
    }
    return ans;
    
}
int main(void){
    
    int ans = solve();
    cout << ans << endl;
}


Measured memory_bytes: 3272
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll a;
    ld b;
    cin >> a >> b;
    ll c = (b + EPS) * 100;
    cout << a * c / 100 << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3772
#include <algorithm>
#include<cfenv>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include<numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;
vector<llong> AllDivisors(llong N) {
	vector<llong> ANS;
	for (llong i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ANS.push_back(i);
			if (N / i != i)ANS.push_back(N / i);
		}
	}
	sort(ANS.begin(), ANS.end());
	return ANS;
}
bool IsPrime(llong N) {
	for (llong i = 2; i * i <= N; i++) {
		if (N % i == 0) return false;
	}
	return true;
}
pair<llong, llong> Reduction(pair<llong, llong> A) {
	llong tmp = gcd(A.first, A.second);
	auto p = make_pair(A.first / tmp, A.second / tmp);
	return p;
}
//ここまで共通
int main() {
	string S;
	cin >> S;
	int count = 0;
	int tmp = 0;
	for (int i = 0; i < 3; i++) {
		if (S[i] == 'S') tmp = 0;
		else tmp++;
		count = max(count, tmp);
	}
	cout <<count << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <queue>

using namespace std;

int main(){
    queue<char> q;
    string s;
    string t;

    cin >> s >> t;

    for(int i = 0; i < s.length(); i++){
        q.push(s[i]);
    }
    int count = 0;
    while(s != t && count < s.length()){
        char tmp = q.front();
        q.pop();
        q.push(tmp);
        for(int i = 0; i < s.length(); i++){
            s[i] = q.front();
            q.pop();
            q.push(s[i]);
        }
        count++;
    }
    
    if(s == t) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        Console.WriteLine((1000 - n % 1000) % 1000);
    }
}


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


int main()
{
    double n;
    std::vector<int> a;
    std::cin>>n;
    a.resize(n);
    for(int i=0;i<n;i++)std::cin>>a[i];
    double res = 0;
    for(int i=0;i<n;i++){
        res += 1.0/a[i];
    }
    std::cout<<std::setprecision(10)<<1.0/res<<std::endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string a, b;
    cin >> a >> b;
    a += b;
    int x = stoi(a);
    string ans = "No";
    rep(i, 1001) {
        if (i*i==x) ans = "Yes";
    }
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3468
package main

import (
	"fmt"
	"math"
)

const EPS float64 = 1e-8

func add(a float64, b float64) float64 {
	if math.Abs(a+b) < EPS*(math.Abs(a)+math.Abs(b)) {
		return 0.0
	}
	return a + b
}

type Point struct {
	X, Y float64
}

func (p Point) Add(q Point) Point {
	return Point{add(p.X, q.X), add(p.Y, q.Y)}
}

func (p Point) Sub(q Point) Point {
	return Point{add(p.X, -q.X), add(p.Y, -q.Y)}
}

func (p Point) Mul(d float64) Point {
	return Point{p.X * d, p.Y * d}
}

func (p Point) Dot(q Point) float64 {
	return p.X*q.X + p.Y*q.Y
}

type Line struct {
	A, B Point
}

func (l Line) Project(p Point) Point {
	base := l.B.Sub(l.A)
	t := (p.Sub(l.A)).Dot(base) / base.Dot(base)
	return base.Mul(t).Add(l.A)
}

func main() {
	var line Line
	var q int
	var point Point
	fmt.Scan(&line.A.X, &line.A.Y, &line.B.X, &line.B.Y)
	fmt.Scan(&q)
	for i := 0; i < q; i++ {
		fmt.Scan(&point.X, &point.Y)
		result := line.Project(point)
		fmt.Printf("%.8f %.8f\n", result.X, result.Y)
	}
}



Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
 
 
#define ll long long
#define MOD 1000000007
#define pll             pair<ll,ll>
#define pii             pair<int,int> 
#define mp(a,b)         make_pair(a,b)
#define pb 				push_back
#define vi				vector<int>
#define vl 				vector<long long>
#define vb 				vector<bool>
#define printv(v)		for(auto x : v) cout<<x<<' ';br;
#define FOR(i,a,b) 		for(ll i = a; i <= b ; i++)
#define forn(i,n) 		for(ll i = 0 ; i < n; i++)
#define br 				cout<<endl;
#define testc()			ll t;cin>>t;while(t--)
 
#define fast 			ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define INF				INT_MAX
#define INFL			LLONG_MAX
#define max1(x,y) (x)>(y)?(x):(y)
#define ss second
#define ff first
#define MAXN 1000000001

struct item
{
    /* data */
    ll wt,v;
};
bool comp(item i1,item i2){
    if(i1.wt==i2.wt)
    return i1.v>i2.v;
    return i1.wt<i2.wt;
}

int main(){
    fast
    ll n,w;
    cin>>n>>w;
    item it[n+1];
    it[0].wt=0;
    it[0].v=0;
    FOR(i,1,n)
    cin>>it[i].wt>>it[i].v;
    sort(it+1,it+1+n,comp);
    ll dp[n+1][w+1];
    memset(dp,0,sizeof(dp));
    // FOR(i,0,n){
    //     FOR(j,0,w)
    //     cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
    FOR(i,1,n){
        FOR(j,1,w){
            if(j>=it[i].wt){
                dp[i][j]=max(dp[i-1][j],it[i].v+dp[i-1][j-it[i].wt]);
            }
            else
            dp[i][j]=dp[i-1][j];
        }
    }
    // FOR(i,1,n){
    //     FOR(j,1,w)
    //     cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
    cout<<dp[n][w]<<endl;
    return 0;
}

Measured memory_bytes: 79232
#include<stdio.h>
#define L 100001

int main(){
  int N, min_sub = 0;
  int i, j, k, count = 0;
  unsigned int a[L];
  int v[L] = {0};

  scanf("%d",&N);
  
  for(i=0;i<N;i++){
  	scanf("%lu",&a[i]);
    k = N;
    if(k >= L) k = 100000;
    if(k < a[i])
      min_sub++;
    else
      v[a[i]] += 1;
  }
  
  for(i=1;i<=k;i++){
    if(v[i] > i)
      min_sub += v[i] - i;
    else if(v[i] < i)
      min_sub += v[i];
  }

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

  return 0;
}

Measured memory_bytes: 896
def main():
    def warshall_floyd(d):
        for k in range(10):
            for i in range(10):
                for j in range(10):
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j])
        return d
    def flatten_list(l):
        for el in l:
            if isinstance(el, list):
                yield from flatten_list(el)
            else:
                yield el
    H, W = list(map(int, input().split()))
    C = [list(map(int, input().split())) for _ in range(10)]
    A = [list(map(int, input().split())) for _ in range(H)]
    A = list(flatten_list(A))
    C = warshall_floyd(C)
    ans = 0
    for a in A:
        if a != -1:
            ans += C[a][1]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
using System;

class ITP1_7_B
{
  static void Main()
  {
    while (true)
    {
      string[] inputs =  Console.ReadLine().Split(' ');
      int n = int.Parse(inputs[0]);
      int x = int.Parse(inputs[1]);
      if (n == 0 && x == 0) break;

      int count = 0;
      for (int i = 1; i <= n; i ++)
      {
        for (int j = 1; j <= n; j ++)
        {
          for (int k = 1; k <= n; k ++)
          {
            if (i + j + k == x && i < j && j < k) count ++;
          }
        }
      }
      Console.WriteLine(count);
    }
  }
}



Measured memory_bytes: 15900
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[26]={0};
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)a[s[i]-'a']++;
	for(int i=0;i<26;i++){
		if(a[i]==0){cout<<(char)(i+97);return 0;}
	}
	cout<<"None";
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	int n;
	int i,j,k;
	long long int dp[1001][8];
	int cnt=0;
	int m;
	char joi[1001];
	
	scanf("%d",&n);
	scanf("%s",joi);
	for(i=0;i<=n;i++){
		for(j=0;j<8;j++){
			dp[i][j]=0;
		}
	}
	dp[0][4]=1;
	for(i=0;i<n;i++){
		for(j=0;j<8;j++){
			for(k=0;k<8;k++){
				if(joi[i]=='J')	{
					m=4;
				}
				else if(joi[i]=='O'){
					m=2;
				}
				else if(joi[i]=='I'){
					m=1;
				}
				if((k&m) != 0 && (j&k) != 0){
					dp[i+1][k]+=dp[i][j];
					dp[i+1][k]=dp[i+1][k]%10007;
				}
			}
		}
	}
/*	for(j=0;j<=n;j++){
	printf("j=%d\n",j);
		for(k=0;k<8;k++){
			printf("%d ",dp[j][k]);
		}
		printf("\n");
	}
	*/
	for(j=0;j<8;j++){
		cnt+=dp[n][j];
		cnt=cnt%10007;
	}
	printf("%d\n",cnt);
	return 0;
}

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

const int Mod = 2019;
class mll {
public:
	int x;
	mll(int x = 0) : x((x% Mod + Mod) % Mod) {};
	void operator += (const mll& a) {
		if ((x += a.x) >= Mod) x -= Mod;
	}
	void operator *= (const mll& a) {
		(x *= a.x) %= Mod;
	}
	mll operator + (const mll& a) const {
		mll ans = *this;
		ans += a;
		return ans;
	}
	mll operator * (const mll& a) const {
		mll ans = *this;
		ans *= a;
		return ans;
	}
};
int main() {
	string S;
	cin >> S;
	int N = S.length();
	map<int,int> Mods;

	mll before = S[N - 1] - '0', now;
	Mods[before.x]++;
	mll ten = 1;
	for (int i = 1; i < N; i++) {
		ten *= 10;
		now = before + ten * (S[N - i - 1] - '0');
		Mods[now.x]++;
		before = now;
	}

	long long ans = 0;
	for (auto p : Mods) {
		if (p.first == 0) ans += p.second;
		if (p.second > 1) ans += p.second * (p.second - 1) / 2;
	}
	cout << ans << endl;

}


Measured memory_bytes: 3708
import sys

def check(s, x, y):

    while s and s[0] == "F":
        s = s[1:]
        x -= 1
    while s and s[-1] == "T":
        s = s[:-1]

    d = 0
    vxs = []
    vys = []
    while s:
        while s and s[0] == "T":
            s = s[1:]
            d ^= 1
        l = 0
        while s and s[0] == "F":
            s = s[1:]
            l += 1
        if d:
            vys.append(l)
        else:
            vxs.append(l)

    def check1(vs, t):
        xs = [0]
        for v in vs:
            xs = set([x + v for x in xs]) | set([x - v for x in xs])
        return t in xs

    r = check1(vxs, x) and check1(vys, y)
    return r

if __name__ == "__main__":
    s = sys.stdin.readline().strip()
    x, y = [int(n) for n in sys.stdin.readline().strip().split()]
    if check(s, x, y):
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 4580
N, M = map(int, input().split())
H = [int(i) for i in input().split()]
adj = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
ans = 0
for i in range(N):
    if all(H[i] > H[neighbor] for neighbor in adj[i]):
        ans += 1
print(ans)

Measured memory_bytes: 29440