akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  for (int a = 0; a <= 100; a++) {
    for (int b = 0; b <= 100; b++) {
      if (a * 4 + b * 7 == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
import itertools
N,M,R=map(int,input().split())
towns=[int(i) for i in input().split()]
path=[[10**20]*N for i in range(N)]
for i in range(N):
  path[i][i]=0
for i in range(M):
  a,b,c=map(int,input().split())
  path[a-1][b-1]=c
  path[b-1][a-1]=c

for k in range(N):
  for i in range(N):
    for j in range(i):
      path[i][j]=min(path[i][j],path[i][k]+path[k][j])
      path[j][i]=path[i][j]   
Roots=list(itertools.permutations(towns))
ans=10**20
s=0
for r in Roots:
  for n in range(R-1):
    s+=path[r[n]-1][r[n+1]-1]
  ans=min(ans,s)
  s=0
print(ans)

Measured memory_bytes: 62424
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

#define mem(ar,a)       memset(ar,a,sizeof ar)
#define iOS           	ios_base::sync_with_stdio(false);cin.tie(NULL); 
#define pb(x)           push_back(x)
#define all(c)          c.begin(), c.end()
#define int             long long
#define ff              first
#define ss              second
#define nl              '\n'

int32_t main()
{
	iOS
	int x,n;
	cin>>x>>n;
	vector<int> v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	sort(all(v));
	int res=10000,mini=100000;
	for(int i=0;i<=200;i++){
		if(abs(x-i)<abs(mini) and !binary_search(all(v),i)){
			if(abs(x-i)==abs(mini))
			res=min(res,i);
			else if(abs(x-i)<abs(mini))
				res=i;
			//cout<<i<<" ";
			mini=min(mini,abs(x-i));
		}
	}
	cout<<res;
}



Measured memory_bytes: 3628
import java.util.*;

public class Main {
    static int MAX = 10010017;  // (1 ≦ k ≦ n ≦ 10^7 程度)
    static int MOD = 1000000007;
    static long[] fac;  // 階乗
    static long[] finv;
    static long[] inv;  // 逆元
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        // 2r + b = x
        // r + 2b = y
        // -> r - b = x - y
        // -> (b = x - 2r)
        // -> r - x + 2r = x - y
        // -> r = 2x/3 -y/3
        // -> b = 2y/3 -x/3
        
        if ((x + y) % 3 != 0) {
            System.out.println(0);
            return;
        }
        
        int r = 2 * x / 3 - y / 3;
        int b = 2 * y / 3 - x / 3;
        
        COMinit();
        
        // ans[i]: 赤玉(yx^2)と青玉(xy^2)を並べるパターン数
        long ans = nCkMOD(r+b, r);
        System.out.println(ans);
        
    }
    
    // テーブルを作る前処理
    public static void COMinit() {        
        fac = new long[MAX];
        finv = new long[MAX];
        inv = new long[MAX];
        
        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;
        }
    }
    
    // 二項係数計算(1 ≦ k ≦ n ≦ 10^7 程度)
    public static long nCkMOD(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;
    }
    
    public static long modpow(long a, long n) {
        long res = 1;
        while (n > 0) {
            long tmp = n & 1;
            if (tmp > 0) res = res * a % MOD;
            a = a * a % MOD;
            n >>= 1;
        }
        return res;
    }
}

Measured memory_bytes: 259796
#include <bits/stdc++.h>
using namespace std;
int main() {
    // 入力受け取り, 入次数も管理する
string a,b;
    cin >> a >> b;
  int aa,bb;
aa=stoi(a);
bb=stoi(b);
string tempa="";
string tempb="";
for(int i=0;i<aa;i++){
tempb+=b;
}
for(int i=0;i<bb;i++){
tempa+=a;
}

if(tempa<tempb)cout << tempa;
else cout << tempb;



   
}


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

namespace AtCoder
{
    class Program
    {
        public static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            long A = long.Parse(s[0]);
            long B = long.Parse(s[1]);
            Console.WriteLine(XorGet(A - 1) ^ XorGet(B));
        }

        static long XorGet(long x)
        {
            return (((x + 1) % 4) == 0) ? 0
                 : (((x + 1) % 4) == 1) ? x
                 : (((x + 1) % 4) == 2) ? 1
                                        : x + 1;
        }
    }
}

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

using namespace std;

int main() {
  string S;
  cin >> S;
  unordered_set<char> C;
  for (char c : S) {
    C.insert(c);
  }

  for (char c = 'a'; c <= 'z'; c++) {
    if (C.count(c) == 0) {
      cout << c;
      return 0;
    }
  }
  cout << "None";

  return 0;
}


Measured memory_bytes: 512
import math
from collections import Counter


