akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    int N;  cin >> N;
    if(N == 0){
        cout << 0 << endl;
        return 0;
    }

    string ans = "";
    int cnt = 0;
    while(N != 0){
        // cout << N << endl;
        if(N%2 != 0){
            ans = "1" + ans;
            if(cnt%2 == 0){
                N--;
            }else{
                N++;
            }
        }else{
            ans = "0" + ans;
        }
        N /= 2;
        cnt++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;
 
#define for01(k,n)  for (ll i=k; i<n; i++)
#define for02(k,n)  for (ll j=k; j<n; j++)
#define for03(k,n)  for (ll k=k; k<n; k++)
#define for11(k,n)  for (ll i=k; i<=n; i++)
#define for12(k,n)  for (ll j=k; j<=n; j++)
#define for13(k,n)  for (ll k=k; k<=n; k++)

#define pb push_back
#define mp make_pair
#define pf push_front
#define popf pop_front
#define popb pop_back
#define vll vector<ll>
#define F first
#define S second
#define pp pair <ll, ll>
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define si size()
#define bk back()
#define deci(n)  fixed<<setprecision(n)
#define mll map<ll,ll>
#define mint map<int,int>
#define mll_it map<ll,ll>::iterator
#define mint_it map<int,int>::iterator

#define p0(a) cout << a << " "
#define p1(a) cout << a << "\n"

#define mem(a,n) memset(a, n, sizeof(a)); // n = 0 OR -1 only

#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define MOD 1000000007
#define MOD2 998244353

using namespace std;

int *ans;
vector<char> Sieve(ll n)
{
    vector<char> prime (n+1, true);
    prime[0] = prime[1] = false;
    
  	ll fact = 1;
    for (int i=2; i*i<=n; i++)
    {
      int ct = 0;
      
        if (prime[i])
        {    
            if (i * 1ll * i <= n)               // To avoid Overflow
            {
                for (int j=i*i; j<=n; j+=i)     // We begin to move from i ^ 2, since all smaller                                              
                    prime[j] = false;           // numbers that are multiples of i necessarily have a simple divisor less i,
            }                                   // which means that all of them have already been eliminated earlier
        }
    }
    return prime;
}

void factorise(int n)
{
    vector<char> primes = Sieve(n);
    map<int, int> factors;
    
    for01(0, primes.size())
    {
        if(primes[i])
        {
            int temp = n;
            int ct = 0;
            
            while(temp % i == 0)
            {
                temp = temp/i;
                ct++;
            }
            if(ct > 0)
            {
                factors.insert(mp(i,ct));
                ans[i] += ct;
            }
        }
    }
    
}


int main()
{
    string s;
    cin >> s;
    
    cout << s.find_last_of('Z') - s.find('A') + 1;
    return 0;
    
}

Measured memory_bytes: 640
N, M = map(int,input().split())
S = []
C = []
flag = True
if N == 1 and M == 0:
    print("0")
    quit()

for i in range(M):
    s,c = map(int,input().split())
    if s in S:
        if C[S.index(s)] != c:
            flag = False
            break
    if s == 1 and N > 1:
        if c == 0:
            flag = False
            break
    S.append(s)
    C.append(c)

if flag:
    n = [1] + [0 for i in range(N - 1)]
    for i in range(len(S)):
        n[S[i]-1] = C[i]
    print(*n, sep="")
else:
    print("-1")

Measured memory_bytes: 3064
#include <iostream>
#include <set>
#include <vector>

using namespace std;

bool solve() {
    int R, C;
    cin >> R >> C;
    if (!(R || C)) return false;
    vector<vector<int>> table(R, vector<int>(C));
    for (int i = 0; i < R; i++) {
        for (int j = 0; j < C; j++) {
            cin >> table[i][j];
        }
    }

    int ret = -1;
    for (int mask = 0; mask < (1 << R); mask++) {
        int cnt = 0;
        for (int j = 0; j < C; j++) {
            int tmp = 0;
            for (int i = 0; i < R; i++) {
                int bit = (mask >> i) & 1;
                tmp += bit ^ table[i][j];
            }
            cnt += max(tmp, R-tmp);
        }
        ret = max(ret, cnt);
    }
    cout << ret << endl;
    return true;
}

signed main() {
    while (true) {
        if (!solve()) break;
    }
}


Measured memory_bytes: 3400
from collections import defaultdict


def main():
    W, a, b = map(int, input().split())
    i, j, k, l = a, a + W, b, b + W
    if (i <= k <= j) or (i <= l <= j) or (k <= i <= l) or (k <= j <= l):
        print(0)
    else:
        print(min([abs(k - i), abs(k - j), abs(l - i), abs(l - j)]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ll n,k,a,b;
    cin>>n>>k;
    vector<P> A;
    rep(i,n) cin>>a>>b,A.push_back(P(a,b));
    sort(all(A));
    ll sum=0;
    rep(i,n){
        sum+=A[i].second;
        if(sum>=k){
            cout<<A[i].first;
            return 0;
        }
    }
}

Measured memory_bytes: 2420
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve();
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve()
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int a = vs[0];
			int b = vs[1];
			int c = vs[2];
			int d = vs[3];

			if (Math.Abs(a - c) <= d || (Math.Abs(a - b) <= d && Math.Abs(b - c) <= d)) {
				Console.WriteLine("Yes");
			} else {
				Console.WriteLine("No");
			}

		}
	}
}


