akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back

using namespace std;
typedef pair<int,int> Pair;
typedef long double ld;
typedef long long ll;

const int mod = 1e9, MAX = 1e9, N = 200005;
const long double Pi = 3.14159265358979323846l;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; };
inline void inc(int &x, int y) { x += y; x -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		x = mul(x, x), y >>= 1;
	} return ans;
}

template <class T> inline T	input() {
	T x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

template <class T> inline bool chkmin(T &x, T y) { x = x < y ? x : y; return x == y; }
template <class T> inline bool chkmax(T &x, T y) { x = x > y ? x : y; return x == y; }
template <class T> inline T gcd(T x, T y) { return !y ? x : gcd(y, x % y); }
template <class T> inline T sqrm(T x) { return (ll) x * x % mod; }
template <class T> inline T sqr(T x) { return x * x; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

struct BIT {
	int Max[MAX + 5];
	void modify(int pos, int val) {
		for (int i = pos; i <= MAX; i += i & -i)
			chkmax(Max[i], val);
	}
	int query(int pos) {
		if (!pos) return 0;
		if (pos < 0) return -inf;
		int res = 0;
		for (int i = pos; i; i ^= i & -i)
			chkmax(res, Max[i]);
		return res;
	}
};

int n, k, s, i;
int a[N];

signed main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	freopen("log", "w", stderr);
#endif
	ios::sync_with_stdio(false);

	cin >> n >> k >> s;
	for (i = 1; i <= k; ++i) a[i] = s;
	for (; i <= n; ++i) a[i] = s == MAX ? 1 : MAX;
	for (i = 1; i <= n; ++i) printf("%d ", a[i]);
	puts("");
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "First" << endl; else cout << "Second" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}

#define N0 300
double dp[N0 + 1][N0 + 1][N0 + 1];
signed main(){

    int N; cin >> N;
    vec a(N); readv(a);

    dp[0][0][0] = 0.0;
    FOR(n, 1, N + 1){
        REP(k, n + 1){
            REP(j, n + 1 - k){
                int i = n - j - k;
                double tmp = (double)N / n;
                if(i > 0) tmp += (double)i / n * dp[i - 1][j][k];
                if(j > 0) tmp += (double)j / n * dp[i + 1][j - 1][k];
                if(k > 0) tmp += (double)k / n * dp[i][j + 1][k - 1];
                dp[i][j][k] = tmp;
            }
        }
    }
    int c[3] = {0, 0, 0};
    REP(i, N) c[a[i] - 1]++;
    cout << setprecision(15) << dp[c[0]][c[1]][c[2]];
    
    return 0;
}

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

//bubbleSort????????????????°????????????????????????????????????\?????????????????????
int bubbleSort(int A[],int N){
	int sw=0;
	bool flag=1;
	for(int i=0;flag/*??????????´????flag?????????*/;i++){
	flag=0;//?????????
	for (int j=N-1;j>=i+1;j--){
		if(A[j]<A[j-1]){
			swap(A[j],A[j-1]);
			flag=1;
			sw++;
		}
	}
	}
	return sw;
}

int main(){
	int A[100],N,sw;
	cin>>N;
	for(int i=0;i<N;i++)cin >> A[i];

		sw=bubbleSort(A,N);

	for(int i=0;i<N;i++){
		if(i)cout << " ";
		cout << A[i];

	}
	cout <<endl;
	cout << sw << endl;
	return 0;

}

Measured memory_bytes: 3080
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

def f(a,b):
  return a*b//math.gcd(a,b)

ans = 1
n = readInt()
for j in [readInt() for i in range(n)]:
  ans = f(ans,j)

print(ans)

Measured memory_bytes: 9476
import fractions
n, x = map(int, input().split())
list_X = list(map(int, input().split()))
list_Y = []

for c in list_X:
    list_Y.append(abs(c-x))

ans = list_Y[0]

for i in range(1, n):
    ans = fractions.gcd(ans, list_Y[i])

print(ans)

Measured memory_bytes: 16280
from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
from math import *
from collections import defaultdict as dd, deque
def data(): return sys.stdin.readline().strip()
def mdata(): return map(int, data().split())
#def print(x): return sys.stdout.write(str(x)+'\n')
#sys.setrecursionlimit(100000)
mod=int(1e9+7)

n,k=mdata()
n=n%k
print(min(n,k-n))

Measured memory_bytes: 3444
import collections
x = []
for xx in range(3):
    aa, bb = (int(i) for i in input().split()) 
    x.append(aa)
    x.append(bb)

c = collections.Counter(x)
cc = c.most_common()

if cc[0][1] == 2 and cc[1][1] == 2 and cc[2][1] == 1 and cc[3][1] == 1 :
    print("YES")
else:
    print("NO")


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

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


int main(){
    int N,K;
    cin>>N>>K;
    K++;
    int h[N];
    int dp[N];
    for(int i=0;i<N;i++){
        cin>>h[i];
        dp[i]=INT_MAX;
    }
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=0;i<N;i++){
        for(int j=1;j<K;j++){
            if(i+j>=N){
                break;
            }
            chmin(dp[i+j],abs(h[i+j]-h[i])+dp[i]);

        }
    }
    
    cout << dp[N-1];
    return 0;
}

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



