akhauriyash/Code-Regression huggingface dataset:
n = int(input())
k = int(input())

ans = 0


def k1(n):
    str1_n = str(n)
    keta1 = len(str1_n)
    cnt = 9 * (keta1 - 1) + int(str1_n[0])
    return cnt


def k2(n):
    str2_n = str(n)
    keta2 = len(str2_n)
    cnt = 81 * (keta2 - 1) * (keta2 - 2) // 2
    cnt += (int(str2_n[0]) - 1) * k1(10 ** (keta2 - 1) - 1)
    cnt += k1(n - (int(str2_n[0]) * 10 ** (keta2 - 1)))
    return cnt


def k3(n):
    str3_n = str(n)
    keta3 = len(str3_n)
    t = 0
    for i in range(keta3-2):
        t += (i+1)*i//2
    cnt = 729 * t
    cnt += (int(str3_n[0]) - 1) * k2(10 ** (keta3 - 1) - 1)
    cnt += k2(n - (int(str3_n[0]) * 10 ** (keta3 - 1)))
    return cnt


if k == 1:
    ans = k1(n)

if k == 2:
    ans = k2(n)

if k == 3:
    ans = k3(n)

print(ans)


Measured memory_bytes: 3064
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();

        int[] a = new int[n];

        for (int i = 0; i < a.length; i++) {
            a[i] = scanner.nextInt();
        }

        System.out.println(enumerate(a, 0));
    }

    private static int enumerate(int[] a, int index){
        if (index == a.length - 1) return a[index] % 2 == 0?1:2;
        int even = a[index] % 2 == 0?1:2;
        return even*(int) Math.pow(3, a.length - index - 1) + (3 - even)*enumerate(a, index + 1);
    }
}


Measured memory_bytes: 24020
from sys import stdin
import fractions
n,k = [int(x) for x in stdin.readline().rstrip().split()]
li = list(map(int,stdin.readline().rstrip().split()))
li.sort()
if k > li[-1]:
    print("IMPOSSIBLE")
    exit()
gcd = li[0] 
for i in range(n-1):
    gcd = fractions.gcd(gcd,li[i+1])
if k%gcd != 0:
    print("IMPOSSIBLE")
    exit()
print("POSSIBLE")

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

    
    int n;
    cin >> n;

    vector<ll> a(n);
    vector<ll> b(1);

    rep(i, n){
        cin >> a[i];
        b.push_back((b[i] + a[i]) % MODN);
    }

    ll ans = 0;

    rep(i, n){
        ll sum = b[n] - b[i + 1];
        if(sum < 0) sum += MODN;

        sum = sum % MODN;
        ans = (ans + (a[i] * sum) % MODN) % MODN; 
    }

    cout << ans << endl;

    
    return 0;

}


Measured memory_bytes: 6936
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<stack>
#include<queue>

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

using namespace std;

long long comb[51][51];

int main() {
    rep(j, 51) {
        comb[0][j] = 0;
    }
    comb[0][0] = 1;
    REP (i, 1, 51){
        rep (j, i + 1){
            comb[i][j] = j != 0 ? comb[i - 1][j - 1] + comb [i - 1][j] : 1;
           // printf("%lld ", comb[i][j]);
        }
        // printf("\n");
    }
    int N, P;
    cin >> N >> P;

    int even = 0;
    int odd = 0;

    rep(i, N){
        int ai;
        cin >> ai;
        if (ai % 2 == 0) {
            even += 1;
        } else {
            odd += 1;
        }
    }

    long long ans_even = 0;
    for (int i = 0; i <= even; ++i){
        ans_even += comb[even][i];
    }

    long long ans_odd = 0;
    for (int i = P % 2; i <= odd; i += 2){
        ans_odd += comb[odd][i];
    }

    cout << ans_even * ans_odd << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, k, c, d int64
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&k)
	if a < k {
		c = 0
	} else {
		c = a - k
	}
	if k < a {
		d = b
	} else if k < a+b {
		d = b - k + a
	} else {
		d = 0
	}
	fmt.Println(c, d)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[2019] = {};
    ll k, z = 0;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) if (a[i] > a[j]) {
            if (i < j) z = (z + k * (k + 1) / 2) % mod;
            else z = (z + k * (k - 1) / 2) % mod;
        }
    }
    cout << z;
}


Measured memory_bytes: 256
from collections import deque


def LI():
    return list(map(int, input().split()))


def LSH(h):
    return [input() for _ in range(h)]


H, W = LI()
Fi = LSH(H)
move = [[1, 0], [0, 1], [-1, 0], [0, -1]]
ans = 0
for sh in range(H):  # スタート位置全部試します
    for sw in range(W):
        if Fi[sh][sw] == "#":
            continue
        d = deque()
        d.append([sh, sw])
        looked = [[0 for i in range(W)]for j in range(H)]
        looked[sh][sw] = 1
        while d:
            h, w = d.popleft()
            for i in move:
                a = h+i[0]
                b = w+i[1]
                if not(0 <= a < H) or not(0 <= b < W) or Fi[a][b] == "#" or looked[a][b] != 0:
                    continue
                d.append([a, b])
                looked[a][b] = looked[h][w]+1
            if len(d) == 0:
                ans = max(ans, looked[h][w]-1)
