akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef long long int64;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
template<class T,class U>bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>void vcin(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(n);
    cis(s);
    int ans = 0;
    char last = 'X';
    rep(i, n){
        if (s[i] != last){
            last = s[i];
            ans++;
        }
    }
    co(ans);
    return 0;
}

Measured memory_bytes: 512
<?php
// 複数行の標準入力を一行ずつ配列に代入する
$stdins = array();
while (true) {
    $input = trim(fgets(STDIN));
    $stdin = explode(' ', $input);
    if ($input == '') {
        break;
    }
    $stdins[] = $stdin;
}

$count = 0;
for ($i = 1; $i <= $stdins[0][0]; $i++) {
    $x = sqrt(($stdins[$i][0] ** 2) + ($stdins[$i][1] ** 2));

    if ($x <= $stdins[0][1]) {
        $count ++;
    }
}

echo $count;
?>

Measured memory_bytes: 108460
arr = gets.strip.split(" ").map!(&:to_i)
w = arr[0]
h = arr[1]
x = arr[2]
y = arr[3]

result = (w * h) / 2.0
if(x == w*1.0 / 2.0 && y == h*1.0 / 2.0) then
  ways = 1
else
  ways = 0
end
printf("%f %d\n", result, ways)


Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main()
{
    while(true){
        int h, w;
        cin >> h >> w;
 
        if(h==0 && w==0)
            break;
 
        int d = h*h+w*w;
 
        int H = 150;
        int W = 150;
        int D = 150*150+150*150;
 
        for(int y=1; y<=150; y++){
            for(int x=y+1; x<=150; x++){
                int z = y*y+x*x;
 
                if(z<=d){
                    continue;
                }
                else{
                    if(z<D){
                        H = y;
                        W = x;
                        D = z;
                    }
                    break;
                }
            }
        }
 
        for(int y=h+1; y<150; y++){
            bool flg = false;
 
            for(int x=y+1; x<=150; x++){
                int z = y*y+x*x;
 
                if(z==d){
                    H = y;
                    W = x;
                    D = z;
 
                    flg = true;
                }
 
                if(z>=d)
                    break;
            }
 
            if(flg)
                break;
        }
 
        cout << H << ' ' << W << endl;
    }
 
    return 0;
}


Measured memory_bytes: 3092
def function(a,b,c,d,e):
	A=[a,b,c,d,e]
	A.sort()
	#4card
	if A[0]==A[3] or A[1]==A[4]:
		print("four card")
	#Full house
	elif (A[0]==A[1] and A[2]==A[4]) or (A[0]==A[2] and A[3]==A[4]):
		print("full house")
	#three card
	elif A[0]==A[2] or A[1]==A[3] or A[2]==A[4]:
		print("three card")

	elif (A[0]==A[1] and A[2]==A[3]) or (A[0]==A[1] and A[3]==A[4]) or (A[1]==A[2] and A[3]==A[4]):
		print("two pair")
	elif A[0]==A[1] or A[1]==A[2] or A[2]==A[3] or A[3]==A[4]:
		print("one pair")
	#straight A?????????
	elif A==[1,10,11,12,13]:
		print("straight")
	#straight A???????????????
	elif A[0]==A[1]-1==A[2]-2==A[3]-3==A[4]-4:
		print("straight")
	else:
		print("null")

while True:
	try:
		a,b,c,d,e=map(int,input().split(','))
		function(a,b,c,d,e)
	except EOFError:
		break

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

int main(void) {
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d.at(i);
    }
    sort(d.begin(), d.end());
    cout << d.at(n/2) - d.at(n / 2-1) << endl;
    return 0;
}

Measured memory_bytes: 3736
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	//文字列から10進数に変換するときはparseIntを使います
	var N = parseInt(input[0], 10);
  	var H = input[1].split(" ");
	aCount = "Yes";
  	var i = 0;
  	var Hbefore = 0;
  	while(i < (N - 1)){
      	if((H[i] - Hbefore) >0){
        	H[i]--; 
        }
    	if((H[i + 1] - H[i]) < 0){
          	aCount = "No";
          	break;
        }
      	Hbefore = H[i];
      	i++;
    }
  	// console.log(H);
	console.log('%s',aCount);
}
                   
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 17816
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 998244353;

