akhauriyash/Code-Regression huggingface dataset:
def bfs(n, links):
    painted = set()
    queues = [{0}, {n - 1}]
    scores = [0, 0]
    i = 0
    while True:
        nq = set()
        for v in queues[i]:
            cq = links[v] - painted
            if cq:
                painted.update(cq)
                nq.update(cq)
        queues[i] = nq
        scores[i] += len(nq)
        if not nq:
            scores[i ^ 1] = n - scores[i]
            break
        i ^= 1
    return scores[0] > scores[1]


n = int(input())
links = [set() for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    links[a].add(b)
    links[b].add(a)
print('Fennec' if bfs(n, links) else 'Snuke')


Measured memory_bytes: 42372
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func solve(s string) int {
	ret := len(s)
	letters := ""
	for i, _ := range s {
		if !strings.Contains(letters, s[i:i+1]) {
			letters += s[i : i+1]
		}
	}

	for _, spliter := range letters {
		maxSeries := 0
		tmpSeries := 0
		for _, v := range s {
			if v == spliter {
				maxSeries = max(maxSeries, tmpSeries)
				tmpSeries = 0
			} else {
				tmpSeries++
			}
		}
		maxSeries = max(maxSeries, tmpSeries)
		ret = min(ret, maxSeries)
	}

	return ret
}

func main() {
	s := input()
	fmt.Println(solve(s))
}


Measured memory_bytes: 640
from decimal import Decimal,getcontext
from math import ceil
getcontext().prec = 1000
N = int(input())
 
takahashi,aoki = 1,1
 
for _ in range(N):
    a,b = map(int,input().split())
    c = max(ceil(Decimal(str(takahashi))/Decimal(a)),ceil(Decimal(str(aoki))/Decimal(b)))
    takahashi = c*a
    aoki = c*b
 
print(takahashi+aoki)

Measured memory_bytes: 5076
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

for d in range(D):
  sd_t = [(i + 1, e) for (i, e) in enumerate(s[d])]
  sd_t.sort(key=lambda x: x[1])
  print(sd_t[-1][0])


Measured memory_bytes: 9500
def getInput():
    (a, b, c) = (int(i) for i in input().split(" "))
    return a, b, c

a, b, c = getInput()

n_weeklylogin = 0
n_dailylogin = 0
weekly_gain = 7*a+b

n_weeklylogin = c//weekly_gain
total_bonus = n_weeklylogin*weekly_gain

if total_bonus >= c:
    print(n_weeklylogin*7)
else:
    n_dailylogin = -(-(c-total_bonus)//a)
    print(n_weeklylogin*7 + (n_dailylogin>=7)*7 + (n_dailylogin<7)*(n_dailylogin))



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

int main()
{
  
  int sp[3],ju[2];

  while(cin>>sp[0]>>sp[1]>>sp[2]>>ju[0]>>ju[1]){
    int mini = 1<<26;
    for(int i = 0; i < 3; ++i){
      for(int j = 0; j < 2; ++j){
        mini  = min(mini, sp[i] + ju[j] - 50);
      }
    }
    cout << mini << endl;
  }
  return 0;
}

Measured memory_bytes: 0
table = {}
while True:
    p, s = map(int, input().split(","))
    if p == 0:
        break
    table[p] = s
result = {v: i for i, v in enumerate(sorted(set(table.values()), reverse=True), start=1)}

try:
    while True:
        q = int(input())
        print(result[table[q]])
except EOFError:
    pass


Measured memory_bytes: 5600
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


vector<int> zalgo(vector<ll>S) {
	vector<int>A(S.size());
	A[0] = S.size();
	int i = 1, j = 0;
	while (i < S.size()) {
		while (i + j < S.size() && S[j] == S[i + j])j++;
		A[i] = j;
		if (j == 0) { i++; continue; }
		int k = 1;
		while (i + k < S.size() && k + A[k] < j) { A[i + k] = A[k]; k++; }
		i += k;
		j -= k;
	}
	return A;
}


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

	int N;
	cin >> N;
	vector<ll>a(2*N), b(N),a_(2*N-1),b_(N-1);
	for (int i = 0; i < N; i++) { cin >> a[i]; a[i + N] = a[i]; }
	for (int i = 0; i < N; i++)cin >> b[i];
	for (int i = 0; i < 2 * N - 1; i++)a_[i] = (a[i] ^ a[i + 1]);
	for (int i = 0; i < N - 1; i++)b_[i] = (b[i] ^ b[i + 1]);
	vector<ll>c;
	fore(x, b_)c.pb(x);
	fore(x, a_)c.pb(x);
	auto Z = zalgo(c);
	

	for (int k = 0; k < N; k++) {
		if (Z[N-1+k] >= N - 1)cout << k << " " << (a[k]^b[0])<< endl;
	}


	return 0;
}


Measured memory_bytes: 23016
n = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))

def binary_search(lst,key):
    left = 0
    right = len(lst)
    while left<right:
        mid = (left+right)//2
        if lst[mid]==key:
            return 1
        elif key < lst[mid]:
            right = mid
        else:
            left = mid+1
    return 0

