akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,k;
    cin>>n>>k;
    vp vec(n);
    REP(i,n){
        cin>>vec[i].se>>vec[i].fi;
    }
    sort(all(vec),greater<>());
    priority_queue<P,vp,greater<>> que;
    ll sum=0;
    set<int> se;
    REP(i,k){
        sum+=vec[i].fi;
        if(se.count(vec[i].se)){
            que.push(vec[i]);
        }else{
            se.insert(vec[i].se);
        }
    }
    ll ans=sum+se.size()*se.size();
    FOR(i,k,n){
        if(!que.size()){
            break;
        }
        if(se.count(vec[i].se)){
            continue;
        }
        P p=que.top();que.pop();
        sum-=p.fi;
        sum+=vec[i].fi;
        se.insert(vec[i].se);
        chmax(ans,sum+(ll)se.size()*(ll)se.size());
    }

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

Measured memory_bytes: 5752
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a>=13){
      System.out.println(b);
    }else if(a>=6 && a<=12){
      System.out.println(b/2);
    }else{
      System.out.println("0");
    }
  }
}

Measured memory_bytes: 24020
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;
 
int main(){

	int n;
	cin >> n;
	while(n--){
		string s1, s2;
		cin >> s1 >> s2;
		
		int carry = 0;
		
		//int mini = min(s1.size(), s2.size());
		int maxi = max(s1.size(), s2.size());
		string ans = "";
		
		REP(i, 0, maxi){
			int sum = carry;
			if(i < s1.size()) sum += (int)(s1[s1.size() - 1 - i] - '0');
			if(i < s2.size()) sum += (int)(s2[s2.size() - 1 - i] - '0');
			ans += ('0' + sum % 10);
			carry = sum / 10;
		}
		if(carry != 0) ans += ('0' + carry);
		reverse(ans.begin(), ans.end());
		if(ans.size() <= 80) cout << ans << endl;
		else cout << "overflow" << endl;
	}
	
	return 0;
}

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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
    string S, T;
    cin >> S >> T;
    
    int N = S.length();

    for (int i = 0; i < N; i++)
    {
        int pos = 0;
        while (S[(i + pos) % N] == T[pos] && pos < N) pos++;
        if (pos == N)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
typedef unsigned long long ll;
using namespace std;

int main(void) {
    int N, M; cin >> N >> M;
    int C[M];
    for(int l = 0; l < M; l++) C[l] = 0;
    
    for(int i = 0; i < N; i++){
        int K; cin >> K;
        for (int j = 0; j < K; j++) {
            int y; cin >> y;
            C[y - 1]++;
        }
    }
    int ans = 0;
    for(int l = 0; l < M; l++){
        if (C[l] == N )
            ans += 1;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    ll N;
    cin >> N;
    for(ll i = N; i > 0; i--){
        ll rem = i * (i-1) / 2;
        if(rem < N){
            cout << i << "\n";
            N -= i;
        }
    }
    return 0;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
q=int(input())

for i in range(q):
    query=list(map(int,input().split()))
    b=A[query[0]:query[1]]
    b.reverse()
    A[query[0]:query[1]]=b

print(' '.join(map(str,A)))



Measured memory_bytes: 5636
import heapq

N = int(input())
A = [int(i) for i in input().split()]

B = []
C = []

for i in range(N):
    B.append(A[i])
    C.append(A[2*N+i]*(-1))

heapq.heapify(B)
heapq.heapify(C)

M = []
b = 0

for i in range(N+1):
    if i == 0:
        b = sum(B)
    else:
        heapq.heappush(B,A[N+i-1])
        b = b + A[N+i-1] - heapq.heappop(B)
    M.append(b)

m = []
c = 0

for i in range(N+1):
    if i == 0:
        c = sum(C)
    else:
        heapq.heappush(C,A[2*N-i]*(-1))
        c = c - A[2*N-i] - heapq.heappop(C)
    m.append(c*(-1))

ans = -float('inf')
for i in range(N+1):
    ans = max(ans,M[i]-m[N-i])

print(ans)

Measured memory_bytes: 37212
//long long使う！！！！！！
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;

ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}

const ll big=998244353;
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x);
    ll t=exp(x,y/2);
    return (t*t);
}
 
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

typedef pair<int,int> p;



