akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    int n;
    long w;
    Item[] is;
    private final static int MAX_V = 100;

    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    private void read() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        w = sc.nextLong();
        is = new Item[n];
        for (int i = 0; i < n; i++) {
            int v = sc.nextInt();
            long w = sc.nextLong();
            is[i] = new Item(v, w);
        }
    }

    private void solve() {
        long[][] dp = new long[n+1][MAX_V*(n+1)];
        for (int i = 0;  i < dp.length; i++) {
            Arrays.fill(dp[i], 1000000001);
        }
        dp[0][0] = 0;
        for (int i = 1; i < dp.length; i++) {
            long localW = is[i-1].w;
            int localV = is[i-1].v;
            for (int j = 0; j < dp[0].length; j++) {
                if (j - localV < 0) {
                    dp[i][j] = dp[i-1][j];
                }
                else {
                    dp[i][j] = Math.min(dp[i-1][j], dp[i-1][j-localV] + localW);
                }
            }
//            System.out.println();
        }
        int ans = 0;
        for (int i = 0; i < dp[0].length; i++) {
            if (dp[n][i] != 0 && dp[n][i] <= w && ans < i)
                ans = i;
        }
        System.out.println(ans);
    }

    private class Item {
        int v;
        long w;
        Item (int v, long w) {
            this.v = v;
            this.w = w;
        }
    }
}

Measured memory_bytes: 35132
#include <cstdio>
#include <iostream>
#include <cstdlib>
#define MAX 1024
using namespace std;

typedef struct {
    int top;
    int max = MAX;
    int stk[MAX];
} Stack;

int initialize(Stack *s)
{
    s->top = 0;
    s->max = 100;
    return 0;
}

int isEmpty(Stack *s)
{
    return s->top <= 0;
}

int isFull(Stack *s)
{
    return s->top >= MAX - 1;
}

int push(Stack *s, int x)
{
    if (isFull(s))
        return -1;
    s->stk[s->top++] = x;
    return 0;
}

int pop(Stack *s)
{
    if (isEmpty(s))
        return -1;
    return s->stk[--s->top];
}

int main()
{
    Stack s;
    int x;
    int a, b;
    char str[MAX];
    if (initialize(&s) == -1)
        return -1;

    while (scanf("%s", str) != EOF) {
        if (str[0] == '+') {
            b = pop(&s);
            a = pop(&s);
            push(&s, a + b);
        } else if (str[0] == '-') {
            b = pop(&s);
            a = pop(&s);
            push(&s, a - b);
        } else if (str[0] == '*') {
            b = pop(&s);
            a = pop(&s);
            push(&s, a * b);
        } else {
            x = atoi(str);
            push(&s, x);
        }
    }
    cout << pop(&s) << endl;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
int main()
{
    string s;
    cin >> s;
    rep(i, 2){
        if (s[i]!=s[i+1]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3508
#include <iostream>
#include <string>
#include <vector>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)
typedef vector<int> vi;
int main(){
    string s;
    while(cin>>s){
        int arr[256]={};
        rep(i,s.size())
            arr[s[i]]++;
        vi v{arr['K'],arr['U'],arr['P'],arr['C']};
        int ans=1<<30;
        rep(i,4){
            ans=min(ans,v[i]);
        }
        cout << ans << endl;
    }
}
      

Measured memory_bytes: 1192
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7; 

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF_INT (1<<30)
#define INF_LL (1ll<<62)

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

int N;
bool ok=false;

int main(){
    cin>>N;
    int A[N];
    rep(i,N)cin>>A[i];
    sort(A,A+N);
    rep(i,N-1)if(A[i]==A[i+1])ok=true;
    if(!ok)out("YES");
    else out("NO");
}

Measured memory_bytes: 1024
//16-1
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)

int main(){
    int w;
    cin >> w;
    cout << w*32 << endl;
    return 0;
}



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

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

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    char in[2];
    scanf("%s", in);
    in[0]++;
    printf("%s\n",in);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n;
    cin >> n;
    ll a=2,b=1;
    while(n--){
        ll c=b;
        b=a+b;
        a=c;
    }
    print(a);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3632
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            a.add(sc.nextInt());
        }
        ArrayList<Integer> b = new ArrayList<>();
        b.addAll(a);
        Collections.sort(b);
        int max = b.get(b.size() - 1);
        int max2 = b.get(b.size() - 2);
        for (int i = 0; i < n; i++) {
            int tmp = a.get(i);
            if(max == tmp) {
                System.out.println(max2);
            } else {
                System.out.println(max);
            }
        }
    }
}

Measured memory_bytes: 66456
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <list>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

#define xx first
#define yy second
#define $1 first
#define $2 second

