akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null) {

			int n = Integer.parseInt(line.substring(0, line.indexOf(' ')));
			int m = Integer.parseInt(line.substring(line.indexOf(' ') + 1));
			if (n == 0 && m == 0)
				break;

			//
			m++;
			int[] wish = new int[m];
			for (int i = 0; i < n; i++) {
				line = br.readLine();
				for (int j = 0; j < line.length(); j += 2) {
					if (line.charAt(j) == '1')
						wish[j / 2 + 1]++;
				}
			}

			//
			StringBuilder sb = new StringBuilder();
			for (int i = n; i >= 0; i--) {
				for (int j = 1; j < m; j++) {
					if (wish[j] == i)
						sb.append(j + " ");
				}
			}
			System.out.println(sb.toString().substring(0, sb.length() - 1));
		}
	}
}

Measured memory_bytes: 23316
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <iomanip>
int MOD = 1000000007 ;
using namespace std;
vector<vector<int>> grid;
vector<vector<int>> memory;
int h, w;
int f(int y, int x) {
	if (memory[y][x] != -1) return memory[y][x];
	int sum = 0;
	if (grid[y + 1][x] == 0) sum += f(y + 1, x);
	if (sum > MOD) sum -= MOD;
	if (grid[y][x+1] == 0) sum += f(y, x+1);
	if (sum > MOD) sum -= MOD;
	memory[y][x] = sum;
	return sum;
}

int main(){
	
	int n;
	cin >> n;
	vector<double> coins(n+1);
	for (int i = 0; i < n; i++) {
		double p;
		cin >> p;
		coins[i+1] = p;
	}
	vector<vector<double>> dp(n+1, vector<double>(n+1));
	dp[1][1] = coins[1]; dp[1][0] = 1 - coins[1];
	for (int i = 2; i <= n; i++) {
		for (int j = 0; j <= i; j++) {
			
				dp[i][j] = (j>=1?dp[i - 1][j - 1]:0) * coins[i] + dp[i - 1][j] * (1 - coins[i]);
			
		
		}
	}
	double sum = 0;
	

	for (int i =n/2+1; i <= n; i++) sum += dp[n][i];
	cout <<fixed<<setprecision(9)<< sum;
}


Measured memory_bytes: 73572
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int x,y,r;
    cin >> W >> H >>  x >> y >> r;
    if(0 <= x-r and x+r <= W){
        if(0<= y-r and y+r <= H){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}





Measured memory_bytes: 3104
using System;
using System.Linq;

namespace _1045
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) break;
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                bool[] canmake = new bool[x.Sum() + 1]; canmake[0] = true;
                for (int i = 0; i < n; i++)
                {
                    for (int j = x.Sum(); j >= 0; j--)
                    {
                        if (canmake[j]) canmake[j + x[i]] = true;
                    }
                }
                int ret = -1;
                for (int i = x.Sum() / 2; ret == -1; i--)
                {
                    if (canmake[i])
                        ret = x.Sum() - i * 2;
                }
                Console.WriteLine(ret);
            }
        }
    }
}


Measured memory_bytes: 9652
#include <iostream>
#include <set>
#include <map>
#include <vector>

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
  int N;
  cin >> N;
  
  int ans = 0;
  for (int i = 0; i <= N; i++) {
    ans += i;
    if (ans >= N) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		
		Scanner in = new java.util.Scanner(System.in);
		int D = in.nextInt();
		int T = in.nextInt();
		int S = in.nextInt();
		
		if(T*S >= D) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		in.close();
	}
}


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