print(ans)


Measured memory_bytes: 9484
#include<iostream>
#include<map>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;

typedef pair<int,int> P;
typedef pair<int,P> P2;

int n,m,l,k;
int u,v,c;
int s,g,t;
int b[7];

int dis[51][1<<7][10],vis[51][1<<7];
vector<P> G[51];
const int INF = 100000000;

int main(){
  while(cin >> n >> m >> l >> k,n+m+l+k){
    for(int i=1;i<=n;i++)G[i].clear();
    for(int i=0;i<m;i++){
      cin >> u >> v >> c;
      G[u].push_back(P(c,v));
      G[v].push_back(P(c,u));
    }
    cin >> s >> g;
    for(int i=0;i<l;i++)cin >> b[i];

    for(int i=1;i<=n;i++)
      for(int j=0;j<(1<<l);j++){
	for(int x=0;x<k;x++)dis[i][j][x] = INF;
	vis[i][j] = 0;
      }

    int st = 0;
    for(int i=0;i<l;i++)if(s==b[i])st |= 1<<i;

    priority_queue< P2,vector<P2>,greater<P2> > q;
    q.push(P2(0,P(s,st)));
    
    while(q.size()){
      P2 p = q.top(); q.pop();
      int dist = p.first, pos = p.second.first, state = p.second.second;

      if(vis[pos][state] < k){
	dis[pos][state][vis[pos][state]] = dist;
	vis[pos][state]++;
      }else continue;

      for(int i=0;i<G[pos].size();i++){
	int cost = G[pos][i].first, nxt = G[pos][i].second;
	int nstate = state;
	for(int j=0;j<l;j++)if(nxt==b[j])nstate |= 1<<j;

	if(vis[nxt][nstate] < k)q.push(P2(dist+cost,P(nxt,nstate)));
      }
    }
    int res = dis[g][(1<<l)-1][k-1];
    if(res==INF)cout << "NA\n";
    else cout << res << endl;
  }
}
      

Measured memory_bytes: 41092
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

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

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

    vector<bool> flag(n+2,false);
    int tmp = vec[0];

    rep(i,n-1){
        //cout << tmp << endl;
        if(!flag[tmp]){
            flag[tmp] = true;
            if(tmp == 1){
                cout << i+1 << endl;
                return 0;
            }
        }else{
            cout << -1 << endl;
            return 0;
        }
        tmp =  vec[tmp];
    }

    if(tmp == 1) cout << n << endl;
    else cout << -1 << endl;

    return 0;
}

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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
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; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007

int main(){

    int n;
    cin >> n;
    int a[n];

    REP(i,n){
        cin >> a[i];
    }

    uset<int> a_set;

    REP(i,n){
        if(a_set.find(a[i]) == a_set.end()){
            a_set.insert(a[i]);
        }else{
            a_set.erase(a[i]);
        }
    }

    cout << a_set.size() << endl;

    return 0;
}


Measured memory_bytes: 7664
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    string s;
    cin >> s;

    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,s,ss,z,z1,z2,z3,z4;
	scanf("%d",&n);
	while(n!=0){
	ss=1000-n;
	s=ss/500;
	z=ss%500;
	s+=z/100;
	z1=z%100;
	s+=z1/50;
	z2=z1%50;
	s+=z2/10;
	z3=z2%10;
	s+=z3/5;
	z4=z3%5;
	s+=z4/1;	
	printf("%d\n",s);
	scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1032
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

N, X = [int(n) for n in input().split()]
xs = [int(n) for n in input().split()]

xs.append(X)

m = min(xs)
xs = [n - m for n in xs]
g = gcd(max(xs[0], xs[1]), min(xs[0], xs[1]))
for n in xs[2:]:
    g = gcd(max(g, n), min(g, n))
print(g)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	ll n; cin >> n; 
	vector<ll> a(n);
	for( auto &k : a ) cin >> k;
	vector<ll> sum(n+1);
	sum[0] = 0;
	for( int i = 0; i < n; ++i ){
		sum[i+1] = sum[i] + a[i];
	}
	ll ans = 0;
	sort( sum.begin(), sum.end() );
	ll l = 1;
	for( int i = 0; i <= n; ++i ){
		if( i == n ){
			ans += (l*(l-1)/2);
		} else if( sum[i] != sum[i+1] ){
			ans += (l*(l-1)/2);
			l = 1;
		} else {
			++l;
		}
	}
	cout << ans << endl;
}

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

int main(){
    int A, B;
  	
  	cin >> A >> B;
  	if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0)
      	cout << "Possible" << endl;
  	else
      	cout << "Impossible" << endl;
    
    return 0;
}

Measured memory_bytes: 256
n=int(input())
v=list(map(int,input().split()))
from collections import defaultdict
dict_odd=defaultdict(lambda :0)
dict_even=defaultdict(lambda :0)
dict_even[0],dict_odd[0]=0,0
for i in range(0,n,2):
    dict_even[v[i]]+=1

for i in range(1,n,2):
    dict_odd[v[i]]+=1

