akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <algorithm>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
int main () {
  string n;
  cin >> n;
  int a[20];
  REP(i,n.length()) a[i] = (int)n[i] - (int) '0';
  long int x=0;
  int z = 0;
  REP(i,n.length()) z += a[i];
  REP(i,n.length()) x += a[i] * (int) pow(10,n.length()-i-1);
  if(x % z == 0) {
    cout << "Yes" << "\n";
    return 0;
  } else {
    cout << "No" << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define NIL -1
#define N 100005

struct Node{ int p, l, r; };

Node T[N];
int n, r, D[N];

void print(int u){
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";

	if (T[u].p == NIL) cout << "root, ";
	else if (T[u].l == NIL) cout << "leaf, ";
	else cout << "internal node, ";

	cout << "[";
	for (int i = 0, c = T[u].l; c != NIL; ++i, c = T[c].r)
	{
		if (i) cout << ", ";
		cout << c;
	}
	cout << "]" << endl;
}

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

int main()
{
	cin >> n;
	for (int i = 0; i < n; ++i) T[i].p = T[i].l = T[i].r = NIL;

	for (int i = 0; i < n; ++i){
		int v, d; cin >> v >> d;
		int l;
		for (int j = 0; j < d; ++j){
			int c; cin >> c;
			if (0 == j) T[v].l = c;
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}

	for (int i = 0; i < n; ++i){
		if (T[i].p == NIL) r = i;
	}

	rec(r, 0);
	for (int i = 0; i < n; ++i) print(i);

	return 0;
}

Measured memory_bytes: 7776
function Main(input) {
  input = input.split("\n");
  var [n, d] = input[0].split(" ").map((a) => parseInt(a, 10));
  var counter = 0;
  for (var i=0; i<n; i++) {
    var [x, y] = input[i+1].split(" ").map((a) => parseInt(a, 10));
    var distance = Math.sqrt(x**2 + y**2);
    if (distance <= d) {
      counter += 1;
    }
  }
  console.log(counter);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 62400
#include<cstdio>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<functional>
#include<cstring>
#include<string>
#include<cstdlib>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<map>
using namespace std;
#define N 100000+5
#define rep(i,n) for(int i=0;i<n;i++)
#define sd(n) scanf("%d",&n)
#define sll(n) scanf("%I64d",&n)
#define pd(n) scanf("%d\n",n)
#define pll(n) scanf("%I64d\n",n)
#define MAX 26
typedef long long ll;
const ll mod=1e9+7;
ll n,m;
ll a[N];
ll b[N];
vector<ll>p[N];
int main()
{
	 //string s;
	 //cin>>s;
	 //ll ans=0;
	 //ll sum=0;
	scanf("%d",&n);
	scanf("%d",&m);
	for(int i=0;i<m;i++)
	{
		scanf("%lld%lld",&a[i],&b[i]);
		p[a[i]].push_back(b[i]);
	}
	for(int i=1;i<=n;i++)
	  sort(p[i].begin(),p[i].end());
	for(int i=0;i<m;i++)
	{

		int pos=lower_bound(p[a[i]].begin(),p[a[i]].end(),b[i])-p[a[i]].begin()+1;
		printf("%06lld%06lld\n",a[i],pos);
	}
	//for(int i=1;i<=n;i++)
	//	printf("%I64d",a[i]);
		
	//printf("%I64d\n",ans);
    return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	string a;
	cin>>a;
	int b=0;
	fo(i,4){
		if(a[i]=='+')
			b+=2;
		b--;
	}
	cout<<b<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fit(x) for(auto it=x.begin();it!=x.end();++it)
#define se second
#define mp make_pair
#define ALP "abcdefghijklmnopqrstuvwxyz"
#define nline cout<<"\n"
#define rep(i,x) for(i=0;i<x;++i)
#define repr(i,a,b) for(i=a;i<=b;++i)
#define mi2 500000004
#define mi3 333333336
#define MOD 1000000007
#define N 1000005
#define pll pair<ll,ll>
#define Vll vector<ll>
#define W(t) while(t--)
#define modsum(a,b,M) (a%M + b%M)%M
#define modsub(a,b,M) (a%M - b%M + M)%M
#define modmul(a,b,M) (a%M * b%M)%M
#define moddiv(a,b,M) (a%M * modinv(b,M)%M)%M
using namespace std;
ll powermod(ll x,ll n,ll M)
{
	ll result=1;
	while(n>0)
	{
	  if(n % 2 ==1)
	    result=(result * x)%M;
	  x=(x*x)%M;
	  n=n/2;
	}
	return result;
}
vector<ll> readll() {
	cin>>ws;
	vector<ll> v;
	string input;
	getline(cin, input);
	cout<<input;
	istringstream is(input);
	ll num;
	while(is>>num) v.pb(num);
	return v;
}
ll modinv(ll n,ll p) {
	return powermod(n,p-2,p);
}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll fact[1000005],invf[1000005];
void facmod(ll n,ll M) {
	ll i;
	fact[0]=fact[1]=1;
	for(i=2;i<=n;++i) {
		fact[i]=((fact[i-1])%M * (i%M))%M;
	}
	invf[n]=modinv(fact[n],M);
	for (i=n-1;i>=0;--i){
		invf[i]=invf[i+1]*(i+1);
		invf[i]%=M;
	}
}
/*****
ll T=0;
ll p[200005], d[200005];
ll tin[200005], tout[200005];
vector<ll> g[200005];

void dfs(ll v, ll par = 1, ll dep = 0) {
	p[v] = par;
	d[v] = dep;
	tin[v] = T++;
	for (auto to : g[v]) {
		if (to == par) continue;
		dfs(to, v, dep + 1);
	}
	tout[v] = T++;
}
****/
void solve() {
	ll n,m;
	cin>>n>>m;
	ll ans = (n*(n-1))/2 + (m*(m-1))/2;
	cout<<ans;
}
int main() {
  	fastio;
	ll t=1;
	//cin>>t;
	W(t) {
		solve();
	}
	
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll K;
  cin>>K;
  ll ans=0;
  for(int i=1;i<=K;i++){
    for(int j=1;j<=K;j++){
      for(int k=1;k<=K;k++){
        ans+=gcd(gcd(i,j),k);
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    double a, b;
    cin >> a >> b;
    cout << a / b;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll N,A=1,a,M=1e9+7,i;
	cin>>N;
	priority_queue<pair<ll,ll>> Q;
	for(i=0;i<N;i++)cin>>a,Q.push({a,-1});
	for(i=0;i<N;i++)cin>>a,Q.push({a,1});
	a=0;
	while(!Q.empty()){
		i=Q.top().second;
		if(a!=i*abs(a))(A*=abs(a))%=M;
		a+=i;Q.pop();
	}
	cout<<A<<endl;
}

Measured memory_bytes: 6256
import bisect
from collections import deque

"""
def pl(d,k):

    now = d
    ind = bisect.bisect_left(dlis,d)

    while ind > 0:
        dic[dlis[ind]] += 1

        if dic[dlis[ind]] // k == 0:
            dic[dlis[ind]] = 0
        else:
            break

        ind -= 1

    

def able(k):

    ndep = A[0]
    for i in range(len(dlis)):
        dic[dlis[i]] = 0

    for i in range(N-1):
        i += 1
        if ndep < A[i]:
            dic[A[i]] = 0
            ndep = A[i]
        else:
            ndep = A[i]
            pl(ndep,k)

    print (dic,k)
    if dic[dlis[0]] < k:
        return True
    else:
        return False

"""

def updiv(a,b):
    if a % b == 0:
        return a // b
    else:
        return a // b + 1
    

def able(k):

    nq = deque([0])
    num = deque([A[0]])

    for i in range(N-1):
        i += 1

        if A[i] > A[i-1]:
            if nq[-1] == 0:
                num[-1] += A[i] - A[i-1]
            else:
                nq.append(0)
                num.append(A[i] - A[i-1])

        else:

            if A[i] < A[i-1]:
                ds = A[i-1] - A[i]
                while len(num) > 0 and ds >= num[-1]:
                    nq.pop()
                    ds -= num[-1]
                    num.pop()
                if len(num) == 0:
                    return False
                num[-1] -= ds

            now = 0
            while len(nq) > 0 and nq[-1] == k-1:
                now += num[-1]
                nq.pop()
                num.pop()
            if len(nq) == 0:
                return False

            if num[-1] == 1:
                nq[-1] += 1
            else:
                num[-1] -= 1
                nq.append(nq[-1] + 1)
                num.append(1)

            if now > 0:
                nq.append(0)
                num.append(now)

        while len(nq) > 1 and nq[-1] == nq[-2]:
            num[-2] += num[-1]
            nq.pop()
            num.pop()
    
        #print (k,A[i])
        #print (nq)
        #print (num)
    return True

            


N = int(input())

A = list(map(int,input().split()))
A.append(1)

l = 0
r = N

while r - l != 1 :

    m = (l + r) // 2

    if able(m):
        r = m
    else:
        l = m

print (r)

Measured memory_bytes: 92752
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int main(){
  int n;
  cin >> n;
  vector<vi> a(2 , vi(n));
  rep(i,0,2) rep(j,0,n) cin >> a[i][j];
  int best = 0;
  rep(i,0,n) {
    int sum = 0;
    rep(j,0,i+1) sum += a[0][j];
    rep(j,i,n) sum += a[1][j];
    best = max(best , sum);
  }
  cout << best << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    from sys import setrecursionlimit
    setrecursionlimit(10 ** 7)

    n = int(input())
    graph = [list() for _ in range(n)]
    ans = [0 for _ in range(n - 1)]

    # KeyInsight:
    # 木の問題と再帰関数は相性がいい
    # See:
    # https://www.youtube.com/watch?v=7IlBVSglZqc
    for i in range(n - 1):
        ai, bi = map(int, input().split())
        ai -= 1
        bi -= 1
        graph[ai].append((bi, i))
        graph[bi].append((ai, i))

    def dfs(vertex, parent=-1, edge_color=-1):
        color_code = 1

        for to, edge_id in graph[vertex]:
            if to == parent:
                continue

            if color_code == edge_color:
                color_code += 1

            ans[edge_id] = color_code
            color_code += 1

            dfs(to, vertex, ans[edge_id])

    dfs(0)
    count = 0

    for g in graph:
        count = max(count, len(g))

    print(count)
    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 108516
s,k = input().split()
mod = 998244353
k = int(k)
k = min(300,k)
raw = [0]
l = len(s)
for i in range(l):
  if s[i] == '0':
    raw.append(0)
  else:
    raw[-1] += 1
#print(raw)
now = [[0 for _ in range(k+1)] for _ in range(k+1)]
l = len(raw)
raw.reverse()
#print(raw)
now[0][0] = 1
for x in raw:
  last = now[:]
  now = []
  for i in range(k+1):
    use = last[i][:]
    use.reverse()
    cum = []
    for j in range(k+1):
      if cum:
        cum.append(cum[-1]+use[j])
        cum[-1] %= mod
      else:
        cum = [use[0]]
    cum.reverse()
    now.append(cum)
    #print(cum)
  #print('#')
  cum2 = []
  for i in range(k+1):
    cum = [0 for _ in range(i)]
    cum.append(last[i][0])
    #print('%',cum)
    for l in range(i+1,k+1):
      cum.append(cum[-1]+last[l][l-i])
    #print(cum)
    cum2.append(cum)
  for i in range(k+1):
    for j in range(k+1):
      if j > i:
        pass
      now[i][j] += cum2[i-j][i]
      if i - x - 1 >= 0:
        now[i][j] -= cum2[i-j][i-x-1]
      now[i][j] %= mod
  for i in range(k+1):
    for j in range(k+1):
      now[i][j] -= last[i][j]
      now[i][j] %= mod
  #print(now)
  #print('##')
        
  #print(now)
#print(now)
ans = 0
for i in range(k+1):
  ans += now[i][0]
print(ans%mod)

Measured memory_bytes: 174364
#include <iostream>
#include <map>

int main(int argc, const char * argv[]) {
    // insert code here...
    //std::cout << "Hello, World!\n";
    std::map<int,int> mp;
    int N;
    int d[110];
    
    //std::cout<<"enter N\n";
    std::cin>>N;
    for(int i=0;i<N;i++){
        //std::cout<<"enter d\n";
        std::cin>>d[i];
    }
    
    for(int i=0;i<N;i++){
        mp[d[i]]++;
    }
    
    std::cout<<mp.size()<<std::endl;
    
    return 0;
}

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

using namespace std;
typedef long long ll;
const ll INF = 1e9;
 
int main(void) {
    ll N, K, Q; cin >> N >> K >> Q;
    vector<ll> scores(N, 0);
    
    for (int i = 0; i < Q; i++) { 
        int ai; cin >> ai;
        scores[ai - 1]++;
    }

    // for (int i = 0; i < N; i++) { cout << scores[i] << " "; } cout << endl;

    for (int i = 0; i < N; i++) {
        if (scores[i] > Q - K) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<lint>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    lint n, m;
    cin >> n >> m;

    lint res = -1;

    vi div;

    for (int i = 1; i * i <= m; i++) {
        if (m % i == 0) {
            div.push_back(i);
            if (i * i != m) div.push_back(m/i);
        }
    }

    for (auto&& e : div) {
        if (e * n <= m) {
            res = max(res, e);
        }
    }
    
    cout << res << endl;
    return 0;
}


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

const ll MOD = 1e9 + 7;

int main()
{
	string a; cin>>a;
	int n = a.size();
	int cnt[26]={};
	if(n < 26) {
		for(char x:a) cnt[x-'a']++;
		for(int i=0;i<26;i++){
			if(cnt[i]==0){
				a.push_back('a'+i);
				cout<<a; return 0;
			}
		}	
	}
	int i=n-2;
	while(i >= 0 and a[i] > a[i+1]) i--;
	++i;
    if(i==0){cout<<"-1"; return 0;}
	char t = a[i-1];
	int j;
	for(j=n-1;j>=i;j--) if(a[j]>t) break;
	
	swap(a[i-1],a[j]);

	for(int x=0;x<=i-1;x++) cout<<a[x];
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main (String[] args) {
        FastReader sc = new FastReader();
        String d = sc.nextLine();
        System.out.println(d.substring(0, 3) + "8" + d.substring(4));
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

#define F(i , a , b) for(int (i) = (a) ; (i) <= (b) ; (i)++)
#define pb push_back
#define ll long long
#define E(a) cerr << #a << " = " << a << '\n'
#define X first
#define Y second
#define INF 10000000000000
#define int long long
const int MAX_N = 100000 + 10 , mod = 1000000007;

ll n,a[MAX_N],b[MAX_N],num;

int32_t main(){
    
    //    freopen("input.txt" , "r" , stdin);
    //    freopen("output.txt" , "w" , stdout);
    //    cout << setprecision(10) << fixed;
    ios::sync_with_stdio(0); cin.tie() ; cout.tie();
    
    cin >> n;
    for(int i=0 ; i<n; i++){
    	cin >>a[i] >> b[i];
    }
    for(int i = n-1; i+1 ;i--){
    	a[i] += num;
    	num += b[i]*ceil(1.0*a[i]/b[i]) - a[i];
    	a[i] = b[i]*ceil(1.0*a[i]/b[i]);
    }
    cout << num;
    
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	int a, b;
	cin >> a >> b;

	int N = stoi((to_string(a) + to_string(b)));
	if (int(sqrt(N)) * int(sqrt(N)) == N) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define vs vector<string>
#define ss second
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define tr1(x)                cout<<#x<<": "<<x<<endl
#define tr2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define tr4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl
#define tr3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define db1(x) cerr << #x << ": " << x <<'\n'
#define db2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define db3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<pair<string,int>, int> &a,const pair<pair<string,int>, int> &b)
{
    if(a.ff.ff == b.ff.ff) {
        return (a.ff.ss > b.ff.ss);
    }
    return (a.ff.ff<b.ff.ff);
}
int min(int a, int b){
    if(a<b){
        return a;
    }
    else{
        return b;
    }
}
int max(int a, int b){
    if(a>b){
        return a;
    }
    else{
        return b;
    }
}
int max(int a, int b, int c){
    return(max( max(a,b), c ));
}
int min(int a, int b, int c){
    return (min ( min(a,b) , c));
}
int poww(int a, int b)
{
    int res = 1;
    for(int i = 1; i<=b; ++i)
        res *= a;

    return res;
}
int findlcm(int arr[], int n) 
{ 
    // Initialize result 
    int ans = arr[0]; 
  
    // ans contains LCM of arr[0], ..arr[i] 
    // after i'th iteration, 
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (__gcd(arr[i], ans))); 
  
    return ans; 
}
bool prime[100001];
void SieveOfEratosthenes(int n) 
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
  }
}

//Define mx for maximum range and MOD for large numbers
#define mx 500005
#define mod 1000000007 

// Declare all the variables and global functions here -
int n, m;
int32_t main(){
    IOS;
    cin >> n;
    vi w;
    rep(i, 0, n){
        int c;
        cin >> c;
        w.pb(c);
    }

    //sort(all(w));
    int s1 = 0;
    int s2 = 0;
    int toss = 0;
    int t = 1;
    int ans = inf;
    while(t <n ){
        s2 = 0;
        s1 = 0;
        rep(i, 0, n){
            if(i < t){
                s1+= w[i];
            }
            else{
                s2+= w[i];
            }
        }
        //tr2(t, abs(s2 - s1));
        t++;
        
        ans = min(ans, abs(s2 - s1));
    }

    cout << ans << endl;
}   

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i, n)	for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    /*input*/
    int n, a, b;    cin >> n >> a >> b;
    /*calculation*/
    /*output*/
    cout << min(a*n, b) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int flag=0;
    int n;
    scanf("%d",&n);
    while(n)
    {
        if(n%10==7)flag=1;
        n/=10;
    }
    if(flag)printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 3760
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val H = sc.nextInt()
    val W = sc.nextInt()
    val h = sc.nextInt()
    val w = sc.nextInt()
    println(problem121a(H, W, h, w))
}

fun problem121a(H: Int, W: Int, h: Int, w: Int): Int {
    return (H - h) * (W - w)
}

Measured memory_bytes: 31008
n = int(input())

a = list(map(int, input().split()))

sigma = sum(a)
count = 0
for i in range(len(a)-1):
  start = a[i]
  sigma = sigma-a[i]
  count = count + start * sigma
  if count >= 10**9+7:
    count = count % (10**9+7)

print(count)

Measured memory_bytes: 31396
PROGRAM ATCODER

implicit none
character(len=100) :: s
integer :: i,count=0,n

read*, n,s

do i = 1, n, 1
  if ( s(i:i) == 'R' ) then
    count = count + 1
  end if
end do

if ( count > n/2 ) then
  print'(a)', 'Yes' 
else
  print'(a)', 'No' 
end if

contains
!!!!!! サブルーチンは↓
!!!!!!

END PROGRAM ATCODER


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

#define rep(i,n) for (int i = 0; i < (int)(n);i++)

int main() {
    string a,s,c;
    cin >> a >> s >> c;
    cout << a.at(0) << s.at(0) << c.at(0) << endl;
}

Measured memory_bytes: 256
fun main (args : Array<String>) {
	val n = readLine()!!
	val N : Int = n.toInt()
	val a = readLine()!!.split(" ")
	val b = readLine()!!.split(" ")
	val c = readLine()!!.split(" ")
	var aList : MutableList<Int> = mutableListOf()
	var bList : MutableList<Int> = mutableListOf()
	var cList : MutableList<Int> = mutableListOf()
	var result : Int = 0
	for (i in a) {
		aList.add(i.toInt())
	}
	for (i in b) {
		bList.add(i.toInt())
	}
	for (i in c) {
		cList.add(i.toInt())
	}
	result += bList[aList[0] - 1]
	for (i in 1..N - 1) {
		if ( (aList[i] - 1) == aList[i - 1] ) {
			result += cList[aList[i - 1] - 1]
		}
		result += bList[aList[i] - 1]
	}
	println("${result}")
}

Measured memory_bytes: 35984
N = int(input())
A = list(map(int, input().split()))

answer = "APPROVED"
for i in range(0, len(A)):
    if A[i] % 2 == 0:
        if A[i] % 3 != 0 and A[i] % 5 != 0:
            answer = "DENIED"

print(answer)


Measured memory_bytes: 2940
#include <iostream>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
using namespace std;
int n;
int p[] = {};
void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};
int main(){
    cin >> n;
    inputArray(p,n);
    int counter = 0;
    bool frag = true;
    while(frag){
        for(int i = 0; i < n; i++){
            if(p[i]%2 == 0){
                p[i] /= 2;
            }else{
                frag = false;
            }
        }
        if(frag) counter++;
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 504
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();

		int xMax = w - r;
		int xMin = r;
		int yMax = h - r;
		int yMin = r;

		if (x < xMin || x > xMax) {
			System.out.println("No");
		} else if (y < yMin || y > yMax) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 26332
#include<stdio.h>

int main()
{
int n,i,R[200000],maxv,minv,a;

scanf("%d",&n);

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

maxv=R[1]-R[0];
minv=R[0];

for(i=1;i<=n-1;i++)
{
a=R[i]-minv;
if(maxv<a) maxv=a;
if(minv>R[i]) minv=R[i];
}
printf("%d\n",maxv);
return 0;
}

Measured memory_bytes: 1376
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T> > &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

string L;

int mod_pow(int x, int y) {
  ll res = 1LL;
  while (y > 0) {
    if ((y & 1))
      res = res * x % MOD;
    x = x * x % MOD;
    y >>= 1;
  }
  return res;
}

int dp[100005][2];

signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> L;
  int n = (int)L.size();
  dp[0][0] = 1;
  rep(i, 0, n) {
    if (L[i] == '0') {
      dp[i+1][0] = dp[i][0];
      dp[i+1][1] = dp[i][1];
    } else {
      dp[i+1][1] = (dp[i][0] + dp[i][1]) % MOD;
    }

    if (L[i] == '0') {
      (dp[i+1][1] += dp[i][1]*2 % MOD) %= MOD;
    } else {
      (dp[i+1][0] += dp[i][0]*2 % MOD) %= MOD;
      (dp[i+1][1] += dp[i][1]*2 % MOD) %= MOD;
    }
  }
  cout << (dp[n][0] + dp[n][1]) % MOD << endl;
  return 0;
}




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

int main(void){
  int X;
  cin>>X;
  for(int a=X;;a++){
    bool flag=true;
    for(int i=2;i<=sqrt(a);i++){
      if(a%i==0) {
        flag=false;
        break;
      }
    }
    if(flag){
      cout<<a<<endl;
      break;
    }
  }
  return 0;
}


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

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

#define INF 256;

int V, E;
int cost[110][110];
int mincost[110];
bool used[110];

int prim(){
    REP(i, V){
        mincost[i] = INF;
        used[i] = false;
    }
    mincost[0] = 0;
    int res = 0;

    while(true){
        int v = -1;
        REP(u, V){
            if(!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;
        }

        if(v == -1) break;
        used[v] = true;
        res += mincost[v];

        REP(u, V){
            mincost[u] = min(mincost[u], cost[v][u]);
        }
    }
    return res;
}

int main(){
    while(cin >> V >> E, V+E != 0){
        REP(i, 110) REP(j, 110) cost[i][j] = INF;

        REP(i, E){
            int a, b, c;
            cin >> a >> b >> c;
            cost[a][b] = c;
            cost[b][a] = c;
        }
        cout << prim() << endl;
    }
}

Measured memory_bytes: 1208
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var nums = Console.ReadLine().Split(' ');
            var k = int.Parse(nums[0]);
            var x = int.Parse(nums[1]);
            var ans = (k * 500 >= x) ? "Yes" : "No";
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>

#define FALSE (0)
#define TRUE  (!FALSE)


void sharp(const int);
void line(const int, const int);

int main(void) {
	int h;
	int w;
	
	while (input(&h, &w) == TRUE) {
		line(h, w);
	}
	
	return 0;
}

int input(int *h, int *w) {
	scanf("%d %d", h, w);
	if ((*h == 0) && (*w == 0)) {
		return FALSE;
	} else {
		return TRUE;
	}
}

void sharp(const int w) {
	if (w != 0) {
		putchar('#');
		sharp(w - 1);
	}
}

void line(const int h, const int w) {
	if (h != 0) {
		sharp(w);
		putchar('\n');
		line(h - 1, w);
	} else {
		putchar('\n');
	}
}

Measured memory_bytes: 572
#include<stdio.h>
main( )
{
  int num;
  int i = 0 ;
 
  while(1)
    {
      ++i;
       
      scanf("%d", &num);
      if( num == 0)
    break;
 
      printf("Case %d: %d\n", i, num);
 
    }
 
 
  return 0;
 
 
}

Measured memory_bytes: 2660
#include<string>
#include<cstdlib>
#include<iostream>

using namespace std;

int prior[128];

int parse(string s)
{
	if(s[0]=='(' && s[s.length()-1]==')'){
		bool f=true;
		for(int i=1,d=1;i<s.length()-1;i++){
			if     (s[i]=='(')	d++;
			else if(s[i]==')')	d--;
			if(d==0){	f=false;	break;	}
		}
		if(f)	return parse(s.substr(1,s.length()-2));
	}

	int divprr=3,divpos=10000000;
	for(int i=s.length()-1,d=0;i>=1;i--){
		if     (s[i]==')')	d--;
		else if(s[i]=='(')	d++;

		else if(d==0 && prior[s[i]]!=0){
			if(divprr>prior[s[i]])
				divprr=prior[s[i]],divpos=i;
		}
	}

	if(divpos==10000000)	return atoi(s.c_str());

	switch(s[divpos]){
		case '+': return parse(s.substr(0,divpos)) + parse(s.substr(divpos+1));
		case '-': return parse(s.substr(0,divpos)) - parse(s.substr(divpos+1));
		case '*': return parse(s.substr(0,divpos)) * parse(s.substr(divpos+1));
		case '/': return parse(s.substr(0,divpos)) / parse(s.substr(divpos+1));
	}

	while(1);
}

int main()
{
	prior['+']=prior['-']=1;
	prior['*']=prior['/']=2;

	int n;	cin>>n;
	while(n--){
		string s;	cin>>s;
		s=s.substr(0,s.length()-1);
		cout<<parse(s)<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
    int N, M;  cin >> N >> M;
    vector<ll> a(N);
    vector<ll> b(N);
    vector<ll> c(M);
    vector<ll> d(M);
    rep(i, N) cin >> a[i] >> b[i];
    rep(i, M) cin >> c[i] >> d[i];

    rep(i, N) {
        ll D = INF;
        ll pos = 0;
        rep(j, M) {
            if (D > abs(a[i]-c[j]) + abs(b[i]-d[j])) {
                pos = j + 1;
                D = abs(a[i]-c[j]) + abs(b[i]-d[j]);
            }
        }
        print(pos);
    }
}




Measured memory_bytes: 256
// ARC086
// C - Not so Diverse

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

int K, N;

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

    vector<int> cnt(N + 1);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        cnt[a]++;
    }
    sort(cnt.begin(), cnt.end());

    int ans = 0;
    for (int i = 0; i < N + 1 - K; i++) {
        ans += cnt[i];
    }

    cout << ans << endl;

    return 0;
}


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

const int N = 105;
const int mod = (int) 1e9 + 7;

int n, k;
int arr[N];
int dp[2][100005];

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    sort(arr, arr + n);
    for (int j = 0; j <= arr[0]; j++) dp[0][j] = 1;
    for (int i = 1; i < n; i++) {
        int sum = 0;
        for (int j = 0; j <= k; j++) {
            if (j == 0) {
                sum++;
            }else{
                sum = (sum + dp[(i - 1) & 1][j]) % mod;
            }
            if (j > arr[i]) {
        	    sum = ((sum - dp[(i - 1) & 1][j - arr[i] - 1]) + mod) % mod;
			}
      		dp[i & 1][j] = sum;
    	}
    }
    cout << dp[(n - 1) & 1][k] << endl;
    return 0;
}


Measured memory_bytes: 1152
class BinaryIndexedMaxTree(val size:Int){
    private val array = Array<Long>(size, {0})
    private fun up(idx:Int):Int {//左端の0を1に変える
        return idx + (idx.inv() and (idx + 1))
    }
    private fun left(idx:Int):Int {//左端の
        return idx - (idx.inv() and (idx + 1))
    }
    operator fun get(index:Int):Long{
        var max:Long = 0
        var idx = index
        while (idx >= 0){
            if (array[idx] > max) max = array[idx]
            idx = left(idx)
        }
        return max
    }
    fun increase(index:Int, value:Long):Unit{
        var idx = index
        while(idx < size){
            if (array[idx] < value) array[idx] = value
            idx = up(idx)
        }
    }
}
data class SushiDish(val distance:Long, val caloric:Long)
fun main(args:Array<String>):Unit{
    val (ns, cs) = readLine()!!.split(' ')
    val (n, c) = Pair(ns.toInt(), cs.toLong())
    val sushis = Array(n, {val (d, c) = readLine()!!.trim().split(' ').map(String::toLong); SushiDish(d, c)})
    val rBit = BinaryIndexedMaxTree(n)//rBit[idx] => 時計回りにidx + 1番目の寿司を食べた場合の最大摂取カロリー
    val lBit = BinaryIndexedMaxTree(n)//lBit[idx] => 反時計回りにn - idx番目の寿司を食べた場合の最大摂取カロリー
    val rrBit = BinaryIndexedMaxTree(n + 1)//rrBit[idx] => 時計回りにidx番目の寿司まで食べてスタート地点に戻った場合の最大摂取カロリー
    val rlBit = BinaryIndexedMaxTree(n + 1)//rlBit[idx] => 反時計回りにn - idx + 1番目の寿司まで食べてスタート地点に戻った場合の最大摂取カロリー
    var sumCaloric:Long = 0
    for ((idx, sushi) in sushis.withIndex()){
        sumCaloric += sushi.caloric
        if (sumCaloric > sushi.distance) rBit.increase(idx, sumCaloric - sushi.distance)
        if (sumCaloric > sushi.distance * 2) rrBit.increase(idx + 1, sumCaloric - sushi.distance * 2)
    }
    sumCaloric = 0
    for ((idx, sushi) in sushis.reversed().withIndex()){
        sumCaloric += sushi.caloric
        if (sumCaloric > c - sushi.distance) lBit.increase(idx, sumCaloric - c + sushi.distance)
        if (sumCaloric > (c - sushi.distance) * 2) rlBit.increase(idx + 1, sumCaloric - (c - sushi.distance) * 2)
    }
    println((0 until n).map{idx -> listOf(rBit[idx] + rlBit[n - idx - 1], lBit[idx] + rrBit[n - idx - 1]).max()}.filterNotNull().max())
}

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

int main() {
    int n;
    cin >> n;
    vector<int> as(n);
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }

    vector<int> lis(n + 1, 1e9);
    vector<vector<int>> ds(n);
    for (int i = 0; i < n; i++) {
        int k = lower_bound(lis.begin(), lis.end(), as[i]) - lis.begin();
        lis[k] = as[i];
        ds[k].push_back(as[i]);
    }
    long long ans = 0;
    int k;
    for (k = 0; k < n + 1; k++) {
        if (lis[k] == 1e9) break;
    }

    int nax = 1e9;
    for (int i = k - 1; i >= 0; i--) {
        sort(ds[i].begin(), ds[i].end());
        while (ds[i].back() >= nax) {
            ds[i].pop_back();
        }
        ans += ds[i].back();
        nax = ds[i].back();
    }

    cout << ans << endl;
}


Measured memory_bytes: 9048
//AcFreak

#include<bits/stdc++.h>
#define lint long long int 
#define mp make_pair
#define pb push_back
#define pii pair<int,int >
using namespace std;


int main()
{
      lint n,k;
      cin>>n>>k;
      
      lint i,j;
      
      vector<lint >arr(200000,0);
      
      for(i=0;i<n;i++)
      cin>>arr[i];
      
      lint count=0;
      for(i=0;i<n-1;i+=(k-1))
      {
            count++;
      }
      cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (b < a+1)puts("delicious");
	else if (b < x + a +1)puts("safe");
	else puts("dangerous");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int N;
    int ten[210] = {0};
    scanf("%d",&N);
    int i,j,k,t = 0,m = 0;
    int joi[N + 1][3];
    for(i = 0;i < N;i++){
        for(j = 0;j < 3;j++){
            scanf("%d",&joi[i][j]);
        }
    }
    for(i = 0;i < N;i++){
        for(j = 0;j < 3;j++){
            for(k = 0;k <= N;k++){
                //printf("joi[i][j]==%d  joi[k][j]==%d\n",joi[i][j],joi[k][j]);
                if(joi[i][j] == joi[k][j] && k < N){
                    //printf("%d==%d\n",joi[i][j],joi[k][j]);
                    m++;
                    ten[i] += 0;
                    if(m == 2){
                        break;
                    }
                }
                else t++;
            }
            if(t == N){
                ten[i] += joi[i][j];
            }
            t = 0;
            m = 0;
        }
    }
    for(i = 0;i < N;i++){
        printf("%d\n",ten[i]);
    }



    return 0;
}

Measured memory_bytes: 1824
N, x = map(int,input().split())
A = list(map(int,input().split()))

ans = 0
for i in range(0, N-1):
    while A[i] + A[i+1] > x:
        tmp = A[i + 1] + A[i] - x
        if A[i+1] > 0:
            if tmp > A[i+1]:
                tmp = A[i+1]
            A[i+1] -= tmp
            ans += tmp
        elif A[i] > 0:
            if tmp > A[i]:
                tmp = A[i]
            A[i] -= tmp
            ans += tmp

print(ans)

Measured memory_bytes: 14148
alp = "a b c d e f g h i j k l m n o p q r s t u v w x y z"
alp = list(map(str, alp.split()))
s = input()
for i in range(len(s)):
    for j in range(26):
        if(s[i] == alp[j]):
            alp[j] = "?"
while("?" in alp):
    alp.remove("?")
if(len(alp) == 0):
    print("None")
else:
    print(alp[0])

Measured memory_bytes: 3188
#include <stdio.h>

int main()
{
  int a, b, k, i;
  
  scanf("%d %d %d", &a, &b, &k);
  
  if(b - a + 1 <= 2 * k){
    for(i = 0; i <= b - a; i++){
      printf("%d\n", a + i);
    }
  }

  else{
  for(i = 0; i < k; i++){
      printf("%d\n",a + i);
  }

  b = b - k + 1;
    
  for(i = 0; i < k; i++){
    printf("%d\n",b + i);
  }
  }
  return 0;
}


Measured memory_bytes: 128
a, b, x = map(int, input().split())
vol = a*a*b
half=a*a*b/2
if x> half:
    t = (vol-x)*2/a/a
    tan = t/a
else:
    t= x*2/b/a
    tan=b/t
import math
ans =math.degrees(math.atan(tan))
print(ans)

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

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;

int A[200003];

int main()
{
	// freopen("input.in", "r", stdin);

	int n, k;
	scanf("%d %d", &n, &k);
	for(int i = 0; i < n; i++)
		scanf("%d", &A[i]);

	sort(A, A+n);
	long sum = 0;
	for(int i = 0; i < n-k; i++)
		sum += A[i];
	printf("%lld\n", sum);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型
using pint = pair<int, int>;

int main()
{
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    rep(i, N)
    {
        cin >> A[i];
    }
    ll dis_max = 0;
    ll pot = 0;
    rep(i, N - 1)
    {
        ll dis;
        dis = A[i + 1] - A[i];

        dis_max = max(dis, dis_max);
    }
    ll rmp = A[0] - A[N - 1] + K;
    dis_max = max(dis_max, rmp);

    cout << K - dis_max << endl;
}


Measured memory_bytes: 1024
// ---------- begin snipet ----------
pub trait MoOperator {
    type Answer;
    fn size(&self) -> usize;
    fn insert(&mut self, x: usize);
    fn delete(&mut self, x: usize);
    fn answer(&self) -> Self::Answer;
}

pub struct MoSolver<S> {
    query: Vec<(usize, usize)>,
    phantom: std::marker::PhantomData<S>,
}

impl<State: MoOperator> MoSolver<State> {
    fn new() -> Self {
        MoSolver {
            query: vec![],
            phantom: std::marker::PhantomData,
        }
    }
    fn add(&mut self, l: usize, r: usize) {
        self.query.push((l, r));
    }
    fn solve_with_size(&mut self, state: &mut State, answer: &mut [State::Answer], batch: usize) {
        let size = state.size();
        let mut q = vec![vec![]; size / batch + 1];
        for (k, &(l, r)) in self.query.iter().enumerate() {
            q[l / batch].push((r, l, k));
        }
        let mut x = 0;
        let mut y = 0;
        for (i, mut q) in q.into_iter().enumerate() {
            q.sort_unstable_by_key(|p| p.0);
            if i % 2 == 1 {
                q.reverse();
            }
            for (r, l, k) in q {
                while l < x {
                    x -= 1;
                    state.insert(x);
                }
                while y < r {
                    state.insert(y);
                    y += 1;
                }
                while x < l {
                    state.delete(x);
                    x += 1;
                }
                while r < y {
                    y -= 1;
                    state.delete(y);
                }
                answer[k] = state.answer();
            }
        }
    }
}
// ---------- end Mo algorithm ----------

struct State {
    c: Vec<usize>,
    cnt: Vec<u32>,
    ans: u32,
}

impl MoOperator for State {
    type Answer = u32;
    fn size(&self) -> usize {
        self.c.len()
    }
    fn insert(&mut self, x: usize) {
        let c = &mut self.cnt[self.c[x]];
        if *c == 0 {
            self.ans += 1;
        }
        *c += 1;
    }
    fn delete(&mut self, x: usize) {
        let c = &mut self.cnt[self.c[x]];
        if *c == 1 {
            self.ans -= 1;
        }
        *c -= 1;
    }
    fn answer(&self) -> Self::Answer {
        self.ans
    }
}

fn solve(c: &[usize], ask: &[(usize, usize)]) -> Vec<u32> {
    let mut solver = MoSolver::new();
    for &(l, r) in ask {
        solver.add(l, r);
    }
    let mut state = State {
        c: c.iter().cloned().collect(),
        cnt: vec![0; c.len()],
        ans: 0,
    };
    let mut ans = vec![0; ask.len()];
    solver.solve_with_size(&mut state, &mut ans, 1024);
    ans
}

use proconio::*;
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        q: usize,
        c: [Usize1; n],
        ask: [(Usize1, usize); q],
    }
    let ans = solve(&c, &ask);
    for a in ans {
        println!("{}", a);
    }
}


Measured memory_bytes: 55540
from itertools import accumulate

n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
p = [i-1 for i in p]

seen = [False]*n
ans = -float('inf')
for i in range(n):
    if not seen[i]:
        sc = []
        stop = i
        while True:
            seen[i] = True
            sc.append(c[i])
            if p[i] == stop:
                break
            i = p[i]

        lens = len(sc)
        for j in range(lens):
            if j != 0:
                sc = sc[1:] + [sc[0]]
            ac = list(accumulate(sc))

            if sum(sc) <= 0:
                ans = max(ans, max(ac[:min(k, lens)]))
            else:
                if k%lens == 0:
                    ans = max(ans, ac[-1]*(k//lens-1) + max(ac))
                else:
                    ans = max(ans, ac[-1]*(k//lens) + max(ac[:k%lens]+[0]))
print(ans)

Measured memory_bytes: 102524