akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            string[] str = Console.ReadLine().Split(' ');
            int k = int.Parse(str[0]);
            int x = int.Parse(str[1]);

            if(500*k >= x)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            //ここまで
        }
    }
}


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

using namespace std;

int main(){
    int a,b,k;
    vector<int> vec(0);
    cin >> a >> b >> k;
    for(int i = 1;i <= min(a,b);i++){
        if(a%i == 0 && b%i == 0)vec.push_back(i);
    }
    sort(vec.begin(),vec.end(),greater<int>());
    cout << vec[k-1];
    return 0;
}

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

int main(){
    int k, a, b;
    cin >> k >> a >> b;
    int i, j;
    bool flg = false;
    for(i = 1; i < 1000; i++){
        if(k*i >= a && k*i <= b){
            flg = true;
            break;
        }
    }
    if(flg){
        cout << "OK" << endl;
    }
    else{
        cout << "NG" << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
input = STDIN.read.split("\n").map{|l| l.split(" ").map{|a| a.to_i}}

A = input[1][0]
B = input[1][1]
points = input[2]

e1 = 0
e2 = 0
e3 = 0

points.each{ |point|
    if point <= A
        e1 = e1 + 1
    elsif point > A && point <= B
        e2 = e2 + 1
    else
        e3 = e3 + 1
    end
}

puts [e1, e2, e3].min

Measured memory_bytes: 3836
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int N;
	cin >> N;
	int num = 1;
	rep(i, N) {
		int input;
		cin >> input;
		if (input % 2 == 0)num *= 2;
	}
	int ans = pow(3, N) - num;
	cout << ans;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> h(N);
	for(int i=0; i<N; ++i) cin >> h[i];
	bool flag=1;
	int now=0;
	for(int i=0; i<N; ++i){
	    if(now<h[i]) now=h[i]-1;
	    else if(now>h[i]){
	        flag=0;
	        break;
	    }
	}
	cout << (flag ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans, cnt;

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

	ll N,M;
	cin >> N >> M;

	vector<ll> H(N), A(M), B(M);

	map<ll, vector<ll>> m; // index,繋がってるもの

	rep(i, N) {
		cin >> H[i];
	}
	rep(i, M) {
		cin >> A[i] >> B[i];
		m[A[i]-1].push_back(B[i]-1);
		m[B[i]-1].push_back(A[i]-1);
	}
	
	rep(i, N) {
		if (m.count(i)) {
			ll h = H[i];
			rep(j, m[i].size()) {
				if (H[m[i][j]] >= h) {
					break;
				}
				if (j == m[i].size() - 1) ans++;
			}
		}
		else {
			ans++;
		}
	}


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

Measured memory_bytes: 15844
#選択ソート
number=eval(input())
swap=0
arr=list(map(int, input().split(' ')))
for i in range(number-1):
    minI=arr.index(min(arr[i:]),i)
    if i!=minI:
        arr[i],arr[minI]=arr[minI],arr[i]
        swap+=1
print(' '.join(map(str, arr)))
print(swap)


Measured memory_bytes: 5600
#pragma GCC optimize ("O2")
//#pragma GCC target("avx2")
#include "bits/stdc++.h"
	
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
// Use for file I/O;
#define FIN string _fname = "convention2"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);
const char nl = '\n';

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
 
using namespace std;
 
const ll inf = 1e9;
const ll inf2 = 1e18 + 10;
const int mod = 1e9 + 7;
const ld eps = 1e-4;
 
const int logn = 19;
const int maxn = 2e5 + 5, maxm = 1e6;

const int k = 26;
struct node {
	node *to[k];
	bool term = 0;
};
node* root = new node();


void add_string(string& s) {
	auto v = root;
	for (char c : s) {
		int d = c - 'a';
		if (!v->to[d]) v->to[d] = new node();
		v = v->to[d];
	}
	v->term = true;
}

ll ans;
int cnt[26];
vector<int> q[26];
int t = 0;
void traverse(node * v) {
	if (!v) return;
	else {
		if (v->term) {
			for (int i = 0; i < 26; i++) {
				int lb = 0, ub = q[i].size() - 1, ct = 0;
				while(lb <= ub) {
					int tm = (lb + ub) / 2;
					if (q[i][tm] < cnt[i]) {
						ct = tm + 1;
						lb = tm + 1;
					} else {
						ub = tm - 1;
					}
				}
				ans += ct;
			}
		}

		for (int i = 0; i < 26; i++) {
			if (v->to[i] && v->to[i]->term) q[i].push_back(cnt[i]);
		}

		for (int i = 0; i < 26; i++) {
			if (v->to[i]) {
				cnt[i]++;
				t++;
				traverse(v->to[i]);
				t--;
				cnt[i]--;
			}
		}

		for (int i = 0; i < 26; i++) {
			if (v->to[i] && v->to[i]->term) q[i].pop_back();
		}
	}
}

int main() {
	FAST;

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		reverse(s.begin(), s.end());
		add_string(s);
	}
	traverse(root);
	cout << ans - n;
}


Measured memory_bytes: 280332
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;

int d[1000100];
char fi[1000100];

int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h,w,k; cin >> h >> w >> k;
    int x,y,xx,yy; cin >> x >> y >> xx >> yy;
    x--; y--; xx--; yy--;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> fi[i*w+j];
            d[i*w+j]=1e9;
        }
    }
    d[x*w+y]=0;
    queue<pair<int,int>> q;
    q.push(make_pair(x,y));
    while(q.size()){
        auto p=q.front(); q.pop();
        int sx=p.first,sy=p.second;
        for(int i=sx+1;i<h&&i<=sx+k;i++){
            if(fi[i*w+sy]!='.')break;
            if(d[i*w+sy]<=d[sx*w+sy])break;
            if(d[i*w+sy]>d[sx*w+sy]+1){
                d[i*w+sy]=d[sx*w+sy]+1;
                q.push(make_pair(i,sy));
            }
        }
        for(int i=sx-1;i>=0&&i>=sx-k;i--){
            if(fi[i*w+sy]!='.')break;
            if(d[i*w+sy]<=d[sx*w+sy])break;
            if(d[i*w+sy]>d[sx*w+sy]+1){
                d[i*w+sy]=d[sx*w+sy]+1;
                q.push(make_pair(i,sy));
            }
        }
        for(int i=sy+1;i<w&&i<=sy+k;i++){
            if(fi[sx*w+i]!='.')break;
            if(d[sx*w+sy]>=d[sx*w+i])break;
            if(d[sx*w+sy]+1<d[sx*w+i]){
                d[sx*w+i]=d[sx*w+sy]+1;
                q.push(make_pair(sx,i));
            }
        }
        for(int i=sy-1;i>=0&&i>=sy-k;i--){
            if(fi[sx*w+i]!='.')break;
            if(d[sx*w+sy]>=d[sx*w+i])break;
            if(d[sx*w+sy]+1<d[sx*w+i]){
                d[sx*w+i]=d[sx*w+sy]+1;
                q.push(make_pair(sx,i));
            }
        }
    }
    if(d[xx*w+yy]==1e9){
        printf("-1\n");
    }
    else{
        printf("%d\n",d[xx*w+yy]);
    }
}


