akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
struct cxk{ll s,c,o;}s[100010];
int pr[100010],P;
bool yes[100010];
std::unordered_map<ll,ll>M;
cxk fuck(ll x){
	ll r=1,o=1;
	for(ll j=1;pr[j]<=2154;++j)
		if(x%pr[j]==0){
			int e=0;while(x%pr[j]==0)++e,x/=pr[j];
			e%=3;for(int i=0;i<e;++i)r*=pr[j];
			if(e)for(int i=e;i<3;++i)o*=pr[j];
		}
	if(x!=1){
		ll qt=int(sqrt(x)+0.5);
		if(qt*qt==x)o*=qt;
		else if(1.0*o*x*x>1e18)o=2e18;
		else o*=x*x;
	}
	return{r*x,1,o};
}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),ans=n;
	for(int i=2;i<=100000;++i){
		if(!yes[i])pr[++P]=i;
		for(int j=1;j<=P&&i*pr[j]<=100000;++j){
			yes[i*pr[j]]=1;
			if(i%pr[j]==0)break;
		}
	}
	for(int i=1;i<=n;++i)s[i]=fuck(gi()),s[i].c=1;
	std::sort(s+1,s+n+1,[](cxk a,cxk b){return a.s<b.s;});
	for(int i=1;i<=n;++i)if(s[i].s==s[i-1].s)s[i].c=s[i-1].c+1,s[i-1].c=-1;else s[i].c=1;
	for(int i=1;i<=n;++i)
		if(s[i].c==-1)s[i]=s[n],--n,--i;
	std::sort(s+1,s+n+1,[](cxk a,cxk b){return a.s<b.s;});
	for(int i=1;i<=n;++i){
		if(s[i].s==1)ans-=s[i].c-1;
		else{
			if(M.count(s[i].o))ans-=std::min(s[i].c,M[s[i].o]);
			M[s[i].s]=s[i].c;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 6820
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
#方角が南北/東西でセットであればよさげ
    s = input().rstrip()
    s = set(s)
    WE={'W','E'}
    NS={'N','S'}
    all_direction={'N', 'E', 'S', 'W'}

    if s == set(WE):
        print("Yes")
    elif s == set(NS):
        print("Yes")       
    elif s == set(all_direction):
        print("Yes")
    else:
        print("No")

if __name__=="__main__":
    main()

Measured memory_bytes: 9096
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string.h>
#include <math.h>
typedef long long ll;
#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REP(i,x,y)	for (int (i)=(x);(i)<(y);(i)++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef pair<int, int> Point;
typedef vector<vector<Point>> Graph;
Point num[90001];
int d[90001];

int N,H,W,D,Q,R,L;

int A[301][301];

int main() {
	cin >> H >> W >> D;
	
	REP(i,0,H) REP(j,0,W) {
		cin >> A[i][j];
		num[A[i][j]].first = i+1;
		num[A[i][j]].second = j+1;
	}
	
	REP(i,D+1,H*W+1) 
	d[i] = d[i-D] + ABS(num[i].first - num[i-D].first) + ABS(num[i].second - num[i-D].second);

	cin >> Q;
	
	REP(i,0,Q) {
		cin >> L >> R;
		cout << (d[R]-d[L]) << endl;
	}
	
	return 0;
}


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

using namespace std;



int main(){
	int N, K,a = 0;
	cin >> N >> K;
	int p[1000];
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}
	int flag = 1;
	while (flag == 1) {
		flag = 0;
		for (int j = N - 1; j >= 1; j--) {
			if (p[j - 1] > p[j]) {
				int tmp = p[j - 1];
				p[j - 1] = p[j];
				p[j] = tmp;
				flag = 1;
				a++;
			}
		}
	}
	int sum = 0;
	for (int i = 0; i < K; i++) {
		sum += p[i];
	}
	cout << sum << endl;

return 0;
}


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

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var w = int.Parse(inputs[0]);
            var a = int.Parse(inputs[1]);
            var b = int.Parse(inputs[2]);
            var result = 0;
            if (a > b + w)
            {
                result = a - (b + w);
                result = result < 0 ? 0 : result;
            }
            else
            {
                result = b - (a + w);
                result = result < 0 ? 0 : result;
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27380
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        int M = ni();
        int[] s = new int[M];
        int[] c = new int[M];
        for (int i = 0; i < M; i++) {
            s[i] = ni()-1;
            c[i] = ni();
        }
        int[] tens = {1, 10, 100, 1000};
        for (int i = 0; i < 1000; i++) {
            String val = String.valueOf(i);
            if(val.length()==N){
                boolean isok = true;
                for (int j = 0; j < M; j++) {
                    if(!val.substring(s[j],s[j]+1).equals(String.valueOf(c[j]))){
                        isok = false;
                    }
                }
                if(isok){
                    out.println(i);
                    return;
                }
            }
        }
        out.println(-1);

    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);

    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 32932
N = int(input())
c = list(input())

l, r = 0, N - 1
cnt = 0

while l < r:
    L, R = c[l], c[r]
    if L == 'W' and R == 'R':
        c[l], c[r] = 'R', 'W'
        l += 1
        r -= 1
        cnt += 1
    elif L == 'W' and R == 'W':
        r -= 1
    elif R == 'R' and R == 'R':
        l += 1
    else:
        l += 1
        r -= 1

print(cnt)


Measured memory_bytes: 77596
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;

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

  ll ans=0;
  for(ll i=1;i*i<=n;i++)
  {
    if(n%i==0) //iとn/iがnの約数の時
    {
      if(i>1 && n%(i-1)!=0 && n/i<(i-1)) ans+=(i-1);

      if(n/i>1 && n%(n/i-1)!=0 && i!=n/i && i<(n/i-1)) ans+=(n/i-1);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) {
        cin >> a[i];
        --a[i];
    }

    int ans = 0;
    rep(i, n) {
        if (a[a[i]] == i) ans++;
    }

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

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

ll b_num[55], p_num[55];

void solve()
{
  ll n, x;
  cin >> n >> x;

  //fill(b_num, b_num + 55, 0LL);
  //fill(p_num, p_num + 55, 0LL);
  b_num[0] = 1;
  p_num[0] = 1;

  for(int i = 1; i <= 50; ++i)
  {
    b_num[i] = b_num[i - 1] * 2 + 3;
    p_num[i] = p_num[i - 1] * 2 + 1;
  }

  auto lv_mid = [&](ll lv){ return (b_num[lv] + 1) / 2LL; };
  ll ans = 0;
  ll pos = 0;
  for(int lv = n; lv >= 0; --lv)
  {
    ll mid = lv_mid(lv);

    // 半分より左
    if (x < mid + pos)
    {
      pos++;
      continue;
    }

    if (lv > 0) ans += p_num[lv - 1] + 1;
    else ans++;

    // ちょうど半分
    if (x == mid + pos) break;

    // 半分より右
    pos += mid;
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    ll a = 0, w = 0, t = 0, r = 0;
    for(i = 0;i < n;++i){
        string s;
        cin >> s;
        if(s == "AC") ++a;
        else if(s == "WA") ++w;
        else if(s == "TLE") ++t;
        else if(s == "RE") ++r;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << w << endl;
    cout << "TLE x " << t << endl;
    cout << "RE x " << r << endl;

    return 0;
}

Measured memory_bytes: 3640
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

x,y = inpl()
res = 0
while x*2**res <= y:
    res += 1
print(res)

Measured memory_bytes: 38384
// うそ
#include<stdio.h>
#include<stdlib.h>

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

int main(void){
    int n;
    scanf("%d", &n);
    int s[n];
    int sum = 0;
    for(int i=0; i<n; i++){
        scanf("%d", &s[i]);
        sum += s[i];
    }

    qsort(s, n, sizeof(int), compare);

    int ans;
    int flag = 0;
    if(sum%10 != 0){
        ans = sum;
        flag = 1;
    }
    else{
        for(int i=0; i<n; i++){
            if((sum-s[i])%10 != 0){
                ans = sum-s[i];
                flag = 1;
                break;
            }
        }
    }

    if(flag){
        printf("%d\n", ans);
    }else{
        printf("0\n");
    }
    // int s[n+1];
    // s[0] = 0;
    // for(int i=1; i<n+1; i++){
    //     s[i] = s[i-1] + score[i-1];
    //     printf("s[%d]:%d\n", i, s[i]);
    // }

    // int ans;
    // for(int i=n; i>=0; i--){
    //     if(s[i]%10 != 0){
    //         ans = s[i];
    //         break;
    //     }
    //     ans = s[i];
    // }
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int mod = 1000000007;

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

    int H, W;
    cin >> H >> W;
    char a[H][W];
    for (int i = 0; i < H; i++) {
        cin >> a[i];
    }

    ll dp[H][W];
    fill(dp[0], dp[H-1]+W, 0);
    dp[0][0] = 1;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (a[i][j] == '.') {
                if (i > 0 && a[i-1][j] == '.') {
                    dp[i][j] += dp[i-1][j];
                }
                if (j > 0 && a[i][j-1] == '.') {
                    dp[i][j] += dp[i][j-1];
                }
                dp[i][j] %= mod;
            }
        }
    }

    cout << dp[H-1][W-1] << "\n";
    return 0;
}

Measured memory_bytes: 9088
#include<stdio.h>
#define INFTY 1000000001

typedef struct{
    char suit;
    int value;
}Card;

void Swap(int* x, int* y){
    int tmp;
    tmp = *x;
    *x = *y;
    *y = tmp;
}

void merge(Card A[], int left, int mid, int right){
    int n1, n2, i, j;
    n1 = mid - left;
    n2 = right - mid;
    Card L[n1 + 1], R[n2 + 1];
    for(i = 0; i < n1; i++){
        L[i] = A[left + i];
    }
    for(i = 0; i < n2; i++){
        R[i] = A[mid + i];
    }
    L[n1].value = INFTY;
    R[n2].value = INFTY;
    i = 0; j = 0;
    for(int k = left; k < right; k++){
        if(L[i].value <= R[j].value){
            A[k] = L[i];
            i++;
        }else{
            A[k] = R[j];
            j++;
        }
    }
}

void mergeSort(Card A[], int left, int right){
    int times;
    if(left + 1 < right){
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int partition(Card A[], int p, int r){
    int x = A[r].value;
    int i = p - 1;
    char c;
    for(int j = p; j < r; j++){
        if(A[j].value <= x){
            i++;
            Swap(&A[i].value, &A[j].value);
            c = A[i].suit; A[i].suit = A[j].suit; A[j].suit = c;
        }
    }
    Swap(&A[i+1].value, &A[r].value);
    c = A[i+1].suit; A[i+1].suit = A[r].suit; A[r].suit = c;
    return i+1;
}

void quickSort(Card A[], int p, int r){
    if(p < r){
        int q = partition(A, p, r);
        quickSort(A, p, q-1);
        quickSort(A, q+1, r);
    }
}

int judge(Card card[], Card scard[], int n){
    int i;
    for(i = 0; i < n; i++){
        if(card[i].suit != scard[i].suit) return 0;
    }
    return 1;
}

void print(Card card[], int n){
    int i;
    for(i = 0; i < n; i++){
        printf("%c %d\n", card[i].suit, card[i].value);
    }
}

int main(){
    int n, i;
    scanf("%d", &n);
    Card card[n], scard[n];
    char S[10];
    for(i = 0; i < n; i++){
        scanf("%s %d", S, &card[i].value);
        scard[i].suit = card[i].suit = S[0];
        scard[i].value = card[i].value;
    }
    quickSort(card, 0, n-1);
    mergeSort(scard, 0, n);
    if(judge(card, scard, n)) printf("Stable\n");
    else printf("Not stable\n");

    print(card, n);

    return 0;
}


Measured memory_bytes: 4088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

using ll = long long;
using ui = unsigned int;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807;


//C

//B

//A
int main() {
	string arr[] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
	
	string s;
	cin >> s;

	ll result = 0;

	for (ll i = 0; i < 7; i++) {
		if (s == arr[i]) {
			result = 7 - i;
			break;
		}
	}

	printf("%lld\n", result);
}


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

using namespace std;

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


int main(void)
{
  int n, k;
  cin >> n >> k;
  vector<int> v(n, 0);
  for (int i = 0; i < n; i++){
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  int res = 0;
  for (int i = n-1; i > n-1-k; i--){
    res += v[i];
  }
  cout << res << endl;
  return 0;
}


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

int main(){
  int n,ma,mb; cin >> n >> ma >> mb;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  for(int i=0;i<n;i++) cin >> a.at(i) >> b.at(i) >> c.at(i);
  int max=n*10+1;
  vector<vector<int>> dp(max,vector<int>(max,-1));
  dp.at(0).at(0)=0;
  for(int i=0;i<n;i++){
    for(int x=max;x>=a.at(i);x--){
      for(int y=max;y>=b.at(i);y--){
	int s=dp.at(x-a.at(i)).at(y-b.at(i));
	if(s>=0){
	  int &p=dp.at(x).at(y);
	  s+=c.at(i);
	  if(p==-1 || s<p)p=s;
	}
      }
    }
  }
  for(int i=0;i<max;i++){
    for(int j=0;j<max;j++){
      if(dp.at(i).at(j)<0)continue;
      if(df) printf("%d,%d: %d\n",i,j,dp.at(i).at(j));
    }
  }
  int min=n*100+1;
  if(df) cout << max<< endl;
  for(int i=1;i<max;i++){
    int aa=ma*i,bb=mb*i;
    if(aa>=max || bb>=max)break;
    int p=dp.at(aa).at(bb);
    if(p<0)continue;
    if(p<min)min=p;
  }
  cout << ((min>n*100)?-1:min);
}


Measured memory_bytes: 896
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  bool done = false;
  long long ans = 0;
  while (!done) {
    done = true;
    for (int i = 0; i < n; i++) if (a[i] >= n) {
      done = false;
      long long del = a[i] / n;
      ans += del;
      a[i] -= del * n;
      for (int j = 0; j < n; j++) if (j != i) a[j] += del;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>

using namespace std;

int main()
{
    int a[101],b[101];
    int n;

    cin>>n;

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

    double ans;

    for(int i=1;i<=3;i++)
    {
        ans=0;
        for(int j=0;j<n;j++)
        {
            ans+=pow(fabs((double)(a[j]-b[j])),i*1.0);
        }
        ans=pow(ans,1.0/i);
        cout<<fixed<<setprecision(6)<<ans<<endl;
    }

    ans=-1;
    for(int i=0;i<n;i++)
    {
        ans=max(ans,fabs(a[i]-b[i]));
    }
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 3480
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

//個数と合計値を持つdp table
//x[i-1]までで個数jで合計値がkになる場合の数をメモ
ll dp[55][80][4000];

int main() {
	int N,A;
	cin>>N>>A;
	vector<int> x(N);
	rep(i,N)cin>>x[i];
	//初期値x[-1]までで個数0で合計値が0になる場合の数は1
	dp[0][0][0] = 1;
	rep(i,N){
		rep(j,50){
			rep(k,3025){
				//x[i]を使わない場合
				dp[i+1][j][k] += dp[i][j][k];
				//x[i]を使う場合、個数が1,合計がx[i]増加する
				dp[i+1][j+1][k+x[i]] += dp[i][j][k];
			}
		}
	}
	ll ans = 0;
	rep1(j,55)rep(k,3025){
		if(k%j == 0&&k/j == A)
		ans += dp[N][j][k];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 125184
def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


mod = 10 ** 9 + 7  # 出力の制限
N = 2*10 ** 6
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)
#
#

k = int(input())
s = input()

head = len(s)+k
ans = 0
for i in range(k+1):
    ans += cmb(head,i,mod)*pow(25,i,mod)
    ans %= mod

print(ans%mod)

Measured memory_bytes: 205116
#include<stdio.h>
int main(void){
	int n,a,b[9]={0},cnt=0;
	for(scanf("%d",&n);n;n--){
		scanf("%d",&a);
		b[a<3200?a/400:8]++;
	}
	for(n=0;n<8;n++){
		cnt+=b[n]!=0;
	}
	printf("%d %d",cnt?cnt:1,cnt+b[8]);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define true 1
#define false 0

int main(void){
    int n=0,k=0;
    int temp=0;
    int flag=false;
    int array[10]={0};
    int count=0;

    scanf("%d %d",&n,&k);

    for(int i=0;i<k;i++){
        scanf("%d",&temp);
        array[temp]=1;
    }

    for(int i=n;i<100000;i++){
        temp=i;
        flag=true;
        while(temp>0){
            if(array[temp%10]==true){
                flag=false;
                break;
            }
            temp/=10;
        }
        if(flag==true){
            count=i;
            break;
        }
    }

    printf("%d",count);
    return 0;
}


Measured memory_bytes: 1696
N, K = map(int,input().split())
a_max = 100000
t = [0 for _ in range(a_max)]

for _ in range(N):
    a, b = map(int,input().split())
    t[a-1] += b

cnt = 0
for i in range(a_max):
    cnt += t[i]
    if cnt >= K:
        ans = i+1
        break

print(ans)

Measured memory_bytes: 5924
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define double long double
#define int long long
#define pb push_back 
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl
#define prtp(ct) for(auto &(it) : (ct)) cerr<<it.F<<" "<<it.S<<nl; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef pair<pii,pii> ppp;
typedef vector< pii > vp;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> baap;

void swap(char &a,char &b)
{ auto tm=a; a=b; b=tm; }

void mina(int &a,int b)
{ a=(a<b?a:b); }

void maxa(int &a,int b)
{ a=(a>b?a:b); }

  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=1e18;
  const int N=2e5+25;
  const int M=31;

 
 void doit()
 { 
   int n,k; cin>>n>>k;
   vi pre(n+1),suf(n+1);

   for(int i=1;i<=n;++i)
   pre[i]=(pre[i-1]+i)%mod;
   
   suf[n]=n;

   for(int i=n-1;i>=0;--i)
   suf[i]=(suf[i+1]+i)%mod;
   
   int ans=0;
   
 
   for(int i=k;i<=n+1;++i)
   {
     int t=(suf[n+1-i]-pre[i-1]+mod+1)%mod;
     ans=(ans + t)%mod;
   }

   cout<<ans;

 }

signed main()
{ 
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


  
   int tc=1;                         
 //  cin>>tc;

  rep(i,1,tc+1)
  { // cout<<"Case #"<<i<<": ";
    
   doit();
   if(i<tc)
   cout<<nl;
  }


 return 0; 
}

Measured memory_bytes: 6336
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        while(input.hasNext()){
        	int a = input.nextInt();
        	int sum = 0;
        	for(int i = a ; i < 600 ; i+=a){
        		sum += Math.pow(i, 2)*a;
        	}
        	System.out.println(sum);
        }
    }    
}

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

vector<vector<int>> v;
vector<int> d, f;

int t = 0;
void dfs(int x){
  d[x] = ++t;
  for(int i=0; i<v[x].size(); ++i){
    if(v[x][i] == 1 && d[i] == 0){
      dfs(i);
    }
  }
  f[x] = ++t;
}

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

  v.resize(n);
  d.resize(n);
  f.resize(n);

  for(int i=0; i<n; ++i) v[i].resize(n);

  for(int i=0; i<n; ++i){
    int u, k; cin >> u >> k;
    while(k--){
      int x; cin >> x;
      v[u-1][x-1] = 1;
    }
  }

  for(int i=0; i<n; ++i){
    if(d[i] == 0) dfs(i);
  }

  for(int i=0; i<n; ++i){
      cout << i+1 << " " << d[i] << " " << f[i] << endl;
  }
}



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

using namespace std;

typedef long long LL;
typedef pair<LL, LL> PLL;
const LL p = 1e9 + 7;
LL n, k;
LL cnt[100005];

LL modpow(LL a, LL n) {
	if (n == 0) return 1;
	if (n % 2) return ((a%p) * (modpow(a, n - 1) % p)) % p;
	return modpow((a*a) % p, n / 2) % p;
}

int main() {
	cin >> n >> k;
	for (LL i = k; i >= 1; i--) {
		LL num = k / i;
		cnt[i] = modpow(num, n);
		for (LL j = 2 * i; j <= k; j += i) {
			cnt[i] += p - cnt[j];
			if (cnt[i] >= p) cnt[i] -= p;
		}
	}

	LL res = 0;
	for (LL i = 1; i <= k; i++) res = (res + i * cnt[i] % p) % p;
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 4408
import math
x = int(input())

a = 10**6+1
b = [True]*(a)
b[0] = False
b[1] = False

for i in range(4, a, 2):
  b[i] = False

p = int(math.sqrt(a))
for i in range(3, p+1, 2):
  if b[i]:
    for j in range(i+i, a, i):
      b[j] = False

ans = 0
for i in range(x, a):
  if b[i]:
    print(i)
    break

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	
	int sum = 0;
	REP(i,N){
		int num = 0;
		int v = i+1;
		while(v){
			num++;
			v /= 10;
		}
		if(num%2) sum++;
	}
	out(sum);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=100010;
int n,x,g=0;
int main()
{
  cin>>n;
  for(int i=1;i<=n;i++) cin>>x,g=__gcd(g,x);
  cout<<g<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.math.BigDecimal;

public class Main{


		public static long saidai(long a , long b){
			long c,s,t;
			s = a;
			t = b;
			while(true){
				if(s == t){
					c = s;
					break;
				}else if(s == 0){
					c = t;
					break;
				}else if(t == 0){
					c = s;
					break;
				}else if(s > t){
					s = s % t;
				}else{
					t = t % s;
				}
				
			}
			
			
			return c;
		}
		
		public static  long saishou(long a , long b){
			long c,s,t;
			s = a;
			t = b;
			while(true){
				if(s == t){
					c = s;
					break;
				}else if(s < t){
					s = s+a;
				}else{
					t = t+b;
				}
			
			}
			return c;
		}
		
       public static void main(String[] args){
       int i,j;
       long a,b,c,d,e,f;
       
    	long[] x = new long[60];
    	long[] y = new long[60];
    
        Scanner scan = new Scanner(System.in);
        
        i = 0;
        while(scan.hasNextLong()){
        	a = scan.nextLong();
        	b = scan.nextLong();
        	x[i] = saidai(a,b);
        	y[i] = saishou(a,b);
        	
        	i++;
        
        }
      
        
        j = 0;
        while(j < i){
        	
     		System.out.println(x[j] + " " + y[j]);
        	j++;
       		}
       		}
}

Measured memory_bytes: 25740
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	string s;cin>>s;
	vector<int>x,y;
	int n = 0;for(int i=0;i<s.length();i++)if(s[i]=='T')(x.size()==y.size()?x:y).push_back(n),n=0;else n++;
	(x.size()==y.size()?x:y).push_back(n);
	sort(x.begin() + 1, x.end());sort(y.begin(), y.end());
	int X, Y;cin >> X >> Y;
	int a=x[0], b=0;
	for(int i=x.size()-1;i>=1;i--)a+=x[i]*(a>=X?-1:1);
	for(int i=y.size()-1;i>=0;i--)b+=y[i]*(b>=Y?-1:1);
	cout<<(a==X&&b==Y?"Yes":"No")<<endl;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  ll ans = min(n*a,b);
  cout << ans<< endl;
  return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#include<iostream>
#define LIM 999999
using namespace std;
long long int i,j,a,odd;
bool prime[LIM];
long long int arr[999999];
void sieve()
{
    
    arr[a++]=2;
    for(i=3;i<=LIM;i+=2)
    {
        if(!prime[i])
        {
            arr[a++]=i;
            if(i*i<=LIM)
            {
                odd=i;
                
                for(j=i*i;j<=LIM;j=i*odd)
                {
                    prime[j]=true;
                    odd+=2;
                }
            }
        }
    }
}
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    sieve();
    long long int k, num, count = 0;
    k=0;
    while(scanf("%lld", &num)!=EOF)
    {
        k=0;
        count = 0;

        for(int i=1; i<=num; i++)
        {
            if(i == arr[k])
                {
                    count++;
                    k++;
                }
        }
        printf("%lld\n", count);
    }
    return 0;
}

Measured memory_bytes: 4704
package main

import "fmt"

func main() {
	var x int
	fmt.Scan(&x)
	if x < 3 {
		fmt.Println("1")
		return
	}
	for i := x; i > 0; i-- {
		for j := 2; j <= x/2; j++ {
			t := i
			for {
				if t == 1 {
					fmt.Println(i)
					return
				}
				if t%j == 0 {
					t /= j
					continue
				}
				break
			}
		}
	}
}


Measured memory_bytes: 512
import java.util.Scanner;

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

        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (Math.abs(a - x) < Math.abs(b - x)) {
            System.out.println("A");
        } else {
            System.out.println("B");
        }
    }
}


Measured memory_bytes: 23252
#include <iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define LL long long
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define mem(a,t) memset(a,t,sizeof(a))
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define sz(v) ((int)sizeof(v))
#define N 100005
const int inf=1e9;
struct node{
    int a,b;
    bool friend operator <(node u,node v){
        if(u.a-u.b!=v.a-v.b)
            return u.a-u.b<v.a-v.b;
        return u.b>v.b;
    }
}f[N];
priority_queue<LL>gold,sliver;
LL g[N],s[N];
 
int main()
{
    ios_base::sync_with_stdio(false);
    LL x,y,z,tot;
    LL sum,gsum,ssum;
    cin>>x>>y>>z;
    tot=x+y+z;
    sum=gsum=ssum=0;
    rep(i,1,tot+1){
        int a,b,c;
        cin>>a>>b>>c;
        a-=c;
        b-=c;
        f[i].a=a;
        f[i].b=b;
        sum+=c;
    }
    sort(f+1,f+tot+1);
    //rep(i,0,tot) cout<<f[i].a<<' '<<f[i].b<<endl;
    int i;
    for(i=tot;i>y+z;--i){
        gold.push(-f[i].a);
        gsum+=f[i].a;
    }
    g[x]=gsum;
    for(i=y+z;i>y;--i){
        gold.push(-f[i].a);
        gsum+=f[i].a;
        gsum+=gold.top();
        gold.pop();
        g[tot-i+1]=gsum;
    }
    for(i=1;i<=y;++i){
        sliver.push(-f[i].b);
        ssum+=f[i].b;
    }
    s[y]=ssum;
    for(i=y+1;i<=y+z;++i){
        sliver.push(-f[i].b);
        ssum+=f[i].b;
        ssum+=sliver.top();
        sliver.pop();
        s[i]=ssum;
    }
    LL ans=0;
    //cout<<"heheh"<<endl;
    for(i=y;i<=y+z;++i){
       if(i==y) ans=s[i]+g[tot-i];
       else        ans=max(ans,s[i]+g[tot-i]);
    }
    cout<<ans+sum<<endl;
    return 0;
}

Measured memory_bytes: 2460
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    b = list(set(s))
    a = len(list(set(s)))
    if a == 2 and s.count(b[0]) == s.count(b[1]) == 2:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n = II()
    p = LI()
    ans = 0
    for i in range(1,n-1):
        if (p[i - 1] < p[i] and p[i] < p[i + 1]) or (p[i + 1] < p[i] and p[i] < p[i - 1]):
            ans += 1
    print(ans)
    return

#C
def C():
    n = II()
    d = LI()
    d.sort()
    ans = 0
    for i in range(10**5+1):
        if n // 2 == bisect_left(d, i):
            ans += 1
    print(ans)
    return


def combination_mod(n, k, mod):
    # power_funcを用いて(nCk) mod p を求める 
    # nCk = n!/((n-k)!k!)を使用

    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    a = factorial(n) % mod
    b = factorial(k) % mod
    c = factorial(n - k) % mod
    return (a * power_func(b, mod - 2, mod) * power_func(c, mod - 2, mod)) % mod
    
def power_func(a, b, mod):
    # a^b mod p を求める
    # bを2進数分解して高速累乗

    if b == 0: return 1
    if b % 2 == 0:
        d = power_func(a, b // 2, mod)
        return d * d % mod
    if b % 2 == 1:
        return (a * power_func(a, b - 1, mod)) % mod

#D
def D():
    n, k = LI()
    ans = 0
    for i in range(1,k+1):
        a = combination_mod(n - k + 1, i, mod)
        b = combination_mod(k - 1, i - 1, mod)
        print((a*b)%mod)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 4592
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <functional>
using namespace std;
typedef long long ll;

//Union-Findライブラリ.1は後で修正すること.
class UF{
public:
    int par[1];
    int ran[1];

    void init(int n){
        for(int i = 0;i < n;i++){
            par[i] = i;
            ran[i] = 0;
        }
    }

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

    void unite(int x,int y){
        x = find(x);
        y = find(y);

        if(ran[x] < ran[y])par[x] = y;
        else{
            par[y] = x;
            if(ran[x] == ran[y])ran[x]++;
        }
    }

    bool same(int x,int y){
        return find(x) == find(y);
    }
};
int main(){
    string s;
    string t;
    cin >> s >> t;
    int a,b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(u == s)cout << a - 1 << " " << b << endl;
    else if(u == t)cout << a << " " << b - 1 << endl;
    else cout << a << " " << b << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

ll modpow(ll a, ll N) {
  ll ans = 1;
  ll tmp = a;
  while(N > 0) {
    if(N % 2 == 1) (ans *= tmp) %= mod;
    (tmp *= tmp) %= mod;
    N /= 2;
  }
  return ans;
}
ll modinv(ll a, ll m=mod) {
  ll b = m, u = 1, v = 0;
  while(b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if(u < 0) u += m;
  return u;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, a, b; cin >> n >> a >> b;
  ll ans = (modpow(2, n)+mod-1)%mod;
  {
    ll tmp = 1;
    rep(i, a) (tmp *= (n-i) * modinv(1+i) % mod) %= mod;
    (ans += mod-tmp) %= mod;
  }
  {
    ll tmp = 1;
    rep(i, b) (tmp *= (n-i) * modinv(1+i) % mod) %= mod;
    (ans += mod-tmp) %= mod;
  }
  cout << ans << endk;
  return 0;
}


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

string S;
string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main(){
    cin >> S;

    bool can =true;

    reverse (S.begin(), S.end());
    for(int i = 0 ;i < 4; i++){
        reverse(divide[i].begin(), divide[i].end());
    }


    for (int i = 0; i< S.size(); ){
        bool can2 =false;
        for(int j = 0; j < 4; j++){
            string d = divide[j];
            if (S.substr(i, d.size()) == d){
                can2 = true;
                i = i+ d.size();
            }
        }

        if (!can2){
            can = false;
            break;
        }
    }

    if(can) {
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
}

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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD (ll)1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

ll dp[2][101];

void solve(){
	string s;
	int d;
	cin>>s>>d;
	int n=s.size();
	fr(i,0,s[0]-'0'){
		dp[0][(i%d)]++;
	}
	ll rem=(s[0]-'0')%d;
	int t=1;
	fr(i,1,n){
		fr(j,0,d)
			dp[t][j]=0;
		fr(j,0,d)
			fr(k,0,10)
				dp[t][(j+k)%d]=(dp[t][(j+k)%d]+dp[t^1][j])%MOD;
		fr(k,0,s[i]-'0')
			dp[t][(k+rem)%d]=(dp[t][(k+rem)%d]+1LL)%MOD;
		rem=(rem+ (s[i]-'0'))%d;
		t^=1;
	}
	ll ans=(dp[t^1][0] + (rem==0?1LL:0))%MOD;
	ans=(ans-1LL +MOD)%MOD;
	cout<<ans<<endl;
	return;
}

int main()
{
	boost();
	
	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}

Measured memory_bytes: 3684
k = int(input())
l = ['1','2','3','4','5','6','7','8','9']
lf = ['1','2','3','4','5','6','7','8','9']
sum = 9
while sum < k:
    lff = []
    for i in lf:
        if i[-1] == '0':
            lff.append(i+'0')
            lff.append(i+'1')
        elif i[-1] == '9':
            lff.append(i+'8')
            lff.append(i+'9')
        else:
            lff.append(i+str(int(i[-1])-1))
            lff.append(i+str(int(i[-1])))
            lff.append(i+str(int(i[-1])+1))
    lf = lff
    l += lff
    sum += len(lff)
print(int(l[k-1]))

Measured memory_bytes: 18296
def convertList(G):
    n = len(G)
    GL = [ [0 for _ in range(n)] for _ in range(n)]
    for key, values in G.items():
        GL[key - 1][key - 1] = 0
        for v in values:
            GL[key - 1][v - 1] = 1

    return GL


if __name__ == '__main__':
    G = {}
    n = int(input())
    for _ in range(n):
        tmp = list(map(int, input().split()))
        u = tmp.pop(0)
        k = tmp.pop(0)
        G[u] = tmp
    GL = convertList(G)
    for i in range(n):
        print(*GL[i])

Measured memory_bytes: 8444
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,c=0;
    cin>>n;
    string s;
    cin>>s;
    for(i=1;i<s.size();i++)
    {
        if(s[i]!=s[i-1])
            c++;
    }
    cout<<c+1<<endl;
}


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

vector<int> X(1001001);
vector<int> to[1001001];

void dfsx(int a, int b=-1){
    int v = a;
    rep(i, to[v].size()){
        int c = to[v][i];
        if (c == b){
            continue;
        } else {
            X[c] += X[v];
            dfsx(c, v);
        }
    }
}

int main() {
    int N, Q; cin >> N >> Q;
    rep(i, N -1){
        int a,b; cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    rep(i, Q){
        int p, x; cin >> p >> x;
        p--;
        X[p] += x;
    }

    dfsx(0);

    rep(i, N){
        cout << X[i] << endl;
    }

}

Measured memory_bytes: 48512
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <string>
#include <algorithm>
#include <climits>
#include <set>
#include <queue>
#include <unordered_set>
using namespace std;

#define ll long long

struct Question
{
	int v;
	int d;
	int c;	
};

class Solver
{
public:
	int n;
	int m;
	int q;
	vector<vector<int> > adj;
	vector<Question> qs;
	vector<vector<int> > dp;
	unordered_set<int> us;

	Solver();

	void set(int cur, int depth, int color);
	void exec();
};

Solver::Solver(){
	cin >> n >> m;
	adj.resize(n);
	for (int i = 0; i < m; ++i)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
		// us.insert(i);
	}
	cin >> q;
	for (int i = 0; i < q; ++i)
	{
		Question tmpQ;
		cin >> tmpQ.v >> tmpQ.d >> tmpQ.c;
		tmpQ.v--;
		qs.push_back(tmpQ);
	}
	dp = vector<vector<int> >(n, vector<int>(11, 0));
}


void Solver::set(int cur, int depth, int color){
	if(dp[cur][depth] != 0) return;
	dp[cur][depth] = color;
	if(depth == 0) return;
	set(cur, depth-1, color);
	for (int i = 0; i < adj[cur].size(); ++i)
	{
		set(adj[cur][i] , depth-1, color);
	}
}

void Solver::exec(){
	for (int i = q-1; i >= 0; --i)
	{
		set(qs[i].v, qs[i].d, qs[i].c);
	}

	for (int i = 0; i < n; ++i)
	{
		cout << dp[i][0] << endl;
	}
}

int main(){
	Solver solution = Solver();
	solution.exec();
}


Measured memory_bytes: 16240
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int N;
    
    cin >> N;
    if(N == 1){
        cout << "Hello World" << endl;
    }
    else{
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    
    return 0;
}


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

#define lson l, m, rt*2
#define rson m + 1, r, rt*2+1
#define xx first
#define yy second

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> pii;

int main() {
#ifdef JUDGE
  freopen("case.in", "r", stdin);
#endif
  int n, t = 1;
  cin >> n;
  while (1) {
    if (t * (t + 1) / 2 >= n) {
      cout << t << endl;
      return 0;
    }
    else
      t++;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

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

	if(n % 2 == 1){
		cout << 0 << endl;
		return 0;
	}

	sort(ALL(d));

	n/=2;
	cout << d[n] - d[n-1] << endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,M,i,j,f[5005][5005],a[5005],ans,k;
int main()
{
	scanf("%d %d",&n,&M);
	f[1][n]=1;
	for(i=2;i<=n/2+1;++i)
		a[i]=i-1;
	for(i=n/2+2;i<=n;++i)
		a[i]=n-i+2;
	for(i=2;i<=n;++i)
		for(j=0;j*a[i]<=n;++j)
			for(k=1;k<=n-j*a[i];++k)
				f[i][k]=(f[i][k]+f[i-1][k+j*a[i]])%M;
	for(j=1;j<=n;++j)
		ans=(ans+1ll*f[n][j]*j)%M;
	cout<<ans;
}

Measured memory_bytes: 98048
n = int(input())
l = []
for i in range(n):
    p,q = map(int,input().split())
    l.append((p+q,p-q))
l.sort()
c = -float('inf')

count = 0

for i in range(n):
    if l[i][1]<c:
        count+=1
    else:
        c = l[i][0]
print(n-count)


Measured memory_bytes: 16988
N,K=map(int,input().split());print(-1 if 2*K-1>N else"\n".join("%d %d %d"%(((N+1)//2-k-1)%N+K,N+2*k%N+K+(2*k>=N)*(N+1)%2,2*N+k+K)for k in range(N)))

Measured memory_bytes: 83036
import numpy as np
a,b,h,m = map(int, input().split())
s = 2 * np.pi * (h * 60 + m) / (12 * 60)
t = 2 * np.pi * m / 60
ans = a*a + b*b - 2*a*b * np.cos(min(abs(t-s),abs(s-t)))
print(ans**0.5)

Measured memory_bytes: 27196