even_val=list(dict_even.items())
odd_val=list(dict_odd.items())
even_val=sorted(even_val,reverse=True,key=lambda x: x[1])
odd_val=sorted(odd_val,reverse=True,key=lambda x: x[1])

if even_val[0][0]!=odd_val[0][0]:
    print(n-odd_val[0][1]-even_val[0][1])
else:
    ans1=n-odd_val[1][1]-even_val[0][1]
    ans2=n-odd_val[0][1]-even_val[1][1]
    print(min(ans1,ans2))

Measured memory_bytes: 21376
#include"bits/stdc++.h"
using namespace std;
#define int int64_t
int ar[(int)2e5+10];
int br[(int)2e5+10];
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int count=0;
    int n,k;cin>>n>>k;
    int mini=n;
    for(int i=1;i<=n;i++)
    {
        cin>>ar[i];
        mini=min(mini,ar[i]);
    }
    while(k>0 and mini<n)
    {
        k--;
        count++;
        for(int i=1;i<=n;i++)
        {
            int lw=max(i-ar[i],(int)1);
            int up=min(i+ar[i]+1,n+1);
            br[lw]+=1;
            br[up]-=1;
        }
        mini=n;
        for(int i=1;i<=n;i++)
        {
            br[i]+=br[i-1];
            ar[i]=br[i];
            mini=min(mini,ar[i]);
        }
        for(int i=1;i<=n+1;i++)
            br[i]=0;
    }
    for(int i=1;i<=n;i++)
        cout<<ar[i]<<" ";
    cout<<"\n";
    return 0;
}



Measured memory_bytes: 6768
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define INF 1000000007
#define N 100005
#define PI 3.14159265
bool compare(pair<ll,char> i, pair<ll,char> j) 
{
  return i.S < j.S;
}
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
}
int main()
{
	ios
	ll n,a;
	cin>>n;
	vi v1;
	map <ll,ll> m;
	rep(i,0,n)
	{
		cin>>a;
		v1.pb(a);
		m[a]++;
	}
	ll mat=0;
	ll k=m.size();
	for(auto i:m)
	{
		a=i.S;
		mat+=a*(a-1)/2;
	}
	rep(i,0,n)
	{
		a=m[v1[i]];
		cout<<mat-a+1<<endl;
	}
	return 0;
}

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

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int d,s,t;
    cin>>d>>t>>s;
    cout<<((d+s-1)/s <= t ? "Yes" : "No");
}


Measured memory_bytes: 3604
def group(inp):
    if inp ==  '4' or inp == '6' or inp == '9' or inp == '11':
        return 2
    if inp == '2':
        return 3
    else:
        return 1

if __name__ == '__main__':
    x, y = input().split()
    if group(x) == group(y):
        print('Yes')
    else:
        print('No')


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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

typedef long long ll;
typedef pair<int, int> ii;