int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(0);
    /*--------------------------------*/
    
    vector<int> x(5);
    rep(i,5){cin >> x[i];if(x[i]==0)cout << i+1 << endl;}
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
void fp(bool flag, string s, string t){
    if(flag)cout << s << endl;
    else cout << t << endl;
}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
signed main(){
    cout << fixed << setprecision(10);
    intl x,y;
    cin >> x >> y;
    intl a,b,c;
    cin >> a >> b >> c;
    intl p[a],q[b],r[c];
    cin(i,p);
    cin(i,q);
    cin(i,r);
    sort(p, p + a,greater<>());
    sort(q, q + b,greater<>());
    sort(r, r + c,greater<>());
    intl pi = x - 1;
    intl qi = y - 1;
    //rdebug(i,r);
    rep(i,c){
        if(pi < 0)pi = 0;
        if(qi < 0)qi = 0;
        if((p[pi] < r[i])&&(q[qi] >= r[i])){
            p[pi] = r[i];
            pi--;
        }
        else if((p[pi] >= r[i])&&(q[qi] < r[i])){
            q[qi] = r[i];
            qi--;
        }
        else if((p[pi] < r[i])&&(q[qi] < r[i])){
            if(p[pi] > q[qi]){
                q[qi] = r[i];
                qi--;
            }
            else {
                p[pi] = r[i];
                pi--;    
            }
        }
        else break;
    }
    intl xi = 0;
    intl yi = 0;
    rep(i,x){
        xi += p[i];
    }
    rep(i,y){
        yi += q[i];
    }
    cout << xi + yi << endl;
    return 0;
}

Measured memory_bytes: 2560
n,m = list(map(int,input().split()))
tmp = [list(map(int,input().split())) for i in range(m)]
cities = [[] for i in range(n+1)]


for i,(pref,year) in enumerate(tmp):
    cities[pref].append([year,i])
    
answers = [""] * m
for i in range(n+1):
    for j,(year,index) in enumerate(sorted(cities[i])):
        answer = str(i).zfill(6) + str(j+1).zfill(6)
        answers[index] = answer
        
print(*answers,sep=("\n"))

Measured memory_bytes: 56616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,Y;
  cin>>N>>Y;
  bool ans_i=false; bool ans_j=false; bool ans_k=false;
  for(int i=0;i<=N;i++){
    for(int j=0;i+j<=N;j++){
      for(int k=0;i+j+k<=N;k++){ 
        if(i+j+k==N&&10000*i+5000*j+1000*k==Y){
          cout<<i<<" "<<j<<" "<<k<<endl;
          ans_k=true;
          break;}
      }
        if(ans_k){
          ans_j=true;
        break;}
    }
     if(ans_j){
       ans_i=true;
       break;}
  }
    if(!ans_i){cout<<"-1"<<" "<<"-1"<<" "<<"-1"<<endl;}
}


Measured memory_bytes: 256
n, q = map(int, input().split())
s = "_{}_".format(input())
td = [input().split() for _ in range(q)]

current_l = 0
current_r = len(s) - 1

for t, d in reversed(td):

    if current_l + 1 < len(s) - 1 and t == s[current_l + 1] and d == "L":
        current_l += 1
    elif t == s[current_l] and d == "R":
        current_l -= 1

    if 0 < current_r - 1 and t == s[current_r - 1] and d == "R":
        current_r -= 1
    elif t == s[current_r] and d == "L":
        current_r += 1

print(max(current_r - current_l - 1, 0))


