akhauriyash/Code-Regression huggingface dataset:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque 
def main():
    n, m = map(int, readline().split())
    to = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, readline().split())
        a -= 1
        b -= 1
        to[a].append(b)
        to[b].append(a)

    INF = int(1e6) 
    dq = deque()
    dq.append(0)
    dist = [INF for _ in range(n)]
    dist[0] = 0
    while len(dq)>0: 
        v = dq.popleft()
        for nx in to[v]:
            if dist[nx] != INF:
                continue
            dq.append(nx)    
            dist[nx] = dist[v]+1
    if dist[n-1] == 2:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
if __name__ == '__main__':
    main()


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

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b) { return a * b / GCD(a, b); }

int main(void) {
    long long a;
    long long b;
    long long c;
    long long d;
    cin >> a >> b >> c >> d;
    a = a - 1;
    long long e = LCM(c, d);
    long long count_a = a / c + a / d - a / e;
    long long count_b = b / c + b / d - b / e;
    long long f = a - count_a;
    long long g = b - count_b;
    cout << g - f << endl;
    return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

const int maxw = 100005;
ll dp[105][maxw]; // i個目までで重さjの容量に入れられる最大の価値

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int N, W; cin>>N>>W;
  vi w(N+1), v(N+1);
  reps(i,N) cin>>w[i]>>v[i];
  
  reps(i,N){
    reps(j,W){
      if(j>=w[i]) dp[i][j]=max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
      else dp[i][j]=dp[i-1][j];
    }
  }
  cout<<dp[N][W]<<endl;
}

Measured memory_bytes: 79360
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#

def main():
    H=ii()
    c = 1
    ans = 0
    while H:
        ans += c
        H >>= 1
        c <<= 1
    print(ans)

main()