int main() {
  int C;
  string Num;
  cin >> Num;
  C = 0;
  
  for (int i = 0; i < 3; i++) {
    if (Num.at(i) == '7') {
      C = C + 1;
    }
  }
  
  if (C > 0) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b


signed main(){
	string s; cin>>s;
	int n=s.size();
	ll ans=0;
	ll cnt=0;
	rep(i,0,n){
		if(s[i]=='S')cnt++;
		else if(cnt>0){
			cnt--;
			ans++;
		}
	}
	cout<<n-(ans*2)<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3572
import sys

def lcm(a, b):
    a, b = max(a, b), min(a, b)
    c = a * b
    while a % b > 0:
        a, b = b, a % b
    return c // b

def solve():
    input = sys.stdin.readline
    A, B, C, D = map(int, input().split())
    divC = B // C - (A - 1) // C
    divD = B // D - (A - 1) // D
    cd = lcm(C, D)
    divCD = B // cd - (A - 1) // cd
    print(B - A + 1 - (divC + divD - divCD))


    return 0

if __name__ == "__main__":
    solve()

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

int main()
{
    int N, Y;
    cin >> N >> Y;
    // i枚, j枚
    for (int i = 0; i <= N; i++)
    {
        for (int j = 0; j <= N - i; j++)
        {
            int a = 10000 * i;
            int b = 5000 * j;
            if (Y - a - b >= 0 && (Y - a - b) / 1000 == N - i - j)
            {
                cout << i << ' ' << j << ' ' << N - i - j << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())
a = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
for i in range(len(s)):
    k= a.index(s[i])
    s[i] = a[(k + n) % 26]
for k in s:
    print(k,end = "")


Measured memory_bytes: 43096
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

class UnionFindTree
{
private:
    int n;
    int groupNum;       // グループの数
    vector<int> parent; // 親ノード
    vector<int> rank;   // 木の高さの上限
    vector<int> num;    // グループの要素数
    int find(int i){
        if(parent[i] == i)
            return i;
        else
            return parent[i] = find(parent[i]);
    }
public:
    UnionFindTree(int n){ // コンストラクタ
        this->n = n;
        groupNum = n;
        parent.resize(n);
        for(int i=0; i<n; ++i)
            parent[i] = i;
        rank.assign(n, 0);
        num.assign(n, 1);
    }
    void unite(int a, int b){ // aとbのグループを併合
        if((a = find(a)) != (b = find(b))){
            if(rank[a] < rank[b]){
                parent[a] = b;
                num[b] += num[a];
            }
            else{
                parent[b] = a;
                if(rank[a] == rank[b])
                    ++ rank[a];
                num[a] += num[b];
            }
            -- groupNum;
        }
    }
    bool same(int a, int b){ // aとbのグループが同じかを調べる
        return find(a) == find(b);
    }
    int getNum(){ // グループの数を返す
        return groupNum;
    }
    int getNum(int a){ // aのグループの要素数を返す
        return num[find(a)];
    }
};

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

    UnionFindTree uft(n);
    for(int i=0; i<m; ++i){
        int x, y, z;
        cin >> x >> y >> z;
        -- x;
        -- y;
        uft.unite(x, y);
    }
    cout << uft.getNum() << endl;

    return 0;
}


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

int main(){
  int money;
  int happy_count_500=0, happy_count_5=0;
  
  cin >> money;
  
  happy_count_500 = money/500;
  happy_count_5 = (money - (500*happy_count_500))/5;
  
  cout << happy_count_500*1000 + happy_count_5*5 << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Console;

namespace a {
static class Extensions {
   public static int ToInt(this string str) {
      return int.Parse(str);
   }

   public static int[] readIntArr() {
      return ReadLine().Split(' ').Select(int.Parse).ToArray();
   }
}

class Program {
   public static void Main(string[] args) {
      var a = ReadLine().ToInt();
      var b = ReadLine().ToInt();
      var c = ReadLine().ToInt();
      var d = ReadLine().ToInt();
      var e = ReadLine().ToInt();
      var k = ReadLine().ToInt();

      if (e - a > k) {
         WriteLine(":(");
      }
      else {
         WriteLine("Yay!");
      }
   }
}

}


Measured memory_bytes: 11092
// B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<string>
using namespace std;

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

    cin >> s >> t;

   // cout << s[1] << endl;

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

    cout << ans << endl;


}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////

int main(){
    int n, m;
    cin>>n>>m;
    double x = (double)n / (double)100.0;
    double y = (double)m / (double)100.0;
    for(int i = 1; i<= 10000000;i++){
        int k = .08 * i;
        int k1 = 0.10 * i;
        if(k== n && m== k1){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<(-1)<<endl;
    return 0;
}

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

int main()
{
  string N;
  cin >> N;
  
  int num = N.size();
  
  int sum = 0;
  for(int i = num-1; i >= 0; i--){
    int kazu = N.at(i) - '0';
    sum += kazu;
  }
  if( (sum % 9) == 0 ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int main() {
    int N, K;
    cin >> N >> K;

    int ans = 0;

    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        if (x < K - x)
            ans += x;
        else
            ans += K - x;
        /* code */
    }
    cout << ans * 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
using namespace std;
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)
 
int a[200];
int chk(int n, int k){
    int ms = 0;
    rep(i,n-k+1){
        int p = 1;
        for(int j=i;j<i+k;j++){
            p *= a[j];
        }
        ms = max(ms, p);
    }
    return ms;
}
 
int main(){
    int n, k;
    while(cin>>n>>k && n){
        rep(i,n)cin>>a[i];
        int x = chk(n, k);
        int y=0;
        rep(i,n)rep(j,i){
            swap(a[i],a[j]);
            y = max(y,chk(n,k));
            swap(a[i],a[j]);
        }
        cout << y - x << endl;
    }
}

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

#define pb push_back

int main()
{
	int d;
	while (cin >> d, d)
	{
		int n, m;
		cin >> n >> m;

		vector<int> s;
		s.pb(0);
		for (int i=1; i<n; i++)
		{
			int tmp;
			cin >> tmp;
			s.pb(tmp);
		}
		s.pb(d);
		sort(s.begin(), s.end());

		int t;
		int ans = 0;
		while (m--)
		{
			cin >> t;

			vector<int>::iterator it = upper_bound(s.begin(), s.end(), t);
			ans += min(*it-t, t-*(it-1));
		}

		cout << ans << endl;
	}

	return 0;

}

Measured memory_bytes: 1428
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define gc getchar
#define pc putchar
#define fi first
#define queue QQQ
#define se second
#define debug(x) cout << #x" = " << x << endl;
#define pp(x,y) cout << "pp: " << x << " " << y << endl;
#define rank __RAnK
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
#define rd read
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
const int maxn = 5e5+233;
const int mod = 998244353;
int fac[maxn*4],inv[maxn*4];
int n,K;
int ans = 0;
inline int C(int n,int m){
	if(n<m) return 0;
//	printf("C{%d %d}\n",n,m);
	return 1ll * fac[n] * inv[m] % mod * inv[n-m] % mod;
}
inline int solve(int n,int m){
	return C(n+m,n);
}
inline int calc(int n,int m,int t){
	if(m-n>=t||t<=0) return 0;
	return ((solve(n,m) - solve(n+t,m-t)) + mod) % mod;
}
inline int qpow(int a,int b){
	int ans = 1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1) ans = 1ll * ans * a % mod;
	return ans;
}
void init(int n){
	fac[0] = 1;
	Rep(i,1,n) fac[i] = 1ll * fac[i-1] * i % mod;
	inv[n] = qpow(fac[n],mod-2);
	Dep(i,n-1,0) inv[i] = 1ll * inv[i+1] * (i+1) % mod;
}
int main(){
	init(2e6+10);
	n = rd(),K = rd(),ans = 0;
	for(int R=K,B=K-R;R>=B&&R>=0;--R,B=K-R){
		if(R==B)
			ans = (ans + calc(R,B-1,R-n+1)) % mod;
		else
			ans = (ans + calc(R,B,R-n+1)) % mod;
	}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 15872
#include <iostream>
using namespace std;
typedef long long ll;

int N;
/* dp[i][j][k]は  0~iまでj個とって合計kになる組み合わせ 0<=i<=N, 0<=j<=N 0<=k<=sum*/
ll dp[51][51][50*50+1];

int A;
int X[51];

ll rec(int i, int j, int k){
    if(i == N) {
        if(A*j ==k && k != 0) return 1;
        else return 0;
    }
    if(dp[i][j][k]!=-1) return dp[i][j][k];
    
    ll ret = 0;
    ret += rec(i+1, j+1, k+X[i]) + rec(i+1, j, k);
    
    return dp[i][j][k] = ret;
}

int main(void){
    // Your code here!
    cin >> N >> A;

    for(int i = 0; i < N; i++){
        cin >> X[i];
    }
    
    for(int i = 0; i <= 50; i++) for(int j = 0; j <= 50; j++) for(int k = 0; k <= 2500; k++) dp[i][j][k] = -1;
    ll ans = rec(0, 0, 0);
    cout << ans << endl;
    
}


Measured memory_bytes: 51072
import java.util.Scanner;

//A Popular Ice-cream Shop
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[] c = new int[10];
			while(n--!=0)c[sc.nextInt()]++;
			for(int i=0;i<10;i++){
				if(c[i]==0)System.out.print("-");
				else for(int j=0;j<c[i];j++)System.out.print("*");
				System.out.println();
			}
		}
	}
}

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

int p[10000], c[500], e[500];
int dp[501][10001];

int main() {
	int m, n; scanf("%d%d", &m, &n);
	rep(i, m)scanf("%d", &p[i + 1]);
	sort(p + 1, p + m + 1, greater<>());
	for (int i = 1; i <= m; i++)p[i] = p[i - 1] + p[i];
	rep(i, n)scanf("%d%d", &c[i], &e[i]);
	memset(dp, 0x3f, sizeof(dp));
	dp[0][0] = 0;
	rep(i, n)
		rep(j, m + 1)
			dp[i + 1][j] = min(dp[i][j], dp[i][j - min(j, c[i])] + e[i]);
	int Max = 0;
	rep(i, m + 1)Max = max(Max, p[i] - dp[n][i]);
	printf("%d\n", Max);
}

Measured memory_bytes: 22872
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
int inf=100000000;
ll INF=100000000000000000;

int main() {
    int n;
    cin >> n;
    for (int i=0;i<n;i++){
        vector<int> a(6);
        int y=0;
        set<int> s;
        rep(j,6) {
            cin >> a.at(j);
            s.insert(a.at(j));
        } 
        sort(a.begin(),a.end());
        if (a.at(0)==1 && a.at(5)==13){cout << "no" << endl;continue;}
        if (a.at(0)!=1 && a.at(5)!=13){cout << "yes" << endl;continue;}
        
        int mi=0,en=0;
        if (a.at(5)!=13) {
            int b=6,bb=8;
            while (true){
            auto e=s.find(bb),ee=s.find(b);
            if (ee!=s.end() && b>=1 ){b--;mi++;}
            else if (e!=s.end() && bb<=13) {bb++;mi++;}
            
            if (mi==6) {cout << "yes" << endl;break;}
            auto q=s.find(bb),qq=s.find(b);
            if (q==s.end() && bb<=13) {bb++;en++;}
            else if (qq==s.end() && b>=1) {b--;en++;}
            if (en==6) {cout << "no" << endl;break;}
            //cout << mi << " " << en  << " " << b << " " << bb << endl;
            }
        }
        if (a.at(5)==13) {
            int bb=6,b=8;
            while (true){
            auto ee=s.find(bb),e=s.find(b);
            
            if (e!=s.end()) {b++;mi++;}
            else if (ee!=s.end()){bb--;mi++;}
            
            if (mi==6) {cout << "yes" << endl;break;}
            auto qq=s.find(bb),q=s.find(b);
            
            if (qq==s.end() && b>=1) {bb--;en++;}
            else if (q==s.end() && b<=13) {b++;en++;}
            if (en==6) {cout << "no" << endl;break;}
            //cout << mi << " " << en  << " " << b << " " << bb << endl;
            }
        }
}
}



Measured memory_bytes: 3160
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please



char iremono[12001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N;
	scanf("%d ", &N);
	char* S = iremono + 4000;
	fread(S, 1, N, stdin);

	int R[4010], G[4010], B[4010];
	int r = 0, g = 0, b = 0;
	rep(i, N) {
		if (S[i] == 'R') R[r++] = i;
		if (S[i] == 'G') G[g++] = i;
		if (S[i] == 'B') B[b++] = i;
	}

	ll kotae = ll(r) * g * b;

	if (b > g && b > r) {
		for (auto i = R; i - R < r; i++) for (auto j = G; j - G < g; j++) {
			kotae -= (S[*i * 2 - *j] == 'B');
			kotae -= (S[*j * 2 - *i] == 'B');
			kotae -= (!(*i + *j & 1) && S[*i + *j >> 1] == 'B');
		}
	}
	else if (g > r && g > b) {
		for (auto i = R; i - R < r; i++) for (auto j = B; j - B < b; j++) {
			kotae -= (S[*i * 2 - *j] == 'G');
			kotae -= (S[*j * 2 - *i] == 'G');
			kotae -= (!(*i + *j & 1) && S[*i + *j >> 1] == 'G');
		}
	}
	else {
		for (auto i = G; i - G < g; i++) for (auto j = B; j - B < b; j++) {
			kotae -= (S[*i * 2 - *j] == 'R');
			kotae -= (S[*j * 2 - *i] == 'R');
			kotae -= (!(*i + *j & 1) && S[*i + *j >> 1] == 'R');
		}
	}

	printf("%lld\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 1756
k, a, b = map(int, input().split())
if b - a <= 2:
    print(1 + k)
else:
    if k > a:
        d = (k - a + 1) // 2
        m = (k - a + 1) % 2
        print(max(a + (b - a) * d + m, k + 1))
    else:
        print(k + 1)

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

int main()
{
	int N;
	scanf("%d", &N);
	int count = 0;
	int *a = malloc((1 + N) * sizeof(int));
	for (int i = 1; i <= N; i++)
	{
		scanf("%d", &a[i]);
		if (i % 2 == 1 && a[i] % 2 == 1)
			count++;
	}
	printf("%d\n", count);

	return (0);
}



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

using namespace std;
int main()
{
    unsigned long long h;
    cin >> h;
    int b = 0;
    while(h)
    {
        h /= 2;
        b++;
    }
    unsigned long long ans = 1;
    for (int i = 0; i < b; i++)
    {
        ans *= 2;
    }
    cout << ans - 1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

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

    if (b == 0) return a;
    return gcd(b, a%b);
}

int main() {
    ll N, X;
    ll x[100001];
    cin>>N>>X;
    REP(i, 0, N) cin>>x[i];

    sort(x, x+N);
    ll ans=abs(X-x[0]);
    REP(i, 0, N-1){
        ans=gcd(x[i+1]-x[i], ans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+5;
 
 
int pa[N];
int n,m;
 
ll szz[N];
ll ans[N];
struct edge{
    int u,v;
}edges[N];
 
int find(int x){
    if(pa[x]==x) return pa[x];
    else{
        pa[x]=find(pa[x]);
        return pa[x];
    }
 
}
 
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    int a,b;
    
    for(int i=1;i<=m;++i){
        cin>>edges[i].u>>edges[i].v;
 
    }
    //cout<<"hre"<<endl;
    
    for(int i=1;i<=n;++i){
        //raank[i]=0;
        pa[i]=i;
        szz[i]=1;
    }
    ans[m]=(ll)n*(ll)(n-1)/(ll)2;
    //cout<<"herew   df  "<<endl;
    for(int i=m;i>=1;--i){
 
          a=find(edges[i].u);
          b=find(edges[i].v);
          
 //        cout << a << " " << b << "\n";
          if(a==b){
               ans[i-1]=ans[i];
          }
          else{
               ans[i-1]=ans[i]-(szz[a]*szz[b]);
               szz[a]+=szz[b];
               pa[b]=a;
          }
          //cout<<szz[a]<<endl;
     
 
 
     }
     for(int i=1;i<=m;i++) 
         cout<<ans[i]<<"\n";
      
    
     return 0;
}

Measured memory_bytes: 4096
S = input()
temp = 1
result = 0
for i in S:
    if (temp % 2 == 0):
        if (i == "R"):
            result = 1
    else:
        if (i == "L"):
            result = 1
    temp += 1

if (result == 1):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int i,j,n,y;
	cin>>n;
	string w[n];
	for(i=0;i<n;i++)
	{
		cin>>w[i];
	}
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(w[i]==w[j])
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	for(i=1;i<n;i++)
	{
		y=w[i-1].size();
		if(w[i][0]!=w[i-1][y-1])
		{
			cout<<"No"<<endl;
			return 0;
		}
		
	}
	cout<<"Yes"<<endl;
	
}

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

int main()
{
    int N, M, C, times = 0, result = 0;
    cin >> N >> M >> C;
    int B[M];
    int A[N][M];

    for(int i = 0; i < M; i++)
    {
        int BM;
        cin >> BM;
        B[i] = BM;
    }

    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < M; j++)
        {
            int AM;
            cin >> AM;
            A[i][j] = AM;
        }
    }

    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < M; j++)
        {
            result += A[i][j] * B[j];
        }

        if(result + C > 0)
        {
            times += 1;
        }
        result = 0;
    }

    cout << times << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
     List<string> s1 = Console.ReadLine().ToList().ConvertAll(x => x.ToString());
     List<string> s2 = Console.ReadLine().ToList().ConvertAll(x => x.ToString());
     //Console.WriteLine(string.Join(" ",s2));
     s2.Reverse();
     //Console.WriteLine(string.Join(" ",s2));
     if (string.Join(" ",s1)==string.Join(" ",s2))
     {
       Console.WriteLine("YES");
     }
     else
     {
       Console.WriteLine("NO");
     }
      
    }
}


Measured memory_bytes: 26400
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int a,b,c,k;
  cin>>a>>b>>c>>k;
  long long int sum = 0;
  if(k!=0){
    if(a<=k){
      k=k-a;
      sum += a*1;
    }
    else{
      long long int  d = k;
      k-=d;
      sum+= d*1;
    }
  }
  if(k!=0){
    if(b<=k){
      k-=b;
    }
    else{
      long long int  d = k;
      k-=d;
    }
  }
  if(k!=0){
    if(c<=k){
      k-=c;
      sum-= c;
    }
    else{
      long long int  d = k;
      k-=d;
      sum-= d;
    }
  }
  cout<<sum<<endl;

}


Measured memory_bytes: 3584
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
ll h[100000];
ll dp[100000];
int main() {
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> h[i];
	fill(dp, dp + N, 1LL << 60);
	dp[0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 1; j <= K; j++) {
			if (i + j >= N) break;
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}
	cout << dp[N - 1] << endl;
}


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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

int pre[MAX_N];
long long d[MAX_N];
bool seen[MAX_N];
struct Edge {
    int to;
    long long cost;
};
// require: cost value is positive
// O(nlog|v|)
void dijkstra(int s, vector<vector<Edge>> &graph) {
    fill(pre, pre + MAX_N, -1);
    fill(seen, seen + MAX_N, false);
    fill(d, d + MAX_N, INF);

    auto comPair = [](const P one, const P two) {
        return one.second > two.second;
    };
    // que(v, distance)
    priority_queue<P, vector<P>, decltype(comPair)> que(comPair);
    que.emplace(0, 0);
    d[0] = 0;
    seen[0] = true;

    while (!que.empty()) {
        int u = que.top().first;
        que.pop();

        for (auto e : graph[u]) {
            int v = e.to;
            int c = e.cost;

            if (not seen[v] and d[v] > d[u] + c) {
                d[v] = d[u] + c;
                pre[v] = u;
                que.emplace(v, d[v]);
            }
        }
        seen[u] = true;
    }
};

int main() {
    int n;
    cin >> n;
    vector<vector<Edge>> graph(n);
    int k;
    rep(i, n) {
        cin >> k;
        cin >> k;
        rep(j, k) {
            Edge e;
            cin >> e.to >> e.cost;
            graph[i].push_back(e);
        }
    }
    dijkstra(0, graph);
    rep(i, n) {
        cout << i << ' ' << d[i] << endl;
    }
}



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

int main(){
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    int i;
    for(i = 0; i < n; i++){
        bool flag = true;
        for(int j = i; j < n; j++){
            if(s[j] != t[j-i]) flag = false;
        }
        if(flag) break;
    }
    cout << n + i << endl;
    return 0;
}

Measured memory_bytes: 3564
#include<cstdio>
#include<cmath>
using namespace std;
const double eps=1e-10;
#define equals(a,b) (fabs((a)-(b))<eps)
int n;
double cx,cy,r;
struct point{
    double x,y;
    point(double x=0,double y=0):x(x),y(y){}
    point operator +(point a){
        return point(x+a.x,y+a.y);
    }
    point operator -(point a){
        return point(x-a.x,y-a.y);
    }
    point operator *(double a){
        return point(x*a,y*a);
    }
    point operator /(double a){
        return point(x/a,y/a);
    }
    void print(){
        printf("%.10lf %.10lf",x,y);
    }
};
typedef point vector;
double norm(vector a){
    return a.x*a.x+a.y*a.y;
}
double abs(vector a){
    return sqrt(norm(a));
}
double cross(vector a,vector b){
    return a.x*b.y-a.y*b.x;
}
double dot(vector a,vector b){
    return a.x*b.x+a.y*b.y;
}
struct segment{
    point p1,p2,base,e;
    segment(point a,point b){
        p1=a,p2=b,base=b-a;
        e=base/abs(base);
    }
};
typedef segment line;
struct circle{
    point c;
    double r;
    circle(point a=point(),double b=0){
        c=a,r=b;
    }
}c;
double d_pl(line l,point p){
    return abs(cross(p-l.p1,l.base))/abs(l.base);
}
point project(line l,point p){
    double t=dot(p-l.p1,l.base)/abs(l.base);
    return l.p1+l.e*t;
}
void print(point p1,point p2){
    p1.print();
    printf(" ");
    p2.print();
    printf("\n");
}
void cp(circle c,line l){
    double dis=d_pl(l,c.c);
    if(dis>c.r){
        printf("no!!");
        return;
    }
    point pr=project(l,c.c);
    double t=sqrt(c.r*c.r-dis*dis);
    point p1=pr+l.e*t,p2=pr-l.e*t;
    if(p1.x<p2.x) print(p1,p2);
    else if(equals(p1.x,p2.x)&&p1.y<p2.y) print(p1,p2);
    else print(p2,p1);
}
int main(){
    scanf("%lf%lf%lf",&cx,&cy,&r);
    c=circle(point(cx,cy),r);
    scanf("%d",&n);
    double x1,y1,x2,y2;
    for(int i=1;i<=n;++i){
        scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
        cp(c,segment(point(x1,y1),point(x2,y2)));
    }
    return 0;
}


Measured memory_bytes: 2736
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>

using namespace std;


int main() {
	long long int N, T,t,ans = 0,b;
	cin >> N >> T;
	cin >> b;
	
	for (int i = 1; i < N;i++) {
		cin >> t;
		if (t - b > T) {
			ans += T;
		}
		else {
			ans += t - b;
		}
		b = t;
	}
	ans += T;

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

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

using namespace std;

long long n, W, v[107], w[107], dp[107][100007];

int main() {
	cin >> n >> W;
	for ( int i = 1; i <= n; i++ ) {
		cin >> w[i] >> v[i];
	}
	for ( int i = 1; i <= n; i++ ) {
		for ( int j = 0; j <= W; j++ ) {
			dp[i][j] = dp[i - 1][j];
			if ( j >= w[i] ) {
				dp[i][j] = max( dp[i][j], dp[i - 1][j - w[i]] + v[i] );
			}
		}
	}
	cout << dp[n][W];
}

Measured memory_bytes: 79360
from operator import add, mul, sub, or_


class SegmentTree:
    '''
    1-indexd セグメント木
    values : 値の配列
    op : 区間に対する関数
    ie : 初期値
    '''

    def __init__(self, values, op, ie):
        self.values = values
        vlen = len(values)
        self.op = op
        self.size = 2 ** (vlen-1).bit_length()
        self.tree = [ie]*self.size + self.values + [ie]*(self.size-vlen)
        self.ie = ie

        for i in range(self.size-1, 0, -1):
            self.tree[i] = self.op(self.tree[i*2], self.tree[i*2+1])

    def update(self, i, v):
        i += self.size
        self.tree[i] = v
        while i > 0:
            i //= 2
            self.tree[i] = self.op(self.tree[i*2], self.tree[i*2+1])

    def query(self, l, r):
        l += self.size
        r += self.size
        ret = self.ie
        while l < r:
            if l & 1:
                ret = self.op(ret, self.tree[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.op(ret, self.tree[r])
            l //= 2
            r //= 2
        return ret


def bit(c):
    return 1 << (ord(c)-ord('a'))


def bitcount(c):
    b = bin(c)[2:]
    return b.count("1")


N = int(input())
s = input().strip()
Q = int(input())

seg = SegmentTree([bit(c) for c in s], or_, 0)
for q in range(Q):
    i, l, r = input().split()
    if i == "1":
        l = int(l)-1
        seg.update(l, bit(r))
    else:
        l = int(l)-1
        r = int(r)-1
        v = seg.query(l, r+1)
        print(bitcount(v))


Measured memory_bytes: 91808
def main():
    k = int(input())
    tmp = 7
    mul = 1
    p = 1
    while p < 10**7 and tmp % k != 0:
        mul *= 10
        tmp += 7 * mul
        mul %= k
        tmp %= k
        p += 1
    if tmp % k == 0:
        print(p)
    else:
        print(-1)

if __name__ == "__main__":
    main()

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

int main() {
  int N = 0, A = 0, B = 0;

  cin >> N >> A >> B;
  
  int P1 = A * N;
  int P2 = B;
  
  if( P1 < P2 )
	cout << P1 << endl;
  else
    cout << P2 << endl;
}

Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'

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

  int n; cin >> n;
  int64 a[n], b[n]; 
  rep(i, n) {
    cin >> a[i];
    if (a[i] >= 0) b[i] = a[i];
    else b[i] = -1 * a[i];
  }

  sort(b, b + n);

  int neg = 0;
  int num0 = 0;
  rep(i, n){
    if (a[i] == 0) ++num0;
    else if (a[i] < 0) ++neg;
  }

  if ((num0 + neg) % 2 == 1 && neg & 1) print(accumulate(b + 1, b + n, int64()) - b[0]);
  else print(accumulate(b, b + n, int64()));

  return 0;
}

Measured memory_bytes: 1792
package main

import "fmt"

func sub(x, y int) int {
	if y == 1 {
		return x
	}

	return (x - 1) * sub(x, y - 1)
}

func main() {
	var x, y int
	fmt.Scan(&x)
	fmt.Scan(&y)

	fmt.Println(sub(y, x))
}


Measured memory_bytes: 640
N = int(input())
ans = 1000000
for i in range(1, N+1):
    A = i
    B = N - i
    if A <= B:
        Asum = sum(map(int, str(A)))
        Bsum = sum(map(int, str(B)))
        if ans > (Asum + Bsum):
            ans = Asum + Bsum
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using G = vector<vector<int>>;
    
int main(){
    ll x, k, d;
    cin >> x >> k >> d;
    if(x<0) x *= -1;
    ll move;
    ll ans = 0;
    move = x / d;
    if(k<=move) ans = x - k * d;
    else{
        ll r = x - d * move;
        ll l = -1 * (x-d*(move+1));
        ll last = k - move - 1;
        if(last%2) ans = r;
        else ans = l;

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

Measured memory_bytes: 3672
l = int(input())
bits = []
x = l
while(x>0):
    bits.append(x%2)
    x //= 2

ans = []
n = len(bits)
for i in range(1,n):
    ans.append('{} {} {}'.format(i,i+1,0))
    ans.append('{} {} {}'.format(i,i+1,2**(n-i-1)))

base = 2**(n-1)
for i,bi in enumerate(bits[:-1]):
    if(bi==1):
        ans.append('{} {} {}'.format(1,n-i,base))
        base += 2**i

print('{} {}'.format(n,len(ans)))
print('\n'.join(ans))

Measured memory_bytes: 61792
#include<iostream>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x;
    cin>>x;
    if(x>=30)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


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

int N, M, X, Y, Z;
bool war;

int main(void) {
	cin >> N >> M >> X >> Y;
	vector<int> x(N);
	vector<int> y(M);
	for (int i = 0; i < N; i++) {
		cin >> x.at(i);
	}
	for (int i = 0; i < M; i++) {
		cin >> y.at(i);
	}
	for (int i = 0; i < M; i++) {
		war = false;
		Z = y.at(i);
		if (Z <= X || Z > Y) {
			war = true;
		}
		for (int j = 0; j < N; j++) {
			if (Z <= x.at(j)) {
				war = true;
			}
		}
		for (int j = 0; j < M; j++) {
			if (Z > y.at(j)) {
				war = true;
			}
		}
		if (war == false) {
			break;
		}
	}

	war == false ? cout << "No War" : cout << "War";
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 10**9 + 7
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    n, k = LI()

    dp = [[0] * (k + 1) for _ in range(n + 1)]
    dp[0][0] = 1

    for i in range(n):
        for j in range(k):
            dp[i+1][j+1] = dp[i][j] + (j + 1) * dp[i][j+1]
            dp[i+1][j+1] %= MOD

    ans = 0
    for i in range(k + 1):
        ans += dp[n][i]
        ans %= MOD

    print(ans)

if __name__ == '__main__':
    resolve()



Measured memory_bytes: 30452
W,H,N = map(int,input().split())

CoordinateList = []
for i in range(N):
    x,y,a = map(int, input().split())
    CoordinateList.append([x,y,a])

# raw White & Black
AllArea = []
for numline in range(H):
    rawWhite = []
    rawBlack = []
    for numraw in range(W):
        rawWhite.append("W")
        rawBlack.append("B")
    AllArea.append(rawWhite)

# coloring from white to Black
for n in range(N):
    if CoordinateList[n][2] == 1:
        if CoordinateList[n][0] == 0:
             pass
        else:
            for i in range(H):
                del AllArea[i][:(CoordinateList[n][0])]
                for numX in range(CoordinateList[n][0]):
                    AllArea[i].insert(0,"B")

    elif CoordinateList[n][2] == 2:
        if CoordinateList[n][0] == 0:
            print(0)
            exit()
        else:
            for i in range(H):
                del AllArea[i][(CoordinateList[n][0]):]
                for numX in range(CoordinateList[n][0]):
                    AllArea[i].append("B")

    elif CoordinateList[n][2] == 3:
        changeY = H - int(CoordinateList[n][1])
        if changeY == 0:
            print(0)
            exit()
        else:
            del AllArea[changeY:]
            
            for changeRaw in range(int(CoordinateList[n][1])):
                AllArea.append(rawBlack)
            

    elif CoordinateList[n][2] == 4:
        changeY = H - int(CoordinateList[n][1]) 
        if changeY == 0:
            pass
        else:
            del AllArea[:changeY]
            for changeRaw in range(changeY):
                AllArea.insert(0,rawBlack)
            
# counting 
AreaWhite = 0
for i in range(H):
    AreaWhite += AllArea[i].count("W")

print(AreaWhite)

Measured memory_bytes: 3316
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()
//X.order_of_key()
int main()
{
fast;
    string s;
    cin>>s;
    if(s=="ABC")
        cout<<"ARC";
    else
        cout<<"ABC";
    return 0;
}

Measured memory_bytes: 3640
N = int(input())
x_list = [0]
y_list = [0]
t_list = [0]

for i in range(N):
	t,x,y = map(int, input().split( ))
	t_list.append(t)
	x_list.append(x)
	y_list.append(y)

ans = 'Yes'

for i in range(N):
	t_d = t_list[i+1] - t_list[i]
	x_d = abs(x_list[i+1] - x_list[i])
	y_d = abs(y_list[i+1] - y_list[i])
	xy_d = x_d + y_d
	if xy_d > t_d:
		ans = 'No'
		break
	else:
		if xy_d % 2 != t_d % 2:
			ans = 'No'
			break
print(ans)


Measured memory_bytes: 11764
#include <iostream>
#define _for(i,n) for(int i = 0; i < n; i++)

using namespace std;


int main() {
    int n;
    string s;
    cin >> n >> s;
    int a[n];
    int b[n];
    a[0] = (s[0]=='#');
    b[n-1] = (s[n-1]=='.');
    for (int i = 1;i<n;i++) {
        a[i] = a[i-1] + (s[i]=='#');
        b[n-i-1] = b[n-i] + (s[n-i-1]=='.');
    }
    int changemin = n;
    for(int i = 0;i<n;i++) {
        changemin = min(changemin,a[i]+b[i]-1);
    }
    cout << changemin << endl;
    return 0;
}


Measured memory_bytes: 2180
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
    int N;
    cin >> N;
    string S,T;
    cin >> S >> T;
    string A = "";
    for (int i = 0; i<N; ++i){
        A = A + S[i]+ T[i];
    }
    cout << A;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() { 
    int res = 0x3f3f3f3f;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        int r = 0;
        while (a % 2 == 0) {
            r++;
            a /= 2;
        }
        res = min(res, r);
    }
    cout << res << endl;
}




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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, q;
	cin >> n >> q;
	vvl adj(n);
	FOR(i,1,n) {
		ll a, b;
		cin >> a >> b;
		a--, b--;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	vl sum(n);
	while (q--) {
		ll p, x;
		cin >> p >> x;
		sum[p-1] += x;
	}
	
	function<void(ll,ll)> dfs = [&](ll i, ll p) {
		for (ll j: adj[i]) if (j != p) {
			sum[j] += sum[i];
			dfs(j,i);
		}
	};
	dfs(0,-1);
	
	FOR(i,0,n) cout << sum[i] << " ";
	cout << endl;

}



Measured memory_bytes: 30592
a=input().split()

if a[0]=="A":
    x=10
elif a[0]=="B":
    x=11
elif a[0]=="C":
    x=12
elif a[0]=="D":
    x=13
elif a[0]=="E":
    x=14
elif a[0]=="F":
    x=15

if a[1]=="A":
    y=10
elif a[1]=="B":
    y=11
elif a[1]=="C":
    y=12
elif a[1]=="D":
    y=13
elif a[1]=="E":
    y=14
elif a[1]=="F":
    y=15

if x<y:
    print("<")
elif x>y:
    print(">")
else:
    print("=")
    




Measured memory_bytes: 3064
n, k = map(int, input().split())
a = list(map(int, input().split()))

for _ in range(k):
    tmp = [0] * (n + 1)
    for i in range(n):
        tmp[max(0, i - a[i])] += 1
        tmp[min(n, i + a[i] + 1)] -= 1
    for i in range(n):
        a[i] = tmp[i]
        tmp[i + 1] += tmp[i]
    if min(a) == n:
        break

print('\n'.join(map(str, a)))


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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

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

  --x; --y;
  vector<int> ans(n);
  rep(sv, n) {
    vector<int> dist(n, INF);
    queue<int> q;
    auto push = [&](int v, int d) {
		  if (dist[v] != INF) return;
		  dist[v] = d;
		  q.push(v);
		};
    push(sv, 0);
    while (!q.empty()) {
      int v = q.front(); q.pop();
      int d = dist[v];
      if (v-1 >= 0) push(v-1, d+1);
      if (v+1 < n) push(v+1, d+1);
      if (v == x) push(y, d+1);
      if (v == y) push(x, d+1);
    }
    rep(i, n) ans[dist[i]]++;
  }
  rep(i,n) ans[i] /= 2;
  for (int i=1; i<n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256