Measured memory_bytes: 41388
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int power(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


int a, b, c;

int read() {
  if (scanf("%d%d%d", &a, &b, &c) < 3) {
    return 0;
  }
  return 1;
}

void solve() {
  int res = 0;
  while (!(a & 1) && !(b & 1) && !(c & 1)) {
    long long sum = a;
    sum += b;
    sum += c;
    a = (sum - a) / 2;
    b = (sum - b) / 2;
    c = (sum - c) / 2;
    ++res;
    if (res > (int) 1e8) {
      printf("-1\n");
      return;
    }
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main() {
  int H, W, D;
  cin >> H >> W >> D;
  vector<i64> ah(H * W + 1), aw(H * W + 1);
  for(int i = 0;i < H;i++) {
    for(int j = 0;j < W;j++) {
      int a;
      cin >> a;
      ah[a] = i;
      aw[a] = j;
    }
  }

  vector<i64> dp(H * W + 1);
  for(int i = D + 1;i <= H * W;i++) dp[i] = dp[i - D] + abs(ah[i] - ah[i - D]) + abs(aw[i] - aw[i - D]);

  int Q;
  cin >> Q;
  for(int q = 0;q < Q;q++) {
    int l, r;
    cin >> l >> r;
    cout << dp[r] - dp[l] << endl;
  }
}


Measured memory_bytes: 3200
var a:array[0..100000]of longint;
    n,x,ans,i:longint;
begin
  readln(n);
  for i:=1 to n do
  begin
    read(x);
    if x>n then
      inc(ans)
    else
      inc(a[x]);
  end;
  for i:=1 to n do
    if a[i]<>0 then
      if a[i]<i then
        inc(ans,a[i])
      else
        if(a[i]>i) then
          inc(ans,a[i]-i);
  writeln(ans);
end.

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define pb push_back
int main(){
    string s; cin>>s;
    int tam = (int)s.size();
    if(tam%2==1){cout<<"No"<<endl; return 0;}
    for(int i=0; i<tam; i+=2){
        if(s[i]!='h' || s[i+1]!='i'){cout<<"No"<<endl; return 0;}
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
power = sum(B)
def draw(a, b):
    ba = a-b
    if ba < 0 :
        return 0, -ba
    else:
        return ba, 0

for i in range(N):
    B[i],A[i] = draw(B[i], A[i])
    A[i+1], B[i] = draw(A[i+1],B[i])
print(power - sum(B))

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

#define N 36

typedef struct {
    int value;
    char mark;
} TRUNP;

int main(){
    int n, i, j, cnt = 0, min, flg, stable_i[13]={}, stable_ti[13]={};
    char tmp[4], stable[13][N], stable_t[13][N];
    TRUNP C[N], RESULT[N], tmp_c;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%s", tmp);
        RESULT[i].mark = C[i].mark = tmp[0];
        RESULT[i].value = C[i].value = atoi(&tmp[1]);
        stable[C[i].value][stable_i[C[i].value]] = C[i].mark;
        stable_i[C[i].value]++;
    }
    
    
    for (i = 0; i < n; i++) {
        for (j = n - 1; j  > i; j--) {
            if (RESULT[j].value < RESULT[j-1].value) {
               tmp_c = RESULT[j];
               RESULT[j] = RESULT[j-1];
               RESULT[j-1] = tmp_c;
            }
        }
    }
    
    for (i = 0; i < n - 1; i++) {
        printf("%c%d ",RESULT[i].mark, RESULT[i].value);
    }
    printf("%c%d\n",RESULT[i].mark, RESULT[i].value);
    
    for (i = 0; i < n; i++) {
        stable_t[RESULT[i].value][stable_ti[RESULT[i].value]] = RESULT[i].mark;
        stable_ti[RESULT[i].value]++;
    }
    
    flg = 0;
    
    for (i = 0; i < 13; i++) {
        for (j = 0; j < stable_i[i]; j++) {
            if (stable[i][j] != stable_t[i][j]) flg = 1;
        }
    }
    if (flg) printf("Not stable\n");
    else printf("Stable\n");
    
    for (i = 0; i < n; i++) {
        min = i;
        for (j = i; j < n; j++) {
            if (C[j].value < C[min].value) {
                min = j;
            }
        }
        tmp_c = C[i];
        C[i] = C[min];
        C[min] = tmp_c;
    }
    
    for (i = 0; i < n - 1; i++) {
        printf("%c%d ",C[i].mark, C[i].value);
    }
    printf("%c%d\n",C[i].mark, C[i].value);

    for (i = 0; i < 13; i++) {
        stable_ti[i]  = 0;
    }

    for (i = 0; i < n; i++) {
        stable_t[C[i].value][stable_ti[C[i].value]] = C[i].mark;
        stable_ti[C[i].value]++;
    }
    
    
    flg = 0;
    for (i = 0; i < 13; i++) {
        for (j = 0; j < stable_i[i]; j++) {
            if (stable[i][j] != stable_t[i][j]) flg = 1;
        }
    }
    if (flg) printf("Not stable\n");
    else printf("Stable\n");
    
    return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=LLONG_MAX;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  string s;
  cin>>s;
  int cnt[26]={};
  REP(i,4){
    cnt[(int)(s[i]-'A')]++;
  }
  int num=0;
  REP(i,26){
    if(cnt[i]==2){
      num++;
    }
  }
  if(num==2){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


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


void solve(std::string S){
    int cnt = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] != S[i+1]) cnt++;
    }
    cout << cnt - 1 << endl;
}

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


Measured memory_bytes: 512
#include <iomanip>
#include <iostream>
#include <cmath>

using namespace std;

int main(){
	int n;
	cin >> n;
	double dist, x2, x[n];
	double d1 = 0, d2 = 0, d3 = 0, dinf = 0;
	for(int i = 0; i < n; i++){
		cin >> x[i];
	}
	for(int i = 0; i < n; i++){
		cin >> dist;
		dist = abs(x[i] - dist);
		x2 = dist*dist;
		d1 += dist;
		d2 += x2;
		d3 += x2*dist;
		if(dist > dinf) dinf = dist;
	}

	cout << fixed << setprecision(5)
			<< d1 << endl
			<< sqrt(d2) << endl
			<< cbrt(d3) << endl
			<< dinf << endl;
	return 0;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	if (abs(n - m) > 1)cout << 0 << endl;
	else {
		int p = max(n, m);
		vl v(p + 1);
		v[0] = 1;
		REP(i, p) {
			v[i + 1] = v[i] * (i + 1);
			v[i + 1]  %= MOD;
		}
		if (n == m)cout << v[n] * v[m] * 2 % MOD << endl;
		else cout << v[n] * v[m] % MOD << endl;
	}
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100010],b[100010],c[100010];
int f[100010][5];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
	}
	f[1][1]=a[1];
	f[1][2]=b[1];
	f[1][3]=c[1];
	for(int i=2;i<=n;i++)
	{
		f[i][1]=a[i]+max(f[i-1][2],f[i-1][3]);
		f[i][2]=b[i]+max(f[i-1][1],f[i-1][3]);
		f[i][3]=c[i]+max(f[i-1][1],f[i-1][2]);
	}
	printf("%d",max(f[n][1],max(f[n][2],f[n][3])));
	return 0;
}


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

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

	int num = N, sum = 0, dig = 0;
	for (int num = N; num>0; num = num / 10) {
		dig = num % 10;
		sum = sum + dig;
	}
	string CHECKER = "No";
	if (num % sum == 0) {
		CHECKER = "Yes";
	}

	cout << CHECKER << endl;
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


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

    int lst[n+1][n+1];
    REPP(i,1,n+1) REPP(l,1,n+1) lst[i][l] = 0;

    int idx,op,tmp;
    for(int i = 0; i < n;i++){
        cin >> idx >> op;
        for(int l = 0; l < op;l++){
            cin >> tmp;
            lst[idx][tmp] = 1;
        }
    }

    for(int i = 1; i < n+1;i++){
        for(int l = 1; l < n+1;l++){
            cout << lst[i][l];
            if(l != n){
                cout << " ";
            }
        }
        cout << endl;
    }


    

    return 0;
}