Measured memory_bytes: 28248
#include <stdio.h>

int main(void)
{
	int n, i, j, p, d, sum;
	scanf("%d", &n);
	int a[n+1];

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

	p = sum = 0;
	for(i = 0; i < n+1; i++){
		if(p > a[i]){
			sum += p - a[i];
		}
		else{
			sum += (p - a[i]) * -1;
		}
		p = a[i];
	}

	p = 0;
	for(i = 0; i < n; i++){
		d = 0;
		if(p > a[i+1]){
			d = p - a[i+1];
			if(p > a[i]){
				d -= p - a[i];
				if(a[i] > a[i+1]){
					d -= a[i] - a[i+1];
				}
				else{
					d += a[i] - a[i+1];
				}
			}
			else{
				d += p - a[i];
				if(a[i] > a[i+1]){
					d -= a[i] - a[i+1];
				}
				else{
					d += a[i] - a[i+1];
				}
			}
		}
		else{
			d = (p - a[i+1]) * -1;
			if(p > a[i]){
				d -= p - a[i];
				if(a[i] > a[i+1]){
					d -= a[i] - a[i+1];
				}
				else{
					d += a[i] - a[i+1];
				}
			}
			else{
				d += p - a[i];
				if(a[i] > a[i+1]){
					d -= a[i] - a[i+1];
				}
				else{
					d += a[i] - a[i+1];
				}
			}
		}
		p = a[i];
		printf("%d\n", sum+d);
	}  

	return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
    int x, n;
    cin >> x >> n;
    vector<bool> a(110);
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        a[t] = 1;
    }
    int best = 0;
    for (int i = 0; i <= 101; i++) {
        if (!a[i] && abs(best - x) > abs(i - x)) best = i;
    }
    cout << best << "\n";
}


Measured memory_bytes: 3592
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  string s,t; cin >>s >>t;
  cout <<t <<s;
}

/// confirm df==0 ///


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int INF = 2e6;
ll MOD = 1e9 + 7;

/*
int main(){
    
    int n; cin >> n;
    vector<vector<pair<int,ll>>> g(n);
    rep(i,n-1){
        int a, b; ll c;
        cin >> a >> b >> c;
        a--; b--;
        g[a].pb(make_pair(b,c));
        g[b].pb(make_pair(a,c));
    }
    
    int q, k; cin >> q >> k;
    k--;
    vector<int> x(q),y(q);
    rep(i,q) {
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
    }

    queue<int> que;
    que.push(k);
    vector<bool> vis(n,false);
    vis[k] = true;
    vector<ll> dist(n);

    while(que.size()){
        int v = que.front();
        que.pop();
        for(auto i : g[v]){
            if(!vis[i.first]){
                vis[i.first] = true;
                dist[i.first] = dist[v] + i.second;
                que.push(i.first);                
            }
        }
    }

    rep(i,q){
        cout << dist[x[i]] + dist[y[i]] << endl;
    }
}
*/