Measured memory_bytes: 9044
#include <stdio.h>
int main(void){
    int N,D,ans;
    scanf("%d %d",&N,&D);
    if(N % (2*D+1) ==0)ans=N / (2*D+1);
    else ans =N / (2*D+1) + 1;
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())
#define mp make_pair

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
//typedef pair<int, pair<int, int> > PP;
const int MAX=1e5+10;



int main(){
	int N;
	cin>>N;
	int a[MAX];
	rep1(i,N)cin>>a[i];
	
	
	ll ans[MAX];
	rep1(i,N)ans[i]=0;
	
	priority_queue<P> q;
	rep1(i,N)q.push(mp(a[i], -i));
	q.push(mp(0,0));
	 
	P tp=q.top();
	int ni=(-1)*(tp.second);
	int tmp=tp.first;
	ll rm=tp.first;
	int nm=1;
	
	q.pop();
	while(!q.empty()){
	 	P p=q.top();
	 	q.pop();
	 	if(p.first==tmp || (-1)*p.second>ni){
		 	rm+=(ll)p.first;
		 	nm++;
		}
	 	else{
	 		ans[ni]=rm-(ll)p.first*nm;
	 		tmp=p.first;
	 		ni=(-1)*(p.second);
          	nm++;
	 		rm=(ll)nm*p.first;
	 	}
	}
	rep1(i,N)cout<<ans[i]<<endl;
}

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

typedef long long int ll;