int main() {
    // your code goes here
    ll a,c=0;
    char b[10];
    cin >> a >> b;
    c+=(b[0]-'0')*100;
    c+=(b[2]-'0')*10;
    c+=(b[3]-'0')*1;
    c=a*c;
    cout << (c-c%100)/100 << endl;
    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
using namespace std;
 
ll gcd(ll n1,ll n2){
    if(!n1)return n2;
    if(!n2)return n1;
    if(n1%n2==0)return n2;
    return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
    base%=mod;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    ans%=mod;
    return ans;
}
int main()
{
    string s,t;
    
    cin>>s>>t;
    
   if(s[0]==t[2]&&s[1]==t[1]&&s[2]==t[0]) cout<<"YES"<<endl ;
   else cout<<"NO"<<endl;    
    
    return 0;
}


Measured memory_bytes: 384
#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>;

int main() {
    int N;
    cin >> N;
    vector<int> PP (N);
    rep(i,N) cin >> PP[i];
    int ans = 0;
    int cmin = 1e9;
    rep(i,N) {
        cmin = min(cmin,PP[i]);
        if (cmin == PP[i]) ans++;
    }
    cout <<ans <<endl;
    return 0;
}


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

using namespace std;
#define ll long long int
int main() 
{
	int n;
	ll W;

	cin>>n>>W;

	vector<pair<ll, int>> A;
	ll weight,value;
	ll sum = 0;

	for(int i = 0;i<n;i++)
	{
		cin>>weight>>value;
		A.push_back({weight, value});
		sum += value;
	}

	vector<vector<ll>> dp(sum+1, vector<ll> (n+1, INT_MAX));
	for(ll i = 0;i<= sum;i++)
	{
		for(int j = 0;j<=n;j++)
		{
			if(i == 0 )
				dp[i][j] = 0;
			else if( j == 0 )
				dp[i][j] = INT_MAX;
			else if( i >= A[j-1].second && dp[i-A[j-1].second][j-1] != INT_MAX)
			{
				dp[i][j] = min(dp[i][j-1], A[j-1].first + dp[i-A[j-1].second][j-1]);
			}
			else
				dp[i][j] = dp[i][j-1];
		}

	}

	int ans = 0;
	for(int i = sum;i>=0;i--)
	{
		if(dp[i][n] <= W)
		{
			ans = i;
			break;
		}


	}

	cout<<ans<<endl;

}

Measured memory_bytes: 82304
#include<bits/stdc++.h>
using namespace std;
char a[100009];
char p[]= {'d','r','e','a','m','e','r'};
char q[]= {'e','r','a','s','e','r'};
int main()
{
    scanf("%s",&a);
    int n=strlen(a);
    int d=0;
    int e=0;
    for(int i=0; i<n; i++)
    {
        if(d==0&&e==0)
        {
            if(a[i]=='d')
            {
                d++;
            }
            else if(a[i]=='e')
            {
                e++;
            }
            else
            {
                cout<<"NO"<<endl;
                return 0;
            }
            continue;
        }
        else if(e==0&&d)
        {
            if(d<5)
            {
                if(a[i]!=p[d])
                {
                    cout<<"NO"<<endl;
                    return 0;
                }
                if(a[i]==p[d])
                {
                    d++;
                }
                if(d==5)
                {
                    if(i==n-1)
                    {
                        cout<<"YES"<<endl;
                        return 0;
                    }
                    else if(a[i+3]=='a'||a[i+1]=='d')
                    {
                        d=0;
                    }
                }
                continue;
            }
            else if(d<7)
            {
                if(a[i]!=p[d])
                {
                    cout<<"NO"<<endl;
                    return 0;
                }
                if(a[i]==p[d])
                {
                    d++;
                }
                if(d==7)
                {
                    if(i==n-1)
                    {
                        cout<<"YES"<<endl;
                        return 0;
                    }
                    else
                    {
                        d=0;
                    }
                }
                continue;
            }
            continue;
        }
        else if(d==0&&e)
        {
            if(e<5)
            {
                if(a[i]!=q[e])
                {
                    cout<<"NO"<<endl;
                    return 0;
                }
                if(a[i]==q[e])
                {
                    e++;
                }
                if(e==5&&i==n-1)
                {
                    cout<<"YES"<<endl;
                    return 0;
                }
                 if(e==5&&a[i+1]!='r')
                 {
                     e=0;
                 }
                continue;
            }
            else if(e<6)
            {
                if(a[i]!=q[e])
                {
                    cout<<"NO"<<endl;
                    return 0;
                }
                if(a[i]==q[e])
                {
                    e++;
                }
                if(e==6)
                {
                    if(i==n-1)
                    {
                        cout<<"YES"<<endl;
                        return 0;
                    }
                    else
                    {
                        e=0;
                    }
                }
            }
        }
    }
        cout<<"NO"<<endl;
}


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

using namespace std;

#define int long long
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int H, N;
int located[100000];
int dp[2][1 << 4];
int down[5] = {0b0000, 0b0011, 0b0110, 0b1100, 0b1111};
int score[5] = {0, 1, 1, 1, 2};
signed main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> H >> N;
    for(int i = 0; i < N; ++i) {
        int x, y;
        cin >> x >> y;
        located[y] |= (1 << x);
    }
    int *now = dp[0];
    int *next = dp[1];
    for(int i = 0; i < (1 << 4); ++i) {
        if(i & located[0]) now[i] = -1;
        else now[i] = 0;
    }
    int res = 0;
    for(int i = 0; i < H - 1; ++i) {
        fill(next, next + (1 << 4), -1);
        for(int j = 0; j < (1 << 4); ++j) {
            if(now[j] == -1) continue;
            for(int k = 0; k < 5; ++k) {
                int front = down[k] & located[i];
                int back = down[k] & located[i + 1];
                if(front || back || j & down[k]) continue;
                int next_put = down[k] | located[i + 1];
                next[next_put] = max(next[next_put], now[j] + score[k]);
            }
        }
        for(int i = 0; i < (1 << 4); ++i) chmax(res, next[i]);
        int *temp = now;
        now = next;
        next = temp;
    }
    cout << res << endl;
	return 0;
}