Measured memory_bytes: 3224
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A;
    cin >> A;
    int flag = 0;
    for(int i = 1; i <=9; i++){
        if(A%i == 0){
            
            if(A/i <= 9){
               cout << "Yes" << endl;
               return 0;
            }
        }
    }
    cout << "No" << endl;

}


Measured memory_bytes: 256
r = float(input())
pi = 3.141592653589

# print("%F %F"%(r*r*pi, 2*r*pi))
# print("{0:.6f} {1:.6f}".format(r*r*pi, 2*r*pi))
print(f"{r*r*pi:.6f} {2*r*pi:.6f}")


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

int main() {
	int		a[3][3];
	int		b,c,i,j,k,n,m,x,y,ans = 0;
	string	str;
	
	for(i=0;i<3;i++) for(j=0;j<3;j++)
		cin >> a[i][j];

	cin >> n;
	
	for(k=0;k<n;k++) {
		cin >> x;
		for(i=0;i<3;i++) for(j=0;j<3;j++) {
			if (a[i][j] == x) a[i][j] = 0;
		}
	}
	
	for(i=0;i<3;i++) {
		ans = 0;
		for(j=0;j<3;j++) {
			if (a[i][j] == 0) continue;
			ans = 1;
		}
		if (ans == 0) break;
	}
	
	if (ans == 1) {
		for(i=0;i<3;i++) {
			ans = 0;
			for(j=0;j<3;j++) {
				if (a[j][i] == 0) continue;
				ans = 1;
			}
			if (ans == 0) break;
		}
	}
	
	if ((a[0][0] == 0) && (a[1][1] == 0) && (a[2][2] == 0)) ans = 0;
	if ((a[2][0] == 0) && (a[1][1] == 0) && (a[0][2] == 0)) ans = 0;
	
	if (ans == 1)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val S = next()
    val C = mutableMapOf<Char, Int>('0' to 0, '1' to 0)
    S.forEach { C[it] = C[it]!! + 1 }
    println(2 * Math.min(C['0']!!, C['1']!!))
}
fun next() = readLine()!!

