akhauriyash/Code-Regression huggingface dataset:
N=int(input())
A=list(map(int,input().split()))
A.reverse()
S=sum(A)-A[0]
ans=0
for i in range(len(A)-1):
    ans+=A[i]*S
    S-=A[i+1]
print(ans%(10**9+7))
















    

                
            





    









        

    









    

        




    















    



    





    






        






    
















        


























            
    


    


    
    














    


    














Measured memory_bytes: 31608
#include <stdio.h>

int main(){
	int a, b, c, n, i;
	n = 0;

	scanf("%d %d %d", &a, &b, &c);
	for (i = a; i <= b; i++){
		if (c % i == 0){
			n++;
		}
	}
	printf("%d\n", n);
	return 0;
}

Measured memory_bytes: 596
h,w=map(int,input().split())
n=int(input())
a=[0]+list(map(int,input().split()))
c=[[0]*w for _ in range(h)]
g=[0,w-1][h%2]
x,y=0,0
i=1
while True:
  c[x][y]=i
  a[i]-=1
  if x==h-1 and y==g:break
  if a[i]==0:i+=1
  if x%2:
    if y:y-=1
    else:x+=1
  else:
    if y==w-1:x+=1
    else:y+=1
for i in c:
  print(*i)

Measured memory_bytes: 68888
#include <bits/stdc++.h>
//#ifndef ONLINE_JUDGE
//#  define LOG(x) (cerr << #x << " = " << (x) << endl)
//#else
//#  define LOG(x) 0
//#endif
#define pb push_back
#define mod 1000000007
#define endl '\n'
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

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

const integer NN = 200005;
int ar[NN];
int n, m, k;
vector<int> adj[NN];


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

    int t = 1;
//    cin >> t;
    while (t--) {
        cin >> n;
        for (int i = 1; i < n; i++){
            int a;
            cin >> a;
            adj[a].push_back(i+1);
        }
        for (int i = 0; i < n; i++){
            cout << adj[i+1].size() << endl;
        }

    }

}



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