ans = 0
for key in T:
    ans+=binary_search(S,key)
print(ans)


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

int main(){
  
  string s, ans = "No";
  cin >> s;

  int x = stoi(s);
  int fx = 0;
  
  rep(i, s.length()){
    fx += s[i] - '0';
  }


  if (x % fx == 0) ans = "Yes";
  cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int sum[n];
    sum[0]=0;
    sum[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
        sum[i]=min(sum[i-2]+abs(a[i]-a[i-2]),sum[i-1]+abs(a[i]-a[i-1]));
    cout<<sum[n-1];
    return 0;
}


Measured memory_bytes: 1024
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define print_time cerr << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
    if(y==0)
        return x;
    else
        return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
        if(m%2)
            r=(r*n)%p;
        n=(n*n)%p;
        m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}
int func(double x,vector<int>&a)
{
	int t=0;
	for(int i=0;i<a.size();i++)
	{
		t=t+abs(a[i]-(x+i+1));
	}
	return t;
}
int32_t main()
{
   /*IOS;
   #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);
   #endif
   /********************* Code starts here ***********************/	
   int n;
   cin>>n;
   vector<int>a(n);
   for(int i=0;i<n;i++)
   {
   	cin>>a[i];
   }	
   int l=-1e10,r=1e10;
   for(int i=0; r-l>100; i++) 
   {
      	double l1 = (l*2.0+r)/3.0;
      	double l2 = (l+2.0*r)/3.0;
      //cout<<l1<<" "<<l2<<endl;
      	if(func(l1,a) < func(l2,a)) r = l2; else l = l1;
      //	debug2(l,r);
   }
   int ans=inf;
   for(int i=l;i<=r;i++)
   {
   	int t=func(i,a);
   //	debug2(i,t);
   	ans=min(ans,t);
   }
   cout<<ans<<endl;
} 	

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = new Program();
            p.Solve();
        }

        void Solve()
        {
            int n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine().Split();
            bool four = false;
            for (int i = 0; i < n; i++)
            {
                if (s[i] == "Y")
                {
                    four = true;
                }
            }
            Console.WriteLine(four ? "Four" : "Three");
        }

    }
}


Measured memory_bytes: 11092
m, d = map(int, input().split())
cnt = 0
for j in range(1, m + 1):
    for i in range(1, d + 1):
        if len(str(i)) == 2:
            if int(str(i)[0]) >= 2 and int(str(i)[1]) >= 2:
                if int(str(i)[0]) * int(str(i)[1]) == j:
                    cnt += 1
print(cnt)

Measured memory_bytes: 40432
/**
 *    author:  math2do
 *    created: 31.05.2020 17:32:57
**/

#include <bits/stdc++.h>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(const char &ch) {
  return "'" + string(1, ch) + "'";
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  reverse(res.begin(), res.end());
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ld = long double;

ld threshold = (ld) ((long long)(1e18));

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  cout << fixed << setprecision(0);
  cerr << fixed << setprecision(0);
  vector <long long> arr(n);
  bool zero = false;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    zero |= (arr[i] == 0);
  }
  if (zero) cout << 0 << '\n';
  else {
    ld pro = 1;
    bool found = false;
    for (int i = 0; i < n; i++) {
      pro = pro * (ld) arr[i];
      if (pro > threshold) {
        found = true;
        break;
      }
    }
    cout << (found ? -1 : pro) << endl;
  }   
  return 0;
}


Measured memory_bytes: 3992
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var ans = 0;
            var arr = new int[N + 1];
            for (var i = 0; i < N; i++)
            {
                arr[i + 1] = a[i];
                if (i + 1 == arr[a[i]]) ans++;
            }

            Console.WriteLine(ans);
        }
    }
}

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

int main(void){
    int a,b,h,m;
    long double pi,argA,argB,argAB,c;
    pi = 3.1415926535897932384626433;

    cin >> a >> b >> h >> m;

    argA = pi * (60.0 * (long double)h + (long double)m) / 360.0;
    argB = pi * (60.0 * (long double)h + (long double)m) / 30.0;
    argAB = argB - argA;

    c = (long double)(a * a + b * b )- 2.0 * (long double)a *(long double) b * (long double)cos(argAB);
    c = sqrt(c);

/*    if(h == 0 && m == 0){
        cout << b - a << endl;
    }else{
*/        cout <<  fixed  << setprecision(20) << c << endl;
//    }

    return 0;
}

Measured memory_bytes: 4096
n, k = map(int, input().split())
a_ = list(map(int, input().split()))


def tentousu(a_):
    count = 0
    for i in range(len(a_)):
        for j in range(i + 1, len(a_)):
            if a_[i] > a_[j]:
                count += 1
    return count


def chiisai(a_):
    count = 0
    for i in range(len(a_)):
        for j in range(len(a_)):
            if a_[i] > a_[j]:
                count += 1
    return count