Measured memory_bytes: 36268
#include <bits/stdc++.h>
using namespace std;
long long a[200010], b[200010], n, m, k, ans;
signed main()
{
    cin >> n >> m >> k;
    for (long long i = 1; i <= n; i++)
    {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    for (long long i = 1; i <= m; i++)
    {
        cin >> b[i];
        b[i] += b[i - 1];
    }
    for (long long i = 0; i <= n; i++)
    {
        if (a[i] > k)
            break;
        ans = max(ans, (long long)(i + (upper_bound(b + 1ll, b + m + 1ll, k - a[i]) - b) - 1ll));
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 6720
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(),(obj).end()

using namespace std;


int main() {
	speed;
	vector <int> a;
	rep(i, 3) {
		int b;
		cin >> b;
		a.push_back(b);
	}
	sort(All(a));
	int ans = a.at(0)*a.at(1);

	cout << ans/2;
	ed;
	return 0;
}


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

int main(){
    int n;string s;
    cin>>n;
    set<string> st;
    for(int i=0;i<n;i++){
        cin>>s;
        st.insert(s);
    }
    cout<<st.size()<<endl;
}

Measured memory_bytes: 19196
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  int D, G;
  cin >> D >> G;

  int p[ D ];
  int c[ D ];
  for( int i = 0; i < D; ++i )
  {
    cin >> p[ i ] >> c[ i ];
  }

  int totalScore[ D ];
  for( int pi = 0; pi < D; ++pi )
  {
    totalScore[ pi ] = 0;
    for( int i = 0; i < p[ pi ]; ++i )
    {
      totalScore[ pi ] += 100 * ( pi + 1 );
      if( i == ( p[ pi ] - 1 ) )
      {
        totalScore[ pi ] += c[ pi ];
      }
    }
  }

  vector< int > order( D );
  for( int i = 0; i < D; ++i )
  {
    order[ i ] = i;
  }

  int minSolveNum = 10000;

  auto calcSolveNum = [ & ]( const vector< int >& order, int minSolveNum )
  {
    int solveNum = 0;
    int scoreSum = 0;
    for( auto pi : order )
    {
      if( ( scoreSum + totalScore[ pi ] ) < G )
      {
        scoreSum += totalScore[ pi ];
        solveNum += p[ pi ];

        if( solveNum >= minSolveNum )
        {
          return minSolveNum + 1;
        }

        continue;
      }
      else
      {
        for( int i = 0; i < p[ pi ]; ++i )
        {
          scoreSum += 100 * ( pi + 1 );
          if( i == ( p[ pi ] - 1 ) )
          {
            scoreSum += c[ pi ];
          }

          ++solveNum;

          if( solveNum >= minSolveNum )
          {
            return minSolveNum + 1;
          }

          if( scoreSum >= G )
          {
            return solveNum;
          }
        }
      }
    }
  };

  do
  {
    int solveNum = calcSolveNum( order, minSolveNum );
    if( solveNum < minSolveNum )
    {
      minSolveNum = solveNum;
    }
  } while( next_permutation( order.begin(), order.end() ) );

  cout << minSolveNum << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner in = new Scanner(System.in);

    public static void main(String[] args) {
        char[] ac = in.nextLine().toCharArray(), bc = in.nextLine().toCharArray(), cc = in.nextLine().toCharArray();
        int a = 0, b = 0, c = 0;
        char w = 'a';

        while (true) {
            switch (w) {
            case 'a':
                if (a == ac.length) {
                    System.out.println("A");
                    return;
                }
                w = ac[a++];
                break;
            case 'b':
                if (b == bc.length) {
                    System.out.println("B");
                    return;
                }
                w = bc[b++];
                break;
            case 'c':
                if (c == cc.length) {
                    System.out.println("C");
                    return;
                }
                w = cc[c++];
                break;
            }
        }
    }
}


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

int main() {
int N;
  cin>>N;
  int sum,i;
    sum=0;
  
  for(i=0;i<N;i++){
    int A,B;
    cin>>A>>B;
    sum+=B-A+1;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        s: chars,
    }
    let mut ans = 1usize;
    let mut cnt = vec![0; 26];
    for c in s {
        let k: usize = c.to_digit(36).unwrap() as usize - 10;
        for (i, x) in cnt.iter().enumerate() {
            if i != k {
                ans += *x;
            }
        }
        cnt[k] += 1;
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
n = int(input())
t = [0]
x = [0]
y = [0]
ans = "Yes"
for i in range(n):
    t_i, x_i, y_i = map(int,input().split())
    t.append(int(t_i))
    x.append(int(x_i))
    y.append(int(y_i))

for i in range(n):
    dt = t[i+1] - t[i]
    dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    if dist > dt:
        ans = "No"
        break
    if dist%2 != dt%2:
        ans = "No"
        break
print(ans)


Measured memory_bytes: 11816
#include <bits/stdc++.h>
using namespace std;
using ll=long long ;
const ll inf=1e18L+5;
// dp[i] is storing the value of minimum weights such that exactly i sum  is possible  
int min1(ll a,ll b){
	return max(a,b);
}
int main(){
	int  n,w,sum=0;
	cin>>n>>w;
	vector <ll > weight(n),val(n);
	for(int i=0;i<n;i++){
		cin>>weight[i]>>val[i];
	}
	for(int x:val){
		sum+=x;
	}
	vector <ll> dp(sum+1,inf);
	dp[0]=0;
	for(int item=0;item<n;item++){
		for(int value=sum-val[item];value>=0;value--){
				dp[value+val[item]]=min(dp[value+val[item]],dp[value]+weight[item]);
		}
	}
	ll ans=0;
	/*
	for (ll i:dp){
		cout<<i<<" ";
	}*/
	for(int i=sum;i>=0;i--){
		if(dp[i]<=w)
			ans=max(ans,(ll)i);
	}
	cout<<ans<<endl;
 }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define nl '\n'
#define f(i, n) for (int i = 0; i < n; ++i)

using namespace std;
void solve() {
    int n, d;
    cin >> n >> d;
    int ans = 0;
    f(i, n) {
        ll a, b;
        cin >> a >> b;
        if (sqrt(a * a + b * b) <= d) ans++;
    }
    cout << ans << nl;
}

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

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int n = in();
  vector<char> v(n);
  cin >> v;

  sort(v);
  v.erase(unique(all(v)), v.end());

  if (v.size() == 3) {
    cout << "Three" << endl;
  } else {
    cout << "Four" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define RREP(i, a, n) for(int i=n-1; i>=a; --i)

int n;
int a[101];
int dp[101010];
int main(void)
{
    cin>>n;
    REP(i, 0, n) cin>>a[i];

    long long sum=1000, stock;
    REP(i, 0, n-1){
        if(a[i]<a[i+1] && sum>=a[i]){
            stock=sum/a[i];
            sum-=(a[i]*stock);
            sum+=(a[i+1]*stock);
        }
    }
    cout<<sum<<endl;
    return 0;
}

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


#define mod 1000000007
#define ull unsigned long long int
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

ll ncr(int n, int k)  
{  
    if(k>n)return 0;
    ll res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
} 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
#define  deb(x)       cout << '>' << #x << ':' << x << endl;
bool comp(pair<string,int> a,pair<string,int> b)
{
    return a.second>b.second;
}
void  solve()
{
    int n;
    cin>>n;
    map<string,int> m;
    set<string> ss;
    int mx=0;
    forn(i,n)
    {
        string s;
        cin>>s;
        m[s]++;
        ss.insert(s);
        mx=max(m[s],mx);
    }
    for(auto i:ss)
    {
        if(m[i]==mx)
        {
            cout<<i<<endl;
        }
    }
    
}


int main()
{
    FastIO;
   // init();
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

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

// int/long:		-2147483648 - 2147483648 (-2^31 <= int < 2^31)
// long/long long:	-9223372036854775808 - 9223372036854775807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536870912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// bit: &/and, |/or, ^/xor, ~/not

#define	MOD 1000000007

bool	P(vector<long> &A, vector<long> &F, long &N, long K, long &CM) {
	for (int i=0; i<N; i++) {
		long x=A.at(i);
		long y=F.at(i);
		if (CM>=x*y)
			continue;
		else {
			long X=CM/y;
			K -=x-X;
		}
		if (K<0)
			return false;
	}
	return true;
}

int	main() {
	long N, K;
	cin >>N >>K;
	vector<long> A(N, 0);
	vector<long> F(N, 0);
	for (long i=0; i<N; i++)
		cin >>A.at(i);
	for (long i=0; i<N; i++)
		cin >>F.at(i);
	sort(A.begin(), A.end());
	sort(F.begin(), F.end());
	reverse(F.begin(), F.end());
	long CH=0;
	for (int i=0; i<N; i++)
		CH=max(CH, A.at(i)*F.at(i));
	long CL=-1;
	while(1<CH-CL) {
		long CM=(CH+CL)/2;
		if (P(A, F, N, K, CM))
			CH=CM;
		else
			CL=CM;
	}
	cout <<CH <<endl;
	return 0;
}



Measured memory_bytes: 3328
import Control.Applicative
data Dice = Dice {x1::Int,x2::Int,x3::Int,x4::Int,x5::Int,x6::Int} deriving Show
main = do
  s <- (map read . words) <$> getLine
  let d = Dice (s!!0) (s!!1) (s!!2) (s!!3) (s!!4) (s!!5 )
  op <- getLine
  putStrLn . show . x1 $ trans op d
  
trans :: [Char] -> Dice -> Dice
trans [] x = x
trans (x:xs) d = case x of 
  'E' -> trans xs (opE d)
  'W' -> trans xs (opW d)
  'N' -> trans xs (opN d)
  'S' -> trans xs (opS d)
  
opE :: Dice -> Dice
opE d = Dice (x4 d) (x2 d) (x1 d) (x6 d) (x5 d) (x3 d)

opW :: Dice -> Dice
opW d = Dice (x3 d) (x2 d) (x6 d) (x1 d) (x5 d) (x4 d)

opN :: Dice -> Dice
opN d = Dice (x2 d) (x6 d) (x3 d) (x4 d) (x1 d) (x5 d)

opS :: Dice -> Dice
opS d = Dice (x5 d) (x1 d) (x3 d) (x4 d) (x6 d) (x2 d)

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

#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(ll i = (m); i < (n); ++i)

#define INF 1e9

const int MAX = 510000;
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;
}


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

  COMinit();
  FOR(i, 1, K+1){
    if(N-K+1 < i){
      cout << 0 << endl;
      continue;
    }
    // cout << i << ": " << COM(N-K+1, i) << " " << COM(K-1, i-1) << endl;
    ll ans = COM(N-K+1, i) * COM(K-1, i-1);
    ans %= MOD;
    cout << ans << endl;
  }
  return 0;
}


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


int main() {
    string s;
    cin >> s;

    int keta = s.length();

    ll sum = 0;
    int index_num = 0;
    int cnt = 0;
    for ( int i = 0; i < (1<<(keta-1)); i++ ) {
        cnt = 0;
        for ( int j = 0; j < keta; j++ ) {
            if ( i & (1<<j) ) {
                sum += stol(s.substr(keta-j-1, cnt+1));
                cnt = 0;
            }
            else {
                cnt++;
            }
        }
        if ( cnt > 0 ) {
//            cout << stol(s.substr(0, cnt)) << " " << i << endl;
            sum += stol(s.substr(0, cnt));
        }
//        cout << i << " " << sum << " " << cnt << endl;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

int n,m,f[101][101];
bool map[101][101];
bool get(){
	char ch=getchar();
	while(ch!='.'&&ch!='#')ch=getchar();
	return (ch=='#');
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			map[i][j]=get();
	memset(f,0x7f7f7f7f,sizeof f);
	f[0][1]=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			f[i][j]=std::min(f[i][j-1]+(map[i][j]&&!map[i][j-1]),f[i-1][j]+(map[i][j]&&!map[i-1][j]));
		}
	printf("%d\n",f[n][m]);
}

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

const int dice[6][4] = {{2,3,5,4},
                        {1,4,6,3},
                        {1,2,6,5},
                        {1,5,6,2},
                        {1,3,6,4},
                        {2,4,5,3}};

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

int roll(int curr, int dir)
{
    int next = dice[curr/4][(dir+curr)%4] - 1;
    for(int i=0; ; ++i){
        if(dice[next][(2+dir+i)%4] - 1 == curr/4){
            next *= 4;
            next += i;
            return next;
        }
    }
}

class Data
{
public:
    int y, x, d;
    Data (int y0, int x0, int d0){
        y = y0;
        x = x0;
        d = d0;
    }
};

int main()
{
    for(;;){
        int h, w;
        cin >> h >> w;
        if(h == 0)
            return 0;

        vector<vector<int> > grid(h, vector<int>(w));
        for(int i=0; i<h; ++i){
            for(int j=0; j<w; ++j){
                cin >> grid[i][j];
            }
        }
        int sy, sx, gy, gx;
        cin >> sy >> sx >> gy >> gx;

        vector<vector<vector<int> > > dp(h, vector<vector<int> >(w, vector<int>(24, INT_MAX)));
        dp[sy][sx][0] = 0;
        multimap<int, Data> m;
        m.insert(make_pair(0, Data(sy, sx, 0)));
        while(!m.empty()){
            int cost = m.begin()->first;
            Data d = m.begin()->second;
            m.erase(m.begin());
            if(cost > dp[d.y][d.x][d.d])
                continue;
            if(d.y == gy && d.x == gx){
                cout << cost << endl;
                break;
            }
            for(int i=0; i<4; ++i){
                Data d1 = Data(d.y+dy[i], d.x+dx[i], roll(d.d, i));
                if(d1.y < 0 || d1.y >= h || d1.x < 0 || d1.x >= w)
                    continue;
                int cost1 = cost + (6 - d1.d/4) * grid[d1.y][d1.x];
                if(cost1 < dp[d1.y][d1.x][d1.d]){
                    dp[d1.y][d1.x][d1.d] = cost1;
                    m.insert(make_pair(cost1, d1));
                }
            }
        }
    }
}

Measured memory_bytes: 936
N,M = map(int,input().split())
A = []
B = []
C = []
for i in range(M):
  a,b = map(int,input().split())
  A.append(a)
  B.append(b)
  c = list(map(int,input().split()))
  C.append(c)
#print(A)
#print(B)
#print(C)

INF = 10**9+7
dp = [INF for _ in range(1<<N)]
dp[0] = 0
for j in range(1<<N):
  for i in range(M):
    t = 0
    for c in C[i]:
      t |= 1<<(c-1)
    dp[j|t] = min(dp[j|t], dp[j] + A[i])
    #print(dp)

print(dp[(1<<N)-1] if dp[(1<<N)-1] != INF else -1)


Measured memory_bytes: 46772
#include<bits/stdc++.h>
using namespace std;
int n,m;
map<int,int> M;
inline void read(int &x)
{
	int data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=(data<<3)+(data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
int main()
{
	read(n);
	for(register int i=1;i<=n;++i)
	{
		int temp;
		read(temp);
		M[temp]++;
	}
	read(m);
	for(register int i=1;i<=m;++i)
	{
		int temp;
		read(temp);
		if(M[temp])M[temp]--;
		else
		{
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

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

int mod = 1'000'000'007;

long long modpow(long long x, long long y){
    if (y == 0) return 1;
    if (y % 2) return x * modpow(x, y - 1) % mod;
    long long res = modpow(x, y / 2);
    return res * res % mod;
}

int main(){
    vector<long long> fac(100'001, 1);
    for (int i = 2; i < 100'001; i++) fac[i] = fac[i - 1] * i % mod;
    vector<long long> inv(100'001, 0);
    inv[1] = 1;
    for (int i = 0; i < 100'001; i++) inv[i] = modpow(fac[i], mod - 2);
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++) cin >> x[i];
    long long ans = 0;
    long long b = 0;
    for (int i = 0; i < n - 1; i++){
        long long tmp = fac[n - 1] * (i + 1) % mod;
        long long c = ((fac[i] * fac[n - 1] % mod) * inv[i + 1] % mod) * i % mod;
        c += b;
        c %= mod;
        b = c;
        tmp += mod - c;
        tmp %= mod;
        tmp *= (x[i + 1] - x[i]);
        tmp %= mod;
        ans += tmp;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int x,z;
    cin>>x>>z;
    cout<<(x+z)%24;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _for(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define FOR(...)   _for (__VA_ARGS__)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;

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

  ll x;
  cin >> x;

  ll ans = 0;
  ans += (x / 500) * 1000;
  x %= 500;
  ans += (x / 5) * 5;
  x %= 5;

  cout << ans << endl;
}


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

using namespace std;

#define pb push_back
#define F first
#define S second
#define ALL(v) v.begin(),v.end()
#define fast_cin() ios_base::sync_with_stdio(0);
#define smid ((i + j) >> 1)
#define lc (sidx * 2)
#define rc (lc + 1)

typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
typedef pair <int,int> pii;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

bool bit(int n, int i) { return (n >> i) & 1; }
int ceil(int a, int b) { return ceil(((ld)a) / b); }

int faltu;

const int mod = 1e9+7;
const ll inf = 4e18;
const ll ninf = -inf;
const int imax = 2e9 + 100;


int main()
{
	time_t t1, t2;
	t1 = clock();
	srand(time(0));
	
	int n;
	cin >> n;
	int a[n + 1];
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int cnt = 0;
	for(int i = 1; i <= n; i++) {
		if(a[i] == a[i - 1]) {
			cnt ++;
			a[i] = -1;
		}
	}
	cout << cnt << endl;

	t2 = clock();
	cerr << "time taken: " << t2 - t1 << endl;
	return 0;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int n;
	cin >> n;
	int a[n];
	rep(i,n) cin >> a[i];
	sort(a,a+n);
	bool able = true;
	if(n%2){
		if(a[0]) able = false;
		for(int i=1; i<n; i+=2){
			if(a[i]!=i+1) able = false;
		}
	}else{
		for(int i=0; i<n; i+=2){
			if(a[i]!=i+1) able = false;
		}
	}
	if(able){
		ll tmp = 1;
		for(int i=0; i<n/2; i++){
			tmp*=2;
			tmp%=1000000007;
		}
		cout << tmp << endl;
	}else{
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 640
N, L = map(int, input().split())

tastes = [i for i in range(L, L+N)]

if tastes[0] * tastes[-1] < 0:
    ans = sum(tastes)
elif tastes[0] >= 0:
    ans = sum(tastes) - tastes[0]
else:
    ans = sum(tastes) - tastes[-1]

print(ans)


Measured memory_bytes: 3060