Measured memory_bytes: 3272
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <cmath>


using namespace std;

//  ||
// \

int main() {
	float t = 0, x = 0;
	cin >> t >> x;
	float sum = t / x;
	cout << sum << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <limits>
using namespace std;

int main()
{
  int N,M;
  cin>>N>>M;
  int A[N][M];
  for(int i=0;i<N;i++){
      for(int j=0;j<M;j++){
	A[i][j]=0;
      }
  }
  for(int i=0;i<N;i++){
    int K;
    cin>>K;
    for(int j=0;j<K;j++){
      int tmp;
      cin>>tmp;
      A[i][tmp-1]=1;
    }
  }
  int ans=0;
  for(int i=0;i<M;i++){
    int tmp2=1; 
    for(int j=0;j<N;j++){
      tmp2*=A[j][i];
    }
    if(tmp2==1) ans++;
  }
  cout<< ans <<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
string s,t;cin>>s;int cnt=0,i=-1;
while(++i<s.size())if(cnt&1){if(s[i]=='Z')cnt++;}else if(s[i]=='A')cnt++;
if(cnt/=2)while(cnt--)cout<<"AZ";else cout<<-1;cout<<endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

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

    int n, r;
    cin >> n >> r;
    if (n >= 10) {
        cout << r;
        return 0;
    }

    int tmp = 100 * (10 - n);

    cout << r+tmp;








    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>

using namespace std;

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

	long int r1=1, r2=0;

	vector<bool> a(N, true);

	for(int i=0; i<M; i++){
		int j;
		cin >> j;
		a[j-1]=false;
	}

	long int r;
	for(int i=0; i<N; i++){
		if(a[i]){
			r=r1; r1=r2; r2=r;
			r1+=r2;
			r1%=1000000007;
		}else{
			r2=r1; r1=0;
		}
	}

	cout << r1 << endl;

	return 0;

}



Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
count = 0
for i in range(N):
    if B[i]<=A[i]:
        count += B[i]
    else:
        B[i] -= A[i]
        count +=A[i]
        if B[i]<=A[i+1]:
            A[i+1] -= B[i]
            count +=B[i]
        else:
            count+=A[i+1]
            A[i+1]=0
print(count)

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

map<string, int> dp;
int direction[4] = { 1, -1, 4, -4 };

void bfs()
{
	queue<string> que;
	que.push("01234567");
	dp["01234567"] = 0;
	while (!que.empty())
	{
		string now = que.front(); que.pop();
		int p = 0;
		for (int j = 0; j < 8; ++j)
		{
			if (now[j] == '0')
			{
				p = j;
				break;
			}
		}

		for (int i = 0; i < 4; ++i)
		{
			int n = p + direction[i];
			if (0 <= n && n < 8 &&
				!(p == 3 && i == 0) &&!(p == 4 && i == 1))
			{
				string next = now;
				swap(next[p], next[n]);
				if (dp.find(next) == dp.end())
				{
					dp[next] = dp[now] + 1;
					que.push(next);
				}
			}
		}
	}
}
int main(int argc, char *argv[])
{

	bfs();
	string line;
	while (getline(cin, line))
	{
		line.erase(remove(line.begin(), line.end(), ' '), line.end());
		cout << dp[line] << endl;
	}

	return 0;
}



Measured memory_bytes: 5188
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち
ra = range
enu = enumerate


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


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


def a_int(): return int(readline())


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


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


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


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


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


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


D, T, S = ints()
print('Yes' if D / S <= T else 'No')


Measured memory_bytes: 68056
#include <bits/stdc++.h>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << t)
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef int ll;
//        ios::sync_with_stdio(false);
//        cin.tie(nullptr);

ll f(ll n, ll halnum, vector<map<ll,ll>>& vw, vll& v, vll& w, ll nod, ll cw){
  if(cw < 0){
    return -1e9;
  }
  if(cw == 0){
    return 0;
  }
  if(nod <= halnum){
    auto tmp = vw[nod].upper_bound(cw);
    tmp--;
    return tmp-> second;
  }
  return max(f(n, halnum, vw, v, w, nod/2, cw), f(n, halnum, vw, v,w, nod/2, cw - w[nod]) + v[nod]);
}

int main(){
  ll n;
  cin >> n;
  ll dep = 1;
  while(pow(2,dep)-1 < n){
    dep++;
  }
  vll w(n+1),v(n+1);
  REP(i,1,n){
    cin >> v[i] >> w[i];
  }
  ll q; cin >> q;
  vll qv(q+1), ql(q+1);
  REP(i,1,q){
    cin >> qv[i] >> ql[i];
  }
  ll hal = (dep + 1) / 2;
  ll halnum = pow(2,hal) - 1;
  vector<map<ll,ll>> vw(halnum + 1);
  vw[0].insert({0,0});
  REP(i,1,halnum){
    ll bef = i / 2;
    for(auto x:vw[bef]){
      vw[i].insert(x);
    }
    
    for(auto x:vw[bef]){
      ll befw = x.first;
      ll befv = x.second;
      ll curw = befw + w[i];
      ll curv = befv + v[i];
      if(vw[i].find(curw) == vw[i].end()){
        vw[i][curw] = curv; 
      }else{
        vw[i][curw] = max(vw[i][curw], curv);
      }
    }
  //     REP(i,1,halnum){
  //   cout << i << " ";
  //   for(auto x:vw[i]){
  //     cout << "("<<x.first << ", " << x.second << "), " ;
  //   }
  //   cout << endl;
  // }
    vector<ll> era;
    auto cur = vw[i].begin();
    ll befwei = -1;
    ll befval = -1;
    while(cur != vw[i].end()){
      ll curwei = cur->first;
      ll curval = cur->second;
      if(befval >= curval){
        //vw[i].erase(cur);
        era.push_back(curwei);
        // cout << befval << " !!! " << curwei << endl;
      }else{
        befval = curval;
        befwei = curwei;
      }
      cur++;
    }
    for(auto cur:era){
      vw[i].erase(cur);
    }
    
  }
  // REP(i,1,halnum){
  //   cout << i << " ";
  //   for(auto x:vw[i]){
  //     cout << "("<<x.first << ", " << x.second << "), " ;
  //   }
  //   cout << endl;
  // }
  vll ans(q+2);
  REP(i,1,q){
    ans[i] = f(n, halnum, vw, v, w, qv[i], ql[i]);
  }
  REP(i,1,q){
    cout << ans[i] << endl;
  }
}

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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

constexpr int MAXN = 100000;

vector<int> adj[MAXN + 2];
int dp[MAXN + 2], ans[MAXN + 2], M;

void dfs1(int u, int w) {
	dp[u] = 1;
	for(int v : adj[u]) {
		if(v != w) {
			dfs1(v, u);
			dp[u] = (ll)dp[u] * dp[v] % M;
		}
	}
	dp[u]++;
}

#define pb push_back

void dfs2(int u, int w) {
	int oldv = dp[u];
	ans[u] = (ll)(dp[u] + M - 1) * dp[w] % M;
	int sz = adj[u].size();
	int *head = new int[sz * 2], *tail = head + sz;
	head[0] = 1;
	for(int i = 0; i + 1 < sz; i++) {
		int v = adj[u][i];
		head[i + 1] = (ll)dp[v] * head[i] % M;
	}
	tail[sz - 1] = 1;
	for(int i = sz - 1; i > 0; i--) {
		int v = adj[u][i];
		tail[i - 1] = (ll)dp[v] * tail[i] % M;
	}
	for(int i = 0; i < sz; i++) {
		int v = adj[u][i];
		if(v != w) {
			dp[u] = ((ll)head[i] * tail[i] + 1) % M;
			dfs2(v, u);
		}
	}
	dp[u] = oldv;
}

int main() {
	int N;
	cin >> N >> M;
	for(int i = 0; i < N - 1; i++) {
		int x, y;
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	dfs1(1, 0);
	dp[0] = 1;
	dfs2(1, 0);
	for(int i = 1; i <= N; i++)
		cout << ans[i] << endl;
}


Measured memory_bytes: 16128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <unordered_set>
#include <stack>
#include <iterator>
#include <random>
#include <fstream>
#include <chrono>
using namespace std;
#define int long long
int inv(int x){
    if(x==1)
        return 2;
    else
        return 1;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int X,Y,A,B,C;
    cin >> X >> Y >> A >> B >> C;
    vector<int>p(A);vector<int>q(B);vector<int>r(C);
    for(int i = 0; i < A; i++) cin >> p[i];
    for(int i = 0; i < B; i++) cin >> q[i];
    for(int i = 0; i < C; i++) cin >> r[i];
    sort(p.rbegin(),p.rend());
    sort(q.rbegin(),q.rend());
    vector<int>l;
    for(int i = 0; i < X; i++)
        r.push_back(p[i]);
    for(int i = 0; i < Y; i++)
        r.push_back(q[i]);
    sort(r.rbegin(),r.rend());
    int ans = 0;
    for(int i = 0; i < (X+Y); ++i){
        ans += r[i];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 6256
#include <iostream>
#include <algorithm>
#include <array>
#include <atomic>
#include <bitset>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include <cmath>
using namespace std;

#define rep(i, a, n) for(int i = a; i <= n; i++)

template<class T, class U> inline bool chmax(T& a, U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a, U b) { if (a > b) { a = b; return 1; } return 0; }

// 第一引数 == 第二引数 ? true : false
template<class T, class U>
bool check(T first, U second) {
    return (first == second);
}

// 約数列挙
vector<int64_t> divisor(int64_t n) {
  vector<int64_t> ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


// 数字和
template<class T>
T digitSum(T num) {
    T dig;
    T sum = 0;
    while (num) {
        dig = num % 10;
        sum += dig;
        num /= 10;
    }
    return sum;
}

string background_black(string s) { return "\x1b[40m" + s; }
string background_red(string s) { return "\x1b[41m" + s + "\x1b[40m"; }
string background_green(string s) { return "\x1b[42m" + s + "\x1b[40m"; }
string background_yellow(string s) { return "\x1b[43m" + s + "\x1b[40m"; }
string background_bleu(string s) { return "\x1b[44m" + s + "\x1b[40m"; }
string background_white(string s) { return "\x1b[47m" + s + "\x1b[40m"; }

string black(string s) { return "\x1b[30m" + s + "\x1b[37m"; }
string red(string s) {return "\x1b[31m" + s + "\x1b[37m"; }
string green(string s) { return "\x1b[32m" + s + "\x1b[37m"; }
string yellow(string s) { return "\x1b[33m" + s + "\x1b[37m"; }
string blue(string s) { return "\x1b[34m" + s + "\x1b[37m"; }
string white(string s) { return "\x1b[37m" + s + "\x1b[37m"; }

const int ten = 10;
const int hundred = 100;
const int thousand = 1000;

typedef long long ll;
typedef unsigned long long ull;

string tolower(string s) {
  string c;
  for (int i = 0; i < s.size(); i++) {
    if ((s[i] >= 'A') && (s[i] <= 'Z')) {
        c.push_back((s[i] + 0x20));
    } else {
        c.push_back(s[i]);
    }
  }
  return c;
}
#include <cstdlib>
string solve() {
  string str = "";
// int->string: to_string, string->int: stoi
//=============================================================================


  ull a, b, c;
  cin >> a >> b >> c;

  if (a+b > c) {
    str += to_string(c+b);
  } else {
    if (a+b == c) {
      str += to_string(a+b+b);
    } else {
    str += to_string(a+b+b+1);
    }
  }


//=============================================================================
  str += "\n";
  return str;
}

int main() {	
  std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
  cout << solve() << endl;
}

Measured memory_bytes: 256
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/aizu/alds11d_maximumProfit.py
#
n = int(input())
r = []
for i in range(n):
    r.append(int(input()))

maxv = -2000000000
minv = r[0]

for j in range(1, n):
    maxv = max(maxv, r[j] - minv)
    minv = min(minv, r[j])

print(maxv)


Measured memory_bytes: 13596
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <numeric>
#include <cstdint>
#include <cmath>
using namespace std;
using ll = int64_t;
void solve() {
	ll n;
	cin >> n;
	ll ans = 1e18;
	for (ll i =1; i*i <= n; ++i) {
		if (n % i != 0) continue;
		ll j = n/i;
		ans = min(ans, i+j-2);
	}
	cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int id;
        double w, h;
        char c;
        if(!(cin >> id >> c >> w >> c >> h))
            return 0;

        if(w / (h*h) >= 25.0)
            cout << id << endl;
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;

int main()
{
	double n;

	while(cin >> n){
		if(n == 0)
			break;

		double a=0,m=0;
		int in;
		vector<int> s;

		for(int i=0;i<n;++i){
			cin >> in;
			s.push_back(in);
			m += in;
		}

		m/= n;

		for(int i=0;i<n;++i)
			a += pow((s[i]-m),2.0);
	
		a/=n;

		a = sqrt(a);

		printf("%.08lf\n",a);

	}
	return 0;
}

Measured memory_bytes: 1272
#include <stdio.h>

int main()
{
  char S[5];
  scanf("%s", S);

  int ans=0;
  if(S[0]==S[1] && S[2]==S[3] && S[0]!=S[2]) {
    ans=1;
  }
  if(S[0]==S[2] && S[1]==S[3] && S[0]!=S[1]) {
    ans=1;
  }
  if(S[0]==S[3] && S[1]==S[2] && S[0]!=S[1]) {
    ans=1;
  }

  if (ans) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << x << endl;
#else 
    #define dbg(x)
#endif

#define int long long
#define pb push_back
#define ppb pop_back()
#define mp make_pair
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 410;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int a[MX];
int b[MX];

int add(int a, int b) {
    a += b;
    if (a >= MOD)
        return a - MOD;
    return a;
}

int sub(int a, int b) {
    a -= b;
    if (a < 0)
        return a + MOD;
    return a;
}

int mult(int a, int b) {
    return a * b % MOD;
}


int dp[MX][MX];
int sum[MX][MX];
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    fi(1, MX) {
        int pw = 1;
        fj(0, MX) {
            sum[j][i] = add(sum[j][i - 1], pw);
            pw = mult(pw, i);
        }
    }
    int ans = 0;
    int n, c;
    cin >> n >> c;
    fi(1, n + 1) cin >> a[i];
    fi(1, n + 1) cin >> b[i];
    dp[0][0] = 1;
    fi(1, n + 1) {
        rep(from, 0, c + 1) {
            rep(to, from, c + 1) {
                int pw = to - from;
                int s = sub(sum[pw][b[i]], sum[pw][a[i] - 1]);
                dp[i][to] = add(dp[i][to], mult(dp[i - 1][from], s));
            }
        }
    }   
    cout << dp[n][c] << '\n';
}

Measured memory_bytes: 6268
S=''.join(list(reversed(str(input()))))
words=["maerd","remaerd","esare","resare"]
flag = False
while(True):
    if(len(S) == 0):
        print("YES")
        break
    elif(S[0:len(words[0])] == words[0]):
        S = S[len(words[0]):]
    elif(S[0:len(words[1])] == words[1]):
        S = S[len(words[1]):]
    elif(S[0:len(words[2])] == words[2]):
        S = S[len(words[2]):]
    elif(S[0:len(words[3])] == words[3]):
        S = S[len(words[3]):]
    else:
        print("NO")
        break

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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            List<decimal> length = new List<decimal>();
            for (int i = 0; i < n; i++)
            {
                length.Add(decimal.Parse(Console.ReadLine()));
            }

            for (int j = 1; j <= 6; j++)
            {
                Console.Write("{0}:", j);
                if (j == 1)
                    WriteCome(length.Where(s => s < 165).Count());
                else if (j == 6)
                    WriteCome(length.Where(s => s >= 185).Count());
                else
                    WriteCome(length.Where(s => 155 + j * 5 <= s && s < 160 + j * 5).Count());
            }

        }

        static void WriteCome(int count)
        {
            for (int i = 0; i < count; i++)
            {
                Console.Write("*");
            }
            Console.WriteLine();

        }
    }
}

Measured memory_bytes: 18408
N = int(input())

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
      
result = str(num2alpha(N))
result = result.lower()
print(result)

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

int main()
{
  int a,b;
  cin >> a >> b;
  
  int r = a * b;
  if( r % 2 )
  {
    cout << "Odd" << endl;
  }
  else
  {
    cout << "Even" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys

A, B = map(int, sys.stdin.readline().split())

"""
..........
..........
..........
に、連結にならないように黒を置いていく
白の場合も白黒を逆にして同じことをやれば良い
"""
A -= 1
B -= 1
print(100, 100)
for i in range(100):
    for j in range(100):
        # 黒一面に白を入れていく
        if i < 50:
            if A > 0 and i % 2 == 0 and j % 2 == 0:
                print(".", end="")
                A -= 1
            else:
                print("#", end="")
        # 白一面に黒を入れていく
        elif 50 <= i:
            if B > 0 and i % 2 == 1 and j % 2 == 0:
                print("#", end="")
                B -= 1
            else:
                print(".", end="")
        if j == 99:
            print("")

Measured memory_bytes: 9368
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<list>
#include<vector>
#include<cmath>

#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;


int main(){

    int n;
    cin >> n;

    bool flg = false;
    if(n>=7 && n%4==3)flg = true;
    else if(n>=14 && n%4==2)flg = true;
    else if(n>=21 && n%4==1)flg = true;
    else if(n>=4 && n%4==0)flg = true;

    if(flg)cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
cards = []
nums = []
while True:
    card = raw_input()
    if card == '-':
        break
    cards += [card]
    n = 0
    for _ in range(int(raw_input())):
        n += int(raw_input())
    nums += [n]

for c, n in zip(cards, nums):
    w = c * ((n / len(c)) + 2)
    #print n / len(c)
    #print w
    print w[n:n+len(c)]

Measured memory_bytes: 6380
S=input()
K=int(input())
N=len(S)
if N==1:
	print(S)
else:
	if N>K:
		for i in range(K):
			if S[i]!="1":
				print(S[i])
				exit()
		print("1")
	else:
		for i in range(N):
			if S[i]!="1":
				print(S[i])
				exit()
		print("1")

Measured memory_bytes: 3060
#include <iostream>
    #include <algorithm>
    #include <vector>
    #include <string>
    using namespace std;
     
    #define rep(i,x) for(int i=0;i<(int)(x);i++)
     
    int main(){
     
        int n;
        cin >> n;
        if(n % 10 == 1){
            n += 8;
        }
        else if(n % 10 == 9){
            n -= 8;
        }
     
        if(n /10 % 10 == 1){
            n += 80;
        }
        else if(n / 10 % 10 == 9){
            n -= 80;
        }
       
        if(n / 100 % 10 == 1){
            n += 800;
        }
        else if(n / 100 % 10 == 9){
            n -= 800;
        }
     
        cout << n << endl;
     
    }



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int& i : A) cin >> i;
    vector<int> B(A);
    partial_sort(B.begin(), B.begin() + 2, B.end(), greater<int>());
    for (int i : A) cout << (i == B[0] ? B[1] : B[0]) << endl;
}

Measured memory_bytes: 3200
#include<stdio.h>

int main(){
	int n,m,p,i;

	for( ; scanf("%d%d",&n,&m) , n|m ; printf("%d\n",p) ){
		int f[12]={0};
		for( i=n ; i-- ; f[p] += n )
			scanf("%d%d",&n,&p);
		p=0;
		for( i=10 ; i >= 0 ; p += f[i]*i , i-- )
			for( ; f[i] && m ; )
				m--,f[i]--;
	}
}

Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<vector>
#include<string> 
#include<queue>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define ll long long
#define mp make_pair
int main()
{
	std::ios::sync_with_stdio(false);
	int n,i,k;
	char s[1005];
	cin>>s;
	cin>>k;
	n=strlen(s);
	for(i=0;i<n;i+=k)
	{
		cout<<s[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
////------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//-----------------------------------------
#define all(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//
////clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//
////debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

void prn(VI v){
    rep(i,v.size()-1)
      cout<<v[i]<<" ";
    cout<<v[v.size()-1]<<endl;
} 

int main(){
  int n,t;
  VI dat;
  cin>>n;
  rep(i,n){
    cin>>t;
    dat.PB(t);
  }
  
  int j,key;
  prn(dat);
  FOR(i,1,dat.size()){
     key=dat[i];
     j=i-1;
     while(j>=0&&dat[j]>key){
       dat[j+1]=dat[j];  
       j--;
     }
     dat[j+1]=key;
     prn(dat);
  }
  return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check
const ll INF = 1LL << 60;


void solve(std::string S){
    ll cnt = 0, N = S.length();
    for(ll i=0; i< N/2; i++){
        if(S[i]!=S[N-i-1])
            cnt++;
    }
    cout << cnt <<endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
L,R = map(int,input().split())
kouho = set([])
while len(kouho) < 2019 and L <= R:
  temp = L%2019
  kouho.add(temp)
  L += 1
#print(kouho)
A = list(kouho)
A.sort()
ans = 2018
for i in range(len(A)):
  for j in range(i+1,len(A)):
    temp = A[i]*A[j]%2019
    ans = min(ans,temp)
print(ans)

Measured memory_bytes: 9228
N, K = map(int, input().split())
MOD = 10 ** 9 + 7


def comb(n, k, p):
    """power_funcを用いて(nCk) mod p を求める"""
    from math import factorial
    if n < 0 or k < 0 or n < k:
        return 0
    if n == 0 or k == 0:
        return 1
    a = factorial(n) % p
    b = factorial(k) % p
    c = factorial(n-k) % p
    return (a*power_func(b, p-2, p)*power_func(c, p-2, p)) % p


def power_func(a, b, p):
    """a^b mod p を求める"""
    if b == 0:
        return 1
    if b % 2 == 0:
        d = power_func(a, b//2, p)
        return d*d % p
    if b % 2 == 1:
        return (a*power_func(a, b-1, p)) % p


memo = [[-1 for _ in range(K + 1)] for _ in range(K + 1)]


def dp(n, k):
    # n個のボールをk個のグループに分ける(空のグループを許容)
    if n <= 0 or k <= 1:
        return 1
    if memo[n][k] >= 0:
        return memo[n][k]
    memo[n][k] = 0
    for i in range(n, -1, -1):
        memo[n][k] += dp(n - i, k - 1) % MOD
    return memo[n][k]


for i in range(1, K + 1):
    print(comb(N - K + 1, i, MOD) * comb(K - 1, i - 1, MOD) % MOD)


Measured memory_bytes: 35828
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


mod = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))
box = [0] * (N+1)
ans = []
for i in reversed(range(1, N+1)):
    # iの倍数の箱の合計
    if sum(box[i::i]) % 2 != A[i-1]:
        # sum_ = sum([box[i*j] for j in range(1, N//i+1)])
        box[i] = 1
        ans.append(i)
print(len(ans))
print(*ans)


Measured memory_bytes: 23040
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

n,m = LI()
bulbs = []
for _ in range(m):
    b = LI()
    bulbs.append(b[1:])
p = LI()
ans = 0


for switch in range(1 << n):
    check = [0]*m
    for i, bulb in enumerate(bulbs):
        cnt = 0
        for b in bulb:
            if (switch>>(b-1))&1:
                cnt+=1
        if cnt % 2 == p[i]:
            check[i] = True
        else:
            check[i] = False
    if all(check):
        ans += 1
print(ans)

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

class Magatro
{
    static void Main()
    {
        new Magatro().Solve();
    }
    
    private int N;
    private int[]A;
    
    public void Solve()
    {
        N=int.Parse(Console.ReadLine());
        A=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int anser=0;
        for(int i=1;i<N;i++)
        {
            if(A[i-1]==i)
            {
                var t=A[i];
                A[i]=A[i-1];
                A[i-1]=t;
                anser++;
            }
        }
        if(A[N-1]==N)anser++;
        Console.WriteLine(anser);
    }
}

Measured memory_bytes: 20064
import sys


def main():

    N = int(sys.stdin.readline().rstrip())
    A = list(map(int, sys.stdin.readline().rstrip().split()))
    
    cnt = 0
    exist_odd = False
    while True:
        for i in range(N):
            if A[i] % 2 != 0:
                exist_odd = True
                
        if exist_odd == True:
            break
            
        for i in range(N):
            A[i] /= 2
        cnt += 1
        
    print(cnt)
        
        
            
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
#define Freopen(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
#define int long long
using namespace std;
struct Edg{int fr,to,nxt;}edge[200010];
int head[100010],cnt=0;
int hight[100010];
int n,m;
void add(int f,int t)
{
	edge[++cnt].fr=f;
	edge[cnt].to=t;
	edge[cnt].nxt=head[f];
	head[f]=cnt;
}
signed main()
{
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%lld",&hight[i]);
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%lld%lld",&u,&v);
		add(u,v),add(v,u);
	}
	int ans=0;
	for(int k=1;k<=n;k++)
	{
		int flag=1;
		for(int i=head[k];i;i=edge[i].nxt)
		{
			int to=edge[i].to;
			if(hight[to]>=hight[k]){flag=0;break;}
		}
		if(flag)ans++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 10064
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

long long lcm(long long a, long long b) {
	return a * b / gcd(a, b);
}

int main() {
	long a, b, x;
	cin >> a >> b >> x;
	if (a % x != 0) {
		cout << b / x - a / x << endl;
	}
	else {
		cout << b / x - a / x + 1 << endl;
	}
}

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

int main() {
    int n;
    cin >> n;
    vector<bool> a(1000000000);
    rep(i, 0, n) {
        int x;
        cin >> x;
        if (a[x] == true) {
            cout << "NO" << endl;
            return 0;
        } else {
            a[x] = true;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 122368
n, k = map(int, input().split())
d_list = []
a_list = []
for i in range(k):
	d_list.append(int(input()))
	a_list.append(list(map(int, input().split())))
n_list = []
for i in range(n):
	n_list.append(i+1)
for a_s in a_list:
	if len(n_list) == 0:
		break
	for a in a_s:
		if a in n_list:
			n_list.remove(a)
print(len(n_list))			


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

int main() {
  int N;
  vector<int> A(N);
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end(), greater<int>());
  int a = 0;
  int b = 0;
  for(int i = 0; i < N; i++) {
    if(i % 2 == 0) a += A[i];
    else b += A[i];
  }
  cout << a - b << endl;
  return 0;
}


Measured memory_bytes: 3700