int main()
{
    ll n, r;
    cin >> n >> r;

    if(n >= 10){
        cout << r;
    }
    else{
        cout << r + 100 *(10 - n);
    }
    
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
  line := nextLine()
  str := strings.Split(line, " ")
  num := str[0]
  col := str[1]
  numCol, _ := strconv.Atoi(col)
  numBall, _ := strconv.Atoi(num)
  a := numCol

  for i := numBall; i > 1; i-- {
    a *= numCol - 1
  }

  fmt.Println(a)
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll power(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)

//your code here!

int main(void){
    ll N;
    scanf("%lld", &N);
    printf("ABC%lld\n", N);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

struct CountUnionFind{
    int sz;     // vertex number
    vector<int> par;
    vector<int> rank;
    vector<int> cnt;

    CountUnionFind(int n) : sz(n) {
        par.resize(sz);
        rank.assign(sz, 0);
        cnt.assign(sz, 1);
        for(int i = 0; i < sz; ++i){
            par[i] = i;
        }
    }

    int find(int x){
        if(par[x] == x) return x;
        else    return par[x] = find(par[x]);
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    void unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y)  return;
        if(rank[x] < rank[y]){
            par[x] = y;
            cnt[y] += cnt[x];
        }
        else{
            par[y] = x;
            cnt[x] += cnt[y];
            if(rank[x] == rank[y])  ++rank[x];
        }
    }

    int get_cnt(int x){
        return cnt[find(x)];
    }
};

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

    int N, M;
    cin >> N >> M;
    CountUnionFind uf(N);
    for(int i = 0; i < M; ++i){
        int A, B;
        cin >> A >> B;
        --A, --B;
        uf.unite(A, B);
    }
    int cnt = 0;
    for(int i = 0; i < N; ++i)  chmax(cnt, uf.get_cnt(i));
    cout << cnt << endl;
}