N = int(input())

def sort_string(s):
    s = list(s)
    s.sort()
    
    return ''.join(s)

S = [sort_string(input()) for _ in range(N)]
c = Counter(S)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

count = 0
for s in c.values():
    if s > 1:
        count += combinations_count(s, 2)

print(count)

Measured memory_bytes: 19820
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    score=0
    for i,a in enumerate(A):
        score+=i+1!=a
    if(score<=2):
        print("YES")
    else:
        print("NO")
resolve()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define per(i,n) for(int i=(n)-1; i>=0; i--)
using namespace std;
using vi = vector<int>;
using vv = vector<vi>;

int main(){
    double t,x;cin>>t>>x;
    printf("%.10lf\n", t/x);
    return 0;
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define s 1000000000000001
main()
{
   ll n,i;
   cin>>n;char ans[10005],k1=0;
   ll ara[100];ara[1]=0;ara[2]=26;
   for(i=3;i<=100;i++)
   {
       ara[i]=ara[i-1]+(ara[i-1]-ara[i-2])*26;
       if(ara[i]>s)
       {
           break;
       }
       //cout<<i<<" "<<ara[i]<<endl;
   }
   //cout<<1<<endl;
   for(i=1;;i++)
   {
       //cout<<i<<endl;
       if(i==1)
       {
           ll a=n%26;
           if(a==0)a=26;
           ans[k1]=a+96;k1++;continue;
       }
       if(n<=ara[i])
       {
           break;
       }
       ll a=ara[i]-ara[i-1],d=n-ara[i];
       ll d1=d/a;
       if(d%a!=0)
       {
           d1++;
       }
       ll a1=d1%26;
       if(a1==0)a1=26;
       ans[k1]=a1+96;k1++;
   }
   //cout<<1<<endl;
   for(i=k1-1;i>=0;i--)
   {
       printf("%c",ans[i]);
   }
   cout<<endl;
}


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

using namespace std;

int main()
{
	multiset<int, greater<int> > heights;
	int height;
	
	for (int i=0; i<10; i++)
	{
		cin >> height;
		heights.insert(height);
	}
	
	multiset<int>::iterator it = heights.begin();
	//while( it != heights.end() )
	for (int i=0; i<3; i++)
	{
		cout << *it << endl;
		++it;
	}
	
	
}

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

int main() {

    long long int N;
    long long int a[5];
    long long int min = 1e15+1;
    cin >> N;
    for (int i=0; i<5; i++) {
        cin >> a[i];
        if (a[i] < min) {
            min = a[i];
        }
    }

    cout << 5 + (N - 1)/min << endl;

    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x, y;
    cin >> x >> y;
    if(abs(x-y) <= 1) cout << "Brown" << endl;
    else cout << "Alice" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

const int INF = INT_MAX / 2;

vector<int> xs;
vector<int> ys;

int main(void) {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;

    int xmin = X;
    int xmax = X;
    int ymin = Y;
    int ymax = Y;

    xs.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> xs[i];
        chmin(xmin, xs[i]);
        chmax(xmax, xs[i]);
    }

    ys.resize(M);
    for (int i = 0; i < M; i++) {
        cin >> ys[i];
        chmin(ymin, ys[i]);
        chmax(ymax, ys[i]);
    }

    if (xmax < ymin) {
        cout << "No War" << endl;
    } else {
        cout << "War" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip, std.datetime;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;

    long ans = N;
    int left = 0;
    long xxx = 0;

    foreach (i; 0..N) {
        while (left < i && (xxx + A[i] != (xxx ^ A[i]))) {
            xxx ^= A[left];
            left += 1;
        }
        xxx ^= A[i];
        ans += i - left;
    }

    ans.writeln;
}


Measured memory_bytes: 11356
#include<bits/stdc++.h>
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> B;
  int tmp=A[0];
  for(int i=0; i<N; i++){
    if(tmp==A[i]) continue;
    else{
      B.push_back(tmp);
      tmp = A[i];
    }
  }
  B.push_back(tmp);
  if(B.size()==1){
    cout << "1" << endl;
    return 0;
  }
  int ans =0;
  for(int i=0; i<B.size()-2; i++){
    if(B[i]<B[i+1] && B[i+1]>B[i+2]){
      ans++;
      i=i+1;
    }
    else if(B[i]>B[i+1] && B[i+1]<B[i+2]){
      ans++;
      i=i+1;
    }
  }
  cout << ans+1 << endl;
  return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 3005;
int n, mod, fac[N], inv[N], S[N][N], pw[4100], pw2[2200], ans;
inline void qmo(int &x){x += (x >> 31) & mod;}
inline int calc(int x){return (LL) pw[x & 4095] * pw2[x >> 12] % mod;}
inline int ksm(int a, int b, int p = mod){
	int res = 1;
	for(;b;b >>= 1, a = (LL) a * a % p) if(b & 1) res = (LL) res * a % p;
	return res;
}
inline int C(int n, int m){
	if(n < 0 || m < 0 || n < m) return 0;
	return (LL) fac[n] * inv[m] % mod * inv[n - m] % mod;
}
int main(){
	scanf("%d%d", &n, &mod);
	S[0][0] = fac[0] = 1;
	for(Rint i = 1;i <= n;++ i) fac[i] = (LL) fac[i - 1] * i % mod;
	inv[n] = ksm(fac[n], mod - 2);
	for(Rint i = n;i;-- i) inv[i - 1] = (LL) inv[i] * i % mod;
	for(Rint i = 1;i <= n + 1;++ i)
		for(Rint j = 1;j <= i;++ j)
			qmo(S[i][j] = (LL) j * S[i - 1][j] % mod + S[i - 1][j - 1] - mod);
	pw[0] = pw2[0] = 1;
	for(Rint i = 1;i <= 4096;++ i) qmo(pw[i] = pw[i - 1] * 2 - mod);
	pw2[1] = pw[4096];
	for(Rint i = 2;i <= 2197;++ i) pw2[i] = (LL) pw2[i - 1] * pw2[1] % mod;
	for(Rint i = 0;i <= n;++ i){
		int tmp = 0;
		for(Rint j = 0;j <= i;++ j) qmo(tmp += (LL) S[i + 1][j + 1] * calc((n - i) * j) % mod - mod);
		tmp = (LL) tmp * C(n, i) % mod * ksm(2, ksm(2, n - i, mod - 1)) % mod;
		if(i & 1) qmo(ans -= tmp); else qmo(ans += tmp - mod);
	}
	printf("%d", ans); 
}

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

#define FOR(i, j, k) for(int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for(T &x : vec)
        is >> x;
    return is;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    string s;
    cin >> s;

    bool ans = true;
    REP(i, s.size() - 1) {
        if(s[i] == s[i + 1])
            ans = false;
    }

    if(ans) {
        cout << "Good" << endl;
    } else {
        cout << "Bad" << endl;
    }

    return 0;
}


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

int main() {
    int N ,K;
    string S;
    cin>>N>>K;
    cin>>S;
    int ans=0;
    if(N==1){
        cout<<0<<endl;
        return 0;
    }
    
    int Lcount=0,Rcount=0;
    for(int i=0;i<N;i++){
        if(S[i]=='L'){
            Lcount++;
            for(i;i<N;i++){
                if(S[i]=='R'){
                    break;
                }
            }
            i--;
        }else{
            Rcount++;
            for(i;i<N;i++){
                if(S[i]=='L'){
                    break;
                }
            }
            i--;
        }
    }
    if(Lcount<=K||Rcount<=K){
        cout<<N-1<<endl;
        return 0;
    }
    if(S[0]=='R'){if(S[1]=='R')ans++;}
    if(S[N-1]=='L'){if(S[N-2]=='L')ans++;}
    for(int i=1;i<N-1;i++){
        if(S[i]=='R'){
            if(S[i+1]=='R')ans++;
        }else{
            if(S[i-1]=='L')ans++;
        }
    }
    ans+=K*2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String tmp = br.readLine();
			
			if(tmp == null){
				break;
			}
			
			char prev = '\0';
			int num = 0;
			for(int i = tmp.length() - 1; i >= 0; i--){
				char tmpChar = tmp.charAt(i);
				if(romanToNum(prev) > romanToNum(tmpChar)){
					num -= romanToNum(tmpChar);
				}
				else {
					num += romanToNum(tmpChar);
				}
				
				prev = tmpChar;
				
			}
			
			System.out.println(num);
		}
	}
	
	static int romanToNum(char c){
		if(c == 'I'){
			return 1;
		}
		else if(c == 'V'){
			return 5;
		}
		else if(c == 'X'){
			return 10;
		}
		else if(c == 'L'){
			return 50;
		}
		else if(c == 'C'){
			return 100;
		}
		else if(c == 'D'){
			return 500;
		}
		else if(c == 'M'){
			return 1000;
		}
		else {
			return 0;
		}
	}

}

