akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {


    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        long x = Long.parseLong(sc.next());
        long y = Long.parseLong(sc.next());

        long before = x;
        int count = 1;
        int i = 2;

        while(true){
            if(before * i <= y){
                before = before * i;
//                System.out.println(before);
                count++;
//                i++;
            } else {
                break;
            }
        }

//        for(long i=x; i<=y; i++){
//            if(i % before == 0){
//                before = i;
//                count++;
//            }
//        }

        System.out.println(count);
    }

//    void dfs(int from, List<Integer> list, boolean[] reachedNodes){
////        System.out.println(eachCount);
//        int eachCount = 0;
//        for(boolean b: reachedNodes){
//            if(b){
//                eachCount++;
//            }
//        }
//        if(eachCount == N){
//            count++;
//            return;
//        }
////
//        for(int i: list){
//            if(reachedNodes[i]){
//                continue;
//            }
//            reachedNodes[i] = true;
////            System.out.println(String.format("%s %s", from+1, i+1));
//            dfs(i, map.get(i), reachedNodes);
//            reachedNodes[i] = false;
//        }
//    }

//    void dfs(int from, List<Integer> toList, boolean[] eachReachedNode, boolean[][] threwEdge, boolean countedFlug) {
//
//        reachedNode[from] = true;
//        eachReachedNode[from] = true;
//
//        for (int i : toList) {
//            if ((threwEdge[from][i] || threwEdge[i][from])) {
//                continue;
//            } else if(eachReachedNode[i] && !countedFlug){
////                System.out.println(String.format("%s %s", from , i));
//                count++;
//                countedFlug = true;
//                threwEdge[from][i] = true;
//                threwEdge[i][from] = true;
////                return;
//            } else {
//                if(map.get(i) == null){
//                    return;
//                } else {
//                    threwEdge[from][i] = true;
//                    threwEdge[i][from] = true;
//                    dfs(i, map.get(i), eachReachedNode, threwEdge, countedFlug);
//                }
//            }
//        }
//    }
//    void dfs(int from, int to) {
//
//        if (from > 100 || to > 100 || reachedArray[from][to]) {
//            return;
//        }
//
//        reachedArray[from][to] = true;
//
//        if (hasArray[from][to]) {
//            count++;
//        }
//        dfs(to, to + 1);
//        dfs(to + 1, to);
//    }
}


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

using namespace std;
typedef long long ll;

int main(){
    char b, a;
    cin >> b;
    if(b == 'A'){
        a = 'T';
    }else if(b == 'T'){
        a = 'A';
    }else if(b == 'C'){
        a = 'G';
    }else{
        a = 'C';
    }

    cout << a << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        n: usize,
        a_vec: [usize; n]
    }

    let mut target = 1;

    let mut ans = 0;
    let mut target_vec: Vec<usize> = vec![];
    let mut a_vqueue = VecDeque::from(a_vec);

    for _ in 0..n {
        let tmp = a_vqueue.pop_front().unwrap();
        if tmp == target {
            target += 1;
            target_vec.push(tmp);
        } else {
            ans += 1;
        }
    }

    if target_vec.len() == 0 {
        println!("-1")
    } else {
        println!("{}", ans)
    }

    println!("", );
}


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

using namespace std;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)

void resolve()
{
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    RPT0(i, N) cin >> A[i];
    int max_d = (K - A[N - 1]) + A[0];
    RPT0(i, N - 1) max_d = max(max_d, A[i + 1] - A[i]);
    int ans = K - max_d;
    cout << ans << endl;
}

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


Measured memory_bytes: 1024
struct Read<R: std::io::BufRead> {
    stdin: R,
    v: Vec<String>,
    i: usize,
}
impl<R:std::io::BufRead> Read<R> {
    pub fn new(stdin: R) -> Self {
        Read{
            stdin,
            v: Vec::new(),
            i: 0,
        }
    }
    pub fn read_until<T: std::str::FromStr>(&mut self) -> T {
        if self.i == self.v.len() {
            self.read_line();
        }
        let elem = &self.v[self.i];
        self.i += 1;
        elem.parse().unwrap_or_else(|_| panic!())
    }
    #[allow(dead_code)]
    pub fn read_i32(&mut self) -> i32 {
        if self.i == self.v.len() {
            self.read_line();
        }
        let elem = self.v[self.i].parse().unwrap();
        self.i += 1;
        elem
    }
    pub fn read_string(&mut self) -> String {
        if self.i == self.v.len() {
            self.read_line();
        }
        let elem = &self.v[self.i];
        self.i += 1;
        elem.to_owned()
    }
    pub fn read_line(&mut self) {
        self.i = 0; self.v.clear();
        let mut buf = String::new();
        self.stdin.read_line(&mut buf).unwrap();
        let buf = buf.trim().to_owned();
        let mut ws = buf.split_whitespace();
        loop {
            let x = ws.next();
            if x.is_none() {
                break;
            }
            let x = x.unwrap().to_owned();
            self.v.push(x);
        }
    }
}
fn main() {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let mut read = Read::new(stdin);

    let mut n:usize = read.read_until();
    let mut s:Vec<String> = Vec::new();
    for _i in 0..n {
        s.push(read.read_string());
    }
    s.sort();
    let mut ans = 1;
    for i in 0..n-1 {
        if s[i] != s[i+1] {
            ans+=1;
        }
    }
    println!("{}",ans);
}