Measured memory_bytes: 5568
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<=(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double Pi = acos(-1);
const ll mod=1e9+7;

int main(){
    int x,n;
    cin >>x>>n;
    int ans=x;
    if(n>0){
        
    int p[n];
        rep(i,n) cin >>p[i];
        sort(p,p+n);
    
    int min=1000;
    int count=0;
    rep(i,102){
        if(abs(x-i)<min && p[count]!=i){
            min=abs(x-i);
            ans=i;
        }
        if(p[count]==i && count<n-1) count++;
    }
    }
    
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3600
n, m = map(int, input().split())


arr = [0] * m

for i in range(n):
    tmp = list(map(int, input().split()))
    k = tmp[0]
    a = tmp[1:k+1]

    for j in range(len(a)):
        arr[a[j]-1] += 1

        
count = 0
for i in range(len(arr)):
    if arr[i] == n:
        count += 1

print(count)


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

int main() {
    int n, d;
    cin>>n>>d;
    int p, q;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        cin>>p>>q;
        int dist = (int) ceil(sqrt(pow(p,2) + pow(q,2)));
        if (dist <= d) ans++;
    }

    cout<<ans<<endl;
}

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

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.14159265358979323846264338327950288419

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

using namespace std;

int n, s[100005];
LL ans;

int main(){
	scanf("%d", &n);
	FI(i, 1, n){
		scanf("%d", &s[i]);
		if(s[i] > 0 && s[i - 1] > 0){
			s[i]--, s[i - 1]--;
			ans++;
		}
		ans += s[i] / 2;
		s[i] %= 2;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

#define MAX_S 101
#define MAX_CH 100

int main(){

  int S[MAX_S];
  int top=0;
  char ch[6];
  int sum;

  while(scanf("%s",ch) != EOF){
    if(ch[0] == '+'){
      S[top-1] += S[top]; 
      top--;
    }
    else if(ch[0] == '-'){
      S[top-1] -= S[top]; 
      top--;
    }
    else if(ch[0] == '*'){
      S[top-1] *= S[top]; 
      top--;
    }
    else if(ch[0] == '*'){
      S[top-1] *= S[top]; 
      top--;
    }
    else{
      top++;
      S[top] = atoi(ch);
    }
  }

  printf("%d\n",S[1]);

  return 0;
}

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

using namespace std;

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

    int x, r = 0;
    string s;
    cin >> x >> s;
    for(int i = 0; i < x - 2; i++){
        if(s.substr(i,3) == "ABC"){
            r += 1;
        }
    }
    cout << r << endl;    
}

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

using namespace std;

const int N=200005;
int n,p[N],a,v;

int main(){
	scanf("%d",&n);
	for(int i=1,x;i<=n;i++)scanf("%d",&x),p[x]=i;
	for(int i=n-1;i;i--)if(a&&(p[v]<p[i+1])+(p[i+1]<p[i])+(p[i]<p[v])==2||!a&&p[i]>p[i+1])a++,v=i+1;
	printf("%d\n",a);
	return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = l[0], b = l[1], c = l[2];

            if (a + b == c || a + c == b || b + c == a)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13268
# https://ikatakos.com/pot/programming_algorithm/dynamic_programming/inversion から
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
from itertools import accumulate

def bsearch(target, min_i, max_i, func):
    # func(index) <= target < func(index+1) となるindexを返す
    if func(max_i) <= target:
        return max_i
    if target < func(min_i):
        return None
    index = (max_i + min_i)//2
    while True:
        if max_i - min_i <= 1:
            return min_i
        if func(index) <= target:
            index, min_i = (index + max_i)//2, index
            continue
        index, max_i = (index + min_i)//2, index

N, = map(int, input().split())
As = list(map(int, input().split()))
mna, mxa = min(As), max(As)

def tento(xs):
    bit = Bit(max(xs)+1)
    ans = 0
    for i, p in enumerate(xs):
        ans += bit.sum(p)
        bit.add(p, 1)
        #print(p, ans)
    #print(xs, ans)
    return ans

def f(x):
    Bs = [0] + list(accumulate(map(lambda a: 1 if a>=x else -1, As)))
    mn = min(Bs)
    Bs = list(map(lambda x : x - mn + 1, Bs))
    return -tento(Bs)

M = (N*(N+1))//2
print(bsearch((-M//2) , mna, mxa, f))


Measured memory_bytes: 118472
import math
N,K = [int(x) for x in input().split()]
p = 0
for x in range(N):
    k = K/(x+1)
    if x < K:
        k_log = math.ceil(math.log2(k))
    else:
        k_log = 0
    p += 1/N/pow(2,k_log)

print(p)

Measured memory_bytes: 2940
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int main(){
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<=n;i++)
		for(int j=0;j<=m;j++)
			if(i*m-j*i+j*(n-i)==k)
				return puts("Yes")*0;
	puts("No");			
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<limits>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0;i < (n); ++i)

int main() {
	char a;
	cin >> a;
	if (a == 'a' || a == 'b' || a == 'c' || a == 'd' || a == 'e' || a == 'f' || a == 'g' || a == 'h' || a == 'i' || a == 'j' || a == 'k' || a == 'l' || a == 'm' || a == 'n' || a == 'o' || a == 'p' || a == 'q' || a == 'r' || a == 's' || a == 't' || a == 'u' || a == 'v' || a == 'w' || a == 'x' || a == 'y' || a == 'z') {
		cout << 'a' << endl;
	}
	else cout << 'A' << endl;

	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

int p, n[6], c[6] = {1, 5, 10, 50, 100, 500};
int data[500001];

int calc(int t, bool o){
  int res = 0;
  for(int i=5;i>=0;i--){
    int tmp = t / c[i];
    if(o) tmp = min(tmp, n[i]);
    t -= tmp * c[i];
    res += tmp;
  }
  return res;
}

main(){
  for(int i=0;i<=500000;i++) data[i] = calc(i, false);
  while(scanf("%d", &p) && p){
    int lim = 0;
    for(int i=0;i<6;i++){
      scanf("%d", &n[i]);
      lim += n[i] * c[i];
    }
    int ans = 1000000;
    for(int i=p;i<=lim;i++){
      int tmp;
      if(tmp = calc(i, true)){
        ans = min(ans, tmp + data[i-p]);
      }
    }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 2832
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define End return 0;
int main ()
{
   int a,b,c;
   cin>>a>>b>>c;
   if(a==b && a!=c && b!=c){
    cout<<"Yes"<<endl;
   }
   else if(a==c && a!=b && b!=c){
    cout<<"Yes"<<endl;
   }
    else if(b==c && a!=b && a!=c){
    cout<<"Yes"<<endl;
   }
   else
   {
       cout<<"No"<<endl;
   }
    End;
}
/* pray for me
All is well
*/





Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	int n, k, ans = 1;
	cin >> n >> k;
	rep(i, n) {
		if (ans <= k) ans *= 2;
		else ans += k;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string N;
  cin >> N;
  string result = "No";
  if('7' == N[0]) result = "Yes";
  if('7' == N[1]) result = "Yes";
  if('7' == N[2]) result = "Yes";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		//ArrayListだとTLE
		int[] a = new int[n];

		if (n % 2 == 0) {
			int l = n / 2 - 1;
			int r = n / 2;
			for (int i = 0; i < n / 2; i++) {
				a[r] = Integer.parseInt(sc.next());
				a[l] = Integer.parseInt(sc.next());
				r++;
				l--;
			}
		} else {
			int l = n / 2 - 1;
			int r = n / 2 + 1;
			a[n / 2] = Integer.parseInt(sc.next());
			for (int i = 0; i < n / 2; i++) {
				a[r] = Integer.parseInt(sc.next());
				a[l] = Integer.parseInt(sc.next());
				r++;
				l--;
			}
		}

		for (int i = 0; i < n; i++) {
			System.out.print(a[i]);
			if (i != n - 1) {
				System.out.print(" ");
			}
		}
		sc.close();

	}

}

Measured memory_bytes: 64872
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b

# https://atcoder.jp/contests/abc173/tasks/abc173_d
# 大きい方から使いそう


N = a_int()
A = ints()
A.sort(reverse=True)
ans = A[0]
cnt = 1
for a in A[1:]:
    if cnt == N - 1:
        break
    ans += a
    cnt += 1
    if cnt == N - 1:
        break
    ans += a
    cnt += 1

print(ans)


Measured memory_bytes: 102180
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}




int main(){
  long long A,B,C;
  cin>>A>>B>>C;
  int jotai=0;
  long long sum=0;
  while(true){
    if(jotai==0){
      if(C>0){
      C--;
      sum++;
      jotai=-1;}
      else{
        break;
      }

    }else{
      if(B>0){
        B--;
        sum++;
        jotai=0;
      }else if(A>0){
        A--;
        jotai=0;
      }else{
        break;
      }
    }
  }
  sum+=B;
  cout<<sum<<endl;

  
  


  

  



}


  
  


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;
string s;

int main(void){
  
  ll H, W;
  IN(H);
  IN(W);
  vector<string> grid(H);
  REP(i, H) {
    IN(grid[i]);
  }
  ll table[H][W];
  REP(h, H) {
    REP(w, W) {
      if (grid[h][w] == '#') {
        table[h][w] = 0;
        continue;
      } else {
        ll path = 0;
        if (h > 0) path += table[h-1][w];
        if (w > 0) path += table[h][w-1];
        if (h == 0 && w == 0) path += 1;
        table[h][w] = path % MOD;
      }
    }
  }
  PRINT(table[H-1][W-1]);


}


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

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

    int res = 0;
    for(int a : A) {
        B[a] -= 1;

        bool ok = true;
        for(int i=1; i*i<=a; ++i) {
            if(a % i) continue;

            int x = i, y = a / i;
            if(B[x] || B[y]) ok = false;
        }
        if(ok) ++res;

        B[a] += 1;
    }
    cout << res << '\n';
}

Measured memory_bytes: 32520
N = 100

def mode_value(arr)
  n = 0
  mv = []
  
  N.times do |i|
    if n < arr[i]
      mv = [i + 1]
      n = arr[i]
    elsif n == arr[i]
      mv << i + 1
    end
  end
  
  return mv
end

arr = Array.new(N, 0)


while line = gets
  arr[line.to_i - 1] += 1
end

mode_value(arr).each do |v|
  puts v
end

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

const int maxn = 1e5 + 6;

int f[maxn];
vector<int> E[maxn];

void dfs(int x,int pi) {
	f[x] = 0;
	for (int i = 0; i < E[x].size(); i++) {
		int z = E[x][i];
		if (z == pi) continue;
		dfs(z,x);
		f[x] ^= 1 + f[z];
	}
}

int main() {
	int n;
	scanf("%d",&n);
	for (int i = 1; i < n; i++) {
		int x,y; scanf("%d %d",&x,&y);
		E[x].push_back(y);
		E[y].push_back(x);
	}
	dfs(1,-1);
	printf(f[1]==0 ? "Bob\n" : "Alice\n");
}



Measured memory_bytes: 13952
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define INF (1100000099)
#define INFLL (1100000000000000099ll)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef long double ld;

ll N, M, Ans;

int main() {
    scanf("%lld%lld", &N, &M);
    Ans = min(N, M/2); N -= Ans; M -= Ans*2;
    Ans += M/4;
    printf("%lld\n", Ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int conv(char r)
{
	if(r=='I') return 1;
	if(r=='V') return 5;
	if(r=='X') return 10;
	if(r=='L') return 50;
	if(r=='C') return 100;
	if(r=='D') return 500;
	if(r=='M') return 1000;
	else return 0;
}

int main()
{
	string in;
	while(cin>>in)
	{
		int ans=0;
		for(int i = 1; i < in.size(); ++i)
		{
			int right=conv(in[i]);
			int left=conv(in[i-1]);
			if(!right||!left) continue;
			if(left<right)
			{
				ans+=right-left;
				in[i]=in[i-1]='0';
			}
		}
		for(int i = 0; i < in.size(); ++i)
		{
			ans+=conv(in[i]);
		}
		cout<<ans<<endl;
	}
  return 0;
}

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

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

const int MOD = 1e+9 + 7;

// 箱根駅伝 dp ? {1, 2, ...} と順列を結ぶと考えると、その交点の個数が答え
// dp[i][j][k]: i 番目まで見たとき、まだ結んでいない数が j 個で
//              奇妙さが k の順列の個数
long long dp[55][55][2505] = {};


int main()
{
    int n, k;
    cin >> n >> k;
    
    dp[0][0][0] = 1;
    REP(i, n){
        REP(j, i+1){
            REP(l, k+1){
                // i 番目同士を結ぶ場合
                dp[i+1][j][l+2*j] += dp[i][j][l] % MOD;
                // i 番目の片方のみを結ぶ場合
                dp[i+1][j][l+2*j] += 2*j * dp[i][j][l] % MOD;
                // i 番目をどちらもそれより前のものと結ぶ場合
                if(j >= 1){
                    dp[i+1][j-1][l+2*(j-1)] += j*j * dp[i][j][l] % MOD;
                }
                // i 番目のどちらも結ばない場合
                dp[i+1][j+1][l+2*(j+1)] += dp[i][j][l] % MOD;
            }
        }
    }
    cout << dp[n][0][k] % MOD << endl;
    
    return 0;
}

Measured memory_bytes: 53504
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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 main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll k;
  cin >> k;
  vector<ll> ans(50, 49+k/50);
  rep(i, 50) {
    if (i < k%50)
      ans[i] += 50-(k%50-1);
    else
      ans[i] -= k%50;
  }
  cout << 50 << endl;
  rep(i, 50)
    printf("%lld%c", ans[i], i==49?'\n':' ');
  return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    a, v = map(int, input().split())
    b, w = map(int, input().split())
    t = int(input())
    dist = abs(a - b)
    speed = v - w
    if speed <= 0:
        print("NO")
    elif speed * t >= dist:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int a, b, t;
    cin >> a >> b >> t;
    int sum = 0;
    for (int i = 1; i <= t; i++)
    {
        if (i % a == 0)
            sum += b;
    }
    cout << sum << endl;
}


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

int main(){
	char a,b,res;
	cin>>a>>b;
	if(a=='H'){
		if(b=='H')res='H';
		else res='D';
	}
	else{
		if(b=='H')res='D';
		else res='H';
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<pii>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;

int main() {
    int N;
    cin >> N;
    printf("%.10lf\n", (N % 2 ? (double)(N / 2 + 1) / N : 0.5));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int a[3];

void init() {

}

void input() {
  cin >> a[0] >> a[1] >> a[2];
}

void solve() {
  sort(a, a+3);
  cout << a[0]*a[1]/2 << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <functional>
#include <list>
#include <bitset>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>

#define INF 1e9
#define MOD 1000000007
#define ll long long
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
typedef unsigned long long ull;
typedef pair<int, int> pr;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a[4];
    cin>>a[0]>>a[1]>>a[2]>>a[3];
    sort(a,a+4);
    if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9){cout<<"YES";}
    else{cout<<"NO";}
    return 0;
}

Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Chars;
use std::cmp::max;

fn main()
{
    input! {
    n:i32,
    mut k:i32,
    s:Chars
    }

    let mut ans = 0;
    let mut last = 0;
    let mut index = 0;
    while index < n {
        if s[index as usize] == '0'
        {
            k -= 1;
            while index + 1 < n && s[index as usize] == '0' {
                index += 1;
            }

            if k < 0 {
                loop {
                    last += 1;
                    if s[last as usize] == '1' && s[(last - 1) as usize] == '0' {
                        break;
                    }
                }
                k += 1;
            }
        }
        ans = max(ans, index - last + 1);
        index += 1;
    }

    println!("{}", ans);
}

Measured memory_bytes: 2520
word=input()
if 'hi' == word:
    print('Yes')
elif 'hihi' == word:
    print('Yes')
elif 'hihihi' == word:
    print('Yes')
elif 'hihihihi' == word:
    print('Yes')
elif 'hihihihihi' == word:
    print('Yes')
else:
    print('No')

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

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

  if( a < b ) cout<<"a < b"<<endl;
  if( a > b ) cout<<"a > b"<<endl;
  if( a == b ) cout<<"a == b"<<endl;

  return 0;
}

		
	      

  



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
  IOS;
  int d,t,s;
  cin>>d>>t>>s;

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

Measured memory_bytes: 3644
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn pow_mod(base: i64, power: i64, modulo: i64) -> i64 {
    let mut base = base;
    let mut power = power;
    let mut ans = 1;
    while power > 0 {
        if power & 1 == 1 {
            ans = ans * base % modulo;
        }
        power >>= 1;
        base = base * base % modulo;
    }
    ans
}

#[allow(dead_code)]
fn inv_mod(a: i64, modulo: i64) -> i64 {
    pow_mod(a, modulo - 2, modulo)
}

const MOD: i64 = 1e+9 as i64 + 7;
const FACT_MAX: usize = 100000;
static mut FACTORIAL: [i64; FACT_MAX + 1] = [0; FACT_MAX + 1];
static mut RFACTORIAL: [i64; FACT_MAX + 1] = [0; FACT_MAX + 1];
fn init_fact() {
    unsafe {
        if FACTORIAL[0] == 0 {
            FACTORIAL[0] = 1;
            for i in 1..FACT_MAX + 1 {
                FACTORIAL[i] = (FACTORIAL[i - 1] * i as i64) % MOD;
            }
            RFACTORIAL[FACT_MAX] = inv_mod(FACTORIAL[FACT_MAX], MOD);
            for i in (0..FACT_MAX).rev() {
                RFACTORIAL[i] = RFACTORIAL[i + 1] * (i as i64 + 1) % MOD;
            }
        }
    }
}
#[allow(dead_code)]
fn fact(n: usize) -> i64 {
    init_fact();
    unsafe { FACTORIAL[n] }
}
#[allow(dead_code, unused_comparisons)]
fn combi(n: usize, m: usize) -> i64 {
    if n < m || m < 0 {
        return 0;
    }
    init_fact();
    unsafe {
        FACTORIAL[n as usize] * RFACTORIAL[m as usize] % MOD * RFACTORIAL[(n - m) as usize] % MOD
    }
}

fn calc(rest: usize, cnt: usize, memo: &mut Vec<Vec<i64>>) -> i64 {
    if cnt == 0 {
        return if rest == 0 { 1 } else { 0 };
    }
    if rest == 0 {
        return 0;
    }
    if memo[rest][cnt] != -1 {
        return memo[rest][cnt];
    }
    let mut ret = 0;
    ret = (ret + calc(rest - 1, cnt - 1, memo)) % MOD;
    ret = (ret + calc(rest - 1, cnt, memo)) % MOD;
    memo[rest][cnt] = ret;
    return ret;
}

fn main() {
    let n = read::<usize>();
    let k = read::<usize>();
    let mut memo = vec![vec![-1; k + 1]; k + 1];
    let red = n - k;
    for i in 1..k + 1 {
        let total = red + 1;
        let ans = combi(total, i) * calc(k, i, &mut memo) % MOD;
        println!("{}", ans);
    }
}


Measured memory_bytes: 46972
# -*- coding: utf-8 -*-
import itertools
def main():
# 整数の入力
    
    # スペース区切りの整数の入力
    s = [int(x) for x in input().split(' ')]
    n = s[0]
    m = s[1]
    q = s[2]
    t_list = []
    for i in range(q):
        s = [int(x) for x in input().split(' ')]
        t_list.append(s)

    seq = [x for x in range(1, m+1)]
    candidate_list = list(itertools.combinations_with_replacement(seq, n))

    candidate_d_list = []
    candidate_d_list.append(0)
    for candidate in candidate_list:
        d_list = []
        d_list.append(0)

        for t in t_list:
            a = t[0]
            b = t[1]
            c = t[2]
            d = t[3]
            
            if candidate[b-1] - candidate[a-1] == c:
                d_list.append(d)
        candidate_d_list.append(sum(d_list))

    
    print(max(candidate_d_list))


if __name__ == '__main__':
    main()

Measured memory_bytes: 25200
package main

import (
  "fmt"
  "math"
)

func dist(a, b []float64, d int) float64 {
  res := 0.0
  for i := 0; i < d; i++ {
    res += math.Pow(a[i] - b[i], 2)
  }
  res = math.Sqrt(res)
  return res
}

func main() {
  var n, d int 
  fmt.Scan(&n, &d)
  x := make([][]float64, n)
  for i := 0; i < n; i++ {
    x[i] = make([]float64, d)
    for j := 0; j < d; j++ {
      fmt.Scan(&x[i][j])
    }
  }
  cnt := 0
  for i := 0; i < n - 1; i++ {
    for j := i + 1; j < n; j++ {
      d := dist(x[i], x[j], d) 
      if d == math.Floor(d) {cnt++}
    }
  }
  fmt.Println(cnt)
}

Measured memory_bytes: 512
s = input()
key = 1
i = 0

while i < len(s):
    if s[i:i+5] == "dream":
        if s[i+5:i+10] != "erase" and s[i+5:i+7] == "er":
            i += 7
        elif s[i+5:i+11] == "eraser":
            i += 11
        elif s[i+5:i+10] == "erase":
            i += 10
        else:
            i += 5
    elif s[i:i+6] == "eraser":
        i += 6
    elif s[i:i+5] == "erase":
        i += 5
    else:
        key = 0
        break

if key == 0:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3188
// AOJ 3002: Factorization
// 2017.11.29 bal4u@uu

#include <stdio.h>

int a[6], n;
int ans[6];

char buf[100], *p;
int getint()
{
	int n = 1;
	int minus = 0;

	if (*p == '-') p++, minus = 1;
	else if (*p == '+') p++;
	if (*p >= '0' && *p <= '9') {
		n = 0;
		while (*p >= '0' && *p <= '9') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	}
	if (minus) n = -n;
	return n;
}

long long pow(int x, int k)
{
	long long t = 1;
	while (k--) t = t * x;
	return t;
}

int check(int v)
{
	int i;
	long long s = 0;
	for (i = 0; i <= n; i++) {
		if (a[i] == 0) continue;
		s += a[i] * pow(v, i);
	}
	return s == 0;
}

int main()
{
	int i, k, c;

    fgets(p=buf, 100, stdin);
	p += 2, n = *p++ & 0xf, a[n] = 1;
	while (*p >= ' ') {
		k = getint(), i = 0;
		if (*p == 'x') {
			i = 1, p++;
			if (*p == '^') p++, i = *p++ & 0xf;
		}
		a[i] = k;
	}

	c = a[0]; if (c < 0) c = -c;
	for (i = 0, k = -c; k <= c; k++) if (k != 0) {
		if (a[0] % k == 0 && check(-k)) {
			ans[i] = k;	if (++i >= n) break;
		}
	}
	for (i = 0; i < n; i++) printf("(x%+d)", ans[i]);
	putchar('\n');
    return 0;
}

Measured memory_bytes: 1808
#include <stdio.h>
int main(void){
	int x,y,tmp;
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0 && y==0){
			break;
		}
		if(x>y){
			tmp = x;
			x=y;
			y=tmp;
		}
		printf("%d %d\n",x,y);
	}
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    ll A, B;
    cin >> A >> B;
    ll cnt = B - A + 1;
    if (cnt == 1) {
        cout << A << endl;
        return 0;
    }
    int t;
    ll ans;
    if (A % 2 == 0) {
        if (cnt % 2 == 0) {
            t = cnt / 2;
            if (t % 2 == 0) {
                cout << 0 << endl;
            } else {
                cout << 1 << endl;
            }
        } else {
            t = cnt / 2;
            if (t % 2 == 0) {
                ans = 0 ^ B;
                cout << ans << endl;
            } else {
                ans = 1 ^ B;
                cout << ans << endl;
            }
        }
    } else {
        if ((cnt - 1) % 2 == 0) {
            t = (cnt - 1) / 2;
            if (t % 2 == 0) {
                ans = A ^ 0;
                cout << ans << endl;
            } else {
                ans = A ^ 1;
                cout << ans << endl;
            }
        } else {
            t = (cnt - 1) / 2;
            if (t % 2 == 0) {
                ans = A ^ 0 ^ B;
                cout << ans << endl;
            } else {
                ans = A ^ 1 ^ B;
                cout << ans << endl;
            }
        }
    }
}

Measured memory_bytes: 256
#include<vector>
#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;
  int a,b; cin >>a >>b;
  string u; cin >>u;
  (s==u?a:b)--;
  printf("%d %d\n",a,b);
}

/// confirm df==0 ///


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author toshibablack
 */

#include <algorithm>
#include <cmath>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define REP(i, n) for(int i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()

using namespace std;


class BAcCepted {
public:
    string S;

    void solve(std::istream& in, std::ostream& out) {
        in >> S;
        if (S[0] != 'A') { out << "WA" << endl; return; }
        ll cnt = 0;
        for (int i = 2; i <= S.length() - 2; i++) if (S[i] == 'C') cnt++;
        if (cnt != 1) { out << "WA" << endl; return; }
        REP(i, S.length()) {
            if (S[i] - 'a' < 0 && i != 0 && S[i] != 'C') { out << "WA" << endl; return; }
        }
        out << "AC" << endl;
    }
};


int main() {
    BAcCepted solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

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

	for (int i = 1; i <= n; i++) {
		x = i;
		if (x % 3 == 0) {
			cout << " " << i;
		}
		else {
			while (x) {
				if (x % 10 == 3) {
					cout << " " << i;
					break;
				}
				else x /= 10;
			}
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
int main()
{
	int num[9], a[9]={0}, x=1, n, i,j, b;
	for(i=0; i<9; i++)
		scanf("%d", num+i);
	scanf("%d", &n);
	for(j=0; j<n; j++)
	{
		scanf("%d", &b);
		for(i=0; i<9; i++)
		{
			if(num[i]==b)
			{
				a[i]=x;
				break;
			}
		}
	}
	if((a[0]==x&&a[1]==x&&a[2]==x)
            ||(a[3]==x&&a[4]==x&&a[5]==x)||(a[6]==x&&a[7]==x&&a[8]==x)||
            (a[0]==x&&a[3]==x&&a[6]==x)||(a[1]==x&&a[4]==x&&a[7]==x)||
            (a[2]==x&&a[5]==x&&a[8]==x)||(a[0]==x&&a[4]==x&&a[8]==x)||
            (a[2]==x&&a[4]==x&&a[6]==x))
    {
        printf("Yes\n");
    }
    else
    	printf("No\n");
    return 0;
}

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

using namespace std;
typedef long long ll;
const int N=3e5+100;
ll mod=1e9+7;
ll gcd(ll a,ll b )
{
     return  b==0?a:(gcd(b,a%b));

}
int a[200100];
set<int>s;
set<int>::iterator it;
int main()
{
    int n;cin>>n;
    int x;
    int ans=0,t=1;
    for(int i=1;i<=n;i++){
        cin>>x;
        if(x==t)t++;
        else ans++;
    }
    if(t!=1)
    cout<<ans;
    else cout<<-1;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;

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

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}

int main(){
    int g[12]={1,3,1,2,1,2,1,1,2,1,2,1};
    int x,y;
    cin>>x>>y;
    if(g[x-1]==g[y-1])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 256