Measured memory_bytes: 24160
class christmas:
    def __init__(self,layers,levels):
        self.layers=layers
        self.levels=levels
        self.sum=[1]
        self.patty=[1]
    def num_patties(self):
        for i in range(self.levels):
            self.sum.append(2*self.sum[i]+3)
            self.patty.append(2*self.patty[i]+1)
        def f(layer,level):
            
            if layer==0:
                return 0
            temp=self.sum[level]
            if layer==temp:
                return self.patty[level]
            if layer>temp:
                if layer==temp+1:
                    return self.patty[level]+1
                return self.patty[level]+1+f(layer-temp-1,level)
            return f(layer-1,level-1)
        return f(self.layers,self.levels)
s=input().split()
level=int(s[0])
layer=int(s[1])
s=christmas(layer,level)
print(s.num_patties())

Measured memory_bytes: 3064
def main():
    MOD = 998244353

    n, m, k = map(int, input().split())
    fact = [0] * 220000
    invfact = [0] * 220000

    fact[0] = 1
    for i in range(1, 220000):
        fact[i] = fact[i-1] * i % MOD

    invfact[220000 - 1] = pow(fact[220000 - 1], MOD-2, MOD)
    for i in range(220000-2, -1, -1):
        invfact[i] = invfact[i+1] * (i+1) % MOD

    def nCk(n, k):
        if k < 0 or n < k: return 0
        return fact[n] * invfact[k] * invfact[n - k] % MOD

    ans = 0

    for i in range(0, k+1):
        ans += m * pow(m-1, n-i-1, MOD) * nCk(n-1, i) % MOD

    print(ans%MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26252
N, K = map(int, input().split())
count1 = 0
count2 = 0
ans = 0
for i in range(1, N + 1):
  if i % K == 0:
    count1 += 1
  elif i % K == K / 2:
    count2 += 1
ans += count1 ** 3
ans += count2 ** 3
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end());
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 2001;
string s;
int R[N], B[N], mr[N], mb[N], ar, ab, n;
ll DP[4001], DP2[4001];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  n = sz(s);
  FOR(i, 0, n){
    switch(s[i]){
      case '0':
        ar += R[i+1] = 2;
        break;
      case '1':
        ar += R[i+1] = 1;
        ab += B[i+1] = 1;
        break;
      case '2':
        ab += B[i+1] = 2;
        break;
      default:
        break;
    }
  }
  FOR(i, 0, n){
    mr[i+1] = mr[i];
    if(R[i] == 2) mr[i+1]++;
    if(R[i+1] >0) mr[i+1]++;
    mb[i+1] = mb[i];
    if(B[i] == 2) mb[i+1]++;
    if(B[i+1] >0) mb[i+1]++;
  }
  DP[0] = 1;
  FOR(i, 1, n*2+1){
    FOR(j, 0, i+1){
      DP2[j] = 0;
      int r = j, b = i-j;
      if((i<=n) ? (r<=mr[i] && b<=mb[i]) : (r<=ar && b<=ab)){
        if(r) DP2[j] += DP[j-1];
        if(b) DP2[j] += DP[j];
        DP2[j] %= MOD;
      }else{
        DP2[j] = 0;
      }
    }
    swap(DP, DP2);
  }
  cout << DP[ar] << endl;
}

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