Measured memory_bytes: 14804
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> a >> b;
	cin >> T;
	T[b - 1] += 32;
	cout << T;

}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    cin >> n;
    cout << fixed << setprecision(6) << (double)(n/2 + n %2)/(double)n;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const int INF=100001;

int main(){
  int N,M,a,b;
  cin>>N>>M;
  int D[N];
  int B[N];
  vector<int>G[N];
  for(int i=0;i<N;i++){
    D[i]=INF;
    B[i]=-1;
  }
  
  for(int i=0;i<M;i++){
    cin>>a>>b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  queue<int>Q;
  D[0]=0;
  Q.push(0);
  int u;
  
  while(!Q.empty()){
    u=Q.front();Q.pop();
    for(int i=0;i<G[u].size();i++){
      int v=G[u][i];
      if(D[v]!=INF) continue;
      D[v]=D[u]+1;
      B[v]=u;
      Q.push(v);
    }
  }  
  
  cout<<"Yes"<<endl;
  for(int i=1;i<N;i++){
    cout<<B[i]+1<<endl;
  }
  return 0;
}


Measured memory_bytes: 10800
s = [int(input()) for i in range(5)]
n = len(s)
a = []
ans = 0
for i in range(n):
  amari = s[i]%10
  num = 10-amari if amari!=0 else 0
  a += [[i,num]]
a.sort(lambda x:x[1])  
for j in range(n-1):
  ans += s[a[j][0]] + a[j][1]
ans += s[a[-1][0]]
print(ans)

Measured memory_bytes: 38384
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())

def deci(N):
    if N%10==0:
        return 10
    else:
        return N%10