void solveCase() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int a, b, c; cin >> a >> b >> c;
	set<int> st;
	for (int i = 1; i < 10000; i++) {
		st.insert((a*i) % b);
	}
	if (st.find(c%b) != st.end()) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}

int main() {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	solveCase();
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
// #define double long double
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   200005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+15
vec v;
signed main(){
  fast;
  int n , k;
  cin>>n>>k;
  if(n==1){
  	   if(k==0)
  	   	cout<<"0 0 1 1"<<endl;
  	   else
  	   	cout<<"-1"<<endl;
  	   return 0;
  }
  int mx = (1<<n);
  if(k >= mx){
  	cout<<"-1"<<endl;
  	return 0;
  }
  for(int i=0;i<mx;i++) if(i!=k) v.pb(i);
  v.pb(k);
  for(int i=mx-1;i>=0;i--) if(i!=k) v.pb(i);
  v.pb(k);
  for(int i=0;i<2*mx;i++)
  	cout<<v[i]<<" ";
  cout<<endl;

}
  


Measured memory_bytes: 4080
#include<iostream>
#define _USE_MATH_DEFINES
#include<cmath>
#include<iomanip>

using namespace std;

int main(){

double r;

cin>>r;
cout<<fixed<<setprecision(6);
cout<<r*r*M_PI<<" "<<2*r*M_PI<<endl;
    return 0;
}


Measured memory_bytes: 3264
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

struct P {
    double x, y;
};

const double th = M_PI * 60.0 / 180.0;

void Koch_n(P p1, P p2, int n){
    if(n == 0) return;

    P s, t, u;
    s.x = 2 * p1.x / 3.0 +  p2.x / 3.0;
    s.y = 2 * p1.y / 3.0 +  p2.y / 3.0;
    t.x = p1.x / 3.0 + 2 * p2.x / 3.0;
    t.y = p1.y / 3.0 + 2 * p2.y / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    Koch_n(p1, s, n - 1);
    printf("%.5f %.5f\n", s.x, s.y);
    Koch_n(s, u, n - 1);
    printf("%.5f %.5f\n", u.x, u.y);
    Koch_n(u, t, n - 1);
    printf("%.5f %.5f\n", t.x, t.y);
    Koch_n(t, p2, n - 1);

}

int main(){
    int N;
    scanf("%d", &N);
    P a = {0, 0}, b = {100, 0};
    printf("%.5f %.5f\n", a.x, a.y);
    Koch_n(a, b, N);
    printf("%.5f %.5f\n", b.x, b.y);
}


Measured memory_bytes: 3232
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
#include <string>
//typedef long long LL;
using namespace std;

int main(){
    string s;
    string t;
    char a;
    char b;
    bool ans=true;
    vector<int> prev(26, -1);
    vector<int> next(26, -1);
    cin >> s >> t;
    for(int i=0; i<s.size(); i++){
        a=s[i]-'a';
        b=t[i]-'a';
        if(prev[b]!=-1 && prev[b]!=a){
            ans=false;
            break;
        }
        prev[b]=a;
        if(next[a]!=-1 && next[a]!=b){
            ans=false;
            break;
        }
        next[a]=b;
    }
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 776
//   Rishabh Agarwal
#include <bits/stdc++.h>
#define F first
#define S second
#define MAX 10000003
using namespace std;

typedef long long int ll;
const ll mod = 1e9+7;
const ll INF= 1e18;
long double PI=3.1415926;

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll temp=power(a,b/2)%mod;
    if(b%2==0){
        return (temp*temp)%mod;
    }
    else{
        return ((a*temp)%mod*temp)%mod;
    }
}

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

vector<pair<ll,ll>>v;
vector<ll>::iterator it;
map<ll,ll>mp;

void primeFactors(ll n)  
{  
    while (n % 2 == 0)  
    {  
        mp[2]++;
        n = n/2;  
    }  
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        while (n % i == 0)  
        {  
            mp[i]++;
            n = n/i;  
        }  
    }  
    if (n > 2){ 
        mp[n]++; 
    } 
}  

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    //cin>>t;
    t=1;
    //ll c=1;
    while(t--){
        ll h,w;
        cin>>h>>w;
        char a[h][w];
        for(ll x=0; x<h; x++){
            for(ll y=0; y<w; y++){
                cin>>a[x][y];
            }
        }
        ll dp[h+1][w+1];
        for(ll x=0; x<=h; x++){
            for(ll y=0; y<=w; y++){
                if(x-1>=0&&y-1>=0&&a[x-1][y-1]=='#'){
                    dp[x][y]=0;
                }
                else if(x==0||y==0){
                    dp[x][y]=0;
                }
                else{
                    dp[x][y]=dp[x-1][y]+dp[x][y-1];
                }
                dp[1][1]=1;
                dp[x][y]%=mod;
            }
        }
        cout<<dp[h][w]<<"\n";
        mp.clear();  
        v.clear();
        //cout<<"Case #"<<c<<": "<<ans<<"\n";
        //c++;
    }
    return 0;
}