using namespace std;



int main(){



  int tmp;

  int ans;

  for(int i = 0; i < 5; i++){

    cin >> tmp;

    if(tmp == 0){

      ans = i + 1;

    }



  }

  cin.ignore();

  

  cout << ans << endl;



  return 0;

}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define fastio (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long int;
using namespace std;

int main() {
    fastio;
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s == "abc")
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define LL long long
#define MAXN (200000 + 5)
#define MAXL (32 + 5)
using namespace std;
LL n, a[MAXN], b[MAXN], ak[MAXL][MAXN], bk[MAXL][MAXN], k = 30, ans[MAXL];
int main()
{
//	freopen("in.in", "r", stdin);
	scanf("%lld", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", &a[i]);
		for (int j = 1; j <= k; j++)
			ak[j][i] = a[i] & ((1 << j) - 1);
	}
	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", &b[i]);
		for (int j = 1; j <= k; j++)
			bk[j][i] = b[i] & ((1 << j) - 1);
	}
	for (int i = 1; i <= k; i++)
		sort(bk[i] + 1, bk[i] + n + 1), sort(ak[i] + 1, ak[i] + n + 1);
	/*for (int i = 1; i <= k; i++)
	{
		for (int j = 1; j <= n; j++)
			printf("%d ", ak[i][j]);
		puts("");
	}
	for (int i = 1; i <= k; i++)
	{
		for (int j = 1; j <= n; j++)
			printf("%d ", bk[i][j]);
		puts("");
	}*/
	for (int i = 1; i <= n; i++) // ai + bj >= (1 << (k - 1)) && ai + bj < (1 << (k))
	{
		for (int j = 1; j <= k; j++)
		{
			int to = upper_bound(bk[j] + 1, bk[j] + n + 1, (1 << j) - ak[j][i] - 1) - bk[j];
			int to1 = upper_bound(bk[j] + 1, bk[j] + n + 1, (1 << (j + 1)) - 1 - ak[j][i]) - bk[j];
			int from = lower_bound(bk[j] + 1, bk[j] + n + 1, (1 <<(j - 1)) - ak[j][i]) - bk[j];
			int from1 = lower_bound(bk[j] + 1, bk[j] + n + 1, (1 << j) + (1 << (j - 1)) - ak[j][i]) - bk[j];
			ans[j] += to - from + to1 - from1;
		}
	}
	LL outp = 0;
	for (int i = 1; i <= k; i++)
		outp += (ans[i] & 1) << (i - 1);
	printf("%lld", outp);
	return 0;
}

/*
2
1 2
3 4
*/

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 10007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  int N; cin>>N;
  vector<ll> A(N+1);
  rep1(i,N)cin>>A.at(i);
  ll res = 0;
  ll tmp = 0;
  for(int i = 1; i <= N; i++){
    tmp += A.at(i);
      //cout<<tmp<<endl;
    if(i!=N&&A.at(i)==0){
      res+=tmp/2;
      tmp = 0;
    }
  }
  res+=tmp/2;
  cout<<res<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define lld long long int
#define str string

//????????§??¶????????????()
using namespace std;

lld n,a[110],memo[1000][1000];

lld mas(int kaisu,int goukei){
    //?????¢????????????????????????????????????
    if(kaisu<101 && goukei>-1 && goukei<21 && memo[kaisu][goukei])return memo[kaisu][goukei];
    //????¨??????£?????????????????????
    if(kaisu==n-1&&goukei==a[n-1])return 1;
    //????¨?????¨??????§???????????????????????????
    if(kaisu==n-1||goukei<0||goukei>20)return 0;
    //return ??????????????????
    return memo[kaisu][goukei]=mas(kaisu+1,goukei+a[kaisu])+mas(kaisu+1,goukei-a[kaisu]);
}
int main(){
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> a[i];
    cout << mas(1,a[0]) << endl;
return 0;
}

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