def gauss(N):
    if N%10==0:
        return N
    else:
        return (N//10+1)*10

m=min(deci(A),deci(B),deci(C),deci(D),deci(E))

print(gauss(A)+gauss(B)+gauss(C)+gauss(D)+gauss(E)-10+m)


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

#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll n,k;
    cin >> n >> k;
    if(n>=k){
        n %= k;
    }
    if(n==0){
        cout << 0 << endl;
        return 0;
    }

    ll ans;
    
    while(1){
        ll sn = n;
        n = ll(abs(k-n));
        if(sn<=n){
            ans = sn;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as B

isOK :: V.Vector B.ByteString -> Bool
isOK field = all (\p -> isDot p || isAsc p) [ (x , y)
                                            | x <- [1 .. h]
                                            , y <- [1 .. w] ]
  where h = V.length field - 2
        w = B.length (V.head field) - 2
        dxdy = [(1, 0), (-1, 0), (0, -1), (0, 1)]
        isDot (x, y) = field V.! x `B.index` y == '.'
        isAsc (x, y) = elem '#' $ do
          (dx ,dy) <- dxdy
          let nx = x + dx
              ny = y + dy
          return $ field V.! nx `B.index` ny
                                   

yesNo :: Bool -> B.ByteString
yesNo True = "Yes"
yesNo False = "No"

main :: IO ()
main = do
  [h, w] <- mapM readIO . words =<< getLine
  field <- V.replicateM h B.getLine
  let emptyRow = B.replicate (w + 2) '.'
      mkRow s = B.cons '.' $ B.snoc s '.' 
      field' = V.cons emptyRow $ V.snoc (V.map mkRow field) emptyRow
  B.putStrLn $ yesNo $ isOK field'


Measured memory_bytes: 1020
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll N,K;
  cin>>N>>K;
  vector<ll>A(N),F(N);
  REP(i,N)cin>>A[i];
  REP(i,N)cin>>F[i];
  sort(ALL(A));
  sort(rALL(F));

  ll ok=INFLL,ng=-1;
  while(ok-ng>1){
    ll mid=(ok+ng)/2;
    ll tmpk=0ll;
    REP(i,N){
      if(A[i]>mid/F[i]){
        tmpk+=A[i]-mid/F[i];
      }
    }
    if(tmpk<=K){
      ok=mid;
    }else{
      ng=mid;
    }
  }
  cout<<ok<<endl;
}


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

int main() {
    int n;
    vector<int> s;
    cin >> n;
    while(n){
        s.push_back(n%10);
        n/=10;
    }
    if(s[0] == s[1] && s[1] == s[2]) cout << "Yes" << endl;
    else if(s[1] == s[2] && s[2] == s[3]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  map<int, vector<int>> mng; 
 
  for (int i = 2; i <= N; i++) {
    int a;
    cin >> a;
    mng[a].push_back(i);
  }
  
  for (int j = 1; j <= N; j++) {
    cout << mng[j].size() << endl;
  }
  
  
}


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

int main(){
    int d, g, i, count, score, p_n, mask, ans = MOD;
    cin >> d >> g;
    int p[d], c[d];
    for(i=0; i<d; i++){
        cin >> p[i] >> c[i];
    }
    for(i=0; i<(1 << d); i++){
        score = 0;
        count = 0;
        p_n = -1;
        for(mask=0; mask<d; mask++){
            if((1 << mask) & i){
                score += p[mask]*(mask+1)*100 + c[mask];
                count += p[mask];
            }else{
                p_n = mask;
            }
        }
        if(score < g){
            if(g-score > (p_n+1)*100*p[p_n]) count = MOD;
            else{
                count += (g - score + ((p_n+1)*100)-1) / ((p_n+1)*100);
            }
        }
        ans = min(count, ans);
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N; cin >> N;
    vl a(N); REP(i, N) cin >> a[i];
    int c4 = 0, c2 = 0;
    REP(i, N)
    {
        if(a[i] % 4 == 0) c4++;
        else if(a[i] % 2 == 0) c2++;
    }

    int n = N - c4 - max(c2-1, 0);
    if(n <= c4+1) Yes;
    else No;
}

Measured memory_bytes: 3948
#include <iostream>
#include <cmath>

int main(){
    unsigned long long x, y, t = 1;
    std::cin >> x >> y;
    y /= x;
    int c = 1;
    while(1){
        t *= 2;
        if(t <= y) c++;
        else break;
    }
    std::cout << c << std::endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <utility>

typedef std::pair<int,int> ii;

std::map<ii,int> ans;

int n,k,l;

int par[200200][2];

int get_par(int a, int t)
{
	if(a==par[a][t]) return a;
	return par[a][t]=get_par(par[a][t],t);
}

void make_union(int a, int b, int t)
{
	a=get_par(a,t);
	b=get_par(b,t);
	par[b][t]=a;
}

int main()
{
	scanf("%i %i %i",&n,&k,&l);
	for(int i=1;i<=n;i++)
	{
		par[i][0]=par[i][1]=i;
	}

	for(int i=0;i<k;i++)
	{
		int t1,t2;
		scanf("%i %i",&t1,&t2);
		make_union(t1,t2,0);
	}

	for(int i=0;i<l;i++)
	{
		int t1,t2;
		scanf("%i %i",&t1,&t2);
		make_union(t1,t2,1);
	}

	for(int i=1;i<=n;i++)
	{
		ii on=ii(get_par(i,0),get_par(i,1));
		ans[on]++;
	}

	for(int i=1;i<=n;i++)
	{
		ii on=ii(get_par(i,0),get_par(i,1));
		if(i>1)
			printf(" ");
		printf("%i",ans[on]);
	}
}

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

int main(){
    string s;
    int count[4] = {0};
    cin >> s;
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
            if(s[i] == s[j]) count[i]++;
        }
    }
    if(count[0] == 2 && count[1] == 2 && count[2] == 2 && count[3] == 2) cout << "Yes";
    else cout << "No";

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
c = input()
c = c.split(" ")
c = list(map(int,c))
w = c[0]
h = c[1]
x = c[2]
y = c[3]
r = c[4]
if x >= r and x <= w-r and y >= r and y <= h-r:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 7656
N, K = map(int, input().split())
*A, = map(int, input().split())
A.sort()

def chk(x):
    D = []
    c = 0
    for a in A:
        y = a % x
        D.append(y)
    D.sort()
    s = sum(D)
    e = 0; r = N*x - s
    for d in D:
        e += d
        r -= x - d
        if e == r and e <= K:
            return 1
    return 0

ans = 1
S = sum(A)
for x in range(1, int(S**.5)+1):
    if S % x == 0:
        if chk(x):
            ans = max(ans, x)
        if chk(S // x):
            ans = max(ans, S // x)
print(ans)

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

int main() {
  string s;
  cin >> s;
  if(s.size() < 3){
    cout << 0 << endl;
    return 0;
  }
  long long ans = 0,ac = 1;
  for(int i = 0;i < s.size()-2;i++){
    if(s[i] == 'A' && s[i+1] == 'A') ac++;
    else if(s.substr(i,3) == "ABC"){
      ans += ac;
      s[i+2] = 'A';
      i++;
    }
    else{
      ac = 1;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

int H, N;
int ngmask[10000];
int dp[10000][1 << 4];

int rec(int idx, int upbit)
{
  if(idx == H) return (0);
  if(~dp[idx][upbit]) return (dp[idx][upbit]);
  int ret = rec(idx + 1, ngmask[idx]);
  for(int i = 0; i < 3; i++) {
    if((upbit >> i) & 3) continue;
    if((ngmask[idx] >> i) & 3) continue;
    ret = max(ret, rec(idx + 1, (3 << i) | ngmask[idx]) + 1);
  }
  if(ngmask[idx] == 0 && upbit == 0) {
    ret = max(ret, rec(idx + 1, (1 << 4) - 1) + 2);
  }
  return (dp[idx][upbit] = ret);
}

int main()
{
  cin >> H >> N;
  for(int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    ngmask[y] |= 1 << x;
  }
  memset(dp, -1, sizeof(dp));
  cout << rec(1, ngmask[0]) << endl;
}

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

ll fac[2000005];

ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
} 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
ll nCr(ll n, ll r, ll p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
} 

int main() {
    int  n;
    cin>>n;
    ll mod=1e9+7;
    fac[0] = 1; 
    for (int i=1 ; i<=2000000; i++) 
        fac[i] = fac[i-1]*i%mod; 
    string s;
    cin>>s;
    int m=s.size();
    vector <ll> f(n + m + 7, 0);
    f[n - 1] = 1;
    ll cnt = 25;
    for (int i = m; i <= n + m; i++) {
        ll tmp = nCr(i,m-1,mod);
        f[i] = (tmp*cnt)%mod;
        cnt = (cnt*25)%mod;
    }
    vector <ll> t(n + m + 7, 0);
    t[m] = 1;
    for (int i = m + 1; i <= n + m; i++) {
        t[i]=(t[i]+f[i-1])%mod;
        t[i]=(t[i]+((26*t[i-1])%mod))%mod;
    }
    cout << t[n + m] <<endl;
}



Measured memory_bytes: 51180
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x, y, swap;

		while (true) {
			x = scanner.nextInt();
			y = scanner.nextInt();

			if (x == 0 && y == 0)
				break;

			if (x > y) {
				swap = x;
				x = y;
				y = swap;
			}

			System.out.println(x + " " + y);
		}
	}
}

Measured memory_bytes: 36552
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#define LL long long
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 20160116
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}
const long long mod=1e9+7;
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	if(n>m) swap(n,m);
	if (n==m){
		long long x=1;
		for (long long i=1;i<=n;i++) x*=i,x%=mod;
		x=x*x;
		x%=mod;
		x*=2;
		x%=mod;
		printf("%I64d\n",x);
	}
	else if (n+1==m){
		long long x=1;
		for (long long i=1;i<=n;i++) x*=i,x%=mod;
		x=x*x;
		x%=mod;
		x=x*m;
		x%=mod;
		printf("%I64d\n",x);
	}
	else{
		printf("0\n");
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
int main(void){
    int i,j,k,a,b,dice[2][7],
        side[5] = {2,3,5,4,2},
        n = 0;
      
    for(i=0;i<2;i++)
      for(j=1;j<7;j++)
        scanf("%d", &dice[i][j]);
     
    for(i=0;i<6;i++){
      if(dice[0][1]==dice[1][1])
        for(j=0;j<4;j++){
 
  //一致判定
          for(k=1;k<7;k++)
            if(dice[0][k]!=dice[1][k]) break;
  
          if(k==7){
            printf("Yes\n");
            return 0;
          }
 
  //スピン
          dice[1][0] = dice[1][2];
          dice[1][2] = dice[1][3];
          dice[1][3] = dice[1][5];
          dice[1][5] = dice[1][4]; 
          dice[1][4] = dice[1][0]; 
 
       
      }
          
       //回転  
      
      dice[1][0] = dice[1][1];
          
      switch(i){
                  
          case 2:
              dice[1][1] = dice[1][3];
              dice[1][3] = dice[1][6];
              dice[1][6] = dice[1][4];
              dice[1][4] = dice[1][0]; 
              break;
              
          default:
              dice[1][1] = dice[1][2];
              dice[1][2] = dice[1][6];
              dice[1][6] = dice[1][5];
              dice[1][5] = dice[1][0]; 
              break;
         
          }
    }
 
    printf("No\n");
    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
		#include <ext/pb_ds/assoc_container.hpp>
		#include <ext/pb_ds/tree_policy.hpp>
		using namespace __gnu_pbds;
		using namespace std;
		typedef long long ll;
		typedef unsigned long long int ull;
		// PB-DS
		#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
		#define ff first
		#define ss second
		#define pb push_back
		#define Inf  1000000000000000000
		#define inf -1000000000000000000
		#define mod 1000000007
 
		ll mulmod(ll x,ll y){
			  return (x%mod*y%mod)%mod;
		}
 
		ll addmod(ll x,ll y){
			  return (x%mod+y%mod)%mod;
		}
 
		long long  power(long long  x,long long  y) {
				long long  res = 1;
				x = x%mod;
				while (y > 0)
				{
					if (y & 1)
						res = (res*x)%mod;
					y = y>>1;
					x = (x*x)%mod;
				}
				return res;
		}
	
 
void testcases(int cases){
	int n ;
	cin >> n;
	string s;
	cin >> s;
	int R = 0;
	for(auto it:s)
		if(it=='R')
			R++;
		 int ans =0;	
	for(int i = 0 ;i < R; i ++){
		if(s[i]=='W')
			ans++;
	}
	cout << ans << "\n";
}
	
		 
int main()
{
		
	//sieve();
		ios_base::sync_with_stdio(false);
		cin.tie(0);
		cout.tie(0);
		ll t;
		t = 1;
				//cin >> t;
		ll Case =1 ;
		while(t--)
		{
		 testcases(Case++);
		}
}


Measured memory_bytes: 3776
s = gets.chomp.chars
n = s.size

if n == 1
  puts 0
  exit
end

if n % 2 == 1
  s1 = s[0 .. n/2 - 1]
  s2 = s[n/2 + 1 .. n - 1].reverse
else
  s1 = s[0 .. n/2 - 1]
  s2 = s[n/2 .. n - 1].reverse
end

cnt = 0
for i in 0 .. n / 2
  if s1[i] != s2[i]
    cnt += 1
  end
end

puts cnt


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int n;
		Scanner in = new Scanner(System.in);
		n = in.nextInt();
		int[] heap = new int[n];
		for(int i = 0; i < n; i ++) {
			heap[i]=in.nextInt();
		}
		in.close();
		
		for(int i=0; i<heap.length;i++) {
			int nodeNum = i+1;
			
			System.out.print("node "+ nodeNum +": key = "+heap[i]+", ");
			
			if(i>0) {
				System.out.print("parent key = "+ heap[nodeNum/2-1]+", ");
			}
			if(2*nodeNum<=n) {
				System.out.print("left key = "+ heap[2*nodeNum-1]+", ");
			}
			if(2*nodeNum+1<=n) {
				System.out.print("right key = "+ heap[2*nodeNum]+", ");
			}
				
			System.out.println();
		}
	}
}


Measured memory_bytes: 27624
import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        int steps1 = 0;
        int steps2 = 0;
        for(int i = 0; i < s.length(); i++) {
        	if(i % 2 == 0) {
        		if(s.charAt(i) != '1')
        			steps1++;
        		else
        			steps2++;
        	} else {
        		if(s.charAt(i) != '1')
        			steps2++;
        		else
        			steps1++;
        	}
        }

    	System.out.println(Math.min(steps1, steps2));
    }
}

Measured memory_bytes: 24916
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}


int main(){
    ll n,m,x,ans=INF;
    cin >> n >> m >> x;
    ll a[n][m];
    ll o[n];
    for (ll i=0;i<n;i++){
        cin >> o[i];
        for (ll j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    for (ll bit=0;bit<(1LL<<n);bit++){
        ll rikai[m],c=0;
        fill(rikai,rikai+m,0);
        for (ll i=0;i<n;i++){
            if (bit&(1<<i)){
                c+=o[i];
                for (ll j=0;j<m;j++){
                    rikai[j]+=a[i][j];
                }
            }
        }
        bool flag=true;
        for (ll j=0;j<m;j++){
            if (rikai[j]<x)flag=false;
        }
        if (flag)ans=min(c,ans);
    }
    if (ans<INF){
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}
 
 


Measured memory_bytes: 3200
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto S = sread();
    long K = lread();
    long one;
    while (S[one] == '1')
        one++;
    if (K <= one)
    {
        writeln(1);
        return;
    }
    writeln(S[one]);
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

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

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  string t;
  cin >> t;

  ll n = t.size();

  rep(i, n) {
    if (t[i] == '?') {
      t[i] = 'D';
    }
  }

  cout << t << endl;

  return 0;
}


Measured memory_bytes: 3744
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include <iomanip>
#include <limits>
using namespace std;


int main()
{
	long long int n, s, i, j, k, l, m, d, sum, N, a, b, cc, cnt;
	sum = 0;
	int flag = 0;
	cin >> n >> m >> d;
	long double ans;

		if (d == 0) {
			ans = (long double)(m - 1) / n;
		}
		else {
			ans = ((long double)(2 * (m - 1))/ (long double)(n))*(long double)(n-d) / (long double)(n);
		}
		cout << setprecision(15) << ans << endl;
	


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll N=1000000007;
//ll power(ll a,ll b,ll mod)
//{
//    ll result=1;
//    while(b>0)
//    {
//        if(b%2==1)
//            result=(result*a)%mod;
//        a=(a*a)%mod;
//        b=b/2;
//    }
//    return result;
//}
//ll d,x,y;
//void extendedEuclid(ll a,ll b)
//{
//    if(b==0)
//    {
//        d=a; x=1; y=0;
//    }
//    else
//    {
//        extendedEuclid(b,a%b);
//        ll temp=x; x=y; y=temp-(a/b)*y;
//    }
//}
//ll modInverse(ll a,ll m)
//{
//    extendedEuclid(a,m);
//    return (x%m+m)%m;
//}
//ll lcm(ll a,ll b)
//{
//    if(a==0||b==0)
//        return 0;
//    return (a*b)/(__gcd(a,b));
//}
//void sieve(ll n)
//{
//    bool isPrime[n+1];
//    isPrime[0]=false; isPrime[1]=false;
//    for(ll i=2;i<=n;i++)
//        isPrime[i]=true;
//    for(ll i=2;i*i<=n;i++)
//    {
//        if(isPrime[i]==true)
//        {
//            for(ll j=i*i;j<=n;j+=i)
//                isPrime[j]=false;
//        }
//    }
//}
//bool isPowerOfTwo(ll n)
//{
//    return (n&&!(n&(n-1)));
//}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,j; cin>>n;
    if(n<=599&&n>=400) cout<<8;
    else if(n<=799&&n>=600) cout<<7;
    else if(n<=999&&n>=800) cout<<6;
    else if(n<=1199&&n>=1000) cout<<5;
    else if(n<=1399&&n>=1200) cout<<4;
    else if(n<=1599&&n>=1400) cout<<3;
    else if(n<=1799&&n>=1600) cout<<2;
    else  cout<<1;
}


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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rep2(i, startValue, N) for (int i = (int)(startValue); i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double
#define DUMP(v) "," #v ":" << v


int main(){
  int n;
  cin >> n;
  int cnt = 0;
  int d1, d2;
  bool ans = false;
  rep(i,n) {
    cin >> d1 >> d2;
    if (d1 == d2) {
      cnt++;
    } else {
      cnt = 0;
    }
    if (cnt >= 3) {
      ans = true;
    }
  }

  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3676
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {


int a,b;
Scanner scan = new Scanner(System.in);
a = scan.nextInt();
b = scan.nextInt();

if((a*b)%2==0)
  System.out.println("Even");
  else
    System.out.println("Odd");
}
}


Measured memory_bytes: 23764
///******* In the name of Allah *******///

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

int main()
{
    long long int a,b,c,m,n,t,i,j,k,l,ans;
    char aa[113],bb[113];
    cin>>aa>>bb;
    cout<<bb<<aa;

    return 0;
}


Measured memory_bytes: 256
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<P,ll>;
using V = std::vector<ll>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define fi first
#define se second

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

int main(){
	int h, w;
	scanf("%d %d", &h, &w);
	int sx, sy, gx, gy;
	scanf("%d %d %d %d", &sx, &sy, &gx, &gy);
	sx--, sy--, gx--, gy--;
	
	char fie[h][w+1];
	REP(i, 0, h) scanf("%s", fie[i]);
	
	ll dist[h][w] = {};
	REP(i, 0, h) REP(j, 0, w) dist[i][j] = -1;
	bool used[h][w] = {};
	std::deque<PP> deq;
	deq.emplace_back(P(sx,sy), 0);
	while(!deq.empty()){
		PP pp = deq.front();
		deq.pop_front();
		P p = pp.fi;
		ll d = pp.se;
		if(used[p.fi][p.se]) continue;
		used[p.fi][p.se] = true;
		dist[p.fi][p.se] = d;
		
		REP(i, 0, 4){
			int nx = p.fi + dx[i], ny = p.se + dy[i];
			if(0<=nx && nx<h && 0<=ny && ny<w && fie[nx][ny]!='#'){
				deq.emplace_front(P(nx,ny), d);
			}
		}

		REP(i, -2, 3) REP(j, -2, 3) if(i!=0 || j!=0) {
			int nx = p.fi + i, ny = p.se + j;
			if(0<=nx && nx<h && 0<=ny && ny<w && fie[nx][ny]!='#'){
				deq.emplace_back(P(nx, ny), d+1);
			}
		}
	}
	printf("%ld\n", dist[gx][gy]);
	return 0;
}



Measured memory_bytes: 16288
n=int(input())
i=1
j=0
k=0
s=["3","5","7"]
d=["3","5","7"]
g=[]
k2=0
while i!=10:
    f=len(d)
    while j!=3:
        k = k2
        while k!=f:
            d.append(d[k]+s[j])
            k+=1


        j+=1
    k2 = f
    j=0
    i+=1
i=0
while i!=len(d):
    if ("3" in d[i])==True and ("5" in d[i])==True and ("7" in d[i])==True:
        i+=1
    else:
        del d[i]

d=list(map(int,d))
d.sort()
ans=0
i=0
x=d[i]
while x<=n:
    ans+=1
    i+=1
    x=d[i]

#print(d)
print(ans)


Measured memory_bytes: 12708
import heapq
n,m = [int(x) for x in input().split()]
a = [int(x)*(-1) for x in input().split()]

heapq.heapify(a)

for _ in range(m):
    tmp_min = heapq.heappop(a)
    heapq.heappush(a, (-1)* (-tmp_min//2))

print(-sum(a))

Measured memory_bytes: 14180
#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;

// ?????¬???????????¬??????
#define REP(i,n) for(int i=0; i<(int)n; ++i)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), c.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<double> vd;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<long, long> pil;

// ??°?????????????????¬??????
typedef int Weight;

struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) {}
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;


int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if (a < b) printf("a < b\n");
  else if (a > b) printf("a > b\n");
  else printf("a == b\n");

  return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define co cout
#define ci cin
#define sf1(n) scanf("%lld",&n);
#define sf2(n,m) scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p);
#define en cout<<endl;
#define pb push_back
#define coy cout<< "YES"<<endl;
#define con cout<< "NO"<<endl;
#define For(a,b) for(ll a=0;a<b;a++)
#define br break;
#define i64 long long
i64 M=10000000;
//ll b[805],ans[805];
map< ll,pair<ll,ll> >mp;

int main()
{
    ll t,n,g,k,m,mx=0,mn=1e9,res,c1,x,y,c2;
    string ab;
    ci>>ab;
    if(ab=="SAT") co<<1LL;
    else if(ab=="SUN") co<<7LL;
    else if(ab=="MON") co<<6LL;
    else if(ab=="TUE") co<<5LL;
    else if(ab=="WED") co<<4LL;
    else if(ab=="THU") co<<3LL;
    else if(ab=="FRI") co<<2LL;

}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n,k,temp;
  cin>>n>>k;
  int arr[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
   for(int i=0;i<n;i++)
	{		
		for(int j=i+1;j<n;j++)
		{
			if(arr[i]>arr[j])
			{
				temp  =arr[i];
				arr[i]=arr[j];
				arr[j]=temp;
			}
		}
	}
  int sum=0;
  for(int i=0;i<k;i++)
  {
    sum=sum+arr[i];
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
#define vi vector<int>
#define ii pair<int,int>
const ll mod=2019;

string S;
ll pot, number, resp, ans;
int i, A;
map<ll,ll> M;

int main(){_
    cin>>S;
    M[0]=1;
    pot =1;
    for(i=S.size()-1;i>=0;i--){
        A=S[i]-'0';
        number=(A*pot+number)%mod;
        pot=(pot*10)%mod;
        ans+=M[number];
        M[number]++;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3712
import sys
input = sys.stdin.readline
########   modあり modは素数  ###############
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5+1
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


n=int(input())
A=list(map(int,input().split()))
v=[-1]*n
for i,a in enumerate(A):
    #print(i,a)
    if v[a-1]!=-1:
        s=v[a-1]
        f=i
    if v[a-1]==-1:
        v[a-1]=i

#print(s,f)
mod=10**9+7
for i in range(1,n+1):
    sousuu=cmb(n+1,i,mod)
    tyouhuku=cmb(s+n-f,i-1,mod)
    """if i==1:
        sousuu=n+1
        tyouhuku=1
    else:
        sousuu*=(n+2-i)
        sousuu//=i
        tyouhuku*=(s+n-f+1-i+1)
        tyouhuku//=(i-1)"""
    #print(sousuu,tyouhuku)
    print((sousuu-tyouhuku)%mod)
print(1)


Measured memory_bytes: 63964
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;

int main() {
	int d, n; cin >> d >> n;

	if (d == 0) {
		if (n == 100) {
			cout << "101" << endl;
		}
		else {
			cout << n << endl;
		}
	}
	else {
		if (n == 100) {
			cout << n + 1;
		}
		else {
			cout << n;
		}
		while (d) {
			cout << "00";
			d--;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int n,i;
  long long int ruka[87];
  scanf("%d",&n);
  ruka[0] = 2;
  ruka[1] = 1;
  for(i=2;i<=n;i++)
    {
      ruka[i] = ruka[i-1] + ruka[i-2];
    }
  printf("%lld\n",ruka[n]);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

#define MAX 110
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,time;
int dis[MAX],fin[MAX],color[MAX],num[MAX][MAX];
void DFS(void);
void Visit(int);

int main(){
  int i,j,k,u,v;
  
  scanf("%d",&n);
  
  for(i=1; i<=n; i++){
    scanf("%d%d",&u,&k);
    for(j=1; j<=k; j++){
      scanf("%d",&v);
      num[u][v] = 1;
    }
  }
  DFS();

  for(i=1; i<=n; i++){
    printf("%d %d %d\n",i,dis[i],fin[i]);
  }
  
  return 0;
}

void DFS(){
  int u;
  for(u=1; u<=n; u++){
    color[u] = WHITE;
  }
  time = 0;
  for(u=1; u<=n; u++){
    if(color[u] == WHITE) Visit(u);
  }
}

void Visit(int u){
  int v;
  color[u] = GRAY;
  dis[u] = ++time;
  for(v=1; v<=n; v++){
    if(num[u][v] == 1 && color[v] == WHITE) Visit(v);
  }
  color[u] = BLACK;
  fin[u] = ++time;
}



Measured memory_bytes: 2048
#include<stdio.h>
#define N 500000

int H,T[N];
void BuildMaxHeap(int*);
void MaxHeapify(int* , int );
void swap(int * ,int ,int);

int main(){

  int i,n;

  scanf("%d",&n);
  H=n;
  for(i=1;i<=n;i++)scanf("%d",&T[i]);

  BuildMaxHeap(T);

  for(i=1;i<=n;i++)printf(" %d",T[i]);
  printf("\n");
  
  return 0;
}

void MaxHeapify( int* T,int i){
  int l,r,largest,tmp;

  l=2*i;
  r=2*i+1;

  if(l<=H && T[i]<T[l])largest=l;
  else largest=i;

  if(r<=H && T[largest]<T[r])largest=r;

  if(largest!=i){
    swap(T,i,largest);
    MaxHeapify(T,largest);
  }
  
  
}

void BuildMaxHeap(int* T){
  int i;
  for(i=H/2;i>=1;i--)
    MaxHeapify(T,i);
 
}

void swap(int* T,int i, int j){

  int tmp;

  tmp=T[i];
  T[i]=T[j];
  T[j]=tmp;
}

Measured memory_bytes: 2552
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N, A, B;
  cin >> N >> A >> B;
  int ans = 0;
  for (int i = 1; i <= N; i++)
  {
    string s = to_string(i);
    int total = 0;
    for (int j = 0; j < s.size(); j++)
    {
      int num = s[j] - '0';
      total += num;
    }
    if (A <= total && total <= B)
      ans += i;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	int pW[10], pK[10], W, K;
	for(int a=0; a<10; a++)
		cin >> pW[a];
	for(int b=0; b<10; b++)
		cin >> pK[b];
	for(int j=0; j<10; j++){
		int v0 = pW[j];
		int k = j-1;
		while(k>=0 && v0>pW[k]){
			pW[k+1] = pW[k];
			k--;
			pW[k+1] = v0;
		}
	}
	for(int l=0; l<10; l++){
		int v1 = pK[l];
		int m = l-1;
		while(m>=0 && v1>pK[m]){
			pK[m+1] = pK[m];
			m--;
			pK[m+1] = v1;
		}
	}
	W = pW[0]+pW[1]+pW[2];
	K = pK[0]+pK[1]+pK[2];
	cout << W << ' ' << K << endl;
	return 0;
}


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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)

int n;
map<string,bool> mp;
string p;
int main(){
  cin >> n;
  REP(i,n){
    string a;
    cin >> a;
    if(!mp.count(a)){
      mp[a] = true;
      if(i==0 || p[p.size()-1] == a[0]){
        p = a;
        continue;
      }
    }
    cout << "No" <<endl;
    return 0;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <array>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <limits>
#include <fstream>
#include <numeric>

namespace
{
	template<int N>
	std::array<int, N> GetValue(std::istream& stream)
	{
		std::string buf;
		std::getline(stream, buf);

		std::stringstream sstr(buf);
		std::array<int, N> retval;

		for (int i = 0; i < N; ++i)
		{
			std::getline(sstr, buf, ' ');
			retval[i] = std::stoi(buf);
		}

		return retval;
	}

	std::vector<int> GetValue(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<int> retval;
		retval.reserve(num);

		for (int i = 0; i < num; ++i)
		{
			std::getline(stream, buf, delim);
			retval.push_back(std::stoi(buf));
		}

		return retval;
	}

	class Prime
	{
	public:
		Prime()
		{
			primes_.reserve(256);
			primes_.push_back(2);
			primes_.push_back(3);
			primes_.push_back(5);
			primes_.push_back(7);
			primes_.push_back(11);
		}

		int operator[](size_t index)
		{
			if (primes_.size() -1 < index)
			{
				for (int number = primes_.back() + 2;
					primes_.size() - 1 != index;
					number += 2)
				{
					bool is_prime = true;
					int limit = static_cast<int>(std::sqrt(number)) + 1;

					for (auto itr = primes_.begin(); 
						itr != primes_.end() && *itr <= limit; 
						++itr)
					{
						if (number % (*itr) == 0)
						{
							is_prime = false;
							break;
						}
					}

					if (is_prime)
					{
						primes_.push_back(number);
					}
				}
			}

			return primes_[index];
		}

	private:
		std::vector<int> primes_;
	};
}

int main(int argc, char* argv[])
{
	auto file = (argc == 1) ? std::ifstream() : std::ifstream(argv[1]);
	std::istream& stream = (argc == 1) ? std::cin : file;

	int num = GetValue<1>(stream)[0];
	std::vector<int> values = GetValue(stream, num, '\n');

	int prime_num = 0;
	Prime prime;

	for (int e : values)
	{
		int limit = static_cast<int>(std::sqrt(e)) + 1;
		bool is_prime = true;

		for (size_t i = 0;
			prime[i] <= limit;
			++i)
		{

			if (prime[i] == e)
			{
				break;
			}
			else if (e % prime[i] == 0)
			{
				is_prime = false;
				break;
			}
		}

		if (is_prime)
		{
			++prime_num;
		}
	}

	std::cout << prime_num << std::endl;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	string t;
	int a,b;
	string u;
	cin>>s>>t;
	cin>>a>>b;
	cin>>u;
	if(s==u)
	{
		a--;
		cout<<a<<" "<<b;
	}
else
	{
		b--;
		cout<<a<<" "<<b;
		}
		}


Measured memory_bytes: 256