auto solve(string A, string B){
    if(A.size() < B.size()) {
        return "LESS";
    }
    else if(B.size() < A.size()) {
        return "GREATER";
    }
    else {
        int i = 0;
        for(;i < A.size(); ++i) {
            int a = A[i] - '0';
            int b = B[i] - '0';
            if(b < a) {
                return "GREATER";
            }
            else if(a < b) {
                return "LESS";
            }
        }
    }

    return "EQUAL";
}

int main(){
    string A;
    cin >> A;
    string B;
    cin >> B;
    auto result = solve(A, B);
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m;
vector<int>v[100009];
int dp[100009];
int num[100009];
int bt(int node){
	int &ret = dp[node];
	if(ret != -1)return ret;
	ret = 0;
	for(int i=0;i<v[node].size();i++){
		int u = v[node][i];
		ret = max(ret,bt(u)+1);
	}
	return ret;
}
int main(){
	memset(dp,-1,sizeof(dp));
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		v[a].push_back(b);
	}
	int ans = 0;
	for(int i=0;i<n;i++){
		ans = max(ans,bt(i));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 8192
n = int(input())
s = input()

s_list = list(s)
counter = "No"
a_list = []
b_list = []
if n % 2 == 0:
    for i in range(n//2):
        a_list.append(s_list[i])
        b_list.append(s_list[i + n//2])
    if a_list == b_list:
        counter = "Yes"
print(counter)
        
  


Measured memory_bytes: 3060
#include <stdio.h>
int main() {

     int N[4], M[4];
     int i;

     for(i = 0; i < 4; ++i) {
          scanf("%d", &N[i]);
          M[i] = 0;
     }

     for(i = 0; i < 4; ++i) {
          if(N[i] == 1) {
             M[0] = 1;
          }
          else if(N[i] == 9) {
             M[1] = 9;
          }
          else if(N[i] == 7) {
             M[2] = 7;
          }
          else if(N[i] == 4) {
             M[3] = 4;
          }
     }

     if(M[0] == 1 && M[1] == 9 && M[2] == 7 && M[3] == 4) {
        printf("YES");
     } else {
        printf("NO");
     }

     return 0;
}


Measured memory_bytes: 128
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define inf 1000000000000000000
#define ff first
#define ss second
#define deb(x) cout<<#x<<" "<<x<<"\n"
#define Clear(x) memset(x,0,sizeof(x))
#define all(x) (x).begin(),(x).end()

void checkpoint1()
{
	/******think more code less******/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

bool comp(pair< ll,ll > &a,pair< ll,ll > &b)
{
	if(a.ff!=b.ff)
		return a.ff<b.ff;
	else
	{
		if(a.ss>b.ss)
			return b.ss<a.ss;
		else if(a.ss<b.ss)
			return a.ss<b.ss;
	}
	return a.ff>b.ff;
}

ll powe(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b&1)
		{
			res*=a;
			res%=mod;
		}
		a*=a;
		a%=mod;
		b>>=1;
	}
	return res;
}
set< ll > adj[200005];
bool vis[200005];
vector< ll > ans;
ll op=1;
void dfs(ll v)
{
	for(auto u:adj[v])
	{
		if(!vis[u])
		{
			vis[u]=1;
			op++;
			dfs(u);
		}
	}
}
int main()
{
	checkpoint1();
	ll n,m;
	cin>>n>>m;
	Clear(vis);
	for(ll i=0;i<m;i++)
	{
		ll x,y;
		cin>>x>>y;
		adj[x].insert(y);
		adj[y].insert(x);
	}
	for(ll i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			vis[i]=1;
			op=1;
			dfs(i);
			//cout<<i<<" "<<op<<"\n";
			ans.pb(op);
		}
	}
	ll temp=0;
	for(auto i:ans){
		temp=max(temp,i);
	}
	cout<<temp;
	return 0;
}

Measured memory_bytes: 38052
import scala.io.StdIn
object Main extends App {
  def f(s: List[Char]): Boolean = {
    s match {
      case List('m','a','e','r','d', x @ _*) => f(x.toList)
      case List('r','e','m','a','e','r','d',x @ _*) => f(x.toList)
      case List('e','s','a','r','e',x @ _*) => f(x.toList)
      case List('r','e','s','a','r','e',x @ _*) => f(x.toList)
      case List() => true
      case _ => false
    }
  }
  val S = StdIn.readLine()
  if (f(S.reverse.toList)) println("YES") else println("NO")
}


Measured memory_bytes: 33168
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	sum := 0
	for i := 1; i <= N; i++ {
		if i%3 == 0 || i%5 == 0 {
			continue
		} else {
			sum += i
		}
	}
	fmt.Println(sum)
}

Measured memory_bytes: 1752
#include<bits/stdc++.h>
using namespace std;
int fun(int a)
{
    int u = 0;
    while(a)
    {
        a/=10;
        u++;
    }
    return u % 2;
}
int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    for(auto &a : vec)cin >> a;

    vec[0] -= 1;
    bool g = true;
    for(int x =1; x<n; x++)
    {
        if(vec[x] == vec[x-1])continue;
        else if(vec[x] < vec[x-1]) g = false; 
        vec[x] -= 1;
    }
    if(g)cout << "Yes";
    else cout << "No";
    
}

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



int main(void){
    int n;
    cin >> n;
    vector<int> w(n);
    int sum=0;
    rep(i,n){
        int x;
        cin >> x;
        w[i] = x;
        sum += x;
    }
    int cal = 0;
    int check = 0;
    int min =100000;
    rep(i,n){
        cal += w[i];
        check = abs(sum-2*cal);
        if(check < min){
            min = check;
        }
    }
    cout << min << endl;
    
    
    return 0;
}



























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

int main() {
  string s;
  cin >> s;
  int a, ans;
  a = s.size();
  ans = 0;
  if(a % 2 == 0){
    for(int i = 0; i< (a / 2); i++){
      if(s.at(i) != s.at(a - 1 - i)){
        ans++;
      }
         }
         cout << ans;
         }
  if(a % 2 == 1){
    for(int i = 0; i< ((a-1) / 2); i++){
      if(s.at(i) != s.at(a - 1 - i)){
        ans++;
      }
         }
         cout << ans;
         }
  return 0;
}

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

void abacus(int n);


int main(void){
  int n;
  bool st=true;
  while(cin>>n){
    if(st==false){
      cout<<endl;
    }
    abacus(n);
    st=false;
  }
  return 0;
}

void abacus(int n){
  int keta[5]={n/10000,(n%10000)/1000,(n%1000)/100,(n%100)/10,n%10};

  for(int i=0;i<5;i++){
    if(keta[i]>=5){
      cout<<" ";
    }
    else{
      cout<<"*";
    }
  }
  cout<<endl;

  for(int i=0;i<5;i++){
    if(keta[i]<5){
      cout<<" ";
    }
    else{
      cout<<"*";
      keta[i]-=5;
    }
  }
  cout<<endl;

  cout<<"====="<<endl;

  for(int i=0;i<5;i++){
    if(keta[i]==0){
      cout<<" ";
    }
    else{
      cout<<"*";
    }
  }
  cout<<endl;

  for(int i=0;i<5;i++){
    if(keta[i]==1){
      cout<<" ";
    }
    else{
      cout<<"*";
    }
  }
  cout<<endl;

  for(int i=0;i<5;i++){
    if(keta[i]==2){
      cout<<" ";
    }
    else{
      cout<<"*";
    }
  }
  cout<<endl;

  for(int i=0;i<5;i++){
    if(keta[i]==3){
      cout<<" ";
    }
    else{
      cout<<"*";
    }
  }
  cout<<endl;

  for(int i=0;i<5;i++){
    if(keta[i]==4){
      cout<<" ";
    }
    else{
      cout<<"*";
    }
  }
  cout<<endl;
}



Measured memory_bytes: 3120
import java.util.*;
import static java.lang.System.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean flag = false;
		for (int i = 1; i < 10; i++) {
			for(int j = 1; j < 10; j++) {
				if ( (i * j )== n) {
					flag = true;
					break;
				}
			}
		}
		if(flag)out.println("Yes");
		else out.println("No");
		
	}
}