/*struct edge{
    int to;
    ll cost;
};
*/
using edge = struct {int to; ll cost;};
int main(){
    int n; cin >> n;
    vector<vector<edge>> g(n);
    rep(i,n-1) {
        int a, b; ll c;
        cin >> a >> b >> c;
        a--; b--;
        g[a].pb({b,c});
        g[b].pb({a,c});
    }
    int q, k; cin >> q >> k;
    k--;

    queue<int> que;
    que.push(k);
    vector<bool> vis(n,false);
    vector<ll> dist(n);

    while(que.size()){
        int v = que.front();
        que.pop();
        for(auto e : g[v]){
            if(!vis[e.to]){
                vis[e.to] = true;
                dist[e.to] = dist[v] + e.cost;
                que.push(e.to);
            }
        }
    }

    rep(i,q){
        int x, y; cin >> x >> y;
        x--; y--;
        cout << dist[x] + dist[y] << endl;
    }
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long unsigned int llong;


int main(){
    int n,a,b;
    cin >> n >> a >> b;
    if(n*a < b) cout << n*a << endl;
    else cout << b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
struct edge{
    int u,v,id;
};
int n,m,u,v,deg[maxn],root;
vector<pair<int,int>> a[maxn];
vector<int> nt[maxn];
pair<int,int> b[maxn];
bool ban[maxn],vis[maxn];
void dfs(int nod){
    vis[nod]=true;
    for(auto i:a[nod]){
        if(!vis[i.first]){
            root=nod;
            ban[i.second]=true;
            nt[nod].push_back(i.first);
            nt[i.first].push_back(nod);
            dfs(i.first);
        }
    }
    return;
}
void _dfs(int nod,int pa){
    for(auto i:nt[nod]){
        if(i!=pa){
            _dfs(i,nod);
            if(deg[i]%2){
                printf("%d %d\n",i,nod);
                deg[i]++;
            }
            else{
                printf("%d %d\n",nod,i);
                deg[nod]++;
            }
        }
    }
    return;
}

int main(){
    scanf("%d%d",&n,&m);
    if(m&1)return !printf("-1\n");
    for(int i=1;i<=m;i++){
        scanf("%d%d",&u,&v);
        a[u].push_back({v,i});
        a[v].push_back({u,i});
        b[i]={u,v};
    }
    dfs(1);
    for(int i=1;i<=m;i++){
        if(!ban[i]){
            printf("%d %d\n",b[i].first,b[i].second);
            deg[b[i].first]++;
        }
    }
    _dfs(root,0);

}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,m;
    cin>>n>>m;
    vi p(m);
    vector<string> s(m);
    REP(i,m) cin>>p[i]>>s[i];
    
    vi ac(n);
    vi wa(n);

    REP(i,m){
        if(s[i]=="AC"){
            ac[p[i]-1]=1;
        }else if(s[i]=="WA"){
            if(ac[p[i]-1] == 0){
                wa[p[i]-1]++;
            }
        }
    }

    ll ans1 = accumulate(ALL(ac),0LL);
    ll ans2 = 0;
    REP(i,n){
        if(ac[i]==1) ans2 += wa[i];
    }

    cout << ans1 << " " << ans2 << endl;
    return 0;
}

Measured memory_bytes: 6912
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 A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int[] X = new int[N];
        for (int i=0;i<N;i++) {
            X[i] = Integer.parseInt(sc.next());
        }
        long ans = 0L;
        for (int i=0;i<N-1;i++) {
            ans += Math.min((long)A*(X[i+1]-X[i]), B);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 47772
n,m,c = map(int,input().split())
b = [int(x.strip()) for x in input().split()]
a = []
ans = 0
for i in range(n):
  ai = [int(x.strip()) for x in input().split()]
  a.append(ai)
for j in range(n):
  ch = [x*y for (x,y) in zip(a[j],b)]
  ch_sum = sum(ch)
  if ch_sum + c > 0:
    ans += 1
print(ans)

Measured memory_bytes: 9108
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		//String t = sc.next();
		long n = sc.nextLong();
		long m = sc.nextLong();
		long k = sc.nextLong();
		//long l = sc.nextLong();
		//long count=0;

		for(int i=1;i<100;i++) {
			if(n-m<k*i) {
				System.out.println(n-m-k*(i-1));
				break;
			}
		}
		/*if((n*m)%2==0) {
			System.out.println("Even");
		}else{
			System.out.println("Odd");
		}*/
		//System.out.println((int)Math.ceil((n+m)/2.0));
		//System.out.println(n-m-k*x);
	}
}