print((tentousu(a_) * k + chiisai(a_) * k * (k - 1) // 2) % (10 ** 9 + 7))


Measured memory_bytes: 3188
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int maxN = (int)1e5 + 100;
vector < pair < int, int > > g[maxN];
ll f[maxN];
int sz[maxN];
int n;
void dfs(int v, int p) {
    sz[v] = 1;
    for (auto to : g[v]) {
        if (to.first == p) continue;
        f[to.first] = f[v] + to.second;
        dfs(to.first, v);
        sz[v] += sz[to.first];
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i < n; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        g[a].emplace_back(b, c);
        g[b].emplace_back(a, c);
    }
    dfs(1, -1);
    vector < int > cens;
    for (int i = 1; i <= n; i++) {
        bool ok = true;
        if (2 * (n - sz[i]) > n) continue;
        for (auto it : g[i]) {
            if (f[it.first] < f[i]) continue;
            if (2 * sz[it.first] > n) {
                ok = false;
                break;
            }
        }
        if (ok) cens.emplace_back(i);
    }
    assert(1 <= cens.size() && cens.size() <= 2);
    if (cens.size() == 1) {
        f[cens[0]] = 0;
        dfs(cens[0], -1);
        ll ans = 0;
        for (int i = 1; i <= n; i++) {
            ans += 2 * f[i];
        }
        ll mn = 1e9;
        for (auto it : g[cens[0]]) {
            mn = min(mn, (ll)it.second);
        }
        ans -= mn;
        cout << ans << '\n';
    }
    else {
        f[cens[0]] = 0;
        dfs(cens[0], -1);
        ll ans = 0;
        for (int i = 1; i <= n; i++) {
            ans += 2 * f[i];
        }
        ll mn = 1e9;
        for (auto it : g[cens[0]]) {
            if (it.first == cens[1]) {
                mn = it.second;
                break;
            }
        }
        ans -= mn;
        cout << ans << '\n';
    }
    return 0;
}

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

int cmp(const void *a, const void *b){
	return *(int*)a - *(int*)b;
}

int searchl(int a, int *ary, int n){
	int l = 0, r = n - 1;
	while(1){
		if(r <= l)return r;
		int tmp = (l + r) / 2;
		if(ary[tmp] == a){
			while(ary[tmp] == a && tmp > 0)tmp--;
			return tmp;
		}else if(ary[tmp] > a){
			r = tmp - 1;
		}else{
			l = tmp + 1;
		}
	}
	return 0;
}

int searchr(int a, int *ary, int n){
	int l = 0, r = n - 1;
	while(1){
		if(r <= l)return r;
		int tmp = (l + r) / 2;
		if(ary[tmp] == a){
			while(ary[tmp] == a && tmp > 0)tmp++;
			return tmp;
		}else if(ary[tmp] > a){
			r = tmp;
		}else{
			l = tmp;
		}
	}
	return 0;
}

int max(int a, int b){
	return a > b ? a : b;
}
int min(int a, int b){
	return a < b ? a : b;
}
int main(void){
	int n;
	scanf("%d", &n);
	int *l;
	int count = 0;
	l = malloc(sizeof(int) * n);
	for(int i = 0; i < n; i++)
		scanf("%d", l + i);
	qsort(l, n, sizeof(int), cmp);
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			for(int k = j + 1; k < n; k++){
				if(l[j] - l[i] > l[k])continue;
				if(l[i] + l[j] <= l[k])break;
				count++;
			}
		}
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<set>
#include<deque>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
    int N;
    cin >> N;
    deque<ll> a(N);
    deque<ll> ret, ret2;
    for(int i = 0; i < N; ++i) {
        cin >> a[i];    
    }
    sort(a.begin(), a.end());
    deque<ll> b = a;
    sort(b.begin(), b.end(), greater<ll>());
    int step = 1;
    ret.push_back(a.front());
    a.pop_front();
    while(a.size() != 0) {
        switch (step) {
            case 1 :
                ret.push_front(a.back());
                a.pop_back();
                step++;
                break;
            case 2:
                ret.push_back(a.back());
                a.pop_back();
                step++;
                break;
            case 3:
                ret.push_front(a.front());
                a.pop_front();
                step++;
                break;
            case 4:
                ret.push_back(a.front());
                step = 1;
                a.pop_front();
                break;
        }
    }

    ll diffsum = 0;
    for(int i = 1; i < N; ++i) {
        diffsum += abs(ret[i] - ret[i-1]);
    }

    step = 1;
    ret2.push_back(b.front());
    b.pop_front();
    while(b.size() != 0) {
        switch (step) {
            case 1 :
                ret2.push_front(b.back());
                b.pop_back();
                step++;
                break;
            case 2:
                ret2.push_back(b.back());
                b.pop_back();
                step++;
                break;
            case 3:
                ret2.push_front(b.front());
                b.pop_front();
                step++;
                break;
            case 4:
                ret2.push_back(b.front());
                step = 1;
                b.pop_front();
                break;
        }
    }
    ll diffsum2 = 0;
    for(int i = 1; i < N; ++i) {
        diffsum2 += abs(ret2[i] - ret2[i-1]);
    }

    cout << max(diffsum, diffsum2) << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MOD = (int)1e9 + 7;


//---------------------------------------------------------------
template<int MOD> struct ModInt { int x;
    explicit operator bool() const { return !!x; }
    ModInt(int v = 0) : x(v % MOD) { if (x < 0) x += MOD; }
    ModInt(long long v) : x(v % MOD) { if (x < 0) x += MOD; }
    ModInt &operator+=(const ModInt &r) { if ((x += r.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(const ModInt &r) { if ((x += MOD - r.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(const ModInt &r) { x = 1LL * x * r.x % MOD; return *this; }
    ModInt &operator/=(const ModInt &r) { return *this *= r.inv(); }
    ModInt operator-() const { return x ? ModInt(MOD - x) : ModInt(x); }
    ModInt operator+(const ModInt &r) const { return ModInt(*this) += r; }
    ModInt operator-(const ModInt &r) const { return ModInt(*this) -= r; }
    ModInt operator*(const ModInt &r) const { return ModInt(*this) *= r; }
    ModInt operator/(const ModInt &r) const { return ModInt(*this) /= r; }
    ModInt inv() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
        return ModInt(u); } // x.pow(MOD-2)
    ModInt pow(long long k) const { ModInt r(1), a(x);
        while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
    bool operator==(const ModInt r) const { return x == r.x; }
    bool operator!=(const ModInt r) const { return x != r.x; }
    bool operator< (const ModInt r) const { return x <  r.x; }
    friend ostream& operator<<(ostream &os, const ModInt<MOD>& a) { return os << a.x; }
    friend istream& operator>>(istream &is, ModInt<MOD>& a) { return is >> a.x; }
};
template<typename T, int SZ> struct Comb { vector<T> _fac, _ifac, _inv;
    Comb() : _fac(SZ + 1), _ifac(SZ + 1), _inv(SZ + 1) {
        _fac[0] = _ifac[SZ] = _inv[0] = 1;
        for (int i = 1; i <= SZ; i++) _fac[i] = _fac[i - 1] * i;
        _ifac[SZ] /= _fac[SZ];
        for (int i = SZ - 1; i >= 0; i--) _ifac[i] = _ifac[i + 1] * (i + 1);
        for (int i = 1; i <= SZ; i++) _inv[i] = _ifac[i] * _fac[i - 1]; }
    T inv(int n) { return n < 0 ? T(0) : _inv[n]; }
    T fac(int n) { return n < 0 ? T(0) : _fac[n]; }
    T ifac(int n) { return n < 0 ? T(0) : _ifac[n]; }
    T P(int a, int b) { return (b < 0 || a < b) ? T(0) : _fac[a] * _ifac[a - b]; }
    T C(int a, int b) { return b < 0 ? T(0) : P(a, b) * _ifac[b]; }
    T H(int n, int k) { if (n < 0 || k < 0) return T(0);
        return k == 0 ? T(0) : C(n + k - 1, k); }
    T S(int n, int k) { T r = 0;
        for (int i = 0; i <= k; i++) {
            T t = C(k, i) * T(i).pow(n); r += ((k - i) & 1 ? -t : t);
        }
        return r * _ifac[k];
    }
};
typedef ModInt<MOD> mint;
//---------------------------------------------------------------


int main() {
    Comb<mint, 250000> com;
    int n, k; cin >> n >> k;
    cout << com.S(n, k) << endl;
    return 0;
}


Measured memory_bytes: 5568
n = int(input())
a = list(map(int,input().split()))
total = abs(a[0]) + abs(a[n-1])
for i in range(n-1):
    total += abs(a[i+1] - a[i])
a.insert(0,0)
a.insert(n+1,0)
ans=[]
for i in range(1,n+1):
    if a[i-1]<=a[i]<=a[i+1] or a[i-1]>=a[i]>=a[i+1]:
        ans.append(total)
    else:
        change = total + abs(a[i+1]-a[i-1]) -(abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))
        ans.append(change)
for i in range(n):
    print(ans[i])

Measured memory_bytes: 14172
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use proconio::marker::*;
use proconio::*;
use std::collections::HashSet;

#[fastout]
fn main() {
    input! {
        n: u64,
        k: u64,
    }
    // annotate for rust-analyzer
    let n: u64 = n;
    let k: u64 = k;

    let mut ans = 0u64;
    for i in k..=n + 1 {
        let mx = i * (n + n - i + 1) / 2;
        let mn = i * (i - 1) / 2;
        ans += mx - mn + 1;
        ans %= 1_000_000_007;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2172
module Main where

import           Data.List
import           Control.Monad

main :: IO ()
main = do
    [h, w] <- (map read . words) <$> getLine :: IO [Int]
    list   <- map (map read . words) <$> (replicateM h) getLine :: IO [[Int]]
    let res1    = (map goRight . enumerate2d) list
    let list2   = (map snd) res1
    let result1 = (concatMap fst) res1
    let res2    = (goRight . map last) list2
    let result2 = fst res2
    let result  = concat [result1, result2]

    putStr
        $ (unlines . (((show . length) result) :) . map
              (unwords . (\((a, b), (c, d)) -> (map show) [a, b, c, d]))
          )
              result

    return ()
goRight
    :: [((Int, Int), Int)] -> ([((Int, Int), (Int, Int))], [((Int, Int), Int)])
goRight list@[_         ] = ([], list)
goRight (     a : b : xs) = if even (snd a)
    then let res = goRight (b : xs) in mapSnd (a :) res
    else
        let res = goRight (mapSnd (+ 1) b : xs)
        in  ((fst a, fst b) : (fst res), mapSnd (subtract 1) a : (snd res))

enumerate :: [a] -> [(Int, a)]
enumerate = zip [1 ..]

enumerate2d :: [[a]] -> [[((Int, Int), a)]]
enumerate2d =
    (map (\(y, a) -> (map (\(x, b) -> ((y, x), b)) . enumerate) a) . enumerate)

mapTuple :: (t1 -> a) -> (t2 -> b) -> (t1, t2) -> (a, b)
mapTuple f1 f2 (a, b) = (f1 a, f2 b)

mapFst :: (t1 -> a) -> (t1, b) -> (a, b)
mapFst = flip mapTuple id

mapSnd :: (t2 -> b) -> (a, t2) -> (a, b)
mapSnd = mapTuple id


Measured memory_bytes: 78460
def main ():
	N = int(input())
	A = list(map(int,input(). split ()))
	if 0 in A:
		print(0)
		return
	prod = 1
	for a in A:
		prod *= a
		if prod > 1000000000000000000:
			print(-1)
			return
	print(prod)
main ()


Measured memory_bytes: 21552
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int n,d;
	int ans=0;
	cin>>n>>d;
	int a[100][100];
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=d;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			int x=0;
			for(int k=1;k<=d;k++)
			{
				x+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			}
			int y=sqrt(x);
			if(y*y==x) ans+=1;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
function main( args ) {
  const [N,_A] = args.trim().split('\n');
  const A = _A.split(' ').map(BigInt);
  if ( A.some(a=>!a) ) return console.log('0');
  let M = 1n;
  for ( let i = 0; i < N; i ++ ) {
    M *= A[i];
    if ( M > 1000000000000000000n ) return console.log('-1');
  }
  console.log(M.toString());
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 43668
#include<bits/stdc++.h>
#define pb push_back 
 #define fo(i,n) for(int i=0;i<n;i++)
#define ll long long 
#define int long long 
#define Mod 1000000007 
#define MAX 4294967296  // 2^32
const int M=1e9+7;
#define ip pair<int,int>
#define test(t) ll t;cin>>t;while(t--)
  
using namespace std;
void dfs(vector<int>adj[],vector<int>&vis,int &count,int i){
    vis[i]=1;
    count++;
    for(auto it:adj[i]){
        if(!vis[it])dfs(adj,vis,count,it);
    }
}

void solve(){
int n,k;
cin>>n>>k;
if(k==0){
    cout<<1;
    return ;
}
vector<int>adj[n+1];
fo(i,k){
    int a,b;
    cin>>a>>b;
    adj[a].push_back(b);
    adj[b].push_back(a);
}
int ans=0;
vector<int>vis(n+1,0);
fo(i,n+1){
if(!vis[i] && adj[i].size()>0){
int count=0;
    dfs(adj,vis,count,i);
ans=max(ans,count);
}
}
cout<<ans;
}

signed main(){


    // std::string binary = std::bitset<8>(n).to_string();
    ios::sync_with_stdio(0);
    cin.tie(0);
  solve();
  


}

Measured memory_bytes: 25092
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N=sc.nextInt();
    int T=sc.nextInt();
    int[] t=new int[N];
    int ans = 0;
    
    for(int i=0;i<N;i++){
      t[i]=sc.nextInt();
    }
 
    for(int j=1;j<N;j++){
      if(T >(t[j] - t[j-1])){
        ans += (t[j] - t[j-1]);
      }else{
        ans += T;
      }
    }
    ans += T;

    System.out.println(ans);
  }
}

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

int main() {
  int N, K, x, i, sum = 0;
  cin >> N >> K;
  
  for(i = 0; i < N; i++){
    cin >> x;
    int A = x * 2;
    int B = (K - x) * 2;
    
    if(A > B){
      sum += B;
    } else{
      sum += A;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

int main () {
  int a,b, ans=0;
  cin >> a >> b;
  for(int i=a; i<=b; i++) {
    char temp[6];
    int j;
    sprintf(temp, "%d", i);
    for(j=0; j<2; j++) {
      if (temp[j] != temp[4-j]) break;
    }
    if (j==2) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>


int main(){
	int awal, akhir, temp;
	scanf("%d", &awal);
	temp = awal;
	//debug
	//printf("%d\n", awal);
	akhir = 0;
	while(awal>0){
		akhir = akhir*10 + awal %10;
		awal = awal/10;
		//printf("%d\n", akhir);
	}
	awal = temp;
	if(akhir == awal){
		puts("Yes");
	}
	else{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <map>
#include <climits>
using namespace std;
#define mod (1000000007)
#define ll long long int


int main(void){
  int A,B;
  char op;
  cin >> A >> op >> B;
  if(op=='+'){
    cout << A+B << endl;
  }else{
    cout << A-B << endl;
  }


}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

void solve() {
	ll n, a, b; cin >> n >> a >> b;
    if(a > b) swap(a, b);
    if((b - a) % 2 == 0) {
        cout << (b - a) / 2 << endl;
    } else {
        cout << min(a - 1 + b - 1 + 1, n - a + n - b + 1) / 2 << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int cnt[26];

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    string s;cin >> s;
    int n = s.size();
    if(n != 26){
        for(auto c : s){
            cnt[c-'a']++;
        }
        cout << s;
        inc(i, 0, 26){
            if(!cnt[i]){
                cout << char('a'+i) << endl;
                return 0;
            }
        }
    }else{
        string t = s;
        if(next_permutation(t.begin(), t.end())){
            inc(i, 0, n){
                if(s[i] != t[i]){
                    cout << t[i] << endl;
                    return 0;
                }else{
                    cout << t[i];
                }
            }
        }else{
            cout << -1 << endl;
        }
    }
    return 0;
}


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

class Node{
public:
    int location;
    int p, l, r;
    Node(){}
};

class Point{
public:
    int id, x, y;
    Point(){}
    Point(int id, int x, int y): id(id), x(x), y(y) {}
    bool operator< ( const Point &p) const {
        return id < p.id;
    }

    void print(){
        printf("%d\n", id); // cout より高速なprintf関数を使用
    }
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1, const Point &p2) { return p1.x < p2.x;}
bool lessY(const Point &p1, const Point &p2) { return p1.y < p2.y;}

int makeKDTree(int l, int r, int depth){
    if( !(l<r) ) return NIL;
    int mid = (l + r) / 2;
    int t = np++;
    if( depth % 2 == 0){
        sort(P + l, P + r, lessX);
//        cout << endl << "lessX = " << lessX << endl;
    }else{
        sort(P + l, P + r, lessY);
//        cout << endl << "lessY = " << lessY << endl;
    }
    T[t].location = mid;
    T[t].l = makeKDTree(l, mid, depth+1);
    T[t].r = makeKDTree(mid + 1, r, depth + 1);

    return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans){
    int x = P[T[v].location].x;
    int y = P[T[v].location].y;

    if(sx <= x && x <= tx && sy <= y && y <= ty){
        ans.push_back(P[T[v].location]);
    }

    if(depth % 2 == 0){
        if(T[v].l != NIL){
            if(sx <= x) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
        }
        if(T[v].r != NIL){
            if(x <= tx) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
        }
    }else{
        if(T[v].l != NIL){
            if(sy <= y) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
        }
        if(T[v].r != NIL){
            if(y <= ty) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
        }
    }
}

int main(){
    int x, y;
    scanf("%d", &N);
    for( int i=0; i<N; i++){
        scanf("%d %d", &x, &y); //cinより高速なscanf関数を使用
        P[i] = Point(i, x, y);
        T[i].l = T[i].r = T[i].p = NIL;
    }

    np = 0;

    int root = makeKDTree(0, N, 0);

    int q;
    scanf("%d", &q);
    int sx, tx, sy, ty;
    vector<Point> ans;
    for(int i=0; i<q; i++){
        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
        ans.clear();
        find(root, sx, tx, sy, ty, 0, ans);
        sort(ans.begin(), ans.end());
        for(int j=0; j<ans.size(); j++){
            ans[j].print();
        }
        printf("\n");
    }

    return 0;
}


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

typedef long long int ll;
#define    mod      1000000007
#define    speed    ios_base::sync_with_stdio(false);
#define    up       cin.tie(NULL);
#define    pb       push_back
#define    mp       make_pair
#define    T        int t; cin >> t; while(t--)

int main(){
  speed up
  int r , d, x;
  cin >> r >> d >> x;
  for(int i = 1; i <= 10; i++){
      x = r*x - d;
      cout << x << '\n';
  }
}

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



int main(){
    string S, T; cin >> S >> T;
    ll N = S.size();
    for(int i = 0; i < N; i++){
        if(S[i] != T[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl; 

}


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

using namespace std;

const int MAX = 113;

/*
 * Maximum Bipartite Matching ( O( |V|*|E| ) )
 */
int szV, szC;
int L[ MAX ], R[ MAX ];
vector< int > G[ MAX ];
bool seen[ MAX ];
bool findMatch( int v ) {
  if( seen[ v ] ) return false;
  seen[ v ] = true;
  for( int i = 0; i < int( G[ v ].size( ) ); i++ ) {
    int u = G[ v ][ i ];
    if( R[ u ] == -1 || findMatch( R[ u ] ) ) {
      L[ v ] = u;
      R[ u ] = v;
      return true;
    }
  }
  return false;
}
int maxBipartiteMatching( ) {
  int ans = 0;
  bool found = false;
  memset( L, -1, sizeof( L ) );
  memset( R, -1, sizeof( R ) );
  do {
    found = false;
    memset( seen, false, sizeof( seen ) );
    for( int i = 0; i < szV; i++ ) {
      if( L[ i ] == -1 && !seen[ i ] ) {
        if( findMatch( i ) ) {
          ans++;
          found = true;
        }
      }
    }
  } while( found );
  return ans;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  #ifdef Larra
  freopen("in","r",stdin);
  freopen("out","w",stdout);
  #endif
  int n1, n2,  m;
  cin>>szV>>szC>>m;
  for(int i = 0; i < m; i++){
      int u,v;
      cin>>u>>v;
      G[u].push_back(v);
  }
  cout<<maxBipartiteMatching()<<"\n";
}

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

using namespace std;

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

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

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

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

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

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, X, Y, x, y;
	cin>>n>>m>>X>>Y;
	int m1=-100, m2=100;
	REP(i, n){
		cin>>x;
		m1=max(m1, x);
	}
	REP(i, m){
		cin>>y;
		m2=min(m2, y);
	}
	FOR(i, X+1, Y+1){
		if(m1<i && m2>=i){
			cout<<"No"<<' ';
			break;
		}
	}
	cout<<"War"<<'\n';
	return 0;
}


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

using namespace std;

struct CONTEST_DATA{
	int judgements;
	vector< int > points;
};

int main( void ){

	vector< CONTEST_DATA > contests;
	vector< int > answers;

	while( true ){
		CONTEST_DATA cd;
		cin >> cd.judgements;
		if( cd.judgements == 0 ){
			break;
		}
		int point;
		for( int i = 0; i < cd.judgements; i++ ){
			cin >> point;
			cd.points.push_back( point );
		}
		contests.push_back( cd );
	}

	for( int i = 0; i < contests.size(); ++i ){
		sort( contests[ i ].points.begin(), contests[ i ].points.end() );
	}
	for( int i = 0; i < contests.size(); ++i ){
		vector< int >::iterator p = contests[i].points.begin();
		contests[ i ].points.erase( p );
		p = contests[ i ].points.end() - 1;
		contests[ i ].points.erase( p );
	}

	for( int i = 0; i < contests.size(); ++i ){
		int answer = 0;
		for( int l = 0; l < contests[ i ].points.size(); ++l ){
			answer += contests[ i ].points[ l ];
		}
		cout << answer / ( contests[ i ].judgements - 2 )<< endl;
	}

	return 0;
}

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

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

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

  int N;
  vector<int> len(3);
  int ans = INF;
  vector<pair<int, int>> now(4, pair<int, int>(0, 0));
  void dfs(int depth, vector<int> &l){
    if(N > depth){
      for(int i = 0; i < 4; i++){
        now[i].first += l[depth];
        now[i].second += 1;
        dfs(depth + 1, l);
        now[i].first -= l[depth];
        now[i].second -= 1; 
      }
      }else{
        int tmp = 0;
        for(int i = 0; i < 3; i++){
          if(now[i].second == 0) return;
          tmp += abs(len[i]- now[i].first) + 10 * (now[i].second - 1);
        }
        ans = min(ans, tmp);
      }
    }


  int main(){
    cin >> N;
    REP(i, 3) cin >> len[i];
    vector<int>l(N);
    REP(i, N) cin >> l[i];
    dfs(0, l);
    print(ans);
  }


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

using namespace std;

int kisu(int k){
    if(k%2==0){
        return 0;
    }else{
        return 1;
    }    
    
}
int main(){
    
int a,b,c,check;

check=0;

cin>>a>>b;


for(c=1;c<3;c++){
    int k=a*b*c;
    if(kisu(k)==1){
        cout<<"Yes";
        check=1;
        break;
    }
 //   cout<<c<<endl;

}

if(check==0){
cout<<"No"<<endl;
}
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

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


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

int main(){
    int cnt = 700;
    string S;
    cin >> S;
    if (S[0]=='o') cnt += 100;
    if (S[1]=='o') cnt += 100;
    if (S[2]=='o') cnt += 100;
    
    cout << cnt << endl;
    return 0;
}


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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int main(){
  int N,M;
  cin>>N>>M;
  vector<int> A(M);
  for(int i(0);i<M;i++) cin>>A[i];
  int sum(0);
  for(int i(0);i<M;i++){
    sum += A[i];
  }
  if(N < sum) cout << -1 << endl;
  else cout << N - sum << endl;
  return 0;
}



Measured memory_bytes: 3664
import itertools
n=int(input())
p_tuple=tuple(map(int,input().split()))
q_tuple=tuple(map(int,input().split()))
sort_list=list(range(1,n+1))
all_list=list(itertools.permutations(sort_list, n))
p_index=all_list.index(p_tuple)
q_index=all_list.index(q_tuple)
print(abs(p_index-q_index))


Measured memory_bytes: 8052
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int N = 100005;
int n,m;
int fa[N];

int getfa(int x)
{
    if(x==fa[x])
        return x;
    return fa[x] = getfa(fa[x]);
}

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; ++i)
        fa[i] = i;
    for(int i = 1; i <= m; ++i){
        int u,v;
        cin >> u >> v;
        int fu = getfa(u);
        int fv = getfa(v);
        fa[fu] = fv;
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i){
        if(fa[i]==i)
            ++ans;
    }
    cout << ans - 1 << endl;
}


Measured memory_bytes: 4012
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<ll> L(N),R(N);
    for(int i=0;i<N;i++) cin >> L[i] >> R[i];
    sort(L.begin(),L.end(),greater<ll>());
    sort(R.begin(),R.end());
    ll ans = 0,now1 = 0,now2 = 0;
    for(int i=0;i<N;i++){
        now1 += 2*L[i];
        now2 -= 2*R[i];
        ans = max({ans,now1,now2});
        now1 -= 2*R[i];
        now2 += 2*L[i];
        ans = max({ans,now1,now2});
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	string s;
	cin >> s;

	int n = s.size();
	bool ok = true;
	int c = 0, lower = 0;
	rep(i, n) {
		if (islower(s[i]))
			lower++;
		if (!i && s[i] != 'A')
			ok = false;
		else if (s[i] == 'C' && i >= 2 && i < n - 1)
			c++;
	}
	if (c != 1 || lower != n - 2)
		ok = false;
	if (ok) cout << "AC" << endl;
	else cout << "WA" << endl;
}

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

	solve();
}


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

int main(){
  string s;
  cin >> s;
  int a, b;
  a = atoi(s.substr(0,2).c_str());
  b = atoi(s.substr(2,2).c_str());
  
  if(a > 0 && a <= 12){
    if(b > 0 && b <= 12)cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  }else{
    if(b > 0 && b <= 12)cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define sort(a,b) sort(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
 
int main() {
  ll a;
  ci(a);
  ll b=0;
  for(i,1,6){
    if(a/pow(10,i)<10){
      b=i;
      break;
    }
  }
  //co(b);
  ll c=0;
  if(b==1&&a<10)
    for(i,1,a+1)
      c++;
  else if(b==1)
    c=9;
  else if(b==2){
    for(i,100,a+1)
      c++;
    c+=9;
  }
  else if(b==3)
    c=909;
  else if(b==4){
    for(i,10000,a+1)
      c++;
    c+=909;
  }
  if(a==pow(10,5))
    c=90909;
  co(c);
}

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

int lcs(string x, string y) {
  int m = x.size();
  int n = y.size();
  int maxl = 0;
  x = ' ' + x;
  y = ' ' + y;
  vector<vector<int>> c(m+1, vector<int> (n+1));

  for (int i = 1; i <= m; i ++) {
    for (int j = 1; j <= n; j ++) {
      if (x[i] == y[j]) {
        c[i][j] = c[i-1][j-1] + 1;
      } else {
        c[i][j] = max(c[i-1][j], c[i][j-1]);
      }
      maxl = max(maxl, c[i][j]);
    }
  }

  return maxl;
}

int main() {
  int n; cin >> n;
  string s1, s2;
  for (int i = 0; i < n; i ++) {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
}



Measured memory_bytes: 6776
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define PI 3.1415926535897932384
using namespace std;

const int N=1000001;
vector<int> g[N];
int vis[N], dist[N], parent[N];
queue<int> q;

void bfs(int node){
	vis[node]=1;
	dist[node]=0;
	q.push(node);
	while(!q.empty()){
		int v=q.front();
		q.pop();
		for(int child:g[v]){
			if(vis[child]==0){
				vis[child]=1;
				q.push(child);
				dist[child]=dist[v]+1;
				parent[child]=v;
			}
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m,a,b;
	cin>>n>>m;
	for(int i=1;i<=n;i++) vis[i]=0, dist[i]=-1;
	while(m--)
		cin>>a>>b, g[a].push_back(b), g[b].push_back(a);
	bfs(1);
	for(int i=1;i<=n;i++){
		if(dist[i]==-1){
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
	for(int i=2;i<=n;i++) cout<<parent[i]<<endl;
	return 0;
}


Measured memory_bytes: 32508
Imports System

Module Program
    Sub Main(args As String())
        Dim sInput As String() = Console.ReadLine().Split(" ")
        If sInput(0) = "0" Then
            Console.WriteLine("1")
        ElseIf sInput(1) = "0" Then
            Console.WriteLine("2")
        ElseIf sInput(2) = "0" Then
            Console.WriteLine("3")
        ElseIf sInput(3) = "0" Then
            Console.WriteLine("4")
        Else
            Console.WriteLine("5")
        End If

    End Sub
End Module


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


int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i< N; i++) {
    cin >> L.at(i);
  }
  sort(L.begin(), L.end());
  int sum = 0;
  for (int i = 0; i < N - 1;i++) {
    sum += L.at(i);
  }
  if (sum > L.at(N - 1)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

typedef long long ll;
int main() {
  ll n;
  while(cin>>n,n) {
    ll c = 0;
    while(n != 1) {
      if (n%2) {
        n = n*3+1;
      } else {
        n = n/2;
      }
      c++;
    }
    cout << c << endl;
  }
}

Measured memory_bytes: 0