Measured memory_bytes: 5172
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int n;
	string str;
	cin >> n >> str;
	
	int a = 0,b = 0,c = 0,d = 0;
	
	REP(i,str.size())
	{
		if(str[i] == ')')
		{
			if(a == 0)
			{
				b++;
			}
			else
			{
				a--;
			}
		}
		else
		{
			a++;
		}
	}
	
	REP(i,b)cout<< '(' ;
	cout << str;
	REP(i,a)cout << ')';
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    char str[27];
    int smp[26];
    int i;
    memset(str,0,27);
    for(i=0;i<26;i++){
        smp[i]=0;
    }
    int len;
    scanf("%s",str);
    len=strlen(str);
    for(i=0;i<len;i++){
        smp[str[i]-97]++;
    }
    for(i=0;i<26;i++){
        if(smp[i]>1){
            printf("no\n");
            return 0;
        }
    }
    printf("yes\n");
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
using namespace std;
#define MO 1000000007
#define MAXN 200005
#define LL long long
LL inv[MAXN],s[MAXN];
int n;
LL PowMod(LL a,int b)
{
	LL ret=1;
	while(b)
	{
		if(b&1) ret=ret*a%MO;
		a=a*a%MO;
		b>>=1;
	}
	return ret;
}
void Pre()
{
	s[0]=1;
	for(int i=1;i<=n;i++)
		s[i]=s[i-1]*i%MO;
	inv[0]=1;
	inv[n]=PowMod(s[n],MO-2);
	for(int i=n-1;i>0;i--)
		inv[i]=inv[i+1]*(i+1)%MO;
}
LL C(int a,int b)
{
	if(a<0||b<0) return 1;
	return s[a]*inv[b]%MO*inv[a-b]%MO;
}
int main()
{
	int h,w,A,B;
	scanf("%d%d%d%d",&h,&w,&A,&B);
	n=h+w-2;
	Pre();
	LL ans=C(h+w-2,h-1);
	for(int i=1;i<=B;i++)
	{
		ans-=C(h-A+i-2,h-A-1)*C(A-1+w-i,A-1)%MO;
		ans=(ans%MO+MO)%MO;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 3328
#include<iostream>
#include <bits/stdc++.h>
#include<string>
#include<algorithm>
#include<stdio.h>
using ll = long long;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
static const int INFTY = (1<<21);
int nums[4],flag=0;
string str;





void search(int index, ll sum,string fomula){
    if(index ==3 && sum ==7){
        fomula += "=7";
        cout << fomula<< endl;
        flag++;
        return;
    }
    if(index <4 && flag ==0){
    search(index + 1, sum + nums[index+1],fomula + "+" + str[index+1]);
    }
    if(index <4 && flag ==0){
    search(index + 1, sum - nums[index+1],fomula + "-" + str[index+1]);
    }
}






int main(){
    cin >> str;
    rep(i,4) nums[i]=(int)(str[i]-'0');
    string ini{str[0]};
    search(0,nums[0],ini);
    return 0;

}

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




int main(){
  int c[6];

  while(scanf("%d,%d,%d,%d,%d",&c[0],&c[1],&c[2],&c[3],&c[4])!=EOF){
    map<int,int> card;
    int mex = 0;
    for(int i=0;i<5;i++){
      card[c[i]]++;
      mex = max(mex,card[c[i]]);
    }
    sort(c,c+5);
    bool full = true;
    bool A,B;
    A = B = false;
    for(int i=0;i<5;i++){
      if(c[i] == 13)A = true;
      if(c[i] == 1)B = true;
    }
    if(A && B){
      for(int i=0;i<5;i++){
	if(c[i] == 1){
	  c[i] = 14;
	  break;
	}
      }
      sort(c,c+5);
   
    }
    for(int i=0;i<4;i++){
      if(c[i]+1 != c[i+1]){
	full = false;
	break;
      }
    }


    if(mex == 4){
      cout << "four card" << endl;
    }
    else if(mex == 3 && card.size() == 2){
      cout << "full house" << endl;
    }
    else if(full){
      cout << "straight" << endl;
    }
    else if(mex == 3){
      cout << "three card" << endl;
    }
    else if(card.size() == 3){
      cout << "two pair" << endl;
    }
    else if(mex == 2){
      cout << "one pair" << endl;
    }
    else cout << "null" << endl;


  }
  return 0;
}

Measured memory_bytes: 1220
// header {{{
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <list>
#include <stack>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;

#define kita            cout << "kita\n"
#define print2(i, n)    cout << (i) << ": " << (n) << endl
#define print3(i, j, n)     cout << "(" << (i) << ", " << (j) << ") : " << (n) << endl
#define print4(i, j, n, m)  cout << "(" << (i) << ", " << (j) << ") : " << (n) << ", " << (m) << endl
#define print_mat(mat, h, w) for(int i=0;i<(h);i++){for(int j=0;j<(w);j++){cout << mat[i][j] << " ";}cout << endl;}

#define EPS (1e-10)
#define EQ(a, b) (abs((a)-(b)) < EPS)

typedef long long ll;
typedef unsigned long long ull;
// }}}

int main() {
    vector<int> gap(26, 0);
    vector<int> gapmax(26, 0);
    string s;cin >> s;
    for(int i=0;i<int(s.size());i++){
        char c = s[i];
        for(int j=0;j<26;j++){
            if(j == c-'a'){
                gapmax[j] = max(gapmax[j], gap[j]);
                gap[j] = 0;
            }else{
                gap[j]++;
                if(i == int(s.size())-1){
                    gapmax[j] = max(gapmax[j], gap[j]);
                }
            }
        }
    }
    cout << *min_element(gapmax.begin(), gapmax.end()) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 200000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
LL factor[N];
LL PowMod(LL a,LL b){
    LL res=1;
    while(b){
        if(b&1)
            res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
LL inv(LL x){
    return PowMod(x,MOD-2);
}
LL C(LL n,LL m){
    return factor[n]*inv(factor[m])%MOD*inv(factor[n-m])%MOD;
}
void init(){
    factor[0]=1;
    for(int i=1;i<=N;i++)
        factor[i]=(factor[i-1]*i)%MOD;
}
int main(){
    init();
    LL h,w,A,B;
    scanf("%lld%lld%lld%lld",&h,&w,&A,&B);
    LL res=0;
    for(LL i=B+1;i<=w;i++){
        LL temp=(C(i-1+h-A-1,h-A-1)*C(w-i+A-1,w-i))%MOD;
        res=(res+temp)%MOD;
    }
    printf("%lld\n",res);
    return 0;
}


Measured memory_bytes: 1792
import sys

#+++++

def is_tr(a,b,c):
	if a < b+c:
		return True
	return False


def main():
	n = int(input())
	ll = list(map(int, input().split()))
	n=len(ll)
	ll.sort(reverse = True)
	pa(ll)
	
	ret = 0
	for i,l1 in enumerate(ll[:-2]):
		for j, l2 in enumerate(ll[i+1:-1]):
			pa(ret)
			if not is_tr(l1, l2, ll[j+1]):
				break
			if is_tr(l1,l2,ll[-1]):
				pa('ggg')
				ret += n-(i+1+j+1)
				continue
			ok=i+j+1
			ng=n-1
			while ng-ok > 1:
				mid = (ok+ng)//2
				if is_tr(l1,l2,ll[mid]):
					ok =mid
				else:
					ng = mid
			pa((ok,j+i+1))
			ret += (ok - (i+j+1))
	
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 45276
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int N,R;
	cin>>N>>R;
	if(N<10){
		int t=100*(10-N);
		printf("%d\n",t+R);
	}
	else{
		printf("%d\n",R);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int N, M;
    cin >> N >> M;
    bool AC[N];
    for(int i = 0; i < N; i++) AC[i] = false;
    int WA[N];
    for(int i = 0; i < N; i++) WA[i] = 0;
    
    int count_ac = 0,count_wa = 0;
    for(int i = 0; i < M; i++){
        int p;
        string S;
        cin >> p >> S;
        p--;
        if(!AC[p] && S == "WA"){
            WA[p]++;
        }else if(!AC[p] && S == "AC"){
            count_wa += WA[p];
            count_ac++;
            AC[p] = true;
        }
    }
    
    cout << count_ac << " " << count_wa << "\n";
    return 0;
}


Measured memory_bytes: 768
#include<stdio.h>
int main(void)
{
        int s,i;
        char a[6],b[6];
        scanf("%s %s",a,b);
        s=(b[0]-a[0])*100+(b[1]-a[1])*10+b[2]-a[2]-1;
        if((a[1]>a[3])||((a[1]==a[3])&&(a[0]>=a[4]))) s++;
        if((b[3]>b[1])||((b[3]==b[1])&&(b[4]>=b[0]))) s++;
        printf("%d\n",s);
        return 0;
}


Measured memory_bytes: 128
#include <iostream>

int main(){
	int a, b ,i ,n ;
	while(std::cin>>a>>b){
	i=1;
	for(n=1;a+b>=i*10;n++){
	if(a+b>=i*10){
	i=i*10;
	}
	}
	std::cout<<n<<std::endl;
}
return 0;
}

Measured memory_bytes: 1156
a,b = map(int,input().split())
if b<10:
    x=10*a+b
elif b<100:
    x=100*a+b
else:
    x=1000*a+b
c=0
for i in range(1000):
    if x==i*i:
        print("Yes")
        c=1
if c==0:      
    print("No")



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

const int mod=1e9+7;

int main(){
    int n,k;
    cin>>n>>k;
    vector<int>a(n),s,t;
    rep(i,n){
        cin>>a[i];
        if(a[i]>=0)s.push_back(a[i]);
        else t.push_back(a[i]);
    }
    bool ok=false;
    if(!s.empty()){
        if(n==k){
            if(t.size()%2==0)ok=true;
        }
        else ok=true;
    }
    else if(k%2==0)ok=true;
    ll ans=1;
    if(!ok){
        sort(a.begin(),a.end(),[](int x,int y){
            return abs(x)<abs(y);
        });
        rep(i,k){
            ans*=a[i];
            ans%=mod;
        }
    }
    else{
        priority_queue<ll>q;
        sort(s.rbegin(),s.rend());
        sort(t.begin(),t.end());
        if(t.size()>=1)for(int i=0; i<t.size()-1; i+=2){
            q.push((ll)t[i]*t[i+1]);
        }
        int i=0;
        if(k%2==1)ans*=s[i],i++,ans%=mod;
        if(s.size()>=1)for(; i<s.size()-1; i+=2){
            q.push((ll)s[i]*s[i+1]);
        }
        rep(i,k/2){
            ll x=q.top()%mod;
            ans*=x;
            ans%=mod;
            q.pop();
        }
    }
    if(ans<0)ans+=mod;
    cout<<ans<<endl;
}

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

int main() {
    ll H;
    cin >> H;
    int n = log2(H) + 1;
    ll ans = exp2(n) - 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N , a , b = 1;
   cin >> N;
  vector<int> moti(N);
  for(int i = 0 ; i < N ; i++){
    cin >> a;
    moti.at(i) = a;
  }
  sort(moti.begin() , moti.end());
  for(int i = 0 ; i < N - 1 ; i++){
    if(moti.at(i) != moti.at(i + 1)){
      b++;
    }
  }
  cout << b << endl;
}

Measured memory_bytes: 3572
#include <iostream>
using namespace std;
static int N_MAX = 100;

void p(int n, int A[]) {
	for (int i = 0; i < n; ++i) {
		cout << A[i];
		if (i != n - 1) {
			cout << " ";
		}
	}
	cout << endl;
}

int main() {
	int n;
	int A[N_MAX];
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> A[i];
	}
	p(n, A);
	for (int i = 1; i < n; ++i) {
		int v = A[i];
		int j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			--j;
		}
		A[j + 1] = v;
		p(n, A);
	}
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#define next(i) A[i][ind[i]]
//const long long mod = 1000000007;
//const long long mod = 998244353;
int main() {
	int N;
	scanf("%d", &N);
	int **A = new int*[N];
	for (int i = 0; i < N; i++) {
		A[i] = new int[N - 1];
		for (int j = 0; j < N - 1; j++) {
			scanf("%d", A[i] + j);
			A[i][j]--;
		}
	}
	int **ID = new int*[N];
	for (int i = 0, c = 0; i < N; i++) {
		ID[i] = new int[N];
		for (int j = 0; j < N; j++) {
			if (i < j) {
				ID[i][j] = c;
				c++;
			}
			else if (i > j) {
				ID[i][j] = ID[j][i];
			}
		}
	}
	int N2 = N * (N - 1) / 2;
	int *in = new int[N2];
	std::vector<int> *n = new std::vector<int>[N2];
	for (int i = 0; i < N2; i++) {
		in[i] = 0;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N - 2; j++) {
			int id1 = ID[i][A[i][j]];
			int id2 = ID[i][A[i][j + 1]];
			in[id2]++;
			n[id1].push_back(id2);
		}
	}
	std::vector<int> zero;
	for (int i = 0; i < N2; i++) {
		if (in[i] == 0)zero.push_back(i);
	}
	for (int d = 1, i = 0;; d++) {
		int e = zero.size();
		for (; i < e; i++) {
			for (int j = 0; j < n[zero[i]].size(); j++) {
				in[n[zero[i]][j]]--;
				if (in[n[zero[i]][j]] == 0)zero.push_back(n[zero[i]][j]);
			}
		}
		if (zero.size() == e) {
			if (i == N2) {
				printf("%d", d);
			}
			else {
				printf("-1");
			}
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 39540
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		Scanner in= new Scanner(System.in);
		PrintWriter out= new PrintWriter(System.out);
		String s= in.next();
		if(s.contains("9")) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
		
		
		
		
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 21716
#!/usr/bin/env python3

#import
#import math
#import numpy as np
#= int(input())
S = list(input())
T = list(input())

ls = len(S); lt = len(T)

for i in range(ls - lt, -1, -1):
    isok = True
    for j in range(lt):
        if S[i + j] == "?":
            continue
        if S[i + j] != T[j]:
            isok = False
            break
    if isok:
        S[i:i+lt] = T
        ans = ""
        for s in S:
            if s == "?":
                ans += "a"
            else:
                ans += s
        print(ans)
        exit()

print("UNRESTORABLE")


Measured memory_bytes: 8988
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>

using namespace std;
int n, d;
int cnt;

int main() {
    scanf("%d %d", &n, &d);
    int x, y;
    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &x, &y);
        long long tmp = (long long) x * x;
        tmp += (long long) y * y;
        if ((long long) d * d >= tmp) {
            cnt++;
        }
    }

    printf("%d\n", cnt);

    return 0;
}

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

int main()
{
    string a;

    cin>>a;

    if(a == "A")
        cout<<"T";

    if(a == "T")
        cout<<"A";

    if(a == "G")
        cout<<"C";

    if(a == "C")
        cout<<"G";

    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdlib>

using namespace std;

long long MOD = 1e9+7;

long long fact(long long n){
	long long ans=1;
	for(long long i=1; i<=n; i++){
		ans *=i;
		ans %=MOD;
	}
	return ans;
}


int main(){
	int n,m;
	cin >> n >> m;
	long long ans;
	ans = fact(n)*fact(m);
	if(n==m){
		cout << (ans*2)%MOD << endl;
	}
	else if(abs(n-m)==1){
		cout << (fact(n)*fact(m))%MOD << endl;
	}
	else {
		cout << 0 << endl;
	}
}







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

int main() {
	int n;
	long long k;
	std::cin >> n >> k;

	std::map<int, long long> mp;

	for (int i = 0; i < n; i++) {
		int a, b;
		std::cin >> a >> b;
		mp[a] += b;
	}

	for (auto kv : mp) {
		if (k - kv.second > 0) {
			k -= kv.second;
		} else {
			std::cout << kv.first << std::endl;
			break;
		}
	}
}

Measured memory_bytes: 4224
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (A, B) = read!(i64, i64);
    println!("{}", max(0, A - 2 * B))
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string input;
  string a = "";
  string b = "";
  int lengt;
  cin >> lengt;
  cin >> input;
  for(int i=0;i<input.length()/2;i++){
    a += input.at(i);
  }
  for(int i=input.length()/2;i<input.length();i++){
    b += input.at(i);
  }
  if(a==b){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long dp[401][401];
long long pre[401];

#define ll long long
#define f(i,n) for(ll i=0;i<n;i++)
ll min(ll a, ll b){return (a<b)?a:b;}
ll a[401];
ll solve(ll l, ll r){
        // if(l>r)return 0;
        if(l==r)return 0;
        if(dp[l][r]!=-1)return dp[l][r];
        dp[l][r]=1e18;
        for(ll i=l;i<r;i++){
                dp[l][r]=min(dp[l][r],solve(l,i)+solve(i+1,r)+pre[r]-pre[l-1]);
        }
        return dp[l][r];
}
int main() {
        ll n;
        cin>>n;
        // long a[n];
        f(i,n)cin>>a[i];
        // for( i,n)cin>>a[
                memset(dp,-1,sizeof dp);
                        pre[0]=a[0];
        for(ll i=1;i<n;i++){
                pre[i]=pre[i-1]+a[i];
        }
        solve(0,n-1);
        // ]
        cout<<dp[0][n-1]<<endl;

        return 0;

}


Measured memory_bytes: 4832
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

signed main() {
  int n;cin>>n;
  vector<int> a(n);
  rep(i, n) {
    cin>>a[i];
  }
  dump(a);

  vi b = a;
  sort(all(b));
  map<int, int> d;
  rep(i, n) d[b[i]]=i;
  rep(i, n) a[i] = d[a[i]];
  dump(a);

  int c = 0;
  rep(i, n){
    c += abs(a[i]-i)%2;
  }
  cout << c/2 << endl;
  return 0;
}


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

int main() {
  int N ;
  cin >> N ;
  int ans = 0 ;
  int i = 0 ;
  while( ans < N ){
    i++ ;
    ans += i ;
  }
  cout << i << endl;
}

Measured memory_bytes: 256
n = int(input())
cnt = 0
ca = 0
cb = 0
cab = 0
for i in range(n):
    tmp = input()
    cnt += tmp.count("AB")
    if tmp[0] == "B" and tmp[-1] == "A":
        cab += 1
    elif tmp[0] == "B":
        cb += 1
    elif tmp[-1] == "A":
        ca += 1
if ca == cb == 0 and cab > 0:
    cnt -= 1
print(cnt + cab + min(ca, cb))


Measured memory_bytes: 46440
def IsNum(x,y):
  if x % 2 == 0 :  
    y += 1
    return IsNum(int(x / 2),y)
  else:
    return y

N = int(input())

dict_num = {}
for i in range(N):
  num = i + 1
  rec = IsNum(num,0)
  dict_num[num] = rec
rec = [ num for num,v in dict_num.items() if v == max(dict_num.values())]

print(rec[0])

Measured memory_bytes: 3064
n, m = map(int, input().split())
rsl = [[0, 0] for i in range(n)]
for i in range(m):
  p, s = map(str, input().split())
  p = int(p)
  if rsl[p-1][0] == 0:
    if s == 'AC':
      rsl[p-1][0] += 1
    else:
      rsl[p-1][1] += 1
ac = 0
wa = 0
for i in range(n):
  if rsl[i][0] == 1:
    ac += 1
    wa += rsl[i][1]
print(' '.join((str(ac), str(wa))))

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

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

int n;
vector<int> x;
int avg=0;
int res[2];

int main(void){
    cin >> n;
    rep(i, n){
        int tmp;
        cin >> tmp;
        x.push_back(tmp);
    }
    rep(i, n){
        avg += x.at(i);
    }
    avg/=n;
    rep(i, 2){
        rep(j, n){
            res[i] += (x.at(j) - (avg+i))*(x.at(j) - (avg+i));
        }
    }
    cout << min(res[0], res[1]) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int gcd(int,int);

int main(){
  int x,y,r,ans;
  scanf("%d%d",&x,&y);
  if(x<y)ans = gcd(y,x);
  else ans = gcd(y,x);
  printf("%d\n",ans);
  return 0;
}

int gcd(int a, int b)
{
  int r;
  while(b>0){
    r = a%b;
    a = b;
    b = r;
  }
  return a;
}

Measured memory_bytes: 1796
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define all(x) (x).begin(),(x).end()
#define print(x) if(x)cout<<"YES\n";else cout<<"NO\n";
#define f(i,x,y) for(ll i=x;i<=y;i++)
#define rf(i,x,y) for(ll i=x;i>=y;i--)
#define pb push_back
#define F first
#define S second
using namespace std;
int main()
{
// #ifndef HP
//   freopen("in.txt", "r", stdin);
//   freopen("out.txt", "w", stdout);
// #endif

  fastio;
  int q = 1;
  //cin >> q;
  while (q--)
  {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(max(a * c, a * d), max(b * c, b * d));
  }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c[ohara],d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q,s[ohara],f[ohara];
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
bool fl;
struct edge{int to,cost;};
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    rep(i,n-1)cin>>c[i]>>s[i]>>f[i];
    rep(i,n-1){
        ans=0;
        rrep(j,i,n-1){
            if(ans<=s[j])ans=s[j];
            else{
                while(1){
                    if(ans%f[j]==0)break;
                    ans++;
                }
            }
            ans+=c[j];
        }
        Cout(ans);
    }
    Cout(0);
    return 0;
}

Measured memory_bytes: 4352
#include<stdio.h>

int main()
{
	int n,m=1,s,i,j,p[50000]={1,1},d[5200]={2};
	for(i=2;i*2<50000;i++)
		p[2*i]=1;
	for(i=3;i<50000;i+=2)
		if(p[i]==0)
		{
			d[m++]=i;
			for(j=i*2;j<50000;j+=i)
				p[j]=1;
		}
	while(1)
	{
		s=0;
		scanf("%d",&n);
		if(!n)
			break;
		for(i=0;d[i]<=n/2;i++)
			if(n-d[i]>1&&!p[n-d[i]])
				s++;
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 824
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//

int main(){
    int n,m; cin>>n>>m;
    int b[100001]={};
    int bn[100001]={};
    FOR(i,1,n+1) bn[i]=1;
    b[1]=1;
    FOR(i,0,m){
        int x,y; cin>>x>>y;
        if(b[x]&&bn[x]>1) b[y]=1;
        else if(b[x]&&bn[x]==1){
            b[y]=1;
            b[x]=0;
        }
        bn[x]--;
        bn[y]++;
    }
    int ans=0;
    FOR(i,1,100001){
        if(b[i]) ans++;
    }
    co(ans);
}


Measured memory_bytes: 1024
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

countNum :: [Int] -> Int -> Int
countNum [] x = 0
countNum bs 0 = 0
countNum (b : bs) x
  | x == b = 1
  | x > b = 1 + countNum bs (x - b)
  | otherwise = 0

main = do
  [n, x] <- getIntList
  as <- getIntList
  let bs = sort as
  if sum bs < x
    then print $ n - 1
    else
      if sum bs == x
        then print n
        else do
          print $ countNum bs x


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int h[n],dp[n+2]{0};
    for(int i=1;i<=n;i++)cin>>h[i];
    dp[2]=abs(h[2]-h[1]);
    for(int i=3;i<=n;i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n];
return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<cmath>
int main()
{
	double result[1000];
	int num;
	for(int i = 0;; i++)
	{
		int n;
		std::cin >> n;
		if(n == 0)
		{
			num = i;
			break;
		}
		double*val = new double[n];
		for(int j = 0; j < n; j++)
		{
			std::cin >> val[j];
		}
		double sum = 0;
		for(int j = 0; j < n; j++)
		{
			sum += val[j];
		}
		for(int j = 0; j < n; j++)
		{
			val[j] -= sum / n;
		}
		double sq_sum = 0;
		for(int j = 0; j < n; j++)
		{
			sq_sum += val[j] * val[j];
		}
		result[i] = sqrt(sq_sum / n);
	}
	for(int i = 0; i < num; i++)
	{
		std::cout << std::fixed << std::setprecision(10) << result[i] << std::endl;
	}
	return 0;
}


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

ll solve() {
    ll N, K;
    cin >> N >> K;
    ll ans;
    if ( K & 1 ) {
        ll d = N/K;
        ans = d*d*d;
    } else {
        ll d1 = N/K;
        ll d2 = (N+K/2)/K;
        ans = d1*d1*d1 + d2*d2*d2;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


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); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(){
	string S;
	cin>>S;
	
	int index=0;
	while(index<(int)S.length()){
		cout<<S[index];
		index+=2;
	}
	puts("");

	return 0;
}



Measured memory_bytes: 512
import Data.Char
import Data.List

main = interact $ unlines . map (show . mazes) . read' . lines
 where
  read' ("0 0":_) = []
  read' (wh:xs) = ((w,h),m) : read' xs'
   where
    [w,h] = map read (words wh)
    (m,xs') = splitAt (2*h-1) xs

mazes ((w,h),m) = bfs (2*(w-1),2*(h-1)) m 1 unsearched [(0,0)]
 where unsearched = tail [(x,y) | x<-[0,2..2*(w-1)], y<-[0,2..2*(h-1)]]

bfs e m s u c 
 | elem e c = s
 | null u || null c = 0
 | otherwise = bfs e m (succ s) (u \\ c') c'
 where
  c' = intersect (nub (concatMap neighbor c)) u
  neighbor (x,y) = map snd (filter movable dir)
   where 
    movable ((wx,wy),(x',y')) = elem (x',y') u && m!!wy!!wx == '0'
    dir = [((x-1,y),(x-2,y)),((x+1,y),(x+2,y)),((x,y-1),(x,y-2)),((x,y+1),(x,y+2))]

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

int main(){
  
  int n, a, count = 0;
  cin >> n >> a;
  
  while(a % 2 == 0){//a1の割れる回数
  a /= 2;
    count++;
  }
  
  for(int i = 1; i < n; i++){
    cin >> a;
    for(int j = 0; j < count; j++, a /= 2){
      if(a % 2 ==1)
        count = j;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N,F=0;
	string S;
	cin >> N >> S;
	if (N%2==1){
		cout << "No" << endl;
	}
	else {
		for (int i=0; i<N/2; i++){
			if (S.at(i) != S.at(i+N/2)){
				F = 1;
			}
		}
		if (F == 0){
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	
}

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

using namespace std;

int main() {
    int Num[3];
    int sum = 0;
    for (int i = 0; i < 3; i++) {
        cin >> Num[i];
        sum += Num[i];
    }

    sort(Num, Num + 3);

    if ((3 * Num[2] - sum) % 2 == 0) {
        cout << (3 * Num[2] - sum) / 2 << endl;
    } else {
        cout << (3 * (Num[2] + 1) - sum) / 2 << endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#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 range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=r-1;i>=(int)(l);--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using ll=long long;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

const int mod = 1e9 + 7;

ll inv[200010];
ll fac[200010], fac_inv[200010];

ll C(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return ((fac[n] * fac_inv[k] % mod) * fac_inv[n - k]) % mod;
}

void comb_init()
{
	int N = 200005;
	inv[1] = 1;

	for (int i = 2; i <= N; ++i) {
		inv[i] = mod - (mod / i) * inv[mod % i] % mod;
	}

	fac[0] = fac_inv[0] = 1;

	for (int i = 1; i <= N; ++i) {
		fac[i] = (fac[i - 1] * i) % mod;
		fac_inv[i] = (fac_inv[i - 1] * inv[i]) % mod;
	}
}

inline ll mod_pow(ll a, ll x, ll m)
{
	if (x <= 0) return 1;

	ll res = mod_pow(a, x / 2, m);

	res *= res;
	res %= m;

	if (x % 2) {
		res *= a;
		res %= m;
	}

	return res;
}


signed main()
{
	comb_init();

	int N, K; cin >> N >> K;

	int R = N - K, B = K;

	range(i, 1, K + 1) {
		int ans = 1;
		
		ans *= C(B - 1, B - i);
		ans *= C(R + 1, i);
		ans %= mod;

		cout << ans << endl;
	}
}



Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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


	int N, M;
	cin >> N >> M;
	int G[N][N];
	memset(G, 0, sizeof(G));
	vector<int> v;
	rep(i, 0, M) {
		int tmp_a, tmp_b;
		cin >> tmp_a >> tmp_b;
		tmp_a--; tmp_b--;

		G[tmp_a][tmp_b] = 1;
		G[tmp_b][tmp_a] = 1;
	}

	rep(i, 1, N) v.push_back(i);

	int rsl = 0;
	do {
		if(G[0][v[0]] != 1) continue;
		bool flag = true;
		rep(i, 0, v.size() - 1) {
			if(G[v[i]][v[i + 1]]) continue;
			flag = false;
		}
		if(flag) rsl++;

	} while(next_permutation(v.begin(), v.end()));

	cout << rsl << endl;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;

int main(){
	int n;
	cin >> n;
	int m = 0;
	int res = 0;
	for (int i = 0; i < n; i++) {
		int temp;
		cin >> temp;
		if (temp >= m) {
			m = temp;
			res++;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);

	        int N = sc.nextInt();
	        int M = sc.nextInt();
	        long K = sc.nextLong();
	        long[] a = new long[N+1];
	        for (int i=0 ; i<N+1; i++) {
	        	if(i==0) {
		            a[i] = 0;	        		
	        	} else {
	        		a[i] = a[i-1]+Long.parseLong(sc.next());
	        	}
	        }	        
	        long[] b = new long[M+1];
	        b[0]=0;
	        for (int i=1 ; i<M+1; i++) {
	            b[i] = Long.parseLong(sc.next());
	            if(i!=0)b[i]=b[i]+b[i-1];
	        }
	        long ans=0;
	        for(int i=0;i<N+1;i++) {
	        	int left=-1;
	        	int right=M+1;
	        	while(right-left>1) {
		        	int mid =(left+right)/2;
	        		if(a[i]+b[mid]<=K) {
	        			left=mid;
	        		} else {
	        			right=mid;
	        		}

	        	}
        		if(right>0) {
        			ans=Math.max(ans, i+left);
        		}
	        }
	        System.out.println(ans);
		 }
	}

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

//5-2 線形探索
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		ArrayList<Integer> S = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			S.add(Integer.parseInt(sc.next()));
		}
		int q = Integer.parseInt(sc.next());
		ArrayList<Integer> T = new ArrayList<>();
		for(int i = 0; i < q; i++) {
			T.add(Integer.parseInt(sc.next()));
		}
		
		sc.close();
		
		//線形探索
		int count = 0;
		for(int i = 0; i < T.size(); i++) {
			int tmp = T.get(i);
			if(S.contains(tmp)) {
				count++;
			}
		}
		System.out.println(count);
	}
}


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

int main() {
  int n,m;
  cin>>n>>m;
  int s[n];
  int t[m];
  rep(i,n) cin>>s[i];
  rep(i,m) cin>>t[i];
  ll dp[n][m];
  ll sum[n+1][m+1];
  rep(i,n+1) sum[i][0]=0;
  rep(i,m+1) sum[0][i]=0;
  rep(i,n){
    rep(j,m){
      if(s[i]==t[j]) dp[i][j]=(sum[i][j]+1)%mod;
      else dp[i][j]=0;
      sum[i+1][j+1]=(sum[i+1][j]+sum[i][j+1]-sum[i][j]+dp[i][j]+2*mod)%mod;
    }
  }
  cout<<(sum[n][m]+1)%mod<<endl;
}

Measured memory_bytes: 62848
# vim: fileencoding=utf-8


def main():
    n = int(input())
    a = set()
    for i in range(n):
        m = input()
        if m in a:
            a.remove(m)
        else:
            a.add(m)
    print(len(a))


if __name__ == "__main__":
    main()


Measured memory_bytes: 84596
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N, K;
    cin >> N >> K;
    deque<ll> D;
    rep(i, N) {
        ll v;
        cin >> v;
        D.push_back(v);
    }

    ll ans = 0;

    for (int a = 0; a <= N; a++) {
        for (int b = 0; b <= N; b++) {
            if (a + b <= N && a + b <= K) {
                ll cnt = 0;
                vector<ll> v;
                rep(i, a) {
                    cnt += D[i];
                    v.push_back(D[i]);
                }

                rep(j, b) {
                    cnt += D[N - 1 - j];
                    v.push_back(D[N - 1 - j]);
                }

                sort(all(v));

                rep(k, min(K - a - b, (int)v.size())) {
                    if (v[k] < 0)
                        cnt -= v[k];
                }

                ans = max(ans, cnt);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
 
using namespace std;
 
int main(void) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3, y3, x4, y4;
    x3 = x2 + (y1 - y2);
    y3 = y2 + (x2 - x1);
    x4 = x3 + (y2 - y3);
    y4 = y3 + (x3 - x2);
    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,cnt=1,head[200005],ans[200005];
struct edge{
	int to,next,w;
}e[500005];
void addedge(int u,int v){
	e[cnt].to=v;
	e[cnt].w=1;
	e[cnt].next=head[u];
	head[u]=cnt;
	++cnt;
}
int dis[100005];
bool vis[100005];
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q;
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int x,y;
		cin>>x>>y;
		addedge(x,y);
		addedge(y,x);
	}
	for(int i=1;i<=n;i++)
		dis[i]=0x7fffffff;
	dis[1]=0;
	q.push(make_pair(dis[1],1));
	while(!q.empty())
	{
		pair<int,int> fr=q.top();
		q.pop();
		int now=fr.second;
		if(vis[now]) continue;
		vis[now]=true;
		int ndis=fr.first;
		for(int i=head[now];i;i=e[i].next)
		{
			if(ndis+e[i].w<dis[e[i].to])
			{
				dis[e[i].to]=ndis+e[i].w;
				ans[e[i].to]=now;
				if (!vis[e[i].to])  q.push(make_pair(dis[e[i].to],e[i].to));
			}	
		}
	}
	for(int i=2;i<=n;i++){
		if(ans[i]==0){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	for(int i=2;i<=n;i++)
		cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 10120