Measured memory_bytes: 21716
/* Accepted. */
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
using namespace std;
typedef long long ll;
#define MAXN 2000006
double a , b;
int main() {
	//freopen( "input","r",stdin );
	cin >> a >> b;
	cout << 1.0*a / b;
}//qwq


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

 
int main() {
    ll n, ans = 0;
    vector<int> b;
    
    cin >> n;

    for (int i = 0; i < n-1; i++) {
        int temp;
        cin >> temp;
        b.push_back (temp);
    }

    vector<int> a(n);

    for (int i = 0; i < n; i++) {
        if (i == 0) a[i] = b[i];
        else if (i == n-1) a[i] = b[i-1];
        else a[i] = min(b[i-1], b[i]);
    }

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

    cout << ans << endl;

    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

const int MOD = 1e9 + 7;

inline int add(int x, int y){
	int res = x + y;	
	while(res >= MOD)res-=MOD;
	return res;
}

inline int mul(int x,int y){
	return (1LL * x * y) % MOD;
}

int modpow(int x,int p){
	int res = 1;
	while(p){
		if(p&1)gmul(res,x);
		gmul(x,x);
		p/=2;
	}
	return res;
}

inline int invert(int x){
	return modpow(x,MOD - 2);
}

const int N = 2e5 + 5;

int fac[N], inv[N];

void init(int n){
	fac[0] = inv[0] = 1;
	for(int i = 1;i < n; ++i){
		fac[i] = mul(fac[i-1], i);	
		inv[i] = invert(fac[i]); 
	}
}

int comb(int n,int k){
	return mul(fac[n],mul(inv[k], inv[n-k]));	
}

vector<int> g[N];
int sz[N],par[N],dp[N],ans[N];

int dfs(int u, int p=-1){
	sz[u] = 1;
	par[u] = p;
	for(int v:g[u]){
		if(v == p){
			continue;
		}
		sz[u] += dfs(v,u);
	}
	return sz[u];
}

int n;

void gdp(int u = 0){
	dp[u] = fac[sz[u] - 1];
	for(int v:g[u]){
		if(v == par[u])continue;
		gdp(v);
		gmul(dp[u],dp[v]);
		gmul(dp[u],inv[sz[v]]);
	}
}

void solve(int u){
	if(u == 0)ans[u] = dp[u];
	else{
		int res = dp[u];
		int top = ans[par[u]];
		gmul(top, invert(dp[u]));
		gmul(top, fac[sz[u]]);
		gmul(top, inv[n-1]);
		gmul(top, fac[n-1-sz[u]]);
		ans[u] = mul(comb(n-1,sz[u]-1), mul(res,top));
	}
	for(int v:g[u]){
		if(v == par[u])continue;
		solve(v);
	}
}

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	init(N);
	cin >> n;
	rep(i,0,n-1){
		int x,y;
		cin >> x >> y;
		--x,--y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs(0);
	gdp(0);
	solve(0);
	rep(i,0,n)cout << ans[i] << '\n';
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll n;
    cin >> n;
    vector<ll> P(n);
    rep(i, n) cin >> P[i];
    ll ans = 0;
    rep2(i, 1, n - 1) {
        if(min(P[i - 1], P[i + 1]) < P[i] && max(P[i - 1], P[i + 1]) > P[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
import java.util.*;
import java.io.*;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String[] sa = br.readLine().split(" ");
        String[] array = br.readLine().split(" ");

        int n = Integer.parseInt(sa[0]);
        int k = Integer.parseInt(sa[1]);
        
        List<Integer> list = Arrays.asList(array).stream().map(Integer::valueOf).sorted().collect(Collectors.toList());
        

        int ans = 0;
        
        for(int i=0;i<k;i++) {
            ans+=list.get(i);
        }
        
        System.out.println(ans);
    }
}


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

const long long MAXN = 1e5+5, MOD = 1e9+7;
int n,k;
vector<int> g[MAXN];
long long dp[MAXN];

void dfs(int x, int p) {
	long long cur = (x==1?k-1:k-2);
	for (auto i: g[x]) {
		if (i==p) continue;
		dp[i] = cur;
		cur--;
		dfs(i,x);
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n-1; ++i) {
		int a,b;
		cin >> a >> b;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}
	long long ans = 1;
	dp[1] = k;
	dfs(1,-1);
	for (int i = 1; i <= n; ++i) {
		//cerr << dp[i] <<' ';
		ans = ans % MOD * dp[i] % MOD;
		ans %= MOD;
	}
	cout << ans % MOD;
    return 0;
}


Measured memory_bytes: 9984
import java.util.Arrays;
import java.util.Scanner;

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

        int total = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            total += Math.min(x, k - x) * 2;
        }

        System.out.println(total);
    }
}


Measured memory_bytes: 22740
using System;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int a = sc.NextInt();
        string s = sc.Next();
        if (a >= 3200)
        {
            Console.WriteLine(s);
        }
        else
        {
            Console.WriteLine("red");
        }
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
	int ac=0,re=0,tle=0,wa=0,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		char p[5];
		scanf("%s",p);
		if(p[0]=='A')ac++;
		if(p[0]=='T')tle++;
		if(p[0]=='W')wa++;
		if(p[0]=='R')re++;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d",ac,wa,tle,re);
}

Measured memory_bytes: 3864
#140_C
n = int(input())
b = list(map(int, input().split()))

ans = 0
for i in range(n):
    if i == 0:
        ans += b[i]
    elif i == n-1:
        ans += b[i-1]
    else:
        ans += min(b[i-1], b[i])
print(ans)

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int d[3][3];
    REP(i, 3) {
        REP(j, 3) {
            cin >> d[i][j];
        }
    }

    vector<int> a(3), b(3);
    a[0] = 0;
    b[0] = d[0][0] - a[0];
    b[1] = d[0][1] - a[0];
    b[2] = d[0][2] - a[0];
    a[1] = d[1][0] - b[0];
    a[2] = d[2][0] - b[0];

    bool ok = true;
    
    REP(i, 3) {
        REP(j, 3) {
            if (a[i] + b[j] != d[i][j]) ok = false;
        }
    }
    if (ok) {
        print("Yes");
    } else {
        print("No");
    }
}