Measured memory_bytes: 9088
N, K = map(int, input().split())
d = list(map(str, input().split()))
like = [ str(i) for i in range(10)]
like = list(set(like) ^ set(d))
Ans = 0

while( Ans == 0):
    if set(list(str(N))) <= set(like):
        print(N)
        Ans +=1
        exit()
    N += 1
    

Measured memory_bytes: 3060
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

ll memo[100010];
int a[100010];
int n, m;

ll calc(int x) {
	if (a[x] == 1) return 0;
	if (x > n) return 0;
	if (x == n) return 1;
	ll& res = memo[x];
	if (~res) return res;
	res = 0;
	res += calc(x + 1);
	res %= INF;
	res += calc(x + 2);
	res %= INF;
	return res;
}

void solv() {
	
	int n;
	cin >> n;
	vector<tuple<string,int,int>> v;

	for (size_t i = 0; i < n; i++)
	{
		string s;
		int p;
		cin >> s >> p;
		v.push_back(make_tuple( s,-p,i + 1));
	}
	sort(v.begin(), v.end());
	for (size_t i = 0; i < n; i++)
	{
		cout << get<2>(v[i]) << endl;
	}
}

int main() {
	//COMinit();
	solv();

	return 0;
}
 

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

using namespace std;

int main(){
    string s;
    cin >> s;
    sort(s.begin(), s.end());

    string t;
    cin >> t;
    sort(t.begin(), t.end(), greater<int>());

    if(s < t){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
a,b,k = map(int,input().split())

for i in range(k):
    if i%2 == 0:
        if int(a)%2 == 1:
            a -= 1
        b += a/2
        a /= 2
    else:    
        if int(b)%2 == 1:
            b -= 1
        a += b/2
        b /= 2

print(int(a),int(b))

Measured memory_bytes: 38384
import sys
from collections import defaultdict,Counter

sys.setrecursionlimit(10**7)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    a,b,c,k=mis()
    ans=0
    if k<=a:
        ans=k
    elif k<=a+b:
        ans=a
    else:
        ans=a-(k-a-b)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9460
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
const int SIZE=5;
const double EPS=1e-6;

int v[SIZE];

int main(){
	/*main function start*/
	for(int i=0;i<3;i++){
		int a,b;
		cin>>a>>b;
		v[a]++;
		v[b]++;
	}
	sort(v+1,v+5);
	if(v[1]==1 && v[2]==1 && v[3]==2 && v[4]==2) puts("YES"); else puts("NO");
	return 0;
}


Measured memory_bytes: 256
def main():
    S=input()
    N=len(S)
    abccounter=0
    abcounter=0
    acounter=0
    for i in range(0,N):
        if S[i]=='A':
            acounter+=1
        elif S[i]=='B':
            abcounter+=acounter
        elif S[i]=='C':
            abccounter+=abcounter
    hbccounter=0
    hbcounter=0
    hcounter=0
    for i in range(0,N):
        if S[i]=='?':
            hcounter+=1
        elif S[i]=='B':
            hbcounter+=hcounter
        elif S[i]=='C':
            hbccounter+=hbcounter
    ahccounter=0
    ahcounter=0
    acounter=0
    for i in range(0,N):
        if S[i]=='A':
            acounter+=1
        elif S[i]=='?':
            ahcounter+=acounter
        elif S[i]=='C':
            ahccounter+=ahcounter
    abhcounter=0
    abcounter=0
    acounter=0
    for i in range(0,N):
        if S[i]=='A':
            acounter+=1
        elif S[i]=='B':
            abcounter+=acounter
        elif S[i]=='?':
            abhcounter+=abcounter
    ahhcounter=0
    ahcounter=0
    acounter=0
    for i in range(0,N):
        if S[i]=='A':
            acounter+=1
        elif S[i]=='?':
            ahhcounter+=ahcounter
            ahcounter+=acounter
    hbhcounter=0
    hbcounter=0
    hcounter=0
    for i in range(0,N):
        if S[i]=='B':
            hbcounter+=hcounter
        elif S[i]=='?':
            hbhcounter+=hbcounter
            hcounter+=1
    hhccounter=0
    hhcounter=0
    hcounter=0
    for i in range(0,N):
        if S[i]=='C':
            hhccounter+=hhcounter
        elif S[i]=='?':
            hhcounter+=hcounter
            hcounter+=1
    Q=hcounter
    if Q>=3:
        ans=abccounter*3**Q+(hbccounter+ahccounter+abhcounter)*3**(Q-1)+(ahhcounter+hbhcounter+hhccounter)*3**(Q-2)+(Q*(Q-1)*(Q-2)//6)*3**(Q-3)
    elif Q==2:
        ans=abccounter*3**Q+(hbccounter+ahccounter+abhcounter)*3**(Q-1)+(ahhcounter+hbhcounter+hhccounter)*3**(Q-2)
    elif Q==1:
        ans=abccounter*3**Q+(hbccounter+ahccounter+abhcounter)*3**(Q-1)
    else:
        ans=abccounter*3**Q
    print(ans%(10**9+7))
if __name__ == '__main__':
    main()


Measured memory_bytes: 52464
/*
AizuOnline A0039
Roman Figure
*/
#include <stdio.h>
#include <string.h>

char roman_table[] = "IVXLCDM";
long int  roman_value_table[]={1,5,10,50,100,500,1000};

long int roman2arabic(char roman[])
{
        int i;
        long int s =0;
  
        for(i=0;i<strlen(roman);i++)
          s += roman_value_table[strchr(roman_table,roman[i])-roman_table]

            * (((i<strlen(roman)-1)&&(strchr(roman_table,roman[i])<strchr(roman_table,roman[i+1])))?(-1):1);

        return(s);
}


main()
{
  char roman_str[1024];
  
                  while(EOF != scanf("%s",roman_str))
                    {
                      printf("%ld\n",roman2arabic(roman_str));
                    }

return(0);
}

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

int main()
{

        int A, B, C;
        cin >> A >> B >> C;

        if ((A == B && B != C) || (A != B && B == C) || (A == C && A != B)){
                cout << "Yes" << endl;
        }
        else {
                cout << "No" << endl;
        }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	int n, m;
	cin >> n >> m;
	int sports[n];
	int judge[m];
	REP(i, n) cin >> sports[i];
	REP(i, m) cin >> judge[i];

	int vote[n] = {};

	REP(i, m){
		REP(j, n){
			if (judge[i] >= sports[j]){
				vote[j]++;
				break;
			}
		}
	}

	int max = 0;
	int index = 0;

	REP(i, n){
		if (max < vote[i]){
			max = vote[i];
			index = i;
		}
	}

	cout << index + 1 << endl;
}



Measured memory_bytes: 3120
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

const int maxn = 1010, maxv = 5050;
int head[maxn], nxt[maxn];
int fa[maxn];
int a[maxn];
bool f[maxn][maxv];

bool dfs(int u, int &x, int &y) {
	int sum = 0;
	f[u][0] = 1;

	for(int v = head[u]; v; v = nxt[v]) {
		int vx, vy;
		if(!dfs(v, vx, vy)) return 0;
		sum += vx + vy;

		for(int k = a[u]; k >= 0; k --)
			f[u][k] = (k >= vx ? f[u][k - vx] : 0) | (k >= vy ? f[u][k - vy] : 0);
	}

/* 	for(int k = 0; k <= a[u]; k ++) */
/* 		debug("%d", f[u][k]); */
/* 	debug("\n"); */

	int use = a[u];
	while(use >= 0 and !f[u][use]) -- use;
	if(use < 0) return 0;

	x = a[u];
	y = sum - use;

	/* debug("%d: use=%d x=%d y=%d\n", u, use, x, y); */
	return 1;
}

int main() {
	int n = read;
	for(int i = 2; i <= n; i ++) {
		read(fa[i]);
		nxt[i] = head[fa[i]];
		head[fa[i]] = i;
	}

	for(int i = 1; i <= n; i ++)
		read(a[i]);

	int x, y;
	if(dfs(1, x, y)) puts("POSSIBLE");
	else puts("IMPOSSIBLE");
}


Measured memory_bytes: 4736
import itertools
import collections

n = int(input())
s = input()

password_l = [str(i).zfill(3) for i in range(1000)]

c = 0
for password in password_l:
    idx = 0
    ok = 0
    while idx != n:
        if s[idx] == password[ok]:
            ok += 1
        
        if ok == 3:
            c += 1
            break
        
        idx += 1

print(c)

Measured memory_bytes: 40924
#include <iostream>

using namespace std;

int main() {
	int rr, ww, c, r;
	while (cin >> rr >> ww >> c >> r) {
		if (rr == 0 && ww == 0 && c == 0 && r == 0) {
			break;
		}
		int x = 0;
		while (true) {
			double r2 = rr + x*r;
			double cc = (double)c;
			if (r2 / cc >= (double)ww) {
				break;
			}
			else {
				x++;
			}
		}
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 3068
/* *
 *
 * Author: Hamkor
 *
 * */

#include <bits/stdc++.h>

using namespace std;

/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */
 int c(int n, int m){
	 if (m%2) return (n+1)%2;
	 else return n;
 }
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int a, b, t; cin>>a>>b>>t;
	cout<<t/a*b;
	return 0;
}

Measured memory_bytes: 256
s=input()
if s=="SAT":
	print(1)
elif s=='SUN':
	print(7)
elif s=="FRI":
	print(2)
elif s=="THU":
	print(3)
elif s=="WED":
	print(4)
elif s=="TUE":
	print(5)
elif s=='MON':
	print(6)

Measured memory_bytes: 38384
from collections import Counter

def main():
    n = int(input())
    a = list(map(int, input().split()))
    bigger = [None]*n
    smaller = [None]*n
    for i, ai in enumerate(a):
        bigger[i] = i - ai
        smaller[i] = i + ai
    b = sorted(Counter(bigger).items())
    s = sorted(Counter(smaller).items())
    nb = len(b)
    ns = len(s)
    b.append((10**10, 0))
    s.append((10**11, 0))
    i, j = 0, 0
    ans = 0
    while i < nb or j < ns:
        bi, nbi = b[i]
        si, nsi = s[j]
        if bi == si:
            ans += nbi*nsi
            i += 1
            j += 1
        elif bi > si:
            j += 1
        else:
            i += 1
    print(ans)
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 139580
#include<iostream>

using namespace std;

int main(){
    double x1, x2, x3, x4, y1, y2, y3, y4;
    while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4) {
        bool flag[2] = {true, true};
        
        if( (x2 - x1) * (y4 - y1) - (x4 - x1) * (y2 - y1) < 0 )
		flag[0] = false;
		
        else 
		flag[1]=false;
		
        if( (x3-x2) * (y4 - y2) - (x4 - x2) * (y3 - y2) < 0 )
		flag[0] = false;
		
        else 
		flag[1]=false;
		
        if( (x1 - x3) * (y4 - y3) - (x4 - x3) * (y1 - y3) < 0 )
		flag[0] = false;
		
        else 
		flag[1]=false;
		
		if( flag[0] || flag[1] )
		cout << "YES\n";
		else
		cout << "NO\n";
    }
    return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int N,M;
pair<int,int> PD[10010];
int main() {
  while (cin >> N >> M && N) {
    int d,p;
    for (int i=0; i<N; ++i) {
      cin >> d >> p;
      PD[i] = make_pair(p,d);
    }
    sort(PD,PD+N);
    reverse(PD,PD+N);
    int S = 0;
    for(int i=0; i<N; ++i)
      S += PD[i].first*PD[i].second;
    for(int i=0; i<N; ++i) {
      if(M<=0) break;
      int guarded = fmin(M,PD[i].second);
      S -= PD[i].first*guarded;
      M -= guarded;
    }
    cout << S << endl;
  }
}

Measured memory_bytes: 3180
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, bool> pib;

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;

typedef vector<double> vf;

typedef long double ld;

#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

#define printItr(A) for(auto itr = A.begin(); itr != A.end(); ++itr){cout << * itr << ", ";}cout << endl;

const double PI = 3.141592653589793;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

bool isOK(vi& a, ll k, ll index) {
	return a[index] < k * (index + 1);
}

ll binary_search(vi& a, ll k) {
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = (ll)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;

		if (isOK(a, k, mid))
			right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}

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

template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
	os << "{";
	for (auto e : v)os << e << ",";
	return os << "}";
}

bool eq(vi P, vi Q) {
	rep(i, P.size()) {
		if (P[i] != Q[i]) {
			return false;
		}
	}
	return true;
}

ll gcd(ll a, ll b)
{
	if (a%b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a%b));
	}
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}

ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

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

	vector<string> S(N);
	vi T(N);

	ll all = 0;
	rep(i, N) {
		cin >> S[i] >> T[i];
		all += T[i];
	}

	string X;
	cin >> X;

	ll t = 0;
	rep(i, N) {
		t += T[i];
		if (S[i] == X) {
			break;
		}
	}

	cout << all - t << endl;

	return 0;
}


