akhauriyash/Code-Regression huggingface dataset:
l=list(input())
k=int(input())
m=[0]*len(l)
for i in range(len(l)):
    var=pow(int(l[i]),100)
    if(i==0):
        m[i]+=var
    if(i>=1):
        m[i]+=(m[i-1]+var)
    if(k<=m[i]):
        print(l[i])
        exit()

Measured memory_bytes: 3064
# Problem B - Sum of Three Integers

K, S = map(int, input().split())

count_num = 0
for x in range(K+1):
    tmp_num = S
    tmp_num = tmp_num - x
    for y in range(K+1):
        tmp_num_2 = tmp_num
        z = tmp_num_2 - y
        if z<=K and z>=0:
            count_num = count_num + 1

print(count_num)


Measured memory_bytes: 40684
a, b = map(int, input().split())

if not (a+b) % 3 or not a % 3 or not b % 3:
  print('Possible')
else:
  print('Impossible')

#if not a % 3:
#  print('Impossible')
#elif not b % 3:
#  print('Impossible')
#elif not a+b % 3:
#  print('Impossible')
#else:
#  print('Possible')

Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<int> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

int main(){
    ll X;
    cin >> X;
    ll sum=0;
    llRep(i,X){
        sum += i;
        if (sum >= X){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int main()
{
  int r=rr,d=rr,xx=rr;
  int ans=xx;
  rep(i,0,10)
  {
  	 ans=ans*r-d;
  	 cout<<ans<<"\n";
  }
}




Measured memory_bytes: 256
N,M=map(int,input().split())
A=[input().split() for i in range(1)]

all=0
for i in range(N):
    all+=int(A[0][i])

FLAG=1/(4*M)*all
flag=0

for i in range(N):
    if FLAG<=int(A[0][i]):
        flag+=1

if flag>=M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import collections

n, m = map(int,input().split())
a = []

for i in range(m):
  x, y = map(int,input().split())
  if x == 1: #1の島から行ける島
    a.append(y)
  if y == n: #5の島へ行ける島
    a.append(x)

c = collections.Counter(a)

if c.most_common()[0][1] == 2:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 88272
#include <stdio.h>
int main(void)
{
	int N, X, i = 0;
	scanf("%d", &N);
	scanf("%d", &X);
	int A[100];
	while (i < N)
	{
		scanf("%d", &A[i]);
		i++;
	}
	int t = A[0];
	for (i = 0; i < N; i++)
	{
		X = X - A[i];
		if (A[i] < t)
			t = A[i];
	}
	t = X / t;
	printf("%d\n", i + t);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>

using namespace std;
int main() {
  double x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  printf("%.7f \n", sqrt(pow((x2-x1), (double)2) + pow((y2-y1), (double)2)));

}

Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mset(m,v) memset(m,v,sizeof(m))
#define pr(a,s) printf("Case #%lld: %lld\n",a,s)
#define mod 1000000007
#define mp make_pair
#define all(a)                a.begin(),a.end()
#define pb push_back
#define scan(a) scanf("%d",&a)
#define scanl(a) scanf("%lld",&a)
#define se second
#define fi first
#define pi 3.14159265358979323
#define pii pair<ll,ll>
 
const ll inf = 1e7;
const int MAXM = 1e5+4;
const int MAXN = 1e5+10;

vector<int> v[MAXM];
bool visit[MAXM];
vector<int> top_sort;
int dp[MAXM];

void DFS(int x) 
{
	visit[x] = 1;
	for (auto it : v[x]) {
		if (!visit[it])
			DFS(it);
	}
	top_sort.pb(x);
}

int DFS1(int x)
{
	visit[x] = 1;
	if (dp[x] != -1)	return dp[x];
	int ret = 1;
	for (auto it : v[x]) {
		ret = max(ret, 1+DFS1(it));
	}
	return dp[x] = ret;
}

int main() 
{
	int n,m;
	cin>>n>>m;
	mset(dp,-1);
	for (int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		v[x].pb(y);
	}
	for (int i=1;i<=n;i++){
		if (!visit[i]) {
			DFS(i);
		}
	}
	reverse(all(top_sort));
	mset(visit, false);
	int ans = 1;
	for (int i=0;i<top_sort.size();i++) {
		if(!visit[top_sort[i]]) {
			ans = max(ans, DFS1(top_sort[i]));
		}
	}
	cout << ans-1 << endl;
	return 0;
}

Measured memory_bytes: 11384
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K, S;
    cin >> K >> S;
    int ans = 0;
    rep(i, K + 1) {
        rep(j, K + 1) {
            int n = S - i - j;
            if (n >= 0 && n <= K) ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    N=int(input())
    A=list(map(int,input().split()))
    temp=[]
    i=1
    for id,a in enumerate(A):
        if a==i:
            temp.append(a)
            i+=1
    ans=N-len(temp)
    if temp.__len__()==0:
        print(-1)
    else:
        print(ans)







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


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

	int X[110];
	for(int i=0;i<N;++i)cin>>X[i];

	int tan=1000000000;
	for(int j=1;j<101;++j){
		int count=0;
		for(int i=0;i<N;++i){
			count+=abs(X[i]-j)*abs(X[i]-j);
			//cout<<count<<endl;
		}
		if(count<tan){
			tan=count;
		}

	}
	cout<<tan<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> da(n);
  map<int,int> ma;
  for(int i=0;i<n;i++){
    cin >> da[i];
    if(ma.count(da[i])){
      ma[da[i]]++;
    }
    else{
      ma[da[i]]=1;
    }
  }
  int ans=0;
  for(auto i:ma){
    if(i.second%2){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 5376
N, M = map(int, input().split())
X = list(map(int, input().split()))
X_diffs = [0 for i in range(M - 1)]
if N > M:
    print(0)
else:
    X.sort()
    for i in range(M - 1):
        X_diffs[i] = X[i + 1] - X[i]
    X_diffs.sort(reverse=True)
    print(sum(X_diffs[N - 1:]))

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

int main(void) {
    u_int a, b, n;

    std::cin >> a >> b;
    for (; a != 0 && b != 0; std::cin >> a >> b) {
        std::cin >> n;

        std::vector<std::vector<int>> coords(a);
        for (int x = 0; x < a; ++x) {
            if (x == 0) {
                coords[x].resize(b, 1);
            } else {
                coords[x].resize(b, -1);
            }
            coords[x][0] = 1;
        }

        for (u_int i = 0, x, y; i < n; ++i) {
            std::cin >> x >> y;
            coords[x - 1][y - 1] = 0;
            if (x - 1 == 0) {
                auto it = coords[0].begin();
                for (std::advance(it, y); it != coords[0].end(); ++it) {
                    *it = 0;
                }
            }
            if (y - 1 == 0) {
                for (int i = x; i < a; ++i) {
                    coords[i][0] = 0;
                }
            }
        }

        coords[0][0] = 0;
        for (int x = 1; x < a; ++x) {
            for (int y = 1; y < b; ++y) {
                if (coords[x][y] == -1) {
                    coords[x][y] = coords[x][y-1] + coords[x-1][y];
                }
            }
        }

        std::cout << coords[a-1][b-1] << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
 
using namespace std;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int A1, A2, A3;

	cin >> A1 >> A2 >> A3;

	int c = A1 + A2 + A3;

	if(c > 21) {
		cout << "bust" << endl;
	} else {
		cout << "win" << endl;
	}
}

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

int main(){
  
  while(1){
    int n=0,card[100]={};
    string str;
    getline(cin,str);
    str+=' ';
    for(int i=0,num=0;i<str.size();i++){
      if(isdigit(str[i]))num=num*10+str[i]-'0';
      else card[n++]=num,num=0;
    }
    if(card[0]==0)break;
    sort(card,card+n,greater<int>());
    int score=0;
    for(int i=0;i<n;i++){
      if(card[i]>=10)score+=10;
      else if(card[i]>1)score+=card[i];
      else if(score+11+(n-i-1)<=21)score+=11;
      else score++;

    }
    cout <<(score<=21? score:0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
using ll = long long int;
const ll MOD = 1e9 + 7;

vector<ll> memo(1e6, -1);

ll fact(ll n) {
  if (n == 1) {
    memo[n] = 1;
    return memo[n];
  }

  if (memo[n] == -1) {
    memo[n] = n * fact (n - 1) % MOD;
  }
  return memo[n];
}

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

  map<ll, ll> mp;
  for (ll i = 0; i < N; i++)
  {
    ll ai;
    cin >> ai;
    mp[ai]++;
  }
  

  ll ans = 1;
  for (auto &&e : mp)
  {
    ans *= fact(e.second);
    ans %= MOD;

    if (e.second != 2 && N % 2 == 0) {
      ans = 0;
      break;
    }
    if (e.second == 1 && e.first != 0 && N % 2 == 1) {
      ans = 0;
      break;
    }
  }
  cout << ans << endl;
}

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

using namespace std;
#define Pi acos(-1)
#define _terminated return 0
#define endl "\n"
#define yes cout << "Yes" << endl 
#define no cout << "No" << endl 
#define booster ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<long> > v2l;

const int mod = 1e+5;
const int mx = 2e+5;
const ll inf = 1e18;

void upper_bubble_sort(){
     int i,j,temp,number_of_input;
     int array[100];
     cin >> number_of_input;
     for(i=0; i<number_of_input; i++)
         cin >> array[i];
         for(i=0; i<number_of_input; i++){
             for(j=0; j<(number_of_input-i-1); j++){
               if(array[j] > array[j+1]){
                 temp = array[j];
                 array[j] = array[j+1];
                 array[j+1] = temp;
                }
              }
         }
    for(i=0; i<number_of_input; i++)
      cout << array[i] << endl;
}
void bst(void){
          int low,high,mid,keynum,num,array[100];
          cin >> keynum;
          low = 1;
	         high = num;
         	do{
		        mid = (low + high) / 2;
		         if(keynum < array[mid])
			         high = mid - 1;
		         else if (keynum > array[mid])
			         low = mid + 1;
	         } 
          while (keynum != array[mid] && low <= high);
	        if(keynum == array[mid]){
            cout << "number located at " << mid +1 << endl;}
         else
           no;
}

void solvio(void){
     int k,x;
     cin >> k >> x;
     int temp = 500*k;
     if(temp >= x) yes;
     else no;
}

int main(){
    booster;
    solvio();
    _terminated;
} 

Measured memory_bytes: 3544
# -*- coding: utf-8 -*-
from collections import deque
N, M = map(int, input().split())
abn = [list(map(int, input().split())) for _ in range(M)]

abn.sort(key=lambda x:x[1])

ans = 0
bnum = -1
for a,b in abn:
    if bnum == -1:
        bnum = b - 1
        ans += 1
    elif a <= bnum < b:
        continue
    else:
        bnum = b - 1
        ans += 1

print(ans)

Measured memory_bytes: 64600
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

class Graph{
public:
    int N;
    vector<vector<pair<int,ll>>> vec, rev;
    vector<ll> dist;
    vector<bool> connected;

    Graph(int n) : N(n), vec(n), rev(n), dist(n, -INF), connected(n, false){}

    void SetEdge(int a, int b, ll c){
        vec[a].push_back({b,c});
        rev[b].push_back({a,c});
    }

    void dfs(int p){
        connected[p] = true;
        for(auto i : rev[p]){
            if(!connected[i.first]){
                dfs(i.first);
            }
        }
    }

    bool BellmanFord(int s){
        dist[s] = 0;
        REP(i, N){
            REP(j, N){
                for(auto k : vec[j]){
                    if(connected[j] && dist[j] + k.second > dist[k.first]){
                        if(i == N-1){
                            return true;
                        }
                        dist[k.first] = dist[j] + k.second;
                    }
                }
            }
        }
        return false;
    }

    void Solve(){
        dfs(N-1);
        if(BellmanFord(0)){
            cout << "inf" << endl;
        }else{
            cout << dist.back() << endl;
        }
    }
};

int main(){
    ios();
    int n, m;
    cin >> n >> m;
    Graph g(n);
    REP(i, m){
        int a, b;
        ll c;
        cin >> a >> b >> c;
        g.SetEdge(a-1, b-1, c);
    }

    g.Solve();

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace  std;
int main(){
  int N;
  cin >>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >>vec.at(i);
  }
  int sum=0;
  for(int i=0;i<N;i++){
    int num=0;
    for(int j=0;j<i;j++){
      if(vec.at(j)<=vec.at(i)){
        num++;
      }
    }
    if(num==i){
        sum++;
    }
  }
  cout <<sum<<endl;
}

      


    
    


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	if a+b == c+d {
		fmt.Println("Balanced")
	} else if a+b > c+d {
		fmt.Println("Left")
	} else {
		fmt.Println("Right")
	}

}


Measured memory_bytes: 1836
import sys
input = sys.stdin.readline


if __name__ == "__main__":
    n = int(input())
    s_array = [''.join(sorted(input()[:-1])) for _ in range(n)]

    s_array.sort()
    ans = 0
    count = 0
    word = s_array[0]
    for i in range(1, n):
        if(word == s_array[i]):
            count += 1
        else:
            ans += (count*(count+1))//2
            count = 0
        word = s_array[i]

    ans += (count*(count+1))//2
    print(ans)


Measured memory_bytes: 10640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

    int n; cin >> n;
    int ans = 0;
    int counta = 0, countb = 0;

    int hantei = 1;
    vector<int> ora(n),orb(n);

    for(int i = 0;i < n;i ++){
        string s; cin >> s;

        for(int j = 0;j < s.size()-1;j ++){
            if(s.at(j) == 'A' && s.at(j+1) == 'B') ans ++;
        }

        if(s.at(0) == 'B'){
            countb ++;
            orb.at(i) = 1;
        }
        if(s.at(s.size()-1) == 'A'){
            counta ++;
            ora.at(i) = 1;
        }
    }

    for(int i = 0;i < n;i ++){
        if(ora.at(i) - orb.at(i) != 0) hantei = 0;
    }

    bool all0 = true;
    for(int i = 0;i < n;i ++){
        if(ora.at(i) == 1 || orb.at(i) == 1) all0 = false;
    }

    if(all0 == true) hantei = 0;

    int ab = min(counta,countb);

    cout << ans + min(ab, n) - hantei << endl;

}

Measured memory_bytes: 3752
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;

int n,m;
ll a[maxn],b[maxn];

int main() {
 // freopen("in.cpp","r",stdin);
  cin>>n>>m;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<m;i++)cin>>b[i];
  ll sum=0;
  for(int i=0;i+1<m;i++)sum=(sum+(b[i+1]-b[i])*(i+1)%mod*(m-i-1)%mod)%mod;
  ll ret=0;
  for(int i=0;i+1<n;i++)ret=(ret+sum*(i+1)%mod*(n-i-1)%mod*(a[i+1]-a[i])%mod)%mod;

  cout<<ret<<endl;
  return 0;
}


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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;


int s[110];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n,k;cin>>n>>k;

	for(int i=0; i<k; i++){
		int d;cin>>d;

		for(int j=0; j<d; j++){
			int tmp;cin>>tmp;

			s[tmp]++;
		}
	}
	int ct=0;
	for(int i=1; i<=n; i++){
		if(!s[i])ct++;
	}

	writeln(ct);




}




Measured memory_bytes: 3644
///apigs property
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define F first
#define S second
#define pb push_back
#define vll vector< ll >
#define vi vector< int >
#define pll pair< ll , ll >
#define pi pair< int , int >
#define all(s) s.begin() , s.end()
using namespace std;
typedef long long ll;
ll q, dp[555555][5], a[555555] , b[555555] , c[555555], k, l, m, n, o, p;
map < ll , ll > mp;
vll adj[555555];
const ll mod = 1e9+7;
ll mem(ll idx , ll lst){
    if(idx > n)return 0;
    ll &r = dp[idx][lst];
    if(r != -1)return r;
    if(lst == 4){
        r = max(mem(idx + 1 , 1) + a[idx] , max(mem(idx + 1 , 2) + b[idx] , mem(idx + 1 , 3) + c[idx]));
    }
    else if(lst == 3){
        r = max(mem(idx + 1 , 1) + a[idx] , mem(idx + 1 , 2) + b[idx]);
    }
    else if(lst == 2){
        r = max(mem(idx + 1 , 1) + a[idx] , mem(idx + 1 , 3) + c[idx]);
    }
    else{
        r = max(mem(idx + 1 , 2) + b[idx] , mem(idx + 1 , 3) + c[idx]);
    }
    return r;
}
int main() {
    memset(dp , -1 , sizeof dp);
    fast , cin >> n;
    for(ll i = 1 ; i <= n ; i++)cin >> a[i] >> b[i] >> c[i];
    cout << mem(1 , 4) << endl;
    /*for(ll i = 1 ; i <= n ; i++){
        cout << dp[i][1] << " " << dp[i][2] << " " << dp[i][3] << endl;
    }*/
}


Measured memory_bytes: 48396
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;

int main(void)
{
    string n;

    cin >> n;
    ll r = 0;
    for (int i = 0; i < n.length(); ++i)
    {
        r += n[i] - '0';
    }
    if (r % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
ll cnt = 0;

int main(){
  int n; cin >> n;
  int a,b;
  int v[n],c[n];
  rep(i,n){
      cin >> v[i] ;
  }
  rep(i,n){
      cin >> c[i];
  }

  for(int i=0;i<n;i++){
      if(v[i]-c[i]>0){
          cnt+=v[i]-c[i];
      }
  }
  cout << cnt << endl;


 
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG       // Iterator safety; out-of-bounds access for Containers, etc.
//#pragma GCC optimize "trapv" // abort() on (signed) integer overflow.

#include <bits/stdc++.h>

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
//using namespace __gnu_pbds;
//typedef tree< pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
//ordered_set;
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEFINES &&&&&&&&&&&&&&&&&&&&&&&&&&&

#define int long long int 
#define ld long double
#define X first
#define Y second
#define all(i) i.begin(), i.end()
#define sz(a) (int)a.size()
 
const ld PI  = 3.141592653589793238463;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEBUG &&&&&&&&&&&&&&&&&&&&&&&&&&&
 
#define XOX
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z));
    return res;
}
 
void debug_out(vector<string> __attribute__ ((unused)) args, __attribute__ ((unused)) int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
 
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& CODE &&&&&&&&&&&&&&&&&&&&&&&&&&&


void solve(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int win = 1;
    while(a > 0 and c > 0){
        c -= b;
        if(c <= 0){
            win = 1;
            break;
        }
        a -= d;
        if( a <= 0){
            win = 0;
            break;
        }
    }
    if(win)
        cout << "Yes\n";
    else 
        cout << "No\n";
   
}
 
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    int T = 1; 
    //cin >> T;
    for(int i = 1; i <= T; ++i){
        solve();
    }
    return 0;
}
/*
Sample inp
*/

Measured memory_bytes: 3616
import sys
#input = sys.stdin.readline
input = sys.stdin.buffer.readline

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


def main():
	a,b,c=map(int,input().split())
	ans="No"
	if 4*a*b<(c-a-b)**2 and c-a-b>=0:
		ans="Yes"
	print(ans)












if __name__ == "__main__":
	main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
long long a[100005],s,n,q,w;
int main()
{
cin>>n>>q>>w;
for(int i=0;i<n;i++)cin>>a[i];
for(int i=1;i<n;i++)s+=min((a[i]-a[i-1])*q,w);
cout<<s<<endl;
}

Measured memory_bytes: 1024
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> A(N + 1);
  vector<ll> B(M + 1);
  ll K;
  cin >> K;
  A[0] = 0;
  B[0] = 0;
  for (ll i = 1; i < N + 1; i++) {
    cin >> A[i];
    A[i] += A[i - 1];
  }

  for (ll i = 1; i < M + 1; i++) {
    cin >> B[i];
    B[i] += B[i - 1];
  }
  ll ans = 0;
  ll time = 0;
  ll resi_time = K;
  ll B_i = 0;
  for (int i = N; i >= 0; i--) {
    time = A[i];
    if (time > K) {
      continue;
    }
    resi_time = K - time;
    for (ll j = B_i; j <= M; j++) {
      if (B[j] > resi_time) {
        break;
      }
      ans = max(ans, i + j);
      B_i = j;
    }
  }

  cout << ans << endl;

  return 0;
}

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

const int mod = 2019;

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

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    vector<mint> dp(s.length()+1);
    dp.at(s.length()) = 0;
    for(int i = s.length()-1; i>=0; i--)
    {
        mint num = s.at(i) - '0';
        mint digit(10);
        digit = digit.pow(s.length()-1-i);
        num *= digit;
        dp.at(i) = dp.at(i+1) + num;
    }
    // for(auto num : dp) cout << num << '\n';
    vector<int> numod(2019, 0);
    for(int i=0; i<=s.length(); i++)
    {
        numod.at(dp.at(i).x)++;
    }
    ll ans = 0;
    for(int i=0; i<2019; i++)
    {
        ans += numod.at(i) * (numod.at(i) - 1) / 2;
    }
    cout << ans << '\n';

    return 0;
}

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

// Template for atcoder
public class Main {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    final long MOD = 1000L * 1000L * 1000L + 7;
    private static final int[] dx = {0, -1, 0, 1};
    private static final int[] dy = {1, 0, -1, 0};

    void solve() throws IOException {
        int n = nextInt();
        int[] arr = nextIntArr(n);
        int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        for (int i = 0; i < n; i++) {
            if (i + 1 < n) {
                dp[i + 1] = Math.min(dp[i + 1], Math.abs(arr[i + 1] - arr[i]) + dp[i]);
            }
            if (i + 2 < n) {
                dp[i + 2] = Math.min(dp[i + 2], Math.abs(arr[i + 2] - arr[i]) + dp[i]);
            }
        }
        outln(dp[n - 1]);
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    public Main() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new Main();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}


Measured memory_bytes: 42868
#include <iostream>
#include <stdio.h>

int main() {
    std::ios::sync_with_stdio(false);

    int n_sum;
    char n;

    n_sum = 0;
    while ( (n = getchar()) != '\n') {
        n_sum += n - '0';
    }

    if ((n_sum%9) == 0) {
        std::cout << "Yes" << std::endl;
    }
    else {
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3648
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
k = int(input())
 
cnt = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for m in range(1,k+1):
            cnt += gcd(i,j,m)
            
 
print(cnt)

Measured memory_bytes: 69624
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define MAX 1005
#define INF 1000000007

int N;
int A[MAX],B[MAX];
int dp[MAX][MAX];

int main(){

  scanf("%d",&N);

  vector<P> t;
  for(int i=0;i<N;i++){
    scanf("%d %d",&A[i],&B[i]);
    t.push_back( P(B[i],i) );
  }
  sort(t.begin(),t.end());

  for(int i=0;i<MAX;i++)
    for(int j=0;j<MAX;j++)
      dp[i][j]=INF;

  dp[0][0]=0;

  int ans=0;

  for(int i=1;i<=N;i++){

    int id=t[i-1].second;

    for(int j=0;j<=N;j++){
      dp[i][j]=dp[i-1][j];

      if(j>0){
	int f=dp[i-1][j-1];

	if(f<=B[id]-A[id]){

	  dp[i][j]=min(dp[i][j],f+A[id]);

	}
      }
      
      if(dp[i][j]!=INF){
	ans=max(ans,j);
      }
    }
  }
  /*
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N;j++){
      if(dp[i][j]==INF){
	cout<<" INF";
      }else{
	printf(" %3d",dp[i][j]);
      }
    }
    cout<<endl;

  }
  */
  printf("%d\n",ans);
  return 0;
}
/*
   0 INF INF INF
   0   3 INF INF
   0   3   8 INF
   0   3   8  18
3
stdrsv1122{s1210062}167: ./a.out < in2
   0 INF INF INF
   0 INF INF INF
   0  10 INF INF
   0   5  15 INF
2
*/

Measured memory_bytes: 7168
#include<iostream>
using namespace std;
int main(){
	int n,i;
    string s;
  	cin >> n >> s;
    if(s.size()<=n){
    	cout << s << endl;
    }
    else{
    	for(i=0;i<n;i++)
    		cout << s[i];
        cout << "...\n" << endl;
    }
	return 0;
}


Measured memory_bytes: 3556
#define ll long long

#include "bits/stdc++.h"

using namespace std;
static const int INF = (1 << 21);

int main() {
	ll int N, i;
	cin >> N;
	while (1) {
		if (i*i <= N) i ++;
		else break;
	}
	cout << (i - 1)*(i - 1) << endl;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  ll ans=0;
  bool up=false;
  bool down=false;
  for(int i=0;i<N-1;i++){
    if(!up&&!down){
      if(A[i]>A[i+1])down=true;
      else if(A[i]<A[i+1])up=true;
    }
    else if(down){
      if(A[i]<A[i+1]){
        ans++;
        down=false;
      }
    }
    else if(up){
      if(A[i]>A[i+1]){
        ans++;
        up=false;
      }
    }
  }
  cout<<ans+1<<endl;
  return 0;
}


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

using namespace std;

bool PrimeData[10001] = { false,false,true,true };

void findPrimeNumber() {
	int limit;
	bool flag;

	for (int num = 5; num < 10001; num += 2) {
		limit = sqrt(num) + 1;
		flag = true;
		for (int j = 2; j < limit; j++) {
			if (num%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag) {
			PrimeData[num] = true;
		}
	}
}

int main() {
	int n;

	findPrimeNumber();

	while (cin >> n, n) {
		while (n > 4) {
			if (PrimeData[n] && PrimeData[n - 2]) {
				cout << n - 2 << " " << n << endl;
				break;
			}
			n--;
		}
	}

	return 0;
}


Measured memory_bytes: 3100
#include <stdio.h>
#include <math.h>

int isPrime(int);

int main(){

    int num;
    int n;
    int count = 0;

    scanf("%d",&num);

    while( num > 0 ){

        scanf("%d",&n);

        count += isPrime(n);

        num--;

    }

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

    return 0;

}

int isPrime(int n){

    int i;

    if( n == 2 )
        return 1;

    for( i = 2 ; i <= sqrt(n) ; i++ ){
        if( n % i == 0 )
            return 0;
    }

    return 1;

}

Measured memory_bytes: 596
#include<iostream>
#include <cmath> 
#include <iomanip> 
using namespace std;
#define ll long long
int main(){
  ll n,k;
  cin>>n>>k;
  int ans =0;
  while(n--){
    ll a,b,value;
    cin>>a>>b;
    value = a*a;
   value += b*b;
   double sq = sqrt(value);
   if(sq <=k    ){
     ans ++;
   } 

  }
  cout<<ans;
return 0;}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define INF 1e7

using namespace std;
typedef long long int ll;


int main()
{
    string S,T; cin >> S >> T;
    if(S.length() < T.length())
    {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    int p = -1;
    for(int i = 0; i <= S.length() - T.length(); i++)
    {
        if(S[i] == T[0] || S[i] == '?')
        {
            bool f = true;
            for(int j = 0; j < T.length(); j++) 
            {
                if(S[i+j] == '?') continue;
                if(S[i+j] == T[j]) continue;
                f = false;
            }
            if(f) p = i;
        }
    }
    if(p == -1) 
    {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    for(int i = 0; i < T.length(); i++) S[i+p] = T[i];
    for(int i = 0; i < S.length(); i++) if(S[i] == '?') S[i] = 'a';
    cout << S << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
multiset<ll> st;
ll N, M;
vector<l_l> v;

int main() {
    cin >> N >> M;
    for(int i = 1; i <= N; i++) {
        ll a, b;
        cin >> a >> b;
        v.push_back({a, b});
    }
    sort(v.begin(), v.end());
    int index = 0;
    ll ans = 0;
    for(int day = 1; day <= M; day++) {
        while(index < v.size()) {
            if(v[index].first > day) break;
            st.insert(v[index].second);
            index++;
        }
        if(st.empty()) continue;
        auto itr = st.end();
        itr--;
        ans += *itr;
        st.erase(itr);
    }
    cout << ans << endl;
    return 0;
}


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

class Wall {
public:
    int x, y, r;
    Wall(int x, int y, int r) : x(x), y(y), r(r) {};
};

string solve(vector<Wall> &w, int tx, int ty, int sx, int sy) {
    for (int i=0; i<(int)w.size(); ++i) {
        bool inside_t = w[i].r * w[i].r >= (w[i].x - tx) * (w[i].x - tx) + (w[i].y - ty) * (w[i].y - ty);
        bool inside_s = w[i].r * w[i].r >= (w[i].x - sx) * (w[i].x - sx) + (w[i].y - sy) * (w[i].y - sy);
        if ((inside_t && !inside_s) || (!inside_t && inside_s)) {
            return "Safe";
        } else if (!inside_t && !inside_s) {
            if (sx == tx) {
                bool inside = abs(sx - w[i].x) <= w[i].r;
                if (inside && min(ty, sy) <= w[i].y && w[i].y <= max(ty, sy)) {
                    return "Safe";
                }
            } else {
                double a, b, x, y;
                a = (double)(sy - ty) / (sx - tx);
                b = ty - a * tx;
                x = (w[i].x + a * (w[i].y - b)) / (1 + a * a);
                y = a * x + b;
                bool inside = w[i].r * w[i].r >= (w[i].x - x) * (w[i].x - x) + (w[i].y - y) * (w[i].y - y);
                if (inside && min(tx, sx) <= x && x <= max(tx, sx) && min(ty, sy) <= y && y <= max(ty, sy)) {
                    return "Safe";
                }
            }
        }
    }
    return "Danger";
}

int main() {
    int n;
    while (cin >> n, n) {
        vector<Wall> walls;
        int wx, wy, r;
        for (int i=0; i<n; ++i) {
            cin >> wx >> wy >> r;
            walls.push_back(Wall(wx, wy, r));
        }
        int m;
        cin >> m;
        int tx, ty, sx, sy;
        for (int i=0; i<m; ++i) {
            cin >> tx >> ty >> sx >> sy;
            cout << solve(walls, tx, ty, sx, sy) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int M,T,p,R;
    cin >> M >> T >> p >> R;
    while(M != 0){
        vector<pair<int,pair<int,int>>> G(T);
        for(int i=0; i<T; i++){
            G[i].second.second = i;
        }
        vector<vector<int>> cnt(T,vector<int> (p,0));
        for(int i=0; i<R; i++){
            int m,t,q,j;
            cin >> m >> t >> q >> j;
            t--;
            q--;
            if(cnt[t][q] == -1) continue;
            if(j){
                cnt[t][q]++;
            }else{
                G[t].first++;
                G[t].second.first += (-1)*(cnt[t][q]*20+m);
                cnt[t][q] = -1;
            }
        }
        sort(G.begin(),G.end());
        reverse(G.begin(),G.end());
        cout << G[0].second.second+1;
        for(int i=1; i<T; i++){
            if(G[i-1].first == G[i].first and G[i-1].second.first == G[i].second.first){
                cout << "=";
            }else{
                cout << ",";
            }
            cout << G[i].second.second+1;
        }
        cout << endl;
        cin >> M >> T >> p >> R;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int d,n;cin>>d>>n;
    vector<vector<int>> v(3);
    for(int i=1;i<=10000000;i++){
        if(i%1000000==0) continue;
        if(i%10000==0) v[2].push_back(i);
        else if(i%100==0) v[1].push_back(i);
        else v[0].push_back(i);
    }
    cout<<v[d][n-1]<<endl;
}


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

using namespace std;
using ll = long long;

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	vector<int> r(N);
	for(auto&& v : a){
		cin >> v;
	}
	
	int sum = accumulate(a.begin(), a.end(), 0);
	int fil = 0;
	for(int i=1; i<N; i+=2) {
		fil += a[i];
	}
	r[0] = sum - 2*fil;
	for(int i=1; i<=N-1; i++) {
		r[i] = 2 * a[i-1] - r[i-1];
	}
	for(auto&& v : r){
		printf("%d\n", v);
	}
	
	return 0;
}


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

int main(){
    int a, b, d, r;
    double f;
    
    cin >> a >> b;
    
    d = a / b;
    r = a % b;
    f = 1.0 * a / b;
    
    cout << d << " " << r << " " << fixed << setprecision(5) << f << endl;
    
    return 0;
}


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

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define all(i) (i).begin(),(i).end()å
#define rall(i) (i).begin(),(i).end(),greater<int>()
using namespace std;

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T> void print(T x) { std::cout << x << '\n'; }
 
//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

 
signed main(){
 
    int a[5];
    int k;

    rep(i,5){
        cin >>a[i];
    }
    cin >> k;

    for(int i=0;i<4;i++){
        for(int j=i+1;j<5;j++){
            if(a[j]-a[i]>k){
                cout <<":("<<endl;
                return 0;  
            }
        }
    }

    



    cout <<"Yay!"<<endl;



 
}


Measured memory_bytes: 256
late = input()
i = int(late)
if i >= 400 and i <= 599:
	print("8")
if i >= 600 and i <= 799:
	print("7")
if i >= 800 and i <= 999:
	print("6")
if i >= 1000 and i <= 1199:
	print("5")
if i >= 1200 and i <= 1399:
	print("4")
if i >= 1400 and i <= 1599:
	print("3")
if i >= 1600 and i <= 1799:
	print("2")
if i >= 1800 and i <= 1999:
	print("1")


Measured memory_bytes: 9176
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int q, a, b, c, d;
	char s[100000], t[100000];
	int an1[100000], an2[100000];
	scanf("%s", s);
	scanf("%s", t);
	scanf("%d", &q);
	int n1=strlen(s), n2=strlen(t);
	for(int i=0; i<n1; i++){
		if(i==0){
			if(s[0]=='A'){
				an1[0]=1;
			}else{
				an1[0]=0;
			}
		}else if(s[i]=='A'){
			an1[i]=an1[i-1]+1;
		}else{
			an1[i]=an1[i-1];
		}
	}
	for(int i=0; i<n2; i++){
		if(i==0){
			if(t[0]=='A'){
				an2[0]=1;
			}else{
				an2[0]=0;
			}
		}else if(t[i]=='A'){
			an2[i]=an2[i-1]+1;
		}else{
			an2[i]=an2[i-1];
		}
	}
	for(int i=0; i<q; i++){
		scanf("%d %d %d %d", &a, &b, &c, &d);
		a--;
		b--;
		c--;
		d--;
		int n1, n2;
		if(a==0){
			n1=an1[b];
		}else{
			n1=an1[b]-an1[a-1];
		}
		if(c==0){
			n2=an2[d];
		}else{
			n2=an2[d]-an2[c-1];
		}
		if((n1+2*(b-a+1-n1))%3==(n2+2*(d-c+1-n2))%3){
			printf("%s\n", "YES");
		}else{
			printf("%s\n", "NO");
		}
	}
	return 0;
}

Measured memory_bytes: 1408
from collections import deque

h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
cnt = [[-1] * w for _ in range(h)]

def bfs():
    queue = deque([[0, 0]])
    cnt[0][0] = 0
    while queue:
        i, j = queue.popleft()
        if [i, j] == [h - 1, w - 1]:
            return cnt[i][j]
        for di, dj in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            if (0 <= i + di < h and 0 <= j + dj < w and s[i + di][j + dj] == "." and cnt[i + di][j + dj] == -1):
                cnt[i + di][j + dj] = cnt[i][j] + 1
                queue.append([i + di, j + dj])

bfs()
ans = -1
if cnt[h - 1][w - 1] != -1:
    ans = 0
    for i in range(h):
        for j in range(w):
            if s[i][j] == ".":
                ans += 1
    ans = ans - (cnt[h - 1][w - 1] + 1)
print(ans)

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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;

int n, k;

signed main()
{
    cin >> n >> k;
    set<int> ans;
    int temp;

    rep(i, k)
    {
        cin >> temp;
        vector<int> a(temp);
        rep(j, temp)
        {
            cin >> a[j];
            ans.insert(a[j]);
        }
    }

    cout << n - ans.size() << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  ll x,y;

  cin>>x>>y;

  cout<< (abs(x-y)<=1? "Brown": "Alice") <<"\n";

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


Measured memory_bytes: 256