signed main() {
    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint K, X;
    cin >> K >> X;
    range(i, X - K + 1, X + K) cout << i << " ";
    cout << "\n";
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long

#define for(i,a,b) for (i=a; i<b; i++)
#define forb(i,a,b) for (i=a; i>b; i--)
#define all(S) S.begin(),S.end()
#define sort(S) sort(all(S))

const int inf = 1e9;
const ll INF = 1e18;

const ll r = 1e6+1;

ll n,k=0;
vector <pair <ll,int> > V;

void go(ll m, int q)
{
    if (q==V.size())
    {
        //cout << m << endl;
        if (m==1)
            return;
        ll n1 = n;
        while (n1%m==0)
        n1/=m;
        if (n1%m==1)
            k++;
        return;
    }
    ll p = m;
    int i;
    for (i,0,V[q].s+1)
    {
        go(p,q+1);
        p*=V[q].f;
    }
    return;
}

void go1(ll m, int q)
{
    if (q==V.size())
    {
        //cout << m << endl;
        if (m>1)
        k++;
        return;
    }
    ll p = m;
    int i;
    for (i,0,V[q].s+1)
    {
        go1(p,q+1);
        p*=V[q].f;
    }
    return;
}

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    ll i;
    cin >> n;
    ll m = n;
    for (i,2,r)
        if (m%i==0)
    {
        int q = 0;
        while (m%i==0)
        {
            m/=i;
            q++;
        }
        V.pb(mp(i,q));
    }
    if (m>1)
        V.pb(mp(m,1));
    go(1,0);
    V.clear();

    m = n-1;
    for (i,2,r)
        if (m%i==0)
    {
        int q = 0;
        while (m%i==0)
        {
            m/=i;
            q++;
        }
        V.pb(mp(i,q));
    }
    if (m>1)
        V.pb(mp(m,1));
    go1(1,0);
    cout << k << endl;
    return 0;
}


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

using ll = long long;
using Field = vector<vector<ll>>;
using Graph = vector<vector<ll>>;
using VI = vector<int>;


using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VC = vector<char>;
using PI = pair<int, int>;

#define FOR(i, s, n) for (int i = s; i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

int A, B;

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

    cin >> A >> B;
    cout << A * B << endl;    

    return 0;
}

Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int A[] = new int[N];
		int count = 0;
		int ans = 0;
		for (int i = 0; i < N; i++){
			A[i] = stdIn.nextInt();
			if(A[i] % 2 == 0){
				count++;
				if(A[i] % 3 == 0 || A[i] % 5 == 0){
					ans++;
				}
			}
		}
		if(ans == count){
			System.out.println("APPROVED");
		}
		else{
			System.out.println("DENIED");
		}
		stdIn.close();
	}
}

Measured memory_bytes: 36144
using System;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            var month = int.Parse(str[0]);
            var day = int.Parse(str[1]);

            var takahashi = 0;
            for (var i = 1; i <= month; i++)
            {
                if (i == month)
                {
                    if (i <= day)
                    {
                        takahashi++;
                    }
                    break;
                }
                takahashi++;
            }
            Console.WriteLine(takahashi);
        }
    }
}


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

long long sum(long long num) {
  if (num == 0) return 0;

  return sum(num - 1) + num;
}

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

  long long N;

  cin >> N;

  long long ans = sum(N - 1);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
fun main(arg: Array<String>) {
    val (N, M) = listOfLong()
    val ans = if (M < N * 2) M / 2 else N + (M - N * 2) / 4
    println(ans)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)


Measured memory_bytes: 37928
// Problem : C - Tsundoku
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define pb push_back
#define mod 1000000007
ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % mod; 
    p = (p * p) % mod; 
  
    return (y%2 == 0)? p : (x * p) % mod; 
} 
ll factorial[1000007];
void fact(ll n)
{
    memset(factorial,0,sizeof(factorial));
    factorial[0]=1;
factorial[1]=1;

    for(int i=1;i<n;i++)
    {
        factorial[i]=(factorial[i-1]*i)%mod;
    }
    
}
ll ncr(ll n,ll r)
{
    ll ans=1;
    ll i;
    ans=factorial[n];
    ll ans1=power(factorial[n-r],mod-2);
    ll ans2=power(factorial[r],mod-2);
    ans=((ans*ans1)%mod*ans2)%mod;
    return ans;
}
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