int main() {

    char c;
    cin >> c;

    if( c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' )
        cout << "vowel" << endl;
    else
        cout << "consonant" << endl;
    
}

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

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

    int n;
    cin >> n;
    int cnt[110] = {};
    for (int i = 2; i <= n; i++)
    {
        int num = i;
        for (int j = 2; j < 100; j++)
        {
            while (num % j == 0)
            {
                cnt[j]++;
                num /= j;
            }
        }
    }
    long long ans = 0;
    for (int i = 0; i < 100; i++)
    {
        if (cnt[i] >= 74)
            ans++;
    }
    for (int i = 0; i < 100; i++)
    {
        if (cnt[i] >= 24)
        {
            for (int j = 0; j < 100; j++)
            {
                if (i != j && cnt[j] >= 2)
                    ans++;
            }
        }
    }
    for (int i = 0; i < 100; i++)
    {
        if (cnt[i] >= 14)
        {
            for (int j = 0; j < 100; j++)
            {
                if (i != j && cnt[j] >= 4)
                    ans++;
            }
        }
    }
    for (int i = 0; i < 100; i++)
    {
        if (cnt[i] < 4)
            continue;
        for (int j = i + 1; j < 100; j++)
        {
            if (j == i || cnt[j] < 4)
                continue;
            for (int k = 0; k < 100; k++)
            {
                if (k != i && k != j && cnt[k] >= 2)
                    ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int main(){
    int S; cin >> S;
    vector<int> V;
    int x = S;
    while(find(V.begin(), V.end(), x)==V.end()){
        V.push_back(x);
        if(x%2) x = 3 * x + 1;
        else x/=2;
    }
    cout << V.size()+1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)			(x).begin(),(x).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF				(int)2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))	
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)	
#define FloorN(x, n)	((x)-(x)%(n))			
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long			ll;
typedef unsigned long long	ull;
typedef pair<ll, ll>		P;
typedef vector<ll>			VLL;
typedef vector<VLL>			VVLL;
typedef vector<VVLL>		VVVLL;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	int N;
	string S;
	cin >> N >> S;
	int ans = 0;
	REP(i, S.size()) {
		if (S.compare(i, 3, "ABC") == 0) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import copy


def repeat(pattern, before, n):
    for i in range(before, M + 1):
        new_pattern = copy.copy(pattern)
        new_pattern.append(i)
        if n != N - 1:
            repeat(new_pattern, i, n + 1)
        else:
            P.append(new_pattern)


N, M, Q = [int(i) for i in input().split()]

combination = []
for _ in range(Q):
    combination.append([int(i) for i in input().split()])

P = []
for i in range(1, M + 1):
    repeat([i], i, 1)

a_max = 0
for p in P:
    a = 0
    for c in combination:
        if p[c[1] - 1] - p[c[0] - 1] == c[2]:
            a += c[3]
    if a_max <= a:
        a_max = a
print(a_max)


Measured memory_bytes: 29028
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
typedef long long li;

const int maxn = 2e5;

int n;
li a[maxn + 1];

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", a + i + 1);
    a[i + 1] += a[i];
  }
  map<li, int> sth;
  for (int i = 0; i <= n; ++i) sth[a[i]] += 1;

  li ans = 0;
  for (auto x : sth) {
    ans += (li)x.second * (x.second - 1) / 2;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 14336
using System;

namespace AtCoder {
    class Program {
        static void Main() {
            string input = Console.ReadLine();

            long s_count   = long.Parse(input.Split(' ')[0]);
            long c_count   = long.Parse(input.Split(' ')[1]);
            long scc_count = Math.Min(s_count, c_count / 2);
            s_count -= scc_count;
            c_count -= scc_count * 2;
            scc_count += c_count / 4;

            Console.WriteLine(scc_count);
        }
    }
}

Measured memory_bytes: 11220
main = getLine >>= putStrLn . solve . map read . words

solve :: [Int] -> String
solve (w:h:x:y:r:[])
    | (x + r) <= w && (x - r) >=0 &&
      (y + r) <= h && (y - r) >=0 = "Yes"
    | otherwise = "No"


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int vis[1000006];
vector<int>pr;
void sieve()
{
    for(int i=2;i<=1000000;i++)
    {
        if(vis[i]==0)
        {
            pr.push_back(i);
            for(int j=i+i;j<=1000000;j+=i)
                vis[j]=1;
        }
    }
}
int main()
{
    sieve();
    ll a,b;
    cin>>a>>b;
    ll n=__gcd(a,b);
    //cout<<n<<endl;
    ll cnt=1;
    ll sq=sqrt(n);
    //cout<<sq<<' '<<pr[0]<<endl;
    for(int i=0;i<pr.size()&&pr[i]<=sq;i++)
    {
        if(n%pr[i]==0)
        {
            cnt++;
            while(n%pr[i]==0)
                n/=pr[i];
        }
    }
    if(n>1)cnt++;
    cout<<cnt<<endl;
    return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,k,r,s,p; string t; cin>>n>>k>>r>>s>>p>>t;
	unordered_map<char,int>m;
	m['r']=p,m['s']=r,m['p']=s;
	vector<bool>usd(n,false);
	int ans=0;
	for(int i=0;i<n;++i){
		if(usd.at(i))break;
		char f=0;
		for(int j=i;j<n;j+=k){
			if(t.at(j)==f){
				f=0;
			}
			else{
				ans+=m[t.at(j)];
				f=t.at(j);
			}
			usd.at(j)=true;
		}
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define pb push_back
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const int N=100;
const int W=10000;

vector<ll> a;
ll partition(ll p,ll r){
	ll x = a[r];
	ll i = p - 1;
	FOR(j,p,r){
		if(a[j]<=x){
			i = i+1;
			swap(a[i],a[j]);
		}	
	}
	swap(a[i+1],a[r]);
	return i+1;
}

int main(){
	ll n;
	cin>>n;
	FOR(i,0,n){
		ll k;
		cin>>k;
		a.pb(k);
	}
	ll i = partition(0,a.size()-1);
	FOR(j,0,a.size()){
		if(i==j){
			cout<<"["<<a[j]<<"]";
		}else{
			cout<<a[j];
		}
		if(j!=a.size()-1)cout<<" ";
	}
	cout<<endl;
}


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

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

    int ary[4][3][10] = {0};
    for (int i = 0; i < n; ++i) {
        int b, f, r, v;
        cin >> b >> f >> r >> v;

        ary[b - 1][f - 1][r - 1] += v;
    }

    for (int l = 0; l < 4; ++l) {
        for (int k = 0; k < 3; ++k) {
            for (int j = 0; j < 10; ++j) {
                cout << " " << ary[l][k][j];
            }
            cout << endl;
        }
        if (l != 3) cout << "####################" << endl;
    }
    return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a>b){
    for(int i=0;i<a;i++){
      cout << b;
    }
  }
  else{
    for(int i=0;i<b;i++){
      cout << a;
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>

static int
isPrime (
  int n
  )
{
  int i;

  if ( !( n % 2 ) ) return ( 0 );

  for ( i = 3; i * i <= n; i += 2 )
  {
    if ( !( n % i ) ) return ( 0 );
  }

  return ( 1 );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  for ( ; ; )
  {
    int n;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    for ( n -= !( n % 2 ); ; n -= 2 )
    {
      if ( isPrime ( n ) )
      {
        n -= 2;
        if ( isPrime ( n ) )
        {
          printf ( "%d %d\n", n, n + 2 );
          break ;
        }
      }
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
//只有p4特殊，其余三个都可以选择如果一元的单价小就买光
//P1 P2 P3选一个最小的pX
//如果是偶数而且p4小于pX那么全买第四种
//如果是偶数且P4大于pX那么全买第PX种
//如果是奇数且大于 那么全买第px种
//如果是奇数且小于 那么买n/2个p4
#include<bits/stdc++.h>
using namespace std;
long long P1,P2,P3,PX,Q,H,S,D,N;
double P4=D/2;
long long ans;
int main()
{
    scanf("%lld %lld %lld %lld %lld",&Q,&H,&S,&D,&N);
    P1=Q*4;
    P2=H*2;
    P3=S;
    PX=min(min(P1,P2),P3);
    P4=(double)D/2;
    if(N&1)
    {
        if(P4>=PX)
        {
            ans=N*PX;
        }
        else
        {
            ans=N/2*D+PX;
        }
    }
    else
    {
        if(P4>=PX)
        {
            ans=N*PX;
        }
        else
        {
            ans=N/2*D;
        }
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        int[][] a = new int[n][m];
        int[] b = new int[m];
        
        for(int i = 0 ; i < n ; i++ ){
            for(int j = 0 ; j < m ; j++){
                a[i][j] = sc.nextInt();
            }
        }
        
        for(int i = 0 ; i < m ; i++){
            b[i] = sc.nextInt();
        }
        
        for(int i = 0 ; i < n ; i++ ){
            int sum = 0;
            for(int j = 0 ; j < m ; j++ ){
                sum += a[i][j] * b[j];
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 40852
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trii(x) cerr<<#x<<": ("<<x.F<<","<<x.S<<")\n";
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define triiset(s) cerr<<#s<<": ";for(auto &i:s) trii(i);
#define epsilon 0.000000001L
#define mod 1000000007ll
#define inf 9999999999999999ll
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define modulo 998244353ll

void dfs(ll u,vb &vis,vi &p,vv &e,vi &dist)
{
    vis[u]=true;
    for(ll v:e[u])
    {
        if(!vis[v])
        {
            p[v]=u;
            dist[v]=dist[u]+1;
            dfs(v,vis,p,e,dist);
        }
    }
}

int main()
{
    fast();
    ll n,u,v;
    cin>>n>>u>>v;
    u--;
    v--;
    vv e(n,vi());
    for(ll i=0;i<n-1;i++)
    {
        ll x,y;
        cin>>x>>y;
        x--;y--;
        e[x].pb(y);
        e[y].pb(x);
    }
    vi d1(n,0);
    vb vis(n,false);
    vi p1(n,-1);
    dfs(u,vis,p1,e,d1);

    vi d2(n,0);
    vis.assign(n,false);
    vi p2(n,-1);
    dfs(v,vis,p2,e,d2);
    set <ll> nodes;
    for(ll i=0;i<n;i++)
    {
        if(d1[i]<d2[i])
        {
            nodes.insert(i);
        }
    }
    vv e1(n,vi());
    for(ll i=0;i<n;i++)
    {
        if(nodes.find(i)!=nodes.end())
        {
            for(ll v1:e[i])
            {
                if(nodes.find(v1)!=nodes.end())
                {
                    e1[i].pb(v1);
                }
            }
        }
    }
    vis.assign(n,false);
    vi d3(n,0),p3(n,-1);
    dfs(u,vis,p3,e1,d3);
    ll max_dis=0;
    ll max_node=u;
    for(ll i=0;i<n;i++)
    {
        if(vis[i]==true && max_dis<d2[i])
        {
            max_dis=d2[i];
            max_node=i;
        }
    }
    if(d1[max_node] == d2[max_node])
    {
        cout<<d2[max_node]<<nl;
    }
    else
    {
        cout<<d2[max_node]-1<<nl;
    }
}


Measured memory_bytes: 27264
#pragma region Template
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define COL(x) cout << x << endl
#define CO(x) cout << x
//#define int long long

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using VP = vector<PII>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = INT64_MAX >> 1;
const int INF = INT_MAX >> 1;

inline int sqr(int x) { return (x * x); }
inline void printd(double x) { printf("%.10lf\n", x); }
inline void upsort(VI& x) { sort((x).begin(), (x).end()); }
inline void downsort(VI& x) { sort((x).begin(), (x).end(), greater<int>()); }
inline int absdiff(int a, int b) { return (a - b) * (static_cast<int>(a > b)*2 - 1); }
int gcd(int a, int b) { // 最大公約数
	if (a < b) return gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
inline int lcm(int a, int b) { return a * b / gcd(a, b); } // 最小公倍数
#pragma endregion

signed main()
{
	int K;
	string S;
	cin >> K >> S;

	if (S.size() <= K) {
		COL(S);
	}
	else {
		string sk = S.substr(0, K) + "...";
		COL(sk);
	}

	return 0;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    if(n==m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

ll power(ll x,ll y,ll mod){
    ll result=1;
    while(y>0){
        if(y&1) result=result*x%mod;
        x=x*x%mod;
        y>>=1;
    }
    return result;
}

void solve(){
    ll mod=1000000007;
    int n,x,y,z;
    cin >> n >> x >> y >> z;

    int na=(1<<(z-1))|(1<<(y+z-1))|(1<<(x+y+z-1)),mask=(1<<17)-1;
    vector<vector<ll>> dp(40,vector<ll>(1<<17));
    rep(i,1,11) ++dp[0][1<<(i-1)];
    rep(i,0,n-1){
        rep(j,0,1<<17){
            if(!dp[i][j]) continue;
            rep(k,1,11){
                int tmp=((j<<k)|(1<<(k-1)))&mask;
                if((tmp&na)==na) continue;
                dp[i+1][tmp]=(dp[i+1][tmp]+dp[i][j])%mod;
            }
        }
    }
    ll s=0;
    rep(i,0,1<<17) s=(s+dp[n-1][i])%mod;
    cout << (power(10,n,mod)-s+mod)%mod << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 42368
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{

	public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
        int a = Integer.parseInt(input[0]);
        int b = Integer.parseInt(input[1]);
        if(a + b >= 10){
        	System.out.println("error");
        }else{
        	System.out.println(a + b);
        }
    }

}

Measured memory_bytes: 20692
function Main(input) {
    const lines = input.split("\n");
    let cells = [lines.shift(), lines.shift(), lines.shift()];
    cells = cells.map(l => l.split(' '));

    const n = lines.shift();

    try {
        lines.forEach(b => {
            cells.forEach(row => {
                row.forEach((a, j) => {
                    if (a == b) {
                        row[j] = true;
                        if (row[0] === row[1] === row[2] ||
                            cells[0][j] === cells[1][j] === cells[2][j] ||
                            cells[0][0] === cells[1][1] === cells[2][2] ||
                            cells[0][2] === cells[1][1] === cells[2][0]
                        ) {
                            throw 1;
                        }
                    }
                });
            });
        });
        console.log('No');
    } catch(_) {
        console.log('Yes');
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"sync"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	var ans int
	// 1はすべての約数なのでどこかで足す
	wg := new(sync.WaitGroup)
	wg.Add(1)
	go func() {
		for i := 2; i <= N; i++ {
			for j := 1; i*j <= N; j++ {
				ans += i * j
			}
		}
		wg.Done()
	}()
	wg.Wait()
	ans += N * (N + 1) / 2
	fmt.Println(ans)
}

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 1828
#include<stdio.h>

int main(void){
    int A,B,C;
    scanf("%d",&A); scanf("%d",&B); scanf("%d",&C);
    int day=0,S=0;
    while(S<C){
        S+=A;
        day++;
        if(day%7==0) S+=B;
    }
    printf("%d\n",day);
    return(0);
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int64_t power(int64_t x, int64_t n, int64_t mod) {
int64_t ret = 1;
while(n > 0) {
if(n & 1) (ret *= x) %= mod;
(x *= x) %= mod;
n >>= 1;
}
return ret;
}
int main()
{
    lint X, Y;
    cin >> X >> Y;
    
    if((X+Y)%3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    if(Y/2 > X || X/2 > Y) {
        cout << 0 << endl;
        return 0;
    }
    lint N = (X+Y)/3;
    vector<lint> kai(N);
    kai[0] = 1;
    FOR(i, 1, N+1) {
        kai[i] = kai[i-1]*i % MOD;
    }

    REP(i, N+1) {
        lint j = N - i;
        if(i+j*2 == X && i*2+j==Y) {
            lint ans = kai[i+j] * power(kai[i], MOD-2, MOD) % MOD * power(kai[j], MOD-2, MOD) % MOD;
            cout << ans << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}


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

using  namespace std;

int main(){
    int N,K;
    cin >> N >> K;
    int check,count=0;
    for(int i=0;i<N;i++){
        cin >> check;
        if(check>=K){
            count++;
        }
    }
    cout << count << endl;
}

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

#define REP(i,a,b) for(i=a; i<b; ++i)
#define rep(i,n) REP(i,0,n)

string cor(string order,string message) {
  for(int i=order.length()-1; i>=0; --i) {
    //cout<<i<<"  "<<message<<endl;
    if(order[i] == 'A') {
      reverse(message.begin(),message.end());
    }else if(order[i] == 'J') {
      string mes(message.length(), ' ');
      for(int j=0; j<message.length(); ++j) {
	if(j == 0) mes[j] = message[message.length()-1];
	else mes[j] = message[j-1];
      }
      message = mes;
    }else if(order[i] == 'M') {
      for(int j=0; j<message.length(); ++j) {
	if(message[j] >= '0' && message[j] <= '8') message[j]++;
	else if(message[j] == '9') message[j] = '0';
      }
    }else if(order[i] == 'P') {
      for(int j=0; j<message.length(); ++j) {
	if(message[j] == '0') message[j] = '9';
	else if(message[j] >= '1' && message[j] <= '9') message[j]--;
      }
    }else if(order[i] == 'C') {
      string mes(message.length(), ' ');
      char tmp = message[0];
      for(int j=0; j<message.length(); ++j) {
	if(j == message.length()-1) mes[j] = tmp;
	else mes[j] = message[j+1];
      }
      message = mes;
    }else if(order[i] == 'E') {
      string fore = "";
      string back = "";
      for(int j=0; j<message.length()/2; ++j) fore += string(1, message[j]);
      if(message.length()%2 == 0) {
	for(int j=message.length()/2; j<message.length(); ++j)
	  back += string(1, message[j]);
	//cout<<back<<" "<<fore<<" <- "<<message<<endl;
	message = back + fore;
      }else{
	fore = message[message.length()/2] + fore;
	for(int j = message.length()/2+1; j<message.length(); ++j)
	  back += string(1, message[j]);
	//cout<<back<<" "<<fore<<" <- "<<message<<endl;
	message = back + fore;
      }
    }
  }
  return message;
}

int main() {
  int i,j,k,n;
  string order,message;
  cin>>n;
  rep(i,n) {
    cin>>order;
    cin>>message;
    cout<<cor(order,message)<<endl;
  }
}

Measured memory_bytes: 0
from collections import deque
H,W=map(int,input().split())
MAZE=[list(input()) for _ in range(H)]

d=((-1,0),(0,-1),(1,0),(0,1))
ans_l=set()

def search(pos):
    D=[[0]*W for _ in range(H)]
    while len(pos)>0:
        x,y,depth=pos.popleft()
        D[x][y]=-1
        for i in range(4):
            nx=x+d[i][0]
            ny=y+d[i][1]
            if 0<=nx<H and 0<=ny<W and MAZE[nx][ny]=='.' and D[nx][ny]!=-1:
                pos.append((nx,ny,depth+1))
                D[nx][ny]=-1
    return depth

for i in range(H):
    for j in range(W):
        if MAZE[i][j]=='.':
            p=deque([[i,j,0]])
            ans_l.add(search(p))

print(max(ans_l))

Measured memory_bytes: 3444
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	String c1j = sc.next();
      	String c2j = sc.next();
	   	
      	if((c1j.charAt(0)==c2j.charAt(2))
          && (c1j.charAt(1)==c2j.charAt(1))
          && (c1j.charAt(2)==c2j.charAt(0))){
        	System.out.println("YES");
        }else{
        	System.out.println("NO");
        }
    }
}

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

map<int, int> prime_factor(int n)
{
    map<int, int> ret;
    int i = 2;
    while (n > 1)
    {
        int tmp = 0;
        while (n % i == 0)
        {
            tmp++;
            n /= i;
        }
        if (tmp > 0)
        {
            ret[i] = tmp;
        }
        i++;
    }

    return ret;
}

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

    long long mod = 1e9 + 7;
    long long ans = 1;
    map<int, int> mp;
    for (int i = N; i > 1; i--)
    {
        map<int, int> m = prime_factor(i);
        for (auto x : m)
        {
            mp[x.first] += x.second;
        }
    }

    for (auto x : mp)
    {
        ans *= x.second + 1;
        if (ans >= mod)
        {
            ans %= mod;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;
ll n;
vector<vector<ll>> edge;
vector<ll> parent;
vector<ll> color;
map<P, ll> m;

void make_parent(int cur){
  for (auto p : edge[cur]){
    if (parent[p] == -1){
      parent[p] = cur;
      make_parent(p);
    }
  }
}

void allocate_color(int cur){
  if (parent[cur] == -1){
    ll now_c = 1;
    for (auto child : edge[cur]){
      color[m[P(cur, child)]] = now_c;
      now_c++;
      allocate_color(child);
    }
  }
  else {
    ll c = color[m[P(parent[cur], cur)]];
    ll now_c = 1;
    for (auto child : edge[cur]){

      if (child == parent[cur])
        continue;

      if (now_c == c){
        now_c++;
      }
      color[m[P(cur, child)]] = now_c;
      now_c++;
      allocate_color(child);
    }
  }
}

int main(void){
  cin >> n;
  edge = vector<vector<ll>>(n, vector<ll>(0));
  parent = vector<ll>(n, -1);
  color = vector<ll>(n, -1);

  for (ll i = 0; i < n-1; i++){
    ll a, b;
    cin >> a >> b;
    
    a--; b--;
    edge[a].emplace_back(b);
    edge[b].emplace_back(a);
    m[P(a, b)] = i;
    m[P(b, a)] = i;
  }
  ll k = 0;
  for (ll i = 0; i < n; i++){
    k = max(k, (ll)edge[i].size());
  }


  make_parent(0);
  parent[0] = -1;


  allocate_color(0);



  cout << k << endl;
  for (ll i = 0; i < n-1; i++){
    cout << color[i] << endl;
  }

  return 0;
}


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

#define debug(a) cerr << #a << " = " << (a) << endl;
#define get(t, i) get<(i)>((t))
#define fst first
#define snd second

template<typename T> ostream& operator<<(ostream& o, const vector<T>& v) {
  int b = 0; for (const auto& a : v) o << (b++ ? " " : "") << a; return o;
}

template<typename T, typename U> ostream& operator<<(ostream& o, const pair<T, U>& p) {
  o << p.fst << ' ' << p.snd; return o;
}

int n, k;
vector<int> A;
int dp[101010];

// f(i) min cost on step i
int f(int i) {
  if (i == 0) return 0;

  int& x = dp[i];
  if (x != -1) return x;
  
  x = 1<<30;
  for (int j = 1; j <= k; j++)
    if (i-j >= 0)
      x = min(x, f(i-j) + abs(A[i]-A[i-j]));

  return x;
}

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  cin >> n >> k;
  A.assign(n, 0);
  for (auto& a : A) cin >> a;
  fill(dp, dp+n, -1);
  cout << f(n-1) << endl;
}



Measured memory_bytes: 5760
// https://atcoder.jp/contests/abc134/tasks/abc134_b

#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
    int N, D; cin >> N >> D;
    
    int ans = 0;
    if ( N % (2*D+1) == 0) {
        ans = N / (2*D+1);
    } else {
        ans = N / (2*D+1) + 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
 
#define rep for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

int main(){
  int n;cin >> n;
  vector<pair<int,int>> p(n);
  int h[n];rep{
    cin >> h[i];
    p[i] = make_pair(h[i],i+1);
  }
  sort(p.begin(),p.end());
  rep{
    cout << p[i].second << " ";
  }
  cout << endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long

int main(){
    IOS;

    long int n,k,q;
    cin>>n>>k>>q;

	long int val = q;
    vector<long int> v(n,k);
    while(q--){
        long int a;
        cin>>a;
        v[a-1]++;
    }

    for(long int i = 0; i < n; i++){
        v[i] -= val;
        if(v[i] > 0)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }

    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 4e5 + 10;
const ll mod = 1e9 + 7;
ll ksm(ll a, ll p)
{
	ll res = 1;
	while (p)
	{
		if (p & 1) res = res * a % mod;
		a = a * a % mod;
		p >>= 1;
	}
	return res;
}
ll inv[N], fac[N];
void init()
{
    fac[0] = 1;
    for (int i = 1; i < N; i++)
    fac[i] = (fac[i - 1] * i) % mod;
    inv[N-1] = ksm(fac[N - 1], mod - 2);
    for (int i = N - 2; i >= 0; i--)
    inv[i] = (inv[i + 1] * (i + 1))%mod;
}
ll cal(ll m, ll k)
{
	if (k == 0) return 1;
	ll res = fac[m] * inv[k] % mod * inv[m - k] % mod;
	return res;
}
ll n, k;
int main()
{
	scanf("%lld%lld", &n, &k);
	
	init();
//	cout << cal(4,1)<<endl;
	ll ans = 1;
	for (int i = 1; i <= min(k, n - 1); i++)
	{
		ll cnt = n - i;
		ll num = cal(cnt - 1 + i, cnt - 1);
		ll res = cal(n, i);
//		cout << i << " "<<res << " " << num <<endl;
		ans = (ans + num * res % mod) % mod;
	}
	printf("%lld\n", ans);
}



Measured memory_bytes: 6528
n = int(input())
G = []
for _ in range(n):
    S = list(input().strip())
    C = {}
    for i in range(len(S)):
        x = S[i]
        if x not in C:
            C[x] = 0
        C[x] += 1
    G.append(C)
A = {}
for i in range(97,123):
    flag = 0
    cmin = 50
    for C in G:
        if chr(i) not in C:
            flag = 1
            break
        cmin = min(cmin,C[chr(i)])
    if flag==0:
        A[chr(i)] = cmin
A = sorted(list(A.items()),key=lambda x:x[0])
x = ""
for y in A:
    a,k = y[0],y[1]
    x += a*k
print(x)

Measured memory_bytes: 40560
import java.util.Scanner;
public class Main {

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

    int N = scanner.nextInt();
    int cakeMax = N/4;
    int donutMax = N/7;
    String result = "No";

    for (int i = 0; i <= cakeMax; i++) {
      for (int j = 0; j <= donutMax; j++) {
        if ( i*4 + j*7 == N) {
          result = "Yes";
          break;
        }
      }
    }
    System.out.println(result);
    scanner.close();
  }
}


Measured memory_bytes: 23764
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 998_244_353

def fact_table(N, MOD):
    inv = np.empty(N, np.int64)
    inv[0] = 0
    inv[1] = 1
    for n in range(2, N):
        q, r = divmod(MOD, n)
        inv[n] = inv[r] * (-q) % MOD
    fact = np.empty(N, np.int64)
    fact[0] = 1
    for n in range(1, N):
        fact[n] = n * fact[n - 1] % MOD
    fact_inv = np.empty(N, np.int64)
    fact_inv[0] = 1
    for n in range(1, N):
        fact_inv[n] = fact_inv[n - 1] * inv[n] % MOD
    return fact, fact_inv, inv

def main(N, M, K):
    if N == 1:
        return M
    fact, fact_inv, inv = fact_table(N, MOD)
    f = fact[N - 1] * fact_inv[:N] % MOD * fact_inv[:N][::-1] % MOD
    f = f * M % MOD
    x = 1
    for n in range(1, N):
        x = x * (M - 1) % MOD
        f[n] *= x
    f %= MOD
    f = f[::-1]
    return f[:K + 1].sum() % MOD

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    fact_table = cc_export(fact_table, (i8, i8))
    main = cc_export(main, (i8, i8, i8))
    cc.compile()

from my_module import main

N, M, K = map(int, read().split())

print(main(N, M, K))

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

using namespace std;

const int SIZE = 1013;
const int oo = 999999;

typedef pair<int, int> pii;

int dist[SIZE];
int parent[SIZE];

bool bellmanFord(vector<vector<pii> > &G, int &source, int &N){
    for(int i = 0; i < N; i++)
      dist[i] = oo;
    dist[source] = 0;
    for(int k = 0; k < N; k++){
      for(int u = 0; u < N; u++){
        for(int i = 0; i < G[u].size(); i++){
          pii v = G[u][i];
          if(dist[v.first] > dist[u] + v.second && dist[u] != oo){
            if(k == N-1)
              return true;
            dist[v.first] = dist[u] + v.second;
            parent[v.first] = u;
          }
        }
      }
    }
    return false;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  #ifdef Larra
  freopen("in","r",stdin);
  freopen("out","w",stdout);
  #endif
  int n, m, source;
  cin>>n>>m>>source;
  vector<vector<pii> > G(n);
  for(int i = 0; i < m; i++){
    int u,v,w;
    cin>>u>>v>>w;
    G[u].push_back({v,w});
  }
  bool hasCycle = bellmanFord(G, source, n);
  if(hasCycle){
    cout<<"NEGATIVE CYCLE\n";
  }
  else{
    for(int i = 0; i < n; i++){
      if(dist[i] == oo)
        cout<<"INF";
      else
        cout<<dist[i];
      cout<<"\n";
    }
  }
}

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

using namespace std;

namespace {

#define VERA(i, a, b)for(auto i=(ll)(a);i<(ll)(b);++i)
#define ANDY(i, a, b)for(auto i=(ll)(a);i>(ll)(b);--i)

typedef long long ll;
typedef double dd;

template <class T> inline ll Size(const T& x) { return x.size(); }

ll x, y;

void Solve(ll test_num) {
  (void) test_num;
  ll res = 0;
  ll now = x;
  while (true) {
    ++res;
    now <<= 1;
    if (now > y)
      break;
  }
  cout << res << endl;
}

bool Input() {
  if (not(cin >> x >> y))
    return false;
  return true;
}

void Init() {
}

}

int main() {
#ifdef AZN
  const auto start_time = chrono::system_clock::now();
  freopen("../input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  srand(1223);
  Init();
  ll test = 1;
  while (Input()) {
    Solve(test++);
  }
#ifdef AZN
  cerr << "Took: " << ((chrono::system_clock::now() - start_time).count() /
                       static_cast<double>(chrono::system_clock::period::den)) << " s" << endl;
#endif
  return 0;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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


    lint ans, tmp;
    vector<lint> p(n);
    REP(i, n) {
        int a;
        cin >> a;
        p[a-1] = i+1;
    }
    REP(i, n)
    {
        cout << p[i];
        if(i!=n-1){
            cout << " ";
        }
    }
    cout << "\n";

    return 0;
}

Measured memory_bytes: 1536
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Ord
import Data.Bits

main=do
    [n,k]<-map read.words<$>getLine::IO[Int]
    as<-unfoldr(B.readInt.B.dropWhile(==' '))<$>B.getLine::IO[Int]
    print $ sol k as

sol k as = sum $ unfoldr (f k) (2^40, ss)
    where
        ss = sortBy (flip compare) $ concatMap (scanl1 (+)) $ tails as

f k (bm,ss)
    | length ss < k = Nothing
    | bm == 0 = Nothing
    | length ks >= k = Just(bm, (bm`div`2, ks))
    | otherwise = Just(0, (bm`div`2, ss))
    where
        ks = filter (\s-> s.&.bm /= 0) ss


Measured memory_bytes: 63740
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())

for i in range(n-k):
    if t[i] == t[i+k]:
        t[i+k] = 0
print(sum([t.count("r")*p, t.count("s")*r, t.count("p")*s]))

Measured memory_bytes: 4084
#include <iostream>

using namespace std;

int main(){
  string str;
  while(cin>>str && str!="EOF"){
    int cntA=0,cntB=0;
    for(int i=0;i<str.size()-2;i++){
      if(str[i]=='J' && str[i+1]=='O' && str[i+2]=='I'){cntA++;}
      if(str[i]=='I' && str[i+1]=='O' && str[i+2]=='I'){cntB++;}
    }
    cout<<cntA<<endl;
    cout<<cntB<<endl;
  }
}


Measured memory_bytes: 3120
#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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a,b; cin>>a>>b;
	cout<<a+(b/2)<<endl;
	
	return 0;
}

Measured memory_bytes: 3604