Measured memory_bytes: 256
#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(){
  ll n,a,b;
  cin >> n >> a >> b;
  ll ans = 0;
  ans = (n/(a+b))*a;
  ll rem = n%(a+b);
  ans += min(rem,a);
  cout << ans << endl;
}

Measured memory_bytes: 256
n, l = gets.chomp.split().map(&:to_i)
apples = [*1..n]

tastes = apples.map{|i| l + i - 1}
abs_tastes = tastes.map(&:abs)
min_taste_index = abs_tastes.index(abs_tastes.min)
print(tastes.sum - tastes[min_taste_index])


Measured memory_bytes: 14352
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <functional>
#include <numeric>
#include <math.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(void) {
	string S, T;
	cin >> S >> T;
	int ans = 0;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] != T[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3812
#include <algorithm>
#include <array>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <stack>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define MOD ((ll)1000000007)

int main(int argc, char const *argv[])
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	ll N;
	ll M;
	cin >> N >> M;

	vector<ll> A(N, 0);
	for (ll i = 0; i < N; i++)
	{
		cin >> A[i];
	}

	// 昇順でソート
	sort(A.begin(), A.end());

	// min_happiness以上の幸福度を獲得可能な握手パターンがM以上あるか
	auto isOK = [&](ll min_happiness) {
		ll count_shake = 0;
		// i番目との握手を固定
		for (ll i = 0; i < N; i++)
		{
			// 合計の幸福度がmin_happiness以上となる最小のj
			ll bound = min_happiness - A[i];
			ll j = lower_bound(A.begin(), A.end(), bound) - A.begin();
			// min_happiness以上を達成可能な握手パターン数を加算
			count_shake += N - j;
		}
		return count_shake >= M;
	};

	// isOKがtrueとなる最大のmin_happinessを二分探索
	ll left = 0;
	ll right = A.back() * 2 + 1; // 1度の握手で獲得可能な幸福度の最大値
	while (right - left > 1)
	{
		ll pivot = left + (right - left) / 2;
		if (isOK(pivot))
		{
			// OKの場合、min_happinessをもっと大きくできる
			left = pivot;
		}
		else
		{
			// NGの場合、min_happinessを緩和
			right = pivot;
		}
	}

	// 累積和を計算
	vector<ll> cumsum(N + 1, 0);
	for (ll i = 0; i < N; i++)
	{
		cumsum[i + 1] = cumsum[i] + A[i];
	}

	// 合計幸福度を計算
	ll total_happiness = 0;
	ll count = 0;
	for (ll i = 0; i < N; i++)
	{
		// 合計の幸福度がleft - A[i]以上となる最小のj
		ll j = lower_bound(A.begin(), A.end(), left - A[i]) - A.begin();
		count += N - j;
		total_happiness += cumsum[N] - cumsum[j]; // 各jの幸福度の合計
		total_happiness += A[i] * (N - j);		  // iの幸福度の合計
	}

	total_happiness -= left * (count - M);
	cout << total_happiness << endl;

	return 0;
}


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

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