bool prime[100000006];
void sieve(ll n){
    memset(prime,true,sizeof(prime));
	prime[1]=false; 
    for (ll p=2;p*p<=n;p++){
        if (prime[p]){  
            for (ll i=p*p;i<=n;i+=p)
                prime[i]=false;
        }
    }
}
void bfs(vector<int> v[],int o,int n,int dp[]){
	queue<int> q;
	q.push(o);
	dp[o]=0;
	bool visited[n+1]={0};
	visited[o]=true;
	while(q.empty()==false){
		int a=q.front();
		q.pop();
		for(int i=0;i<v[a].size();i++){
			if(visited[v[a][i]]==false){
				visited[v[a][i]]=true;
				q.push(v[a][i]);
				dp[v[a][i]]=dp[a]+1;
			}
		}
	}
}
int nov[1000001];
bool visited[1000001];
int dp[1000001];
int dfs(vector<int> v[],int o)
{
    if(visited[o]==0)
    {
        visited[o]=1;
        for(int i=0;i<v[o].size();i++)
        {
            if(visited[v[o][i]]==0)
            {
            dp[v[o][i]]=dp[o]+1;
            nov[o]+=dfs(v,v[o][i]);
            }
        }
        return nov[o]+1;
    }
    else
    return 0;
}
// string s=bitset<64>(n).to_string();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll n,m,k;
	cin>>n>>m>>k;
	vector<ll> a(n);
	vector<ll> b(m);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<m;i++)
	{
		cin>>b[i];
	}
	for(int i=1;i<n;i++)
	{
		a[i]+=a[i-1];
	}
	for(int i=1;i<m;i++)
	{
		b[i]+=b[i-1];
	}
	int ans=0;
	for(int i=0;i<m;i++)
	{
		// cout<<b[i]<<" ";
		if(b[i]<=k)
		{
		int pos=upper_bound(a.begin(),a.end(),k-b[i])-a.begin();
		// cout<<i+1+pos<<endl;
		ans=max(i+1+pos,ans);
		}
		else
		break;
	}
	for(int i=0;i<n;i++)
	{
		if(a[i]<=k)
		{
			int pos=upper_bound(b.begin(),b.end(),k-a[i])-b.begin();
			ans=max(i+1+pos,ans);
		}
		else
		break;
	}
	// cout<<endl;
	cout<<ans<<endl;
	return 0;
}


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

#define DIV 998244353

long long modpow(long long ori, long long po){
	long long res = 1;
	while(po > 0){
		if(po&1){
			res *= ori;
			res %= DIV;
		}
		ori *= ori;
		ori %= DIV;
		po >>= 1;
	}
	return res;
}

int main(){
	int N;
	map<long long, long long> dcount;
	cin >> N;
	long long maxi = 0;
	bool ok = true;
	for(int i = 0; i < N; i++){
		long long d;
		cin >> d;
		dcount[d]++;
		maxi = max(maxi, d);
		if(i == 0 && d != 0){
			ok = false;
		}
	}
	if(!ok){
		cout << 0 << endl;
		return 0;
	}

	for(long long i = 0; i <= maxi; i++){
		if(dcount.find(i) == dcount.end()){
			cout << 0 << endl;
			return 0;
		}
	}
	if(dcount[0] != 1){
		cout << 0 << endl;
		return 0;
	}

	long long ans = 1;
	long long parent = 1;
	for( auto i = dcount.begin(); i != dcount.end() ; ++i ) {
		ans *= modpow(parent, i->second);
		parent = i->second;
		ans %= DIV;
	}
	cout << ans << endl;
}

Measured memory_bytes: 6528
import math

N, K = map(int, input().split())
mod = 1000000007


def nCr(n: int, r: int):
    if n == r:
        return 1
    if r > n:
        return 0
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))


for i in range(1, K+1):
    print(nCr(N-K+1, i) * nCr(K-1, i-1) % mod)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
 
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define fff(i,a,b) for(int (i)=(a);(i)<=(b);i++)
#define pb push_back
#define len(a) (a).length()
#define all(a) (a).begin(),(a).end()
#define sz(a) (a).size()
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long ,long long > pll;
typedef unsigned long long ull;
typedef long double ld;
 
const int mn=1e6+69;
int kolko[mn];
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	int num=0;
	for(int i=0;i<n;i++) kolko[a[i]]=0;
	for(int i=0;i<n;i++) kolko[a[i]]++;
	for(int i=0;i<n;i++)
	{
		bool sta=true;
		for(int j=1;j*j<=a[i];j++)
		{ 
			if(a[i]%j==0)
			{
				if(j!=a[i] && kolko[j]>0) sta=false;
				else if(j==a[i] && kolko[j]>1) sta=false;
				int pom=a[i]/j;
				if(pom!=a[i] && kolko[pom]>0) sta=false;
				else if(pom==a[i] && kolko[pom]>1) sta=false;
			}
		}
		if(sta) num++;
	}
	cout<<num<<endl;
	return 0;
}

Measured memory_bytes: 8248
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>

using namespace std;
typedef unsigned int UINT;
typedef long long LLONG;
typedef unsigned long long ULLONG;

//#define LengthOf()