int main(){

	int n;
	cin >> n;

	if(n % 2 == 0) cout << 0.5000000000	<< endl;
	else cout << ((double)n + 1.0) / (2.0 * n) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string,int>;
using T = tuple<string,int,int>;

int main(){
  int a,b,t; cin >> a >> b >> t;
  int now = a;
  int ans = 0;
  while(now <= t){
    now += a;
    ans += b;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    map<string, int> cards;
    int N, M;
    cin >> N;
    for(int i = 0; i < N; i++){
        string s;
        cin >> s;
        cards[s]++;
    }
    cin >> M;
    for(int i = 0; i < M; i++){
        string t;
        cin >> t;
        cards[t]--;
    }
    int ans = 0;
    for(auto i: cards){
        ans = max(ans, i.second);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def main():
  result = 0
  k, s = map(int, input().split())
  for x in range(k + 1):
    for y in range(k + 1):
      z = s - x - y
      if 0 <= z <= k:
        result += 1
  print(result)
if __name__ == "__main__":
  main()

Measured memory_bytes: 67860
#include <cstdio>
#include <vector>

const int maxn = 100005;
int n, k;

struct perm
{
	int data[maxn];
	int operator[](int x) const { return data[x]; }
	int &operator[](int x) { return data[x]; }
} p, q, fold, ans;
perm operator*(const perm &a, const perm &b)
{
	perm c;
	for (int i = 1; i <= n; ++i)
		c[i] = b[a[i]];
	return c;
}
perm inv(const perm &x)
{
	perm y;
	for (int i = 1; i <= n; ++i)
		y[x[i]] = i;
	return y;
}
perm power(const perm &a, int x)
{
	static bool vis[maxn];
	perm ret;
	for (int i = 1; i <= n; ++i)
		if (!vis[i])
		{
			std::vector<int> now;
			now.push_back(i);
			vis[i] = true;
			for (int j = a[i]; j != i; j = a[j])
				now.push_back(j), vis[j] = true;
			for (int i = 0; i < (int)now.size(); ++i)
				ret[now[i]] = now[(i + x) % now.size()];
		}
	for (int i = 1; i <= n; ++i)
		vis[i] = false;
	return ret;
}

int main()
{
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &p[i]);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &q[i]);
	fold = power(p * inv(q) * inv(p) * q, (k - 1) / 6);
	switch (k % 6)
	{
		case 0:
			ans = inv(fold) * inv(q) * p * p * inv(q) * inv(p) * q * fold;
			break;
		case 1:
			ans = inv(fold) * p * fold;
			break;
		case 2:
			ans = inv(fold) * q * fold;
			break;
		case 3:
			ans = inv(fold) * inv(p) * q * fold;
			break;
		case 4:
			ans = inv(fold) * inv(q) * inv(p) * q * fold;
			break;
		case 5:
			ans = inv(fold) * inv(q) * p * inv(q) * inv(p) * q * fold;
			break;
	}
	for (int i = 1; i <= n; ++i)
		printf("%d%c", ans[i], " \n"[i == n]);
	return 0;
}


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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

int main()
{
    canhazfast();

    int n;

    cin >> n;
    cout << setprecision(8) << double((n+1)/2)/n << '\n';

    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
fn main(){
    input!{
        n:usize,
        an:[i64;n],
    }
    let mut ans = 0;
    for &x in &an {
        if is_prime(x) {
            ans += 1;
        }
    }
    println!("{}",ans);
}

fn is_prime(x:i64) -> bool {
    if x == 2 {return true;}
    if x < 2 || x % 2 == 0 {return false;}
    let mut j = 3;
    while j <= (x as f64).sqrt() as i64 {
        if x % j == 0 {
            return false;
        }
        j += 2;
    }
    true
}



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

using namespace std;

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

	int N;
	cin >> N;
	vector<int>V(N);
	vector<int>C(N);

	for (int i = 0; i < N; i++)
	{
		cin >> V[i];
	}

	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}


	vector<int>tmp(N);
	for (int i = 0; i < N; i++)
	{
		tmp[i] = V[i] - C[i];
		
	}

	int ans = 0;

	
	for (int i = 0; i < N; i++)
	{
		if (tmp[i] > 0) {
			ans += tmp[i];
		}
	}

	cout << ans << endl;

	return 0;
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    LL K;
    cin >> K;
    LL N = 50;
    LL X = K/N + N - 1;
    vector<LL> a(N, K/N + N - 1);
    LL c = K - (X - N + 1)*N;
    REP(i, c) {
        a[i] += N - c + 1;
    }
    FOR(i, c, N) {
        a[i] -= c;
    }
    cout << N << endl;
    REP(i, N) {
        cout << a[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
/*ABC 136 A*/

int main(int argc, char const *argv[])
{
  int A,B,C;

  scanf("%d%d%d",&A ,&B ,&C );
  if( (B + C - A ) <= 0)printf("0\n");
  else printf("%d\n",B + C - A );

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(){
    int a;
    scanf("%d", &a);
    int f = 0;
    for(int i=1; i<=9; i++){
        if(a%i == 0 && a/i <= 9){
            f = 1;
            break;
        }
    }
    if(f){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N,K,Q; cin >> N>>K>>Q;
    vector<int>A(Q);
    vector<int>B(N);
    rep(i, Q) {
        cin >> A[i];
        B[A[i]-1]++;
    }
    rep(i, N) {
        if (K <= Q - B[i])cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}

Measured memory_bytes: 4044
#include<stdio.h>

#define N 100000

typedef struct pp{
  char name;
  int value;
}CARD;

CARD data[N],data1[N];

void quicksort(CARD*,int,int);
int partition(CARD*,int,int);
int isstable(CARD*,CARD*,int);
/*void BubbleSort(CARD*,int);*/
void merge(CARD*,int,int,int);
void mergeSort(CARD*,int,int);

int main(){
  int i,j,a,b,n;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf(" %c",&data[i].name);
    scanf("%d",&data[i].value);

    data1[i]=data[i];
  }

  quicksort(data,0,n-1);

  /*BubbleSort(data1,n);*/

  mergeSort(data1,0,n);
  
  a=isstable(data1,data,n);

  if(a==1) printf("Stable\n");
  else printf("Not stable\n");

  
  
  for(i=0;i<n;i++){
    printf("%c %d\n",data[i].name,data[i].value);
  }
  return 0;
}

void quicksort(CARD *A,int p,int r){
  int q;
  
  if(p<r){
    q=partition(A,p,r);
    quicksort(A,p,q-1);
    quicksort(A,q+1,r);
  }
  return;
}

int partition(CARD *A,int p,int r){
  int i,j;
  CARD temp,x;

  x=A[r];
  i=p-1;

  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      temp=A[i];
      A[i]=A[j];
      A[j]=temp;
    }
  }
 
  temp=A[i+1];
  A[i+1]=A[r];
  A[r]=temp;
 

  return i+1;
}

int isstable(CARD *in,CARD *out,int n){
  int i,j,a=0,b=0;
  
  for(i=0;i<n;i++){
    if(in[i].name==out[i].name) a++;
    if(in[i].value==out[i].value) b++;
  }
  
  

  if(a==b) return 1;

  else return 0;
  
  }

/*void BubbleSort(CARD *B,int n){
    int i,j;
  CARD temp;
  
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(B[j].value<B[j-1].value){
	temp=B[j];
	B[j]=B[j-1];
	B[j-1]=temp;
      }
    }
  }

  return;
  }*/

void merge(CARD *A,int left,int mid,int right){
  int n1,n2,i,k,j;
  n1=mid-left;
  n2=right-mid;
  CARD L[n1],R[n2];

  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }

  L[n1].value=2147483647;
  R[n2].value=2147483647;

  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i];
      i=i+1;
    }
    else{
      A[k]=R[j];
      j=j+1;
    }
  }

  return;
}
  