Measured memory_bytes: 23380
#include<stdio.h>
int main(void){
	int a,b,i,j;
	while(1){
		scanf("%d %d",&a,&b);
		if(a==0 && b==0) break;
		for(i=0;i<a;++i){
			if(i%2==0){
				for(j=0;j<b;++j){
					if(j%2==0)printf("#");
					else printf(".");
				}
			}else{
				for(j=0;j<b;++j){
					if(j%2==0)printf(".");
					else printf("#");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

struct person {
  ll h, p;
};

const ll INF = 1e10;

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<person> ps(N);
  FOR(p,ps) {
    cin >> p.h >> p.p;
  }
  sort(ps.begin(), ps.end(), [](const person &x, const person &y){
      return x.h + x.p < y.h + y.p;
    });
  vector<VL> dp(N+1, VL(N+1, INF));
  REP(i,0,N+1) {
    dp[i][0] = 0;
  }
  REP(i,1,N+1) {
    REP(j,1,N+1) {
      if(ps[i-1].h >= dp[i-1][j-1]) {
        dp[i][j] = min(dp[i-1][j], dp[i-1][j-1] + ps[i-1].p);
      } else {
        dp[i][j] = dp[i-1][j];
      }
    }
  }
  int ans = 0;
  REP(i,0,N+1) {
    if(dp[N][i] < INF) {
      ans = i;
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 195968
#include <stdio.h>
 
int main(){
    int x, max = 0, ls[100] = {0};
    
    while(scanf("%d", &x) != EOF) ls[x]++;
    
    for(x = 0; x < 100; x++)
        if(ls[x] > max) max = ls[x];
        
    for(x = 0; x < 100; x++)
        if(ls[x] == max) printf("%d\n", x);
 
    return 0;
}

Measured memory_bytes: 596
N, M = map(int, input().split())
AB = [[int(i) for i in input().split()] for _ in range(N)]

AB.sort()
ret = 0
for A, B in AB :
    if B <= M :
        ret += A * B
        M -= B
    else :
        ret += A * M
        break
        
print(ret)

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    //freopen("output.txt", "w", stdout);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


void smain() {


    int n;
    cin>>n;

    int ans=0;
    for(int i=1;i*i<=n;i++){
        int u=n-i;
        if(u%i==0&&i<u/i){
            ans+=u/i;
        }
    }
    cout<<ans;





}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t m, d;
  std::cin >> m >> d;
  int64_t ans = 0;
  for (int64_t i = 1; i <= m; i++) {
    for (int64_t j = 1; j <= d; j++) {
      const auto d1 = j % 10;
      const auto d10 = j / 10;
      if (d1 == 1 || d10 == 1) {
        continue;
      }

      if (d1 * d10 == i) {
        ans++;
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int h[8],m[8],s[8];
	int i;
	int time[6];
	
	for(i=0;i<6;i++)
	{
		cin >> h[i] >> m[i] >> s[i] ;
		if(i%2==0)
			time[i]=h[i]*3600+m[i]*60+s[i];
		else
			time[i]=h[i]*3600+m[i]*60+s[i]-time[i-1];
	}
	for(i=1;i<6;i+=2)
	{
		cout << time[i]/3600 << " " ;
		time[i]%=3600;
		cout << time[i]/60 << " " ;
		time[i]%=60;
		cout << time[i] << endl;
	}
}

Measured memory_bytes: 0
N,M,q = gets.split.map &:to_i
Q = Array.new(q){ gets.split.map &:to_i }

def build(a,&block)
  if a.size == N
    yield a
  elsif
    a.empty?
    1.upto(M) do |i|
      build([i],&block)
    end
  else
    0.upto(M - a.last) do |i|
      build(a + [a.last + i], &block)
    end
  end
end

ans = 0
build([]) do |x|
  # p x
  cnt = 0
  Q.each do |a,b,c,d|
    cnt += d if x[b-1] - x[a-1] == c 
  end
  ans = cnt if ans < cnt
end

puts ans

Measured memory_bytes: 14332
#include <bits/stdc++.h>///7:07

using namespace std;

#define DIM 200009
#define INF ((long long)1e18+9ll)
#define pairll pair<long long,long long>
#define fi first
#define se second
#define ld long double
#define endl '\n'
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define amen exit(0)

long long i,j,k,l,n,m,sz,C;

string s1,s2;

long long dp[3009][3009],par[3009][3009];

long long get(long long k1,long long k2){
    if(k1<0 || k2<0)return 0;
    if(dp[k1][k2]!=-1)return dp[k1][k2];
    dp[k1][k2]=(s1[k1]==s2[k2]);

    if(dp[k1][k2]==1){
        dp[k1][k2]+=get(k1-1,k2-1);
        par[k1][k2]=3;
        return dp[k1][k2];
    }

    if(get(k1-1,k2)>=get(k1,k2-1)){
        par[k1][k2]=1;
    }
    else{
        par[k1][k2]=2;
    }

    dp[k1][k2]+=max(get(k1-1,k2),get(k1,k2-1));

    return dp[k1][k2];
}

string s;

int main()
{
    fast;

    cin>>s1>>s2;
    memset(dp,-1,sizeof(dp));

    long long x1=s1.length()-1,x2=s2.length()-1;

    get(x1,x2);

    //cout<<get(x1,x2)<<endl;;

    while(x1>=0 && x2>=0){
        if(s1[x1]==s2[x2])s+=s1[x1];
        if(par[x1][x2]==1)x1--;
        else{
            if(par[x1][x2]==2)x2--;
            else x1--,x2--;
        }
    }

    reverse(s.begin(),s.end());

    cout<<s<<endl;

    amen;
}



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

using namespace std;



#define pb push_back
#define prr pair<int,int>

int main() {
    unordered_map<int,prr> m1;
    vector< vector<int> > v1(3,vector<int>(3,-1));
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            int x;
            cin>>x;
        //    cout<<x<<"\n";
             prr p1={i,j};
             m1[x]=p1;
            
        }
    }
//    cout<<"---------\n";
    int n;
    cin>>n;
//    cout<<n<<"\n";
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
//        cout<<x<<"\n";
         if(m1.find(x)!=m1.end()){
             prr p1=m1[x];
             v1[p1.first][p1.second]=1;
         }
    }
    

    
    
    for(int i=0;i<3;i++){
        int x=v1[i][0];
        if(x==v1[i][1] && x==v1[i][2] && x==1){
            cout<<"Yes";
            return 0;
        }
        
    }
    
    for(int i=0;i<3;i++){
        int x=v1[0][i];
        if(x==v1[1][i] && x==v1[2][i] && x==1){
            cout<<"Yes";
            return 0;
        }
        
    }
    if(v1[0][0]==v1[1][1] && v1[0][0]==v1[2][2] && v1[0][0]==1){
        cout<<"Yes";
        return 0;
    }
    if(v1[0][2]==v1[1][1] && v1[0][2]==v1[2][0] &&  v1[0][2]==1){
        cout<<"Yes";
        return 0;
    }
    cout<<"No\n";
    
}

Measured memory_bytes: 256
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define ld             long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
     int x = 1;
     while (b)
     {
          if (b & 1) x *= a;
          a *= a;
          b >>= 1;
     }
     return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a[N], n, m, k;

void solve()
{
     cin >> n >> m;
     while (n > 0)
     {
          n -= m;
          k++;
     }
     cout << k;

}

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


     cout << setprecision(9) << fixed;
     clock_t z = clock();
     solve();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

     return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3
#define mod 1000000007

ll mod_pow(ll x,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*x%mod;
    x=x*x%mod;
    n>>=1;
  }
  return res;
}

ll n;
ll a[111111];
ll idx[111111];
ll sum;
vector<ll> res;

int main(){
	cin.sync_with_stdio(false);
  memset(idx,-1,sizeof(idx));
  cin>>n;
  n++;
  rep(i,n){
    cin>>a[i];
    if(idx[a[i]]==-1)idx[a[i]]=i;
    else{
      sum=idx[a[i]]+n-1-i;
    }
  }
  //dbg(sum);
  ll comb=n%mod,sub=1;
  repl(k,1,n+1){
    if(k==1){
      res.push_back(n-1);
      continue;
    }
    comb=comb*(n-k+1)%mod;
    comb=comb*mod_pow(k,mod-2)%mod;
    //dbg(comb);
    if(k-1>sum)sub=0;
    else{
      sub=sub*(sum-k+2)%mod;
      sub=sub*mod_pow(k-1,mod-2)%mod;
    }
    //dbg(sub);
    res.push_back((comb-sub+mod*2)%mod);
  }
  rep(i,res.size())printf("%lld\n", res[i]);
	return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;

int main(){
	int a,b,t;cin>>a>>b>>t;
	cout<<t/a*b<<endl;
}

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

int main()
{
    int n;
    cin >> n;
    vector<long> a(n, 0);
    vector<long> b(n, 0);
    vector<long> c(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    long ans = 0;
    for (int i = 0; i < n; i++) {
        vector<long>::iterator ita = upper_bound(a.begin(), a.end(), b[i] - 1);
        vector<long>::iterator itc = lower_bound(c.begin(), c.end(), b[i] + 1);
        long cnt_a = ita - a.begin();
        long cnt_c = c.end() - itc;
        ans += cnt_a * cnt_c;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;


int main(void){
    cin.tie(0); ios::sync_with_stdio(false);
    int n, m;

    cin >> n >> m;
    deque<bool> t(n + 1);

    forn(i, n){
        char c;
        cin >> c;
        t[n - i] = (c == '1');
    }
    vector<int> r(0);
    int now = 0;

    while (true) {
        if (now == n) break;
        for(int i = min(m, n - now); i >= 0; --i){
            if (i == 0) {
                cout << -1;
                return 0;
            }
            if (!t[now + i]) {
                r.push_back(i);
                now += i;
                break;
            }
        }
    }

    for (auto i = r.rbegin(); i != r.rend(); ++i) {
        cout << *i << " ";
    }


    return 0;
}


Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
    static const double pi = 3.141592653589793;
 typedef pair<int64_t,int64_t> P;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
string a;
  cin>>a;
  if(a.at(0)==a.at(1) & a.at(1)==a.at(2)) cout<<"No";
  else cout<<"Yes";
  
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    int h, w;
    cin >> h >> w;
    vector<vector<int> > a(h, vector<int>(w));
    rep(i, h) rep(j, w) cin >> a[i][j];
    
    vector<pair<pii, pii> > ans;
    rep(i, h - 1) rep(j, w) {
        if (a[i][j] % 2 != 0) {
            a[i][j]--;
            a[i + 1][j]++;
            ans.eb(make_pair(pii(i, j), pii(i + 1, j)));
        }
    }
    rep(j, w - 1) {
        if (a[h - 1][j] % 2) {
            a[h - 1][j + 1]++;
            a[h - 1][j]--;
            ans.eb(make_pair(pii(h - 1, j), pii(h - 1, j + 1)));
        }
    }
    // rep(i, h) { rep(j, w) cout << a[i][j] << " "; cout << endl; }
    cout << sz(ans) << endl;
    rep(i, sz(ans)) cout << ans[i].F.F + 1 << " " << ans[i].F.S + 1 << " " << ans[i].S.F + 1 << " " << ans[i].S.S + 1 << endl;
}


Measured memory_bytes: 5236
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
#include <cmath>
#include <utility>
#include <numeric>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i=0;(i)<(n);(i)++)
#define repi(i, n) for (int i=0;(i)<=(n);(i)++)
#define repr(i, n) for (int i=n;(i)>=0;(i)--)
#define INF (1<<29);

int main() {
    int n; cin>>n;
    int a; cin>>a;
    cout<<n*n-a<<endl;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  std::string s;
  std::cin >> s;
  int64_t ans = 0;
  for (int64_t i = 0; i < s.size(); i++) {
    if (i % 2 == 0) {
      if (s[i] == 'p') {
        ans--;
      }
    } else {
      if (s[i] == 'g') {
        ans++;
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 512