using ll = long long;
using ull = unsigned long long;

int main() {
  int n;
  int a[100];
  cin >> n;
  rep(i, n) cin >> a[i];
  rep(i, n) {
    if (i != n - 1) cout << a[n - 1 - i] << ' '; 
    else cout << a[n - 1 - i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3052
# -*- coding: utf-8 -*-

import random
import sys
import os
import pprint

#fd = os.open('ALDS1_5_A.txt', os.O_RDONLY)
#os.dup2(fd, sys.stdin.fileno())

n = int(input())
A = list(map(int, input().split()))

# memo table T[i][m]
row_num = len(A)
column_num = 2000
T = [[None for i in range(column_num)] for j in range(row_num)]
#pprint.pprint(T)


def solve(i, m):
    # out of index
    if i >= len(A):
        return False
    if m < 0:
        return False

    if T[i][m] is not None:
        return T[i][m]

    if m == 0:
        T[i][m] = True
    elif m == A[i]:
        T[i][m] = True
    #elif i >= len(A):
    #    T[i][m] = False
    elif solve(i+1, m):
        T[i][m] = True
    elif solve(i+1, m - A[i]):
        T[i][m] = True
    else:
        T[i][m] = False
    return T[i][m]

test_num = int(input())
test_values = map(int, input().split())
for v in test_values:
    result = solve(0, v)
    if result is True:
        print('yes')
    else:
        print('no')

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

#長さN, Mまでの数字を用いてtmpから始まる短調増加数字列（1123,1234など）を全て出力
from collections import deque
from collections import defaultdict
d = defaultdict(int)
n,m=3,100
y = [[x] for x in range(1,50+1)]
tmp=deque(y)
out=0
while tmp:
    T=tmp.pop()
    if len(T) < n:
        for i in range(int(T[-1]),m+1):
            tmp.append(T+[i]) 
    else:
        ans = int((sum(T))**2-(T[0]*T[1]+T[1]*T[2]+T[2]*T[0]))
        if ans <= 10000:
            if T[0] == T[1] and T[1] == T[2]:
                plus = 1
            elif T[0] == T[1] or T[1] == T[2]:
                plus = 3
            else:
                plus = 6
            d[ans] += plus
            
for i in range(N):
    print(d[i+1])

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

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

    int N, M;
    cin >> N >> M;

    int A = 0, a;
    rep(i, M) {
        cin >> a;
        A += a;
    }

    int ans = N - A;
    if (ans < 0) ans = -1;

    cout << ans << endl;
}

Measured memory_bytes: 3612
import sys
N=int(input())

def warshall_floyd(d):
  #d[i][j]: iからjへの最短距離
  for k in range(N):
    for i in range(N):
      for j in range(N):
        if i<j and i!=k and k!=j and d[i][j]==d[i][k]+d[k][j]:
          #print((i,k),(k,j))
          shortcut_set.add((i,j))
        d[i][j]=min(d[i][j],d[i][k]+d[k][j])
  return d

mat=[]
for i in range(N):
  mat.append([int(x) for x in input().split()])
#print(mat)

dist=[[float("inf")]*N for i in range(N)]
graph=[[] for _ in range(N)]
for i in range(N):
  for j in range(N):
    if i==j:
      dist[i][i]=0
    else:
      graph[i].append((j,mat[i][j]))
      dist[i][j]=mat[i][j]
#print(graph)
#print(dist)

shortcut_set=set()
dist=warshall_floyd(dist)
#print(dist)

for i in range(N):
  for j in range(N):
    if dist[i][j]!=mat[i][j]:
      print(-1)
      sys.exit(0)
      
answer=0
for i in range(N):
  for j in range(i+1,N):
    if not (i,j) in shortcut_set:
      answer+=dist[i][j]
      
print(answer)

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

int main() {
  int S;
  string k;
  cin >> S;
  if(S/1000==S%1000/100)
    k="Bad";
  else if(S%1000/100==S%100/10)
    k="Bad";
    else if(S%100/10==S%10)
    k="Bad";
  else
    k="Good";
  cout << k << endl;
}

Measured memory_bytes: 256
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const k = +input[0];
const [a, b] = input[1].split(" ").map((x: string): number => +x);

let result = false;
for (let i = a; i <= b; i++) {
	if (i % k === 0) result = true;
}

console.log(result ? "OK" : "NG");


Measured memory_bytes: 29624
//B - Two Switches: 
//Assunto: 
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int a, b, c, d, ans;
    cin >> a >> b >> c >> d;
    if(b < c or d < a) ans = 0;
    else ans = min(d, b) - max(a, c);
    cout << ans << "\n";
}

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

int main(){
    long long n;
    bool ok = true;

    cin >>n;

    vector<string> A(n);
    vector<string> B(0);

    for(int i = 0;i < n;i++){
        cin >> A[i];
    }
    int max =-1;
    int count = 0;
    int pos = 0;
    sort(A.begin(), A.end());
    int tmp =0;

    for(int i = 0;i < n;i++){
        for(int j = i+1;j < n;j++){
            if(A[i] == A[j]){
                count++;
                if(count > max){
                    max = count;
                    pos = i;
                }
            }else{
                break;
            }
            
        }
        i+=count;
        count=0;
    }
    for(int i = 0;i < n;i++){
        for(int j = i+1;j < n;j++){
            if(A[i] == A[j]){
                count++;
                if(count == max){
                    pos = i;
                    string a = A[pos];
                    B.push_back(a);
                }
            }else{
                break;
            }
            
        }
        i+=count;
        count=0;
    }
    //B.erase(unique(B.begin(), B.end()), B.end());

    if(max == -1){
    for(int i = 0;i < A.size();i++){
        cout << A[i] <<endl;
    }

    }else{
    for(int i = 0;i < B.size();i++){
        cout << B[i] <<endl;
    }

    }

}



Measured memory_bytes: 14208
N,K = map(int,input().split())

MOD = 10**9+7

def comb(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    k=min(n-k,k)
    ans=1
    inv=[1]*(k+1)
    if k>=1:
        ans*=(n-k+1)%MOD
    for i in range(2,k+1):
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        ans=ans*(n-k+i)*inv[i]%MOD
    return ans

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

Measured memory_bytes: 3316
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ALucky7 solver = new ALucky7();
		solver.solve(1, in, out);
		out.close();
	}

	static class ALucky7 {
		public void solve(int testNumber, Scanner in, PrintWriter out) {
			String num = in.next();
			boolean ok = false;
			for (char ch : num.toCharArray()) {
				if (ch == '7') {
					ok = true;
					break;
				}
			}

			out.print(ok ? "Yes" : "No");
		}

	}
}