void mergeSort(CARD *A,int left,int right){
  int mid;
  
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }

  return;
}



Measured memory_bytes: 4048
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
#define MAX 1000004
typedef long long ll;
int main(){
    ll N;
    ll prime_index=0;
    ll prime_seq[MAX]={0};
    bool prime_flag[MAX];    //素数ならtrue;
    for(ll i=2;i<MAX;i++) prime_flag[i]=true;
    scanf("%lld",&N);
    //素数列作るよ
    for(ll i=2;i<MAX;i++){
        if(!prime_flag[i]) continue;
        for(ll j=2;i*j<MAX;j++)
            prime_flag[i*j]=false;
    }
    for(ll i=2;i<MAX;i++)
        if(prime_flag[i]) prime_seq[prime_index++]=i;
    //素数列作り終わったよ
    prime_index--;
    ll ans=0;
    //素因数分解始まるよ
    ll prime_fac[MAX]={0};
    bool f=false;
    while(N!=1){
        ll i=0;
        while(N%prime_seq[i]!=0 && prime_index>i)i++;
        if(prime_index<=i){
            ans++;
            break;
        }
        N/=prime_seq[i];
        prime_fac[prime_seq[i]]++;
        f=true;
    }
    //素因数分解終わったよ

    //総和のテーブル作るよ
    ll table[100];
    table[1]=1;
    for(ll i=2;i<=100;i++)
        table[i]=table[i-1]+i;
    //総和のテーブル作り終わったよ
    for(ll i=0;i<prime_index;i++){
        if(!prime_fac[prime_seq[i]]) continue;
        ll j=1;
        while(table[j]<=prime_fac[prime_seq[i]]) j++;
        j--;
        ans+=j;
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 18312
import Data.List
main = do
  time <- readLn
  let hms = [getHourFrom time, getMinuteFrom time, getSecondFrom time]
  putStrLn $ intercalate ":" $ map show hms

getHourFrom :: Int -> Int
getHourFrom time = div time 3600

getMinuteFrom :: Int -> Int
getMinuteFrom time = div (mod time 3600) 60

getSecondFrom :: Int -> Int
getSecondFrom time = mod time 60

Measured memory_bytes: 3564
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int q = Integer.parseInt(sc.next());
        String s = sc.next();
        Integer[] l = new Integer[q];
        Integer[] r = new Integer[q];
        for (int i = 0; i < q; i++) {
            l[i] = Integer.parseInt(sc.next());
            r[i] = Integer.parseInt(sc.next());
        }
        sc.close();

        // 主処理
        int len = s.length();
        int[] arr = new int[len];
        for (int i = 1; i < len; i++) {
            arr[i] = arr[i - 1];
            if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C') {
                arr[i]++;
            }
        }

        // 出力
        for (int i = 0; i < q; i++) {
            int result = arr[r[i] - 1] - arr[l[i] - 1];
            System.out.println(result);
        }
    }
}


Measured memory_bytes: 71608
#include <iostream>
#include <vector>
#include <algorithm>
#define llint long long

using namespace std;

int n;
string s, t;
vector<int> vec[500005];
int z[500005], z2[500005];

void z_algorithm(string &s, int z[])
{
	z[0] = s.size();
	
	int x = 0, y = 0;
	for(int i = 1; i < s.size(); i++){
		if(i > y){
			z[i] = 0;
			for(int j = 0; j < s.size(); j++){
				if(i+j > s.size() || s[i+j] != s[j]) break;
				z[i]++;
			}
			x = i, y = i + z[i] - 1;
		}
		else if(i + z[i-x] <= y) z[i] = z[i-x];
		else{
			z[i] = y-i+1;
			for(int j = y-i+1; j < s.size(); j++){
				if(i+j > s.size() || s[i+j] != s[j]) break;
				z[i]++;
			}
			x = i, y = i + z[i] - 1;
		}
	}
}

bool pre(int r, int p)
{
	return z[p] >= (r+1)-p;
}
bool suf(int l, int p)
{
	l = n-1-l;
	return z2[p] >= (l+1)-p;
}

bool check(int x, bool f)
{
	int len = x+1;
	if(!f) len = n-x;
	if(len == 1) return true;
	for(int i = 0; i < vec[len].size(); i++){
		int d = vec[len][i];
		if(d == len) continue;
		if(f && pre(x, d) || !f && suf(x, d)) return false;
	}
	return true;
}