int main(){
  long long n, m; cin >> n >> m;
  vector<long long> a(m+1);
  for(long long i = 0; i < m; i++) cin >> a[i];
  vector<long long> ans(n+1);
  ans[0] = 1;
  long long cnt = 0;
  if(a[0]==1){
    ans[1] = 0;
    cnt++;
  }
  else ans[1] = 1;
  
  for(long long i = 2; i <= n; i++){
  	if(a[cnt]==i){
    	cnt++;
    	ans[i] = 0;
    }
  	else ans[i] = (ans[i-1]+ans[i-2])%1000000007;
  }
  cout << ans[n] << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>

typedef long long ll;
const ll MOD = 1e9 + 7;

using namespace std;


int main(){
    std::ios::sync_with_stdio(false);
    int k;
    cin >> k;
    ll ans = 0;

    
    for(int a = 1; a <= k; a++){
        for(int b = 1; b <= k; b++){
            int mini = min(a,b);
            for(int c = 1; c <= k; c++){
                int t = min(mini,c);
                for(int i = t; i >= 1; i--){
                    if(a%i == 0 and b%i == 0 and c%i == 0){
                        ans += i;
                        break;
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int n,m,a[100005],l,r;
string s;
int main(){
    cin>>n>>m>>s;
    for(int i=1;i<s.size();i++)
	{
    	if(s[i]=='C')
		{
    		if(s[i-1]=='A') a[i]+=a[i-1]+1;
			else a[i]+=a[i-1];
		}
		else a[i]+=a[i-1];
	}
    for(int i=1;i<=m;i++)
	{
    	cin>>l>>r;
    	cout<<a[r-1]-a[l-1]<<endl;
	}
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	int N, M;
	cin >> N >> M;

	vector<vector<int>> e(N, vector<int>());
	int A, B;
	for (int i = 0; i < M; i++) {
		cin >> A >> B;
		A--;
		B--;
		e[A].push_back(B);
		e[B].push_back(A);
	}

	vector<int> jdg(N, -1);
	vector<int> v;
	vector<int> d;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (jdg[i] == -1) {
			jdg[i] = cnt;
			v.clear();
			v.push_back(i);
			while (v.size() != 0) {
				d.clear();
				for (int j = 0; j < v.size(); j++) {
					for (int k = 0; k < e[v[j]].size(); k++) {
						if (jdg[e[v[j]][k]] == -1) {
							jdg[e[v[j]][k]] = cnt;
							d.push_back(e[v[j]][k]);
						}
					}
				}
				v.clear();
				v = d;
			}
			cnt += 1;
		}
	}

	vector<vector<int>> t(cnt, vector<int>());
	for (int i = 0; i < N; i++) {
		t[jdg[i]].push_back(i);
	}

	int ans = 0;
	for (int i = 0; i < t.size(); i++) {
		if (t[i].size() > ans) {
			ans = t[i].size();
		}
	}

	cout << ans << endl;

	return 0;
}

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


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

    int max = *max_element(p.begin(),p.end());
    
    int sum = 0;
    rep(i,n){
        sum += p[i];
    }
    sum -= max /2;
    print(sum);
}


Measured memory_bytes: 256
def cycle_detection(V, E, s):
    prev = [-1] * len(V)
    stack = [s]
    while stack:
        v = stack.pop()
        for u in E[v]:
            if u == s:
                prev[u] = v
                return (s, prev)
            if prev[u] == -1:
                stack.append(u)
                prev[u] = v
    return (-1, prev)

N, M = map(int, input().split())
V = list(range(N))
E = [[] for _ in range(N)]
edges = []
for _ in range(M):
    a, b = map(int, input().split())
    E[a-1].append(b-1)
    edges.append((a-1, b-1))

dag = False
for v in range(N):
    s, prev = cycle_detection(V, E, v)
    if s != -1: break
else:
    dag = True

if dag: print(-1)
else:
    # construct a directed cycle
    cycle = set()
    cycle.add(s)
    pv = prev[s]
    while pv != s:
        cycle.add(pv)
        pv = prev[pv]
    # shrink the directed cycle
    for a, b in edges:
        if a in cycle and b in cycle and prev[b] != a:
            pv = prev[b]
            while pv != a:
                cycle.remove(pv)
                pv = prev[pv]
            prev[b] = a
    print(len(cycle))
    print(*[v + 1 for v in cycle], sep='\n')

Measured memory_bytes: 3572
// --------------
// Tejas Pandey  |
// 13 - 09 - 20  |
// Atcoder BC 178|
// --------------

#include <bits/stdc++.h>
using namespace std;
     
#define mod 1000000007
#define vi vector<int>
typedef long long int ll;
     
int main (void){
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<int> a(n),b(n),frq(n + 1,0);
  for(int i = 0;i < n;i++) cin >> a[i];
  for(int i = 0;i < n;i++) cin >> b[i];
  vector<int> pos;
  int mx = 0;
  for(int i = 0;i < n;i++){
	if(a[i] == b[i]) pos.push_back(i),frq[a[i]]++,mx = max(mx,frq[a[i]]);
  }
  int tot = pos.size(),d = 0;
  int mxv = 0;
  for(int i = 1;i <= n;i++){
	if(frq[i] == mx){
		mxv = i;
	}
  }
  while(d < n && tot < 2*mx){
	if(a[d] == b[d]);
	else if(b[d] == mxv || a[d] == mxv);
	else{
		pos.push_back(d);
		tot++;
	}
	d++;
  }
  if(tot < 2*mx) cout << "No\n";
  else{
	sort(pos.begin(),pos.end());  
	cout << "Yes\n";
	vector<int> ans(n,0);
	for(int i = 0;i < tot;i++){
		int prev = pos[i];
		int now = pos[(i + mx)%tot];
		ans[now] = b[prev];
	}
	for(int i = 0;i < n;i++)
		if(ans[i]);
		else ans[i] = b[i];
	for(int i = 0;i < n;i++)
		cout << ans[i] << " ";
	cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 7472
N = int(input())
A = []
for c in range(N):
  A.append(int(input()))
m, i = 0, -1
for j in range(len(A)):
  if A[j] > m:
    m, i = A[j], j
B = A[:]
B.remove(m)
M = max(B)
for k in range(len(A)):
  if k != i:
    A[k] = m
  else:
    A[k] = M
for l in range(len(A)):
  print(A[l])

Measured memory_bytes: 14060
# -*- coding: utf-8 -*-
a, b = map(int, input().split())

if b == 1:
    print(0)
    exit(0)

r = 0

rest_b = b - a

r += 1

if rest_b <= 0:
    print(r)
    exit(0)


while 0 < rest_b:
    rest_b -= a - 1
    r += 1

print(r)

Measured memory_bytes: 3060
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")

#include <stdio.h>
#include <string.h> 
int ans = 1 << 25;
char str[100010];
int main()
{
	scanf("%s", str);
	int len = strlen(str);
	for (int _ = 1; _ < len; ++ _)
	{
		if (str[_] != str[_ - 1])
		{
			ans = ans > (_ > len - _? _: len - _)? (_ > len - _? _: len - _): ans;
		}
	 } 
	 return !printf("%d\n", ans > len? len: ans);
}

Measured memory_bytes: 256
N = input().split()

num = int(N[0])

L = int(N[1])

taste = []

for i in range(num):
    taste.append(i+L)

sum_taste = sum(taste)
#print(sum_taste)
#print(taste)
temp = 999
ans = 0

for index, j in  enumerate(taste):
    t_num = sum(taste[:index]) + sum(taste[index+1:])
    #print(t_num)
    if abs(sum_taste - t_num) < temp:
        temp = abs(sum_taste - t_num)
        ans = t_num

print(ans)

Measured memory_bytes: 3064
#include <iostream>

int main() {
  std::string s, t;
  std::cin >> s;
  std::cin >> t;

  int count = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != t[i]) count++;
  }
  std::cout << count << std::endl;
}


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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if(a + b > c + d)
    cout << "Left" << endl;
  else if(a + b < c + d)
    cout << "Right" << endl;
  else 
    cout << "Balanced" << endl;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a,b,sum=0,bb=1;
	string s;
	cin>>n>>a>>b>>s;
	for(ll i=0;i<n;i++){
		if(s.substr(i,1)=="a"){
			if(sum<a+b){
				cout<<"Yes"<<endl;
				sum++;
			}else{
				cout<<"No"<<endl;
			}
		}else if(s.substr(i,1)=="b"){
			if(sum<a+b && bb<=b){
				cout<<"Yes"<<endl;
				sum++;
				bb++;
			}else{
				cout<<"No"<<endl;
			}
		}else if(s.substr(i,1)=="c"){
			cout<<"No"<<endl;

		}
	}
	return 0;
}


Measured memory_bytes: 3776
#include <iostream>
#include <vector>

using namespace std;

int64_t mod = 1e9 + 7;
vector<int64_t> fact(1, 1);
vector<int64_t> inv_fact(1, 1);

int64_t mpow(int64_t a, int64_t n){
    int64_t x = 1;
    while(n != 0){
        if(n & 1) x = x * a % mod;
        a = a * a % mod;
        n = n >> 1;
    }
    return x;
}

int64_t mcomb(int64_t n, int64_t r){
    if(n == 0 || r == 0) return 1;
    if(n < r || n < 0) return 0;
    int64_t num = inv_fact[n - r] * inv_fact[r] % mod;
    return num * fact[n] % mod;
}

int main(){

    int64_t N, K;
    cin >> N >> K;

    for(int64_t i = 0; i < N; i++){
        fact.emplace_back(fact[i] * (i + 1) % mod);
        inv_fact.emplace_back(inv_fact[i] * mpow(i + 1, mod - 2) % mod);
    }
    for(int64_t i = 1; i <= K; i++){
        int64_t ans = (mcomb(N - K + 1, i) * mcomb(K - 1, i - 1));
        ans %= mod;
        cout << ans << endl;
    }

    return 0;
}

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

int main(void){
  string tile;
  cin >> tile;
  int ans = 0;
  for(int i=1;i<tile.length(); i++){
    if (tile[i] == tile[i-1]){
      if (tile[i] == '0') tile[i]='1';
      else tile[i]='0';
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

using int64 = long long;

constexpr int DEBUG = 0;

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

  int64 a, b;
  cin >> a >> b;

  if (a == b) {
    cout << 1 << endl;
    return 0;
  }

  int64 t = 0;
  for (int i = 59; i >= 0; i--) {
    if ((a & (1LL << i)) != (b & (1LL << i))) {
      a &= (1LL << (i + 1)) - 1;
      b &= (1LL << (i + 1)) - 1;
      t = 1LL << i;
      break;
    }
  }

  bool flag = false;
  for (int i = 59; i >= 0; i--) {
    if ((b & (t - 1) & (1LL << i)) > 0) {
      flag = true;
    }
    if (flag) b |= 1L << i;
  }
  
  if (DEBUG) cout << "a: " << a << " b: " << b << " t : " << t << endl;

  int64 ans = 0;
  ans += t - a;
  ans += b - t + 1;
  ans += t - a;
  if (b >= t + a) {
    ans -= (b - (t + a)) + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  string S;
  cin >> S;
  int N = S.size();
  int count = 0;
  bool low = true;
  for(int i=0; i<N; i++){
    if(S[i] != 'A' && S[i] != 'C' && S[i] >= 'A' && S[i] <= 'Z')
      low = false;
    if(i >= 2 && i <= N-2)
      if(S[i] == 'C')
	count++;
  }
  if(S[0] == 'A' && count == 1 && low)
    cout << "AC" << endl;
  else
    cout << "WA" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 40;
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int N;ll x;

int main(){
    cin >> N >> x;
  
	vector<ll> a(N);
    FOR(i,0,N) cin >> a[i];

    ll res = 0;
    
    FOR(i,0,N-1){
        if(a[i]+a[i+1]<=x)continue;
        else{
            res += (a[i]+a[i+1])-x;
            a[i+1] -= min(a[i+1],(a[i]+a[i+1])-x);
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
/***************************************** 
****       Solution by SlavicG        ****
*****************************************/
 
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm> 
#include <set>
#include <utility>
#include <queue>
#include <map>
#include <assert.h>
#include <stack>
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;++i)
#define MX 10000000001
#define pow2(a) ((a)*(a))
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define endl "\n"
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 int longestIncreasingSubsequenceLenghtDP(int a[],int n){
    int dp[n],ans=0;
    for(int k = 0;k<n;k++){
        dp[k] = 1;
        for(int i = 0;i<k;i++){
            if(a[i] <= a[k]){
                dp[k] = max(dp[k],dp[i] + 1);
                ans = max(dp[k],ans);
            }
        }
    }
    return ans;
 }
int result[1000] = {0};
int factDP(int n) 
{
   if (n >= 0) {
      result[0] = 1;
      for (int i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
      return result[n];
   }
}
bool checkPrime(int n)
{
    if(n<2) return false;
    for(int x = 2;x*x <=n;x++)
    {
        if(n%x == 0)return false;
    }
    return true;
}
vector<int> primeFactors(int n){
    vector<int> f;
    for(int x = 2;x*x<=n;x++){
        while(n%x==0){
            f.push_back(x);
            n/=x;
        }
    }
    if(n>1)f.push_back(n);
    return f;
}
int binary_Search_Classic(int n, int arr[],int target){
	int l,r,mid;
	l=0;
	r=n-1;
	while(l<=r){
		mid= l+(r-l)/2;
		if(arr[mid] == target){
			return mid;
		}
		if(arr[mid] < target){
			l=mid+1;
		}else
		{
			r=mid-1;
		}
	}
	return -1;
}
int binary_Search_First_Greater(int n, int arr[],int target){
	int l,r,ans,mid;
	l = 0;
	r = n-1;
	ans=-1;
	while(l<=r){
		mid = l + (r-l)/2;
		if(arr[mid] > target){
			ans=mid;
			r=mid-1;
		}else{
			l = mid+1;
		}
	}
	return ans;
}
int countDistinctCharsString(string s) {
    unordered_map<char, int> m; 
    for (int i = 0; i < s.length(); i++) { 
        m[s[i]]++; 
    }
    return m.size(); 
} 
int main()
{
	int a[5];
	int rem;
	for(int i = 0;i<5;i++)
	{
		cin >> a[i];
		if(a[i] == 0)rem=i;
	}
	cout << rem+1 << endl;
	return 0;
}

Measured memory_bytes: 3624
n, a, b = map(int, input().split())
mod = 10**9+7


def binary(n):
    return bin(n)[2:]


# a^x mod n : ans = pow_by_binary_exponentiation(2, 1000, 10**9+7)
def pow_by_binary_exponentiation(a, x, n):
    x = [int(b) for b in binary(x)]
    y = a
    for i in range(1, len(x)):
        y = (y**2) % n
        if x[i] == 1:
            y = (y * a) % n
    return y


def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod


ac = combination(n, a, mod)
bc = combination(n, b, mod)
ans = pow_by_binary_exponentiation(2, n, mod)
print(((ans - ac - bc - 1) % mod)//1)


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

#define ll long long
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define f first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pii pair<double, double>
#define all(x) x.begin(), x.end()

const int N = 3000 + 144, mod = 1e9 + 7, inf = 1e9 + 7;
int n;
ll a[N];
ll pr[N];
ll dp[N][N];
bool was[N][N];

ll bp(ll x, ll y){
    if(y == 0)
        return 1;
    if(y & 1)
        return (x * bp(x, y - 1)) % mod;
    ll z = bp(x, y / 2);
    return (z * z) % mod;
}

ll rec(int l, int r){
    if(l == r)
        return a[l];
    if(was[l][r])
        return dp[l][r];
    dp[l][r] = pr[r] - pr[l - 1] - min(rec(l, r - 1), rec(l + 1, r));
    was[l][r] = true;
    return dp[l][r];
}

int main(){
    boost;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        pr[i] = pr[i - 1] + a[i];
    }
    cout << -pr[n] + 2 * rec(1, n);
    return 0;
}


Measured memory_bytes: 84352
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a;
    cin >> n >> a;
    for (int i = 0; i <= a; i++)
    {
        if ((n - i) % 500 == 0)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);
  
  if(T[u].p == NIL) printf("root, ");
  else if(T[u].l == NIL) printf("leaf, ");
  else printf("internal node, ");
  
  printf("[");
  for (i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
  
}

void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].l != NIL) calcDepth(T[u].l, p+1);
  if(T[u].r != NIL) calcDepth(T[u].r, p);
}

int main(){
  int i, j, k;
  int n;
  int id, sib, child;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;

  for(i=0; i<n; i++){
    scanf("%d %d", &id, &k);
    for(j = 0, sib = NIL; j<k; j++){ //子を入力する (input children)
      scanf("%d", &child);
      T[child].p = id;
      if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
      else T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)
      sib = child;//次の子供の左の兄弟 (the left sibling of the next child)
    }
  }

  //根を求める (find the root)
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }

  //それぞれのノードの深さを求める (find depth of each node)
  calcDepth(root, 0);

  //出力 (output)
  for(i=0; i<n; i++) print(i);

  return 0;
}



Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){

  
  ll K;
  cin>>K;
  ll ans=0;
  
  rep(i,K){
rep(j,K){
  rep(l,K){
    ans+=gcd(gcd(i+1,j+1),l+1);
  }
}
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 3644
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTS(s) printf("%s\n",(s))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

typedef long long ll;

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a)>(b) ? (a) : (b);
}

int main() {
	int n;
	scanf("%d", &n);
	int a[2][100];
	REP(i, n) {
		scanf("%d", &a[0][i]);
		if (i != 0) {
			a[0][i] += a[0][i - 1];
		}
	}
	REP(i, n) {
		scanf("%d", &a[1][i]);
		if (i == 0) {
			a[1][0] += a[0][0];
		}
		else {
			if (a[0][i] > a[1][i - 1]) {
				a[1][i] += a[0][i];
			}
			else {
				a[1][i] += a[1][i-1];
			}
		}
	}
	PRINTD(a[1][n - 1]);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e7+10;

LL n;
LL a[maxn];

int main() {
    LL tmp = 0;
    while(~scanf("%lld",&n)) {
        tmp = 0;
        for(LL i=1;;i++) {
            if(tmp+i>n) break;
            tmp+=i;
            LL x = n-tmp;
            //printf("x = %lld i = %lld\n",x,i);
            if(x<=i) {
                for(int j=1;j<=i;j++) {
                    int out = j;
                    if((i-j+1)<=x) out++;
                    printf("%d\n",out);
                }
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
using namespace std;
typedef long long LL;

int main() {
    string s;
    cin >> s;
    s[3] = '8';
    cout << s;
    return 0;
}

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

char S[20];

int main() {
  int cnt = 0;
  cin >> S;
  for (int i = 0; i < strlen(S); i++) {
    if (S[i] == 'o') cnt++;
  }
  if (cnt >= 8) {
    cout << "YES" << endl;
  }
  else {
    int a = 8 - cnt;
    int b = 15 - strlen(S);
    if (a <= b) {
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	auto H = vecin(N);
	reverse(ALL(H));
	int maxN = 0,start = 0;
	bool mode = false;
	for(int i=1;i<N;i++){
		if(!mode){
			if(H[i]>=H[i-1]){
				mode = true;
				start = i-1;
			}
		}
		else{
			if(H[i]<H[i-1]){
				mode = false;
				int l = i-start-1;
				maxN = max(maxN,l);
			}
		}
	}
	if(mode){
		int l = N-start-1;
		maxN = max(maxN,l);
	}
	
	out(maxN);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include<string>
using namespace std;
int main(void){
    int N;
    cin>>N;

    for(int i=0;i<=N/4;i++){
        for(int j=0;j<=N/7;j++){
            
            if(N==i*4+j*7){
                cout<<"Yes"<<endl;
                return 0;
            
            
            }
            
        }
    }
    cout<<"No"<<endl;
    return 0;
    
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return a % 1000000007;
}

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


int main(){
  ll n; cin >> n; ll summin = 10000000000;
  vl num(n); rep(i,n){ ll x; cin >> x; num[i] = x; }
  
  for(ll i = -100; i < 101; i++){
    ll sum = 0;
    for(ll x : num){
      sum += pow(abs(x-i),2);
    }
    
    summin = min(sum,summin);
  }
  
  cout << summin << endl;
}

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n;
	cin >> n;

	vi a(n), b(n), c(n);

	rep(i,n) {
		cin >> a[i];
		a[i]--;
	}
	rep(i,n)cin >> b[i];
	c[0] = 0;
	rep(i,n-1)cin >> c[i+1];

	int ans = 0, be=-1;

	rep(i, n) {
		ans += b[a[i]];
		if (be+1==a[i])ans += c[a[i]];
		be = a[i];
	}

	cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int[] score = new int [5];
		int i, sum = 0;
		for(i = 0; i < 5; i++){
			score[i] = sc.nextInt();
			if(score[i] < 40){
				score[i] = 40;
			}
		}
		//System.out.printf("%d\n", score[0]);
		for(int k = 0; k < 5; k++){
			sum = sum + score[k];
		}
		System.out.printf("%d\n", sum / 5);
	}

}

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

#define MAX 2000001
#define V 10000

int main(){

    unsigned short *A,*B;


    int C[V+1],n,i,j;
    
    
    scanf("%d",&n);

    A = malloc(sizeof(short)*n+1);
    B = malloc(sizeof(short)*n+1);

    for( i=0 ; i<=V+1 ; i++ ){
        C[i] = 0;
    }

    for( i=0 ; i<n ; i++ ){
        scanf("%d",&A[i+1]);
        C[A[i+1]]++;
    }

    for( i=1 ; i<V+1 ; i++ ){
        C[i] = C[i] + C[i-1];
    }

    for( j=1 ;j<n+1 ; j++ ){
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }

    for( i=1 ; i<n+1 ; i++ ){
        if( i>1 && i<n+1 ) printf(" ");
        printf("%d",B[i]);
    }

    printf("\n");

    return 0;
}






Measured memory_bytes: 9560
#include<iostream>
#include<cstring>
using namespace std;
int main(){
    int h,w;    cin>>h>>w;
    char m[h][w+1];
    for(int i=0;i<h;i++)cin>>m[i];

    for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
            if(m[j][i]=='#')break;
            if(j==h-1)for(int k=0;k<h;k++)m[k][i]='0';
        }
    }
    for(int i=0;i<h;i++)if(strchr(m[i],'#')==NULL)for(int k=0;k<w;k++)m[i][k]='0';
    bool flag;
    for(int i=0;i<h;i++,flag=false){
        for(int j=0;j<w;j++)if(m[i][j]!='0'){
            cout<<m[i][j];
            flag=true;
        }
        if(flag)cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();

    int sum = 0;
    int max = 0;
    for (int i = 0; i < N; i++) {
      int p = sc.nextInt();
      sum += p;
      if (max < p) {
        max = p;
      }
    }
    
    System.out.println(sum - max/2);
  }
}

Measured memory_bytes: 23764
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskC {
        final int MOD = (int) 1e9 + 7;
        int[] fact;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt();
            precalc(Math.max(n, m) + 3);
            int ans = (int) ((long) fact[n] * fact[m] % MOD);
            if (n == m) {
                ans *= 2;
                ans %= MOD;
            }
            if (n > m + 1 || m > n + 1) {
                ans = 0;
            }
            out.println(ans);
        }

        private void precalc(int n) {
            fact = new int[n];
            fact[0] = 1;
            for (int i = 1; i < n; ++i) {
                fact[i] = (int) ((long) fact[i - 1] * i % MOD);
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

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

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 22996
#include <iostream>
using namespace std;
int main(void){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    
    const int lower = max(A, C);
    const int upper = min(B, D);
    
    cout << max(0,upper-lower) << endl;
    
    return 0;
    
    
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <math.h>
#define ll long long 
// to increase precision
// std::cout<<std::fixed;
// 	std::cout<<std::setprecision(6)<<z;
#define max1 100001

long long int mod=1e9 +7 ;
int n;
double dp[3000][3000];
vector<double> p(3000);

int main(){	
	cin>>n;
	
	for (int i = 0; i < n; ++i)
	{
		cin>>p[i];
	}
	for (int i = 0; i <=n; ++i)
	{
		dp[0][i]=0;
	}
	dp[0][0]=1;

	for (int i = 1; i <=n; ++i)
	{
		for(int j=0;j<=i;j++){
			dp[i][j]=0;
			dp[i][j]+=dp[i-1][j]*(1-p[i-1]);
			if(j>0){
				dp[i][j]+=dp[i-1][j-1]*p[i-1];
			}
			//cout<<dp[i][j]<<" ";
		}
		//cout<<endl;
	}
	double ans=0;
	for (int i = (n+1)/2; i <=n; ++i)
	{
		ans+=dp[n][i];
	}
	std::cout<<std::fixed;
	std::cout<<std::setprecision(10)<<ans;





		
}
	
	
	
	





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

int main() {
  int i, N, sum = 0;
  int av;
  int hp1 = 0, hp2 = 0, hp3 = 0;
  cin >> N;
  vector<int> jusyo(N);
  for (i = 0; i < N; i++) {
    cin >> jusyo.at(i);
    sum += jusyo.at(i);
  }
  av = sum / N;
  
  for (i = 0; i < N; i++) {
    hp1 += (jusyo.at(i) - av) * (jusyo.at(i) - av);
    hp2 += (jusyo.at(i) - av - 1) * (jusyo.at(i) - av - 1);
    hp3 += (jusyo.at(i) - av + 1) * (jusyo.at(i) - av + 1);
  }
  
  int min_hp = min(hp1, hp2);
  min_hp = min(min_hp, hp3);
  cout << min_hp << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#define SWAP(A,B,C) ((C)=(A),(A)=(B),(B)=(C))
using namespace std;
class State{
public:
  int p[2][4];
  int cost;
  int zx, zy;
  bool operator < (const State &s) const {
    for(int i = 0; i < 2; i++) {
      for(int j = 0; j < 4; j++) {
    if(p[i][j] != s.p[i][j]) return p[i][j] < s.p[i][j];
      }
    }
    return false;
  }
};

int dx[] = {0,1,0,-1},dy[] = {-1,0,1,0};
int main()
{
	State a;
	for(int i = 0;i<2;i++)
		for(int j = 0;j<4;j++)
			a.p[i][j] = i*4+j;
	a.cost = 0;a.zx=0;a.zy=0;
	set<State> data;data.insert(a);
	queue<State> q;q.push(a);
	
	while(!q.empty())
	{
		State b = q.front();q.pop();	
		for(int i = 0;i<4;i++)
		{
			State tb = b;
			int nx = tb.zx + dx[i];
			int ny = tb.zy + dy[i];
			if(nx<0||nx>=4||ny<0||ny>=2)continue;
			tb.cost++;
			int temp;
			SWAP(tb.p[b.zy][b.zx],tb.p[ny][nx],temp);
			tb.zy = ny;tb.zx = nx;
			if(data.find(tb)!=data.end())continue;
			data.insert(tb);
			q.push(tb);
		}
	}
	State input;
	while(cin >> input.p[0][0]) {
    	for(int i = 1; i < 8; i++) {
      	cin >> input.p[i/4][i%4];
    	}
		cout << data.find(input)->cost << endl;
	}
	
}

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

int main(){
    ll N, X;
    cin >> N >> X;

    vector<ll> L(N);
    rep(i, 0, N) cin >> L[i];

    ll ans = 1, pre = 0;
    rep(i, 0, N){
        if(pre + L[i] <= X) ans++;
        else break;
        pre += L[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<int> Vec(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> Vec[i];
		}
		int pos = 0;
		int ohajiki = 32;
		while(ohajiki > 0)
		{
			int temp = (ohajiki - 1) % 5;
			ohajiki -= temp;
			cout << ohajiki << endl;
			if(ohajiki <= Vec[pos])
			{
				ohajiki = 0;
			}
			else
			{
				ohajiki -= Vec[pos];
			}
			pos++;
			if(pos == n)
			{
				pos = 0;
			}
			cout << ohajiki << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);
    
    ll a, b, c;
    cin >> a >> b >> c;
    
    ll d = c - a - b;
    if ( d > 0 && 4 * a * b < d * d) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 3592
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
INF = 10**12

n, m, l = [int(item) for item in input().split()]
dist = [[INF] * n for _ in range(n)]
for i in range(m):
    a, b, c = [int(item) for item in input().split()]
    a -= 1; b -= 1
    dist[a][b] = c
    dist[b][a] = c

for i in range(n):
    dist[i][i] = 0

for k in range(n):
    for i in range(n):
        for j in range(n):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

for i in range(n):
    for j in range(n):
        if i == j:
            dist[i][j] = 0
        elif dist[i][j] <= l:
            dist[i][j] = 1
        else:
            dist[i][j] = INF

for k in range(n):
    for i in range(n):
        for j in range(n):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

q = int(input())
for i in range(q):
    s, t = [int(item) - 1 for item in input().split()]
    if dist[s][t] == INF:
        print(-1)
    else:
        print(dist[s][t] - 1)

Measured memory_bytes: 56412
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    static int[][] cache;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        String t = br.readLine();

        cache = new int[s.length()+1][t.length()+1];

        System.out.println(lcs(s, t));
    }

    private static String lcs(String s, String t) {
        getLengthOfLCS(s, t, s.length(), t.length());

        int len = cache[s.length()][t.length()];
        int temp = len;

        char[] ch = new char[len];

        int i = s.length();
        int j = t.length();

        while(i>0 && j>0) {
            if(s.charAt(i-1) == t.charAt(j-1)) {
                ch[len-1] = s.charAt(i-1);
                i--;
                j--;
                len--;
            } else if(cache[i-1][j] > cache[i][j-1]){
                i--;
            } else {
                j--;
            }
        }

        return new String(ch);
    }

    private static int getLengthOfLCS(String s, String t, int m, int n) {
        for(int i=1; i<=m; i++) {
            for (int j = 1; j <=n ; j++) {
                if(s.charAt(i-1) == t.charAt(j-1)) {
                    cache[i][j] = 1 + cache[i-1][j-1];
                } else {
                    cache[i][j] = Math.max(cache[i][j-1], cache[i-1][j]);
                }
            }
        }

        return cache[m][n];
    }
}


Measured memory_bytes: 81624
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int x[510000],n,tot;
int preans=0;
char ch[510000];
void add(int k){
	tot++; x[1]++;
	int now=1;
	while (x[now]>9){
		x[now]%=10; x[now+1]++; tot-=9; now++;
	}
	n=max(n,now);
}
int check(int ans){
	return tot<=ans&&(ans-tot)%9==0;
}
int main(){
	scanf("%s",ch+1); n=strlen(ch+1);
	for (int i=1;i<=n;i++) x[n-i+1]=ch[i]-'0';
	for (int i=1;i<=n;i++) x[i]*=9;
	for (int i=1;i<=n;i++){
		x[i+1]+=x[i]/10;
		x[i]%=10;
	}
	while (x[n+1]){
		n++; x[n+1]+=x[n]/10; x[n]%=10;
	}
	for (int i=1;i<=n;i++) tot+=x[i];
	int ans=0;
	while (1){
		ans++; add(1);
	//	for (int i=1;i<=n;i++) cout<<x[n-i+1]; cout<<endl;
	//	cout<<ans<<" "<<tot<<endl;
		if (check(ans)){
			printf("%d\n",(ans-1)/9+1);
			return 0;
		}
	}
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;


int N;
int V[20],C[20],A[20];

int main(){
    cin >> N;
    REP(i,N) cin >> V[i];
    REP(i,N) cin >> C[i];
    REP(i,N){
        A[i] = V[i] - C[i];
    }
    sort(A,A+N,greater<int>());
    ll ans = 0;
    REP(i,N){
        if(A[i]<0) break;
        ans += A[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N,C = map(int,input().split())
sushi = [list(map(int,input().split())) for _ in range(N)]

R = [(0,0)]
L = [(0,0)]

for s in sushi:
    R.append((s[0],R[-1][1]+s[1]))

for s in sushi[::-1]:
    L.append((C-s[0],L[-1][1]+s[1]))

R_reversible = [False for _ in range(N+1)]
L_reversible = [False for _ in range(N+1)]

for i in range(N+1):
    if R[i][1]-2*R[i][0] >= 0:
        R_reversible[i] = True
    if L[i][1]-2*L[i][0] >= 0:
        L_reversible[i] = True
        
R_dif = [0 for _ in range(N+1)]
L_dif = [0 for _ in range(N+1)]

for i in range(N+1):
    R_dif[i] = R[i][1]-R[i][0]
    L_dif[i] = L[i][1]-L[i][0]
    
rmax = 0
lmax = 0

for i in range(N+1):
    if rmax > R_dif[i]:
        R_dif[i] = rmax
    if lmax > L_dif[i]:
        L_dif[i] = lmax
    rmax = max(rmax,R_dif[i])
    lmax = max(lmax,L_dif[i])
    
ans = max(rmax,lmax)

for i in range(1,N+1):
    if R_reversible[i]:
        ans = max(ans,R[i][1]-2*R[i][0]+L_dif[N-i])
    if L_reversible[i]:
        ans = max(ans,L[i][1]-2*L[i][0]+R_dif[N-i])

print(ans)

Measured memory_bytes: 63184
#include <stdio.h>
int main(void){
    int a, b;
    
    scanf("%d %d\n", &a, &b);
    
    while((a+b)!=0){
        if (a<=b){ printf("%d %d\n", a, b);} else { printf("%d %d\n", b, a);}
        scanf("%d %d\n", &a, &b);
    }
    
    return 0;
}


Measured memory_bytes: 1980
//https://atcoder.jp/contests/abc159/tasks/abc159_c
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
  using ld=long double;
  ld L; cin>>L;
  ld tmp=L/3;
  ld ans = tmp*tmp*tmp;
  cout<<fixed<<std::setprecision(10)<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int main(){
  int n;
  cin >> n;
  int c = 0;
  rep(n){
    string s;
    cin >> s;
    c += (s == "A" ? 1 : -1);
    if (c < 0) cout << "NO\n", exit(0);
  }
  cout << (c == 0 ? "YES\n" : "NO\n");
}

Measured memory_bytes: 3196
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
inline double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
inline double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
	bool operator<(const L &o)const{
		return (*this)[0].real()<o[0].real();
	}
};
inline int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}
inline bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
inline bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}
inline P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}
inline double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}
inline double distanceSS(const L &s, const L &t) {
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
             min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}

int main(){
	int n; cin>>n;
	if(n>5100){
		cout<<0<<endl; return 0;
	}
	vector<L> ls;
	rep(i,n){
		int x1,y1,x2,y2;
		cin>>x1>>y1>>x2>>y2;
		if(x1<x2)ls.pb(L(P(x1,y1),P(x2,y2)));
		else ls.pb(L(P(x2,y2),P(x1,y1)));
	}
	sort(all(ls));
	
	double ans=INF;
	rep(i,n)for(int j=i+1;j<n;j++){
		if(ls[j][0].real()-ls[i][1].real()>=ans)break;
		ans=min(ans,distanceSS(ls[i],ls[j]));
	}
	printf("%.9f\n",ans);
	return 0;
}

Measured memory_bytes: 1332
#include<stdio.h>

int main(){
    int x, y, z;
    scanf("%d", &x);
    scanf("%d", &y);
    scanf("%d", &z);
    if (x < y && y < z) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 1996