Measured memory_bytes: 27044
#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() {
    vector<vector<int>> c(3, vector<int>(3)) ;

    rep(i,3) {
        rep(j,3) {
            cin >> c.at(i).at(j);
        }
    }

    rep(a1,101) {
        rep(a2,101) {
            rep(a3,101) {
                rep(b1,101) {
                    if ((a1+b1)>100 || (a2+b1)>100 || (a3+b1)>100) continue;
                    if ((a1+b1) != c.at(0).at(0)) continue;
                    if ((a2+b1) != c.at(1).at(0)) continue;
                    if ((a3+b1) != c.at(2).at(0)) continue;
                    rep(b2,101) {
                        if ((a1+b2)>100 || (a2+b2)>100 || (a3+b2)>100) continue;
                        if ((a1+b2) != c.at(0).at(1)) continue;
                        if ((a2+b2) != c.at(1).at(1)) continue;
                        if ((a3+b2) != c.at(2).at(1)) continue;
                        rep(b3,101) {
                            if ((a1+b3)>100 || (a2+b3)>100 || (a3+b3)>100) continue;
                            if ((a1+b3) != c.at(0).at(2)) continue;
                            if ((a2+b3) != c.at(1).at(2)) continue;
                            if ((a3+b3) != c.at(2).at(2)) {
                                continue;
                            } else {
                                cout << "Yes" << endl;
                                return 0;
                            }
                        }
                    }
                }
            }
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3604
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <array>
#include <functional>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <stack>

int main()
{
	//std::cout << std::fixed << std::setprecision(15);

	int n, m;
	std::cin >> n >> m;

	if (n == m)
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using LL = long long int;
#define MAX 1000000000000
using namespace std;

bool is_prime(long long N) {
	if (N == 1) return false;
	for (long long i = 2; i * i <= N; ++i) {
		if (N % i == 0) return false;
	}
	return true;
}

vector<long long> enum_divisors(long long N) {
	vector<long long> res;
	for (long long i = 1; i * i <= N; ++i) {
		if (N % i == 0 ) {
			if (is_prime(i) == true) {
				res.push_back(i);
			}
			// 重複しないならば i の相方である N/i も push
			if (N / i != i && is_prime(N / i) == true) res.push_back(N / i);
		}
	}
	// 小さい順に並び替える
	sort(res.begin(), res.end());
	return res;
}


int main() {
	LL N, ans = 0;
	cin >> N;
	vector<LL> a = enum_divisors(N);
	for (int i = 0; i < a.size(); i++) {
		LL ai = a[i];
		LL ai_n = a[i];
		while (true) {
			LL amari = N % ai_n;
			if (amari != 0) {
				break;
			}
			N = N / ai_n;
			ai_n = ai_n * ai;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main () {

	int S;
	int s, m, h;
	scanf("%d" , &S);

	s = S % 60;
	S /= 60;
	m = S % 60;
	S /= 60;
	h = S;
	

	printf("%d:%d:%d\n", h, m, s);

	return 0;



}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	vector<int> s = a;
	sort(s.rbegin(), s.rend());
	for (int i = 0; i < n; ++i) {
		int ans = s[0];
		if (s[0] == a[i]) ans = s[1];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include<assert.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

signed main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, 0, n) cin >> a[i];
    bool p = 1, s = 1;

    set<int> st;
    rep(i, 0, n) {
        int q = a[i];
        for (int j = 2; j * j <= q; j++) {
            if (q % j == 0) {
                assert(j!=1);
                //if (*st.find(j) == j) {
                if(st.count(j)>0){
                    p = 0;
                    break;
                }
                st.insert(j);
                while (q % j == 0) {
                    q /= j;
                }
            }
        }
        assert(q>=1);
        if (q != 1) {
            //if (*st.find(q) == q) p = 0;
            if(st.count(q)>0)p=0;
        }
        st.insert(q);
        if (!p) break;
    }

    // for (auto p : st) cout << p << " ";

    int now = a[0];
    rep(i, 0, n) { now = gcd(now, a[i]); }
    if (now != 1) s = 0;

    if (p) {
        cout << "pairwise coprime\n";
    } else if (s) {
        cout << "setwise coprime\n";
    } else {
        cout << "not coprime\n";
    }
}


Measured memory_bytes: 11432
#include <iostream>
using namespace std;
int  A, B;

int main() {
	cin >> A >> B;
	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0)cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}




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

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());

    int D;
    cin >> D;

    if (D == 25) {
        cout << "Christmas" << endl;
    } else if (D == 24) {
        cout << "Christmas Eve" << endl;
    } else if (D == 23) {
        cout << "Christmas Eve Eve" << endl;
    } else {
        cout << "Christmas Eve Eve Eve" << endl;
    }
}


Measured memory_bytes: 256