int main(void)
{
	cin >> s;
	n = s.size();
	z_algorithm(s, z);
	
	t = s;
	reverse(t.begin(), t.end());
	z_algorithm(t, z2);
	
	int cyc = n;
	for(int i = 1; i < n; i++){
		if(n % i == 0 && pre(n-1, i)){
			cyc = i;
			break;
		}
	}
	if(cyc == 1){
		cout << n << endl;
		cout << 1 << endl;
		return 0;
	}
	if(cyc == n){
		cout << 1 << endl;
		cout << 1 << endl;
		return 0;
	}
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; i*j <= n; j++) vec[i*j].push_back(i);
	}
	
	cout << 2 << endl;
	int ans = 0;
	for(int i = 1; i < n; i++) if(check(i-1, 1) && check(i, 0)) ans++;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 60804
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC40(void);
void ABC41(void);
void ABC42(void);
void ABC43(void);
void ABC44(void);
void ABC45(void);
void ABC46(void);
void ABC47(void);
void ABC48(void);
void ABC49(void);

int main(void){
    ABC44();
}

void ABC44(){
    int ans=1,d=0;
    char c='\0';
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    for(int i=0;i<s.length();i++){
        if(s[i]==c)d++;
        else{
            if(d%2!=0){
                ans=0;
                break;
            }
            c=s[i];
            d=1;
        }
    }
    if(d%2!=0)ans=0;
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

struct NodeRoute {
	const unsigned int next_node;
	const int cost;
	NodeRoute(const unsigned int& nn, const int& co) : next_node(nn), cost(co) {};
};

enum Color {
	NONE = -1,
	WHITE = 0,
	BLACK = 1,
};

bool ColorCheckBLACK(const Color& cu_color, int cost) {
	int t_cost = (static_cast<int>(cu_color) + cost) % 2;
	return (t_cost == 1) ? true : false;
}

//BFS用にグローバル宣言
int N;
vector<vector<NodeRoute>> v_node_route;

void BFS(vector<Color>& ans, unsigned int  start_pos) {
	for (size_t i = 0; i < v_node_route[start_pos].size(); i++) {
		unsigned int next = v_node_route[start_pos][i].next_node;
		if (ans[next] == NONE) {
			int cost = v_node_route[start_pos][i].cost;
			ColorCheckBLACK(ans[start_pos], cost) ? ans[next] = BLACK : ans[next] = WHITE;
			BFS(ans, next);
		}
	}
}

int main() {
	//int N;
	cin >> N;
	v_node_route.resize(N);
	//vector<vector<NodeRoute>> v_node_route(N);
	for (int i = 0; i < N - 1; i++) {
		unsigned int u;
		cin >> u;
		unsigned int v;
		cin >> v;
		int cost;
		cin >> cost;
		v_node_route[u - 1].push_back(NodeRoute(v - 1, cost));
		v_node_route[v - 1].push_back(NodeRoute(u - 1, cost));
	}

	vector<Color> answer(N, NONE);

	unsigned int first_pos = 0;

	//再帰でのBFS
	BFS(answer, first_pos);

	//while分でのBFS
	/*
	queue <unsigned int> q_current_pos;
	q_current_pos.push(0);
	unsigned int current_pos = q_current_pos.front();
	answer[0] = WHITE;
	
	while (!q_current_pos.empty()) {
		current_pos = q_current_pos.front();
		q_current_pos.pop();
		for (size_t i = 0; i < v_node_route[current_pos].size(); i++) {
			unsigned int next_pos = v_node_route[current_pos][i].next_node;
			int route_cost = v_node_route[current_pos][i].cost;
			if (answer[next_pos] == NONE) {
				q_current_pos.push(next_pos);
				answer[next_pos] = ColorCheckBLACK(answer[current_pos], route_cost) ? BLACK : WHITE;
			}
			else{
				continue;
			}
		}
	}
	*/
	for (auto itr = answer.begin(); itr != answer.end(); itr++) {
		cout << *itr << endl;
	}
	return 0;
}


Measured memory_bytes: 8192
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;
ll a , b;

int main() {
	
	cin >> a >> b;
	
	register ll tmp = b - a;
	
	cout << (1 + tmp) * tmp / 2 - b << endl;
	
	return 0;
	
}

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

using namespace std;
long long q,h,s,d,n;
int main() {
    ios_base::sync_with_stdio(0);
    cin >> q >> h >> s >> d;
    cin >> n;
    long long mn = min(min(q * 4, h * 2), s);
    if (mn * 2 < d) cout << mn * n << "\n";
    else cout << n / 2 * d + n % 2 * mn << "\n";
    return 0;
}


Measured memory_bytes: 256
N, T = map(int, input().split())

time_lis = [int(_) for _ in input().split()]
length = len(time_lis)

ans = 0
for n in range(1, length):
    diff = time_lis[n] - time_lis[n - 1]
    if diff >= T:
        ans += T
    else:
        ans += diff
print(ans + T)


Measured memory_bytes: 25196
<?php
fscanf(STDIN,'%d',$X);
$Xa=str_split($X);
$sum=0;
for ($i=0; $i <count($Xa) ; $i++) {
  // code...
  $sum+=$Xa[$i];
}
if($X%$sum==0){
  echo 'Yes';
}else{
  echo 'No';
}

 ?>


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define M 1000000007
int main()
{

 

  fastio; 

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

  ll prefix[n]={0};
  prefix[0]=a[0];

  for (int i = 1; i < n; ++i)
  {
     prefix[i]=a[i]+prefix[i-1];
  }
  // for (int i = 1; i < n; ++i)
  // {
  //   cout<<prefix[i]<<" ";
  // }
  // co


  ll sum=0;
  for (int i = 0; i <n-1; ++i)
  {

      
     sum+=(a[i])*(prefix[n-1]%M-prefix[i]%M+M);
     sum=sum%M;

     
  }


   cout<<sum;
 
return 0;   
}

Measured memory_bytes: 6756
#include <bits/stdc++.h>
using namespace std;
// int64_tは9*10^18まで、intは2*10^9まで

#define INF (int)pow(10, 8)
typedef tuple<int, int, int> P;

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if(s*t>=d) cout << "Yes";
  else cout << "No";
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b,a||b){
    int in[16][16]={1,0};
    int n;
    cin>>n;
    rep(i,n){
      int c,d;
      cin>>c>>d;
      in[c-1][d-1]=-1;
    }
    rep(i,a){
      rep(j,b){
	if(in[i][j]<0)continue;
	if(j-1>=0&&in[i][j-1]>0)in[i][j]+=in[i][j-1];
	if(i-1>=0&&in[i-1][j]>0)in[i][j]+=in[i-1][j];
      }
    }
    cout<<in[a-1][b-1]<<endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll i,j,k;

//最大公約数
ll gcd(ll a,ll b){
    if(b==0){return a;}
    else{return gcd(b,a%b);}
}

int main(){   
    ll a,b,c;cin>>a>>b;
    c=gcd(a,b);
    ll ins=c;

    int ans=1;//素数以外に1も含む
    for(i=2;i*i<=c;i++){//素数判定および素因数個数を求める
        ll ins2=ins;
        while(ins%i==0){
            ins/=i;
        }
        if(ins!=ins2){ans++;}
    }
    if(ins!=1){ans++;}//insが1ではないならば、ins自体が(比較的)大きい素数になっている

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll  unsigned long long
#define pub push_back
#define mp  make_pair  
using namespace std; 
//ifstream fin("input.txt");

  
int main()
{
    int n ; 
  cin >> n ;
  int s = (n % 1000);
  if (!s)
  cout<<0;
  else
  cout<<1000 - s;
  cout<<endl;
    
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    ll a, b, x; cin >> a >> b >> x;
    ll c = a;
    a /= x;
    b /= x;
    if(c%x==0) a--;
    pr(b-a);
    return 0;}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
   ll n,q1;
   cin>>n>>q1;
   vector<vector<ll>>adj(n+1);
   for(ll i=1;i<n;i++)
   {
       ll a,b;
       cin>>a>>b;
       adj[a].pb(b);
       adj[b].pb(a);
   }
   vector<ll>vv(n+1,0),v1(n+1,0);
   for(ll i=0;i<q1;i++)
   {
       ll x,y;
       cin>>x>>y;
       vv[x]+=y;
   }
   ll z=0;
   bool vis[200001]={0};
   queue<ll>q;
   q.push(1);
   vis[1]=1;
   while(!q.empty())
   {
       ll p=q.front();
       q.pop();
       //z=vv[p];
       //v1[p]+=vv[p];
       //z+=v1[p];
       for(ll i=0;i<adj[p].size();i++)
       {
           if(!vis[adj[p][i]])
           {
               q.push(adj[p][i]);
               vv[adj[p][i]]+=vv[p];
               vis[adj[p][i]]=1;
           }
       }
   }
   for(ll i=1;i<=n;i++)
   cout<<vv[i]<<" ";
   
}

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

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

    int N, K;
    cin >> N >> K;

    long long ans = 0;
    for (int b=K+1; b<=N; ++b) {
        ans += ((N+1) / b) * (b - K);
        ans += max(0, (N+1) % b - K);
        if (K == 0) ans --;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	int xs, ys, xt, yt, n;
	int x[1002], y[1002], r[1002];
	cin >> xs >> ys >> xt >> yt >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y [i] >> r[i];
	}
	x[n + 1] = xs; y[n + 1] = ys; r[n + 1] = 0;
	x[n] = xt; y[n] = yt; r[n] = 0;

	static double dist[1002][1002];
	for (int i = 0; i < n + 2; i++) {
		for (int j = i; j < n + 2; j++) {
			double dx = x[i] - x[j];
			double dy = y[i] - y[j];
			dist[i][j] = dist[j][i] = max(0.0, sqrt(dx * dx + dy * dy) - r[i] - r[j]);
		}
	}

	double cost[1002];
	for (int i = 0; i < n + 1; i++) {
		cost[i] = dist[n + 1][i];
	}

	bool b[1002] = {};
	for (int i = 0; i < n + 1; i++) {
		b[i] = true;
	}
	for (bool l = true; l; ) {
		l = false;
		for(int m = 0; m < n; m++) {
			if (b[m]) {
				b[m] = false;
				for (int i = 0; i < n + 1; i++) {
					if (cost[m] + dist[m][i] < cost[i]) {
						cost[i] = cost[m] + dist[m][i];
						b[i] = true;
						l = true;
					}
				}
			}
		}
	}
	cout << fixed << setprecision(10) << cost[n] << endl;
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;


int main()
{
	int n;
    cin>>n;
    int x,y,c=0,mx=0;
    while(n--)
    {
        cin>>x>>y;
        if(x==y)
            c++;
        else c=0;
        mx=max(c,mx);
        //cout<<mx<<nl;
    }
    if(mx>2)
        cout<<"Yes"<<nl;
    else cout<<"No"<<nl;
    return 0;

}


Measured memory_bytes: 3620
/*
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;
 
int main()
{
    ull s,c;
    cin>>s>>c;
    if(s*2>c) cout<<c/2<<endl;
    else cout<<s+(c-2*s)/4<<endl;
    
    return 0;
}

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

int main(){
    int T; scanf("%d", &T);
    while(T--){
        ll a, b, ans = 0; scanf("%lld%lld", &a, &b);
        if(a==b) ans = 2*a-2;
        else{
            ll sq = sqrt(a*b);
            if(sq*sq == a*b) sq--;
            if(sq*(sq+1) >= a*b) ans = 2*sq-2;
            else ans = 2*sq-1;
        }
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = [int(i) for i in input().split()]
inputs = [[int(i) for i in input().split()] for _ in range(N)]

ans = 0
for i in range(N):
    total = 0
    for a, b in zip(inputs[i], B):
        total += a * b
    if total + C > 0:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#define MN 100005
#define INF 1000000007
using namespace std;
int n, m, v, p;
int a[MN];
bool cmp(const int i, const int j) {
	return i > j;
}
int main() {
	scanf("%d%d%d%d", &n, &m, &v, &p);
	int i;
	for (i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	sort(a + 1, a + 1 + n, cmp);
	int ans=p;
	if (v <= p) {
		for (i = p + 1; i <= n; i++) {
			if (a[p] <= a[i] + m) ans++;
			else break;
		}
	}
	else {
		v = v - p;
		long long votes;
		long long sum = a[p];
		for (i = p + 1; i <= n; i++) {
			if (a[p] > a[i] + m) break;
			if (n - i < v) {
				long long nv = v - (n - i);
				long long votes = nv * m;
				if (votes > (long long)(i - p)* (long long)(a[i] + m) - sum) break;
			}
			ans++;
			sum += a[i];
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 640
while True:
    n = int(input())
    if n == 0:
        break
    for i in range(n):
        p = list(map(int,input().split()))
        if max(p)==100 or sum(p[:2])>=180 or sum(p)>=240:
            print('A')
        elif sum(p)>=210 or (sum(p)>=150 and max(p[:2])>=80):
            print('B')
        else:
            print('C')


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

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

  string ans= (a > 0)      ? "Positive"
             :(b >=0)      ? "Zero"
             :((b-a)%2==1) ? "Positive"
                           : "Negative";
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
using ll = long long;

#define INF 1000000007
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int)(x).size())
#define MSG(a) cout << #a << " " << a << endl;

int N, M;
vector<int> vec_s;
vector<char> vec_c;

bool check(string ans)
{
    if (ans.size() != N) return false;
    for (int i = 0; i < M; i++) {
        int idx = vec_s[i] - 1;
        char c = vec_c[i];
        if (ans[idx] != c) return false;
    }
    return true;
}

int solve()
{
    // cout << "solve" << endl;
    for (int i = 0; i < 999; i++) {
        string str_ans = to_string(i);
        if(check(str_ans)) return i;
    }

    return -1;
}

int main()
{
    cin >> N >> M;
    int ans = -1;
    for (int i = 0; i < M; i++) {
        int tmp_s;
        char tmp_c;
        cin >> tmp_s >> tmp_c;
        vec_s.push_back(tmp_s);
        vec_c.push_back(tmp_c);
    }
    ans = solve();
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll d[105];
int main() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>d[i];
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
                ans=ans+d[i]*d[j];
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from fractions import gcd
def resolve():
    N=int(input())
    for i in range(N+100):
        if int(i*1.08)==N:
            print(i)
            return

    print(":(")
#%%submit!
resolve()

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

int main(){
  string S; cin >> S;

  ll ans = 0;
  ll cnt1=0, cnt2=0;
  rep(i,0,S.size()){
    int n = S[i] - '0';
    if(i % 2 == 0 && n == 1) cnt1++; 
    if(i % 2 == 1 && n == 0) cnt1++;
  }
  rep(i,0,S.size()){
    int n = S[i] - '0';
    if(i % 2 == 0 && n == 0) cnt2++; 
    if(i % 2 == 1 && n == 1) cnt2++;
  }
  ans = min(cnt1,cnt2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3756
# coding: utf-8
import sys

n = int(raw_input())
b = map(int, raw_input().split())

res = 0

for i in xrange(n):
    if i == 0:
        res += b[i]
    elif i == n-1:
        res += b[i-1]
    else:
        tmp = min(b[i],b[i-1])
        res += tmp

print res

Measured memory_bytes: 2568