#if 1
//No.4
int main()
{
	int N, X, Y;
	cin >> N >> X >> Y;

	int  count[2000];
	memset(count, 0, sizeof(int) * 2000);

	X -= 1;
	Y -= 1;

	for (int i = 0; i < N - 1; ++i) {
		for (int j = i + 1; j < N; ++j) {
			//直進
			int cost1 = j - i;

			//X,Yを経由
			int cost2 = abs(i - X) + 1 + abs(j - Y);

			int cost = min(cost1, cost2);
			count[cost] += 1;
			//cout << "(" << i+1 << ", " << j+1 << "): " << cost << endl;
		}
	}

	for (int k = 1; k < N; ++k) {
		cout << count[k] << endl;
	}

#if 0
	UINT* buf = new UINT[N*N];
	memset(buf, 0xFFFFFFFF, sizeof(UINT) * N * N);
	UINT* cost[2000];
	UINT  count[2000];

	for (UINT i = 0; i < N; ++i) {
		cost[i] = &(buf[N * i]);
	}
	memset(count, 0, sizeof(UINT) * 2000);

	for (UINT i = 0; i < N-1; ++i) {
		cost[i][i + 1] = 1;
		cost[i+1][i] = 1;
		count[1] += 1;
	}
//	cost[0][N - 1] = 1;
//	cost[N - 1][0] = 1;
//	count[1] += 1;
	cost[X - 1][Y - 1] = 1;
	cost[Y - 1][X - 1] = 1;
	count[1] += 1;

	for (UINT step = 2; step < N - 1; ++step) {
		for (UINT start = 0; start < N - step; ++start) {
			UINT pass = (start + step - 1);// % N;
			UINT goal = (start + step    );// % N;
			UINT tmp = cost[start][pass] + 1;

			if (tmp < cost[start][goal]) {
				cost[start][goal] = tmp;
				cost[goal][start] = tmp;
				count[step] += 1;
				cout << step << ": (" << start + 1 << ", " << goal + 1 << ")" << endl;
			}
		}
	}

	for (UINT k = 1; k < N; ++k) {
		cout << count[k] << endl;
	}

	delete[] buf;
#endif
	return 0;
}
#endif

Measured memory_bytes: 256
#include<iostream> 
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	int n,a[10000],b=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b+=a[i]-1;
	}
	cout<<b;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    //一回a円、b円持ってる、最大c回
    int ans = 0;
    while(ans < c) {
        if(b - a >= 0){
            b -= a;
            ans++;
        }
        else break;
    }

    cout <<  ans << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end(), greater<>());
  int p1=0;
  int p2=0;
  rep(i,n) {
    if (i % 2 == 0) p1 += a[i];
    else p2 += a[i];
  }
  cout << p1 - p2 << endl;
}

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

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
using namespace std;
int abs(int x) {
    return x > 0 ? x : -x;
}
int main() {
    int n;
    int t, x, y, nt, nx, ny;
    t = x = y = 0;
    scanf("%d", &n);
    for (int i = 0; i < n ; i++) {
        scanf("%d%d%d", &nt, &nx, &ny);
        if ((abs(nx - x) + abs(ny - y) <= (nt - t)) &&
             ((nt - t - abs(nx - x) - abs(ny - y)) % 2 == 0)) {
            x = nx;
            y = ny;
            t = nt;
            continue;
        }
        // printf("%d\n", nt - t - abs(ny - y) - abs(nx - x));
        printf("No");
        return 0;
    }
    printf("Yes");
    return 0;
}


Measured memory_bytes: 128
a = list(map(int, input().split()))
b = [input().split() for l in range(a[0])]

t=0
for i in range(0, a[0]):
    if (int(b[i][0]))**2 + (int(b[i][1])**2) <= (a[1])**2:
        t=t+1
print(t)

Measured memory_bytes: 67564
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int a[3];
    cin >> a[2] >> a[1] >> a[0];
    sort(a, a+3);
    cout << abs(a[0]-a[1]) + abs(a[1]-a[2]) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,i;
  scanf("%d %d",&a,&b);
  if(a>b){
    for(i=0;i<a;i++)printf("%d",b);
  }
  else for(i=0;i<b;i++)printf("%d",a);
  return 0;
}


Measured memory_bytes: 128
from itertools import permutations

n = int(input())

lis = [list(map(int, input().split())) for _ in range(n)]

s = 0
count = 0

for i in permutations(range(n), n):
    count += 1
    for a, b in zip(i, i[1:]):
        s += ((lis[a][0] - lis[b][0])**2 + (lis[a][1] - lis[b][1])**2) ** 0.5

print(s/count)


Measured memory_bytes: 40684
#include<iostream>
#include<cstdio>
#define ll long long
const int M=1e5+10;
using namespace std;
int n,m,top;
ll f[M],s[M],st[M];
void Sol(ll x,ll mul) {
	if(x<st[1]) {s[x]+=mul;return;}
	int l=1,r=n,y;
	while(l<=r) {
		int mid=(l+r)>>1;
		if(st[mid]<=x) y=mid,l=mid+1;
		else r=mid-1;
	}
	f[y]+=mul*(x/st[y]);x=x%st[y];
	if(x) Sol(x,mul);
}
int main() {
	scanf("%d%d",&n,&m);
	st[++top]=n;
	for(int i=1;i<=m;i++) {
		ll x;scanf("%lld",&x);
		while(x<=st[top]&&top) --top;
		st[++top]=x;
	}
	m=n;n=top;f[n]=1;
	for(int i=n-1;i>=1;i--) {
		f[i]+=f[i+1]*(st[i+1]/st[i]);
		Sol(st[i+1]%st[i],f[i+1]);
	}
	for(int i=st[1];i>=1;i--) s[i]+=s[i+1];
	for(int i=1;i<=st[1];i++) s[i]+=f[1];
	for(int i=1;i<=m;i++) printf("%lld\n",s[i]);
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    vector<vector<int>> c(4, vector<int>(4, 0));

    for(int i=1; i<=3; i++) for(int j=1; j<=3; j++) cin >> c[i][j];

    int b1 = c[1][1];
    int b2 = c[1][2];
    int b3 = c[1][3];
    int a2 = c[2][1]-b1;
    int a3 = c[3][1]-b1;

    if(a2+b2 == c[2][2] && a2+b3 == c[2][3] && a3+b2 == c[3][2] && a3+b3 == c[3][3]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int gcd(long long int a, long long int b)
{
    long long int r, tmp;
    if (a < b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}


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

    ans = a * b / gcd(a, b);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <map>
#include <utility>
#include <set>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	string s, t;
	int N;
	cin >> N >> s >> t;

	for(int i = 0; i < N; ++i)
	{
		bool flag = true;
		for(int j = 0; flag && j < N; ++j)
		{
			if(i+j < N && s[i+j] != t[j])
				flag = false;
		}
		if(flag)
		{
			cout << i + N << endl;
			return 0;
		}
	}
	cout << 2*N << endl;
	return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
mod = 10**9+7
def cmb(n, r, mod=mod):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod

N = 2001  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod mod)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod mod)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)


move = []
red = n-k
for i in range(1,k+1):
    blue = i
    ans = 0
    if k - blue > 0:
        ans = cmb(red+1,blue)*fact[i+(k-blue)-1]*factinv[i-1]*factinv[k-blue]
    else:
        ans = cmb(red+1,blue)
    move.append(ans%mod)

for i in move:
    print(i)

Measured memory_bytes: 42480
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int count = 0;

		for(int i=2 ; i<n ; i++) {
			if(s.charAt(i-2)=='A' && s.charAt(i-1)=='B' && s.charAt(i)=='C') {
				count++;
			}
		}
		System.out.print(count);
		sc.close();
	}
}

Measured memory_bytes: 21844
from math import gcd, sqrt, cos, radians, pi, factorial as f
from collections import defaultdict as d

h, w, m = map(int, input().split())
row = [0] * h
col = [0] * w

dico = d(int)
for i in range(m):
	x, y = map(int, input().split())
	row[x-1] += 1
	col[y-1] += 1
	dico[str(x)+'-'+str(y)] = 1
	
m1 = max(row)
m2 = max(col)

res = m1 + m2
t1 = set()
for i in range(h):
	if row[i] == m1:
		t1.add(i)
		
t2 = set()
for i in range(w):
	if col[i] == m2:
		t2.add(i)		
total = len(t1) * len(t2)
counter = 0
for key in dico.keys():
	x, y = map(int, key.split('-'))
	if x-1 in t1 and y-1 in t2:counter+=1 

if total<=counter:res -=1

print(res)

Measured memory_bytes: 85412
from bisect import bisect

a,b,q=map(int,input().split())
s=[-10**18]+[int(input()) for i in range(a)]+[10**18]
t=[-10**18]+[int(input()) for i in range(b)]+[10**18]

for i in range(q):
  x=int(input())
  s_inx=bisect(s,x)
  t_inx=bisect(t,x)

  s_l=s[s_inx-1]
  s_r=s[s_inx]

  t_l=t[t_inx-1]
  t_r=t[t_inx]

  ans=10**18
  for i in [s_l,s_r]:
    for j in [t_l,t_r]:
      d1=abs(i-x)+abs(j-i)
      d2=abs(j-x)+abs(i-j)
      ans=min(ans,d1,d2)

  print(ans)

Measured memory_bytes: 17760
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

int main(){
    int n, k;
    cin >> n >> k;

    ll ans=k;
    rep(i, n-1){
        ans *= (k-1);
    }
    out(ans);
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<string.h>
int main(void)
{
	char s[]="ABCDE",X1;
	int a,b,i,x,X;
		while(1){
		scanf("%d%d",&a,&b);
		if(a==0&&b==0) break;
		X=0;
		X=a+b;
		X1=s[0];
		for(i=1;i<5;i++){
			scanf("%d%d",&a,&b);
			x=0;
			x=a+b;
			if(X<x){
				X=x;
				X1=s[i];
			}
		}
		printf("%c %d\n",X1,X);
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    int a[100100];
    cin >> n >> k;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    int dp[100100];
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        dp[i] = INT_MAX;
        for(int j=1;j<=k;j++)
        {      
            if(j<=i)
            dp[i]= min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024