akhauriyash/Code-Regression huggingface dataset:
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::Ordering;
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

impl<T: Copy> Copy for Rev<T> {}

fn main() {
    input! {
        m: usize,
        k: usize,
    }

    if m == 1 && k == 0 {
        println!("0 0 1 1");
        return;
    }

    if m == 1 && k == 1 {
        println!("-1");
        return;
    }

    let n = 1 << m;

    if k >= n {
        println!("-1");
        return;
    }

    for i in 0..n {
        if i != k {
            print!("{} ", i);
        }
    }
    print!("{} ", k);
    for i in (0..n).rev() {
        if i != k {
            print!("{} ", i);
        }
    }
    println!("{}", k);
}


Measured memory_bytes: 5884
#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    sl = input()
    tl = input()
    ans = 0
    for s, t in zip(sl, tl):
        if s == t:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38480
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


#mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np

from scipy.optimize import fmin



def main():
	n = int(input())
	xy = [list(map(int, input().split())) for _ in [0] * n]
	def calc(k):
		i, j = k
		ans = 0
		for x, y in xy:
			ans = max(ans, (x - i) ** 2 + (y - j) ** 2)
		return ans

	x, y = fmin(calc, [500, 500],ftol=10**-7,disp=0)
	print(calc((x, y)) ** 0.5)



if __name__ == "__main__":
	main()


Measured memory_bytes: 35160
s = list(input())
num = 0
n = len(s)
l = 0
i = 0
while i < n:
  if s[i] == '<':
    l+=num
    num+=1
    i+=1
    if i==n:
      l+=num
  else:
    cur = 0
    while i < n and s[i]=='>':
      i+=1
      cur+=1
    if cur <= num:
      l+=num
      cur-=1
    l+=(cur*(cur+1))//2
    num = 0
print(l)

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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    ll N, M; cin>>N>>M;
    string S, T; cin>>S>>T;
    ll d=__gcd(N,M), l = N*M/d;
    map<ll, char> c;
    
    for(int i = 0; i < N; i++) c[i*l/N+1]=S[i];
    for(int i = 0; i < M; i++)
    {
        if(c.find(i*l/M+1)!=c.end() && c[i*l/M+1]!=T[i]){
            cout<<-1<<endl;
            return 0;
        }
    }
    
    cout<<l<<endl;

    return 0;
}

Measured memory_bytes: 6144
#include<stdio.h>
int main()
{
	int n,m,a[100],all=0,i,ans=0;
	double x=0;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		all+=a[i];
	}
	x=all*1.0/(4*m);
	for(i=0;i<n;i++)
	{
		if(a[i]>=x)
		ans++;
	}
	if(ans>=m)
	printf("Yes");
	else
	printf("No");
	return 0;
}

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

int main() {
  int N,L;
  vector <string> S;
  cin>>N>>L;
  for (int i(0);i<N;i++){
    string s;
    cin>>s;
    S.push_back(s);
  }
  sort(S.begin(),S.end());
  string ans="";
  for (int i(0);i<N;i++){
    ans+=S[i];
  }
  cout<<ans;
}


Measured memory_bytes: 256
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


s = input()

n = ii()
r = 0
head = ''
tail = ''
for i in range(n):
    q = input().split()

    if(q[0] == '1'):
        # reverse
        r += 1
    else:
        if(q[1] == '1'):
            if(r%2 ==0):
                # s = q[2] + s
                head = q[2] + head
            else:
                # s = s + q[2]
                tail = tail + q[2]
        else:
            if(r%2 ==0):
                # s = s + q[2]
                tail = tail + q[2]
            else:
                # s = q[2] + s
                head = q[2] + head

    # print('*********************',i,head,tail)
    

if(r%2==1):
    # s = s[::-1]
    # print('rev')
    print( tail[::-1] + s[::-1]+ head[::-1])
else:

    print(head +  s + tail)


Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;
ll N;

int dfs(string s){
    ll ret = 0;
    vector<char> lis = {'3','5','7'};
    if((int)s.size() > 0){
        if(stoll(s) > N){
            return ret;
        }else{
            bool ok = true;
            for(auto x:lis){
                if(s.find(x) == string::npos) ok = false;
            }
            if(ok) ret++;
        }
    }
    for(auto c:lis){
        s.push_back(c);
        ret += dfs(s);
        s.pop_back();
    }
    return ret;

}

int main(){
    cin >> N;
    string S = "";
    cout << dfs(S) << endl;
}

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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

ll baka(ll l, ll r) {
	ll ret = LLONG_MAX;
	repd(i, l, r + 1) {
		repd(j, i + 1, r + 1) {
			if( (i * j) % 2019 < ret ) ret = (i * j) % 2019;
		}
	}

	return ret;
}

ll aho(const ll nl, const ll nr) {
	ll ret = LLONG_MAX;
	ll l = nl % 2019;
	ll r = nr % 2019;
	if(l >= r || (nl / 2019) * 2019 + 2019 <= nr) r += 2019;

	repd(i, l, r) {
		repd(j, i + 1, r + 1) {
			ll tmp = (i * j) % 2019;
			if(tmp < ret) ret = tmp;
		}
	}

	return ret;
}

int main(int argc, const char* argv[]) {
	ll l, r;
	cin >> l >> r;

	/*
	debug(baka(l, r));
	debug(aho (l, r));

	return 0;
	*/

	cout << aho(l, r) << endl;

	return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/agc008/tasks/agc008_a
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-3.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    ll x,y; cin>>x>>y;
    ll ans=INT64_MAX;
    if(x==y){
        ans=0;
    }else{
        //すすんで、-おす
        ll tmp=-y-x;
        if(tmp>=0) ans=min(tmp+1,ans);
        //-おす、すすんで、-おす
        tmp=x-y;
        if(tmp>=0) ans=min(tmp+2,ans);
        //-おして、すすむ
        tmp=y-(-x);
        if(tmp>=0) ans=min(tmp+1,ans);

        //すすむだけ
        tmp=y-x;
        if(tmp>=0) ans=min(tmp,ans);
        //-おす、すすんで、-おす
        tmp=x-y;
        if(tmp>=0) ans=min(tmp+2,ans);
        //-おして、すすむ
        tmp=y-(-x);
        if(tmp>=0) ans=min(tmp+1,ans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
MOD = 1000000007
n = int(input())
tli = [ int(it) for it in input().split() ]
ali = [ int(it) for it in input().split() ]
#print (tli,ali)

mav1 = max(tli)
mav2 = max(ali)
mav = mav1
#print (mav1,mav2)
if (mav1!=mav2):
  print (0)
else:
  mai1 = tli.index(mav)
  mai2 = n-1-list(reversed(ali)).index(mav)
  #print (mai1,mai2)
  if (mai2<mai1):
    print (0)
  else:
    s = 1
    tma = -1
    for i in range(0,mai1+1):
      if tli[i]>tma:
        tma = tli[i]
        #print ("lt",tma)
      else:
        s*=(tli[i])
        s%=MOD
        #print ("l")
    tma = -1
    for i in range(n-1,mai2-1,-1):
      if ali[i]>tma:
        tma = ali[i]
        #print ("rt",tma)
      else:
        s*=(ali[i])
        s%=MOD
        #print ("r")
    if (mai2-mai1>1):
      for i in range(mai2-mai1-1):
        s*=mav
        s%=MOD
    print ( s%(1000000007) )
      
    
        
    
 

 

Measured memory_bytes: 18624
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int n, ans = 0;
  cin >> n;
  vector<int> a(n);
  for (int i=0; i<n; i++) cin >> a[i];
  int minel = a[0];
  for (int i=0; i<n; i++) {
    if(minel >= a[i]) ans ++;
    if(minel > a[i]) minel = a[i];
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 1024
use std::io::*;//Not mine.
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let a:String = read();
    let b:String = read();
    let mut c:i32 = read();
    let mut d:i32 = read();
    let e:String = read();
    if a == e {
        c -= 1;
    }else if b == e{
        d-=1;
    }
    println!("{} {}",c,d);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}
vector<int> ar[100001];
int vis[100001];
int dist[100001];
void bfs(int v)
{
	queue<int>q;
	vis[v]=1;
	dist[v]=0;
	while(!q.empty())
	{
		int curr=q.front();
		q.pop();
		for(int child:ar[curr])
		{
			if(vis[child]==0)
			{
			vis[child]=1;
			dist[child]=dist[curr]+1;
			q.push(child);
		}
		}
	}
}
int main()
{
   ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int a[200001];
    for(int i=0;i<n;i++)
    {
    	cin>>a[i];
	}
ll sum=0;
sort(a,a+n);
sum=sum+a[n-1];
int k=n-2;
int cnt=n-2;
int cp=1;
while(k--)
{
	if(cp%3==0)
	{
		cnt--;
		cp=1;
		k++;
	}
	else
	{
		sum=sum+a[cnt];
		cp++;
	}
}
cout<<sum<<endl;
}


Measured memory_bytes: 6780
string = str(input())
length = len(string)

t = 0
c = 0

def check(moji1,moji2):
    moji2 = list(moji2)
    moji1 = list(moji1)
    count = 0
    for i in range(t):
        if moji1[i] != moji2[i]:
            count += 1
    return count

if length % 2:
    t = int((length - 1)/2)
    mojimoji = list(string)
    newmoji1 = ""
    newmoji2 = ""
    for a in range(t):
        newmoji1 += mojimoji[a]
        newmoji2 += mojimoji[length-(1+a)]
    c = check(newmoji1,newmoji2)

else:
    t = int(length/2)
    mojimoji = list(string)
    newmoji1 = ""
    newmoji2 = ""
    for a in range(t):
        newmoji1 += mojimoji[a]
        newmoji2 += mojimoji[length-(1+a)]
    c = check(newmoji1,newmoji2)


print(c)

Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
  int i, a, b, c;
  int count = 0;

  scanf("%d %d %d", &a, &b, &c);

  for(i = a;i <= b;i++){
    if(c % i == 0) count++;
  }

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

  return 0;
}


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

using namespace std;

#define allof(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define exists(s, e) (s.find(e)!=s.end())
#define INF 0x3f3f3f3f
#define endl '\n'
#define mp make_pair
#define watch(x) cout << (#x) << " is " << (x) << endl;

typedef pair<int, int> pii;
typedef long long ll;

ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

void solve() {
    int n, l;
    cin >> n >> l;
    vector<string> v(n);
    for(int i=0; i<n; i++) {
        cin >> v[i];
    }
    sort(allof(v));
    for(string x : v) cout << x;
    cout << endl;
}

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



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

using namespace std;

typedef long long ll;
const int N = 3010;
const int mod = 998244353;

int n, s, arr[N];
ll dp[N][N][3];
bool vis[N][N][3];

ll fun(int pos, int rem, int f) {
  //f = 0, when neither L or R has been taken
  //f = 1, when L has been taken but not R
  //f = 2, when both L and R have been taken
  if (pos > n) return (rem == 0 && f == 2);
  ll &ret = dp[pos][rem][f];
  if (vis[pos][rem][f]) return ret;
  vis[pos][rem][f] = true;
  ret = 0;
  if (f == 2) {
    ret = (ret + fun(pos + 1, rem, f)) % mod;
  } else {
    if (f == 0) {
      ret = (ret + fun(pos + 1, rem, f) + fun(pos + 1, rem, 1)) % mod;
      if (arr[pos] <= rem) ret = (ret + fun(pos + 1, rem - arr[pos], 1) + fun(pos + 1, rem - arr[pos], 2)) % mod;
    } else {
      ret = (ret + fun(pos + 1, rem, 1)) % mod;
      ret = (ret + fun(pos + 1, rem, 2)) % mod;
      if (arr[pos] <= rem) ret = (ret + fun(pos + 1, rem - arr[pos], 1) + fun(pos + 1, rem - arr[pos], 2)) % mod;
    }
  }
  return ret;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> s;
  for (int i = 1; i <= n; ++i) cin >> arr[i];
  cout << fun(1, s, 0) << '\n';
}

Measured memory_bytes: 241656
import java.util.Scanner;

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

    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = scanner.nextInt();

    if(a < b){
      if(b <= c){
        if(a < c){
          System.out.println(a + " " + b + " " + c);
        }
        else{   //(a > c)
          System.out.println("No");
        }
      }

      else{     //(b > c)
        if(a <= c){
          System.out.println(a + " " + c + " " + b);
        }
        else{   //(a > c)
          System.out.println(b + " " + c + " " + a);
        }
      }
    }

    else if(a > b){
      if(b < c){
        if(a < c){
          System.out.println(b + " " + a + " " + c);
        }
        else{   //(a > c)
          System.out.println(b + " " + c + " " + a);
        }
      }
      else{     //(b > c)
        if(a < c){
          System.out.println("No");
        }
        else{   //(a > c)
          System.out.println(c + " " + b + " " + a);
        }
      }
    }

  }
}



Measured memory_bytes: 26160
from heapq import heappush, heappushpop

Q = int(input())

b = 0
la = []
sl = 0
ra = []
sr = 0

cnt = 0
for _ in range(Q):
    q = tuple(map(int, input().split()))
    # print(la, ra)
    if q[0] == 2:
        # 求値
        x = -la[0]
        cl = (cnt + 1) // 2
        cr = cnt - cl
        print(x, (cl * x - sl) + (sr - cr * x) + b)
    else:
        # 更新
        b += q[2]
        cnt += 1
        if cnt % 2 == 1:
            sr += q[1]
            x = heappushpop(ra, q[1])
            sr -= x
            sl += x
            heappush(la, -x)
        else:
            sl += q[1]
            x = heappushpop(la, -q[1])
            x *= -1
            sl -= x
            sr += x
            heappush(ra, x)


Measured memory_bytes: 82648
#include <iostream>
using namespace std;
typedef long long ll;

int main(){
  ll n,count1=0,count2=0; cin>>n;
  while(n>=500) {
    n -= 500;
    count1++;
  }
  while(n>=5) {
    n -= 5;
    count2++;
  }
  cout<<count1*1000 + count2*5;
}

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

long long Pow(long long a,long long b)
{
    long long res=1ll;
    a%=mod;
    while (b)
    {
        if (b & 1)
            res = (1ll*res * a) % (1ll*mod);
        a = (1ll*a * a) % (1ll*mod);
        b >>= 1ll;
    }
    return 1ll*res%mod;
}

long long C(long long n,long long m)
{
	if (m*2>n)  m=n-m;
	
	if(m==0) return 1;	
	if(m>n-m) m=n-m;
	long long up=1,down=1;	
	for(long long i=1;i<=m;i++)
	{		
		up=(up*(n-i+1))%mod;		
		down=(down*i)%mod;	
	}	
	return up*Pow(down,mod-2)%mod;
}

signed main()
{
	long long n,a,b,aa,bb;
	cin>>n>>a>>b;
	long long k=Pow(2ll,n)-1ll;
	aa=C(n,a);
	bb=C(n,b);
	
	long long ans=((k-aa-bb)%mod+mod)%mod;
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N,M=map(int, input().split())
H=list(map(int, input().split()))
tenbo=[True]*N
for i in range(M):
    A,B=map(int, input().split())
    if H[A-1]>=H[B-1]:#Aが大きい
        tenbo[B-1]=False
    elif H[A-1]<=H[B-1]:
        tenbo[A-1]=False
    if H[A-1]==H[B-1]:
        tenbo[A-1]=False
        tenbo[B-1]=False
print(sum(tenbo))

Measured memory_bytes: 84992
MOD = 10**9 + 7

N, M = map(int, input().split())
As = [int(input()) for _ in range(M)]

isBroken = [False] * (N+1)
for A in As:
    isBroken[A] = True

dp = [0] * (N+1)
dp[0] = 1
for i in range(1, N+1):
    if isBroken[i]: continue
    if i > 1:
        dp[i] += dp[i-2]
    dp[i] += dp[i-1]
    dp[i] %= MOD

print(dp[N])


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

using namespace std;

int main(void){
  long long K, ans,keta;
  queue<long long> lunlun; //はじめてのqueue
  cin >> K;
  for(int i=1;i<10;i++){
    lunlun.push(i);
  }
  for(long long i=0;i<K;i++){
    ans = lunlun.front();
    lunlun.pop();
    keta = ans%10;
    for(int j=-1;j<2;j++){
      if(keta+j>=0 && keta+j<10){
        lunlun.push(ans*10+keta+j);
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/


int getN(int L){
    int ret = 0;
    for(int i=0;i<=20;i++) if(L & (1<<i)) ret = i;
    return ret + 1;
}

int main(){
    int L; cin >> L;
    // require [0,L)
    int n = getN(L);

    using P = tuple<int,int,int>;
    vector<P> ans;
    // complete [0,2^(n-1))
    for(int i=1;i<n;i++) ans.push_back(P(i,i+1,0));
    for(int i=1;i<n;i++) ans.push_back(P(i,i+1,(1<<(i-1))));

    int r = (1 << (n-1));

    // node 1 -> node t = [0,2^(t-1))
    for(int i=n-1;i>=1;i--){
        int cost = r;
        // [ll,rr)
        int ll = r;
        int rr = ll + (1 << (i-1));
        if(rr > L) continue;
        else{
            ans.push_back(P(i,n,cost));
            r = rr;
        }
    }

    cout << n << " " << ans.size() << endl;
    for(const auto& p : ans){
        int a,b,c;
        tie(a,b,c) = p;
        cout << a << " " << b << " " << c << endl;
    }
}


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

int main(void)
{
    int W, H, x, y, r;

    cin >> W >> H >> x >> y >> r;

    if (W < x + r || 0 > x - r){
        cout << "No" << "\n";
    }
    else if (H < y + r || 0 > y - r){
        cout << "No" << "\n";
    }
    else {
        cout << "Yes" << "\n";
    }

    return (0);
}


Measured memory_bytes: 3088
import math
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque

# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_IL())
def ALL_I(): return map(int, stdin)
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))



##### main #####

def f(x):
	return sum(LM(int, list(str(x))))

def main():
	x = I()
	if x%f(x) == 0:
		print("Yes")
	else:
		print("No")



if __name__ == '__main__':
	main()

Measured memory_bytes: 3444
#include <stdio.h>

int main(){
 	long long N;
 	scanf("%lld", &N);
 	long long A[N], sum = 1;
 	
 	for(long long i=0; i<N; i++){
 		scanf("%lld", &A[i]);
	}
	
	for(long long i=0; i<N; i++){
 		if(A[i] == 0){
 			printf("0\n");
 			return 0;
		 }
	}
	
	for(long long i=0; i<N; i++){
		if(A[i] <= (1000000000000000000/sum)){
			sum *= A[i];
 		} else{
 			printf("-1\n");
            return 0;
		 }
 	}

		printf("%lld\n", sum);
 	
	return 0;
}

Measured memory_bytes: 2508
#include <bits/stdc++.h>
using namespace std;
int main(){
long long int n;
  long long int d;
  cin>>n>>d;
  int c;
  c=n/(2*d + 1);
  if(c*(2*d + 1) == n ){
      cout<<c<<endl;
  }
  else{
      cout<<c+1<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
        int b = sc.nextInt();
        if(a > 8 || b > 8){
           System.out.println(":(");
        }else{
           System.out.println("Yay!");      
        }
 
    }
}

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

int gcd(int m, int n)
{
	// ?????°?????????????????´??????????????????
	if ((0 == m) || (0 == n))
		return 0;

	// ???????????????????????????
	while (m != n)
	{
		if (m > n) m = m - n;
		else         n = n - m;
	}
	return m;
}

int lcm(int m,int n)
{
	// ?????°?????????????????´??????????????????
	if ((0 == m) || (0 == n))
		return 0;

	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

int main() {
	long int m, n;
	while (cin >> m >> n) {
		cout << gcd(m, n) << " " << lcm(m, n) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import fractions

def lcm(x, y):
    return x * y // fractions.gcd(x, y)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    prev_lc = 1
    ans = 0
    for i in A:
        lc = lcm(prev_lc, i)
        ans = ans * (lc // prev_lc) + lc // i
        prev_lc = lc
    print(ans % 1000000007)

if __name__ == '__main__':
    main()

Measured memory_bytes: 70360
import java.io.FileNotFoundException;
import java.util.Scanner;

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

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String S = sc.next();
		sc.close();
		int ans = 0;
		char[] s = S.toCharArray();
		for(int i=0;i<S.length()-2;i++) {
			String a = Character.toString(s[i])+Character.toString(s[i+1])+Character.toString(s[i+2]);
			if(a.equals("ABC")) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
n = int(input())
t = []
for i in range(n):
	s,p = map(str,input().split())
	t.append([s,int(p)])
a = list(enumerate(t))
a = sorted(a,key=lambda x: x[1][1],reverse=True)
a = sorted(a,key=lambda x: x[1][0])
for i in a:
	print (i[0]+1)

Measured memory_bytes: 3064
int main(void)
{
	int n;
	int l;
	int r;
	int a = 0;
	
	scanf("%d", &n);
	
	while(n != 0){
		scanf("%d %d", &l, &r);
		a +=(r - l) + 1;
		
		n--;
	}
	
	printf("%d", a);
	
	return(0);
}


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

inline long long read(){
	long long s = 0, w = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9'){
		if (ch == '-') w = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9'){
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * w;
}

int main(){
	string s;
	cin >> s;
	if (s.size()%2 == 1){
		cout << "No\n";
		return 0;
	}
	for (int i = 0; i < s.size(); i+=2){
		if (s[i] != 'h' || s[i+1] != 'i'){
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}


Measured memory_bytes: 256
using System;
class _0014
{
    public static void Main()
    {
        string str;
        const short x = 600;
        int d, sum;
        while ((str = Console.ReadLine()) != null)
        {
            d = int.Parse(str);
            sum=0;
            for (int i = 0; i * d < x; i++)sum += (i * d) * (i * d) * d;
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 5592
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <algorithm>
using namespace std;

int d, a, b, c;

int main()
{
	scanf ("%d %d %d %d", &a, &b, &c, &d);
	int ans;
	ans = min(b, d) - max(a, c);
	if (ans <= 0)	ans = 0;
	printf ("%d\n", ans);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
const ll mod=1e9+7;
const ll segN=(1LL<<22);

ll calc(ll a,ll b){
  return (a+b)%mod;
}

ll mul(ll x,ll y){return (x*y)%mod;}
ll pow(ll x,ll y){
  ll v=1;
  for(;y;x=mul(x,x),y>>=1)
    if(y&1)v=mul(v,x);
  return v;
}
ll divi(ll x,ll y){return mul(x,pow(y,mod-2));}

ll lcm(ll a,ll b){
  return a/ __gcd(a,b) *b;
}

struct data{
  ll value;
  data* ch[2];
 
  void init(){
    value=0;
    ch[0]=(data*)malloc(sizeof(data));
    ch[1]=(data*)malloc(sizeof(data));
    ch[0]->ch[0]=NULL;
    ch[1]->ch[0]=NULL;
  }
  
  void add(ll i,ll x,ll l,ll r){
    ll m=(l+r)/2;
    if(ch[0]==NULL)init();
    if(i<l || r<=i)return;
    value=calc(value,x);
    if(r-l==1)return;
    ch[0]->add(i,x,l,m);
    ch[1]->add(i,x,m,r);
  }
   
  void add(ll i,ll x){
    add(i,x,0,segN);
  }
   
  ll sum(ll a,ll b,ll l,ll r){
    ll m=(l+r)/2;
    if(ch[0]==NULL)init();
    if(b<=l || r<=a)return 0;
    if(a<=l && r<=b)return value;
    ll res=0;
    res=calc(res,ch[0]->sum(a,b,l,m));
    res=calc(res,ch[1]->sum(a,b,m,r));
    return res;
  }
 
  ll sum(ll a,ll b){
    return sum(a,b,0,segN);
  }
};



struct data2{
  ll value;
  data2* ch[2];
 
  void init(){
    value=1;
    ch[0]=(data2*)malloc(sizeof(data));
    ch[1]=(data2*)malloc(sizeof(data));
    ch[0]->ch[0]=NULL;
    ch[1]->ch[0]=NULL;
  }
  
  void set(ll i,ll x,ll l,ll r){
    ll m=(l+r)/2;
    if(ch[0]==NULL)init();
    if(i<l || r<=i)return;
    value=lcm(value,x);
    if(r-l==1)return;
    ch[0]->set(i,x,l,m);
    ch[1]->set(i,x,m,r);
  }
   
  void set(ll i,ll x){
    set(i,x,0,segN);
  }
   
  ll getLcm(ll a,ll b,ll l,ll r){
    ll m=(l+r)/2;
    if(ch[0]==NULL)init();
    if(b<=l || r<=a)return 1;
    if(a<=l && r<=b)return value;
    ll res=1;
    res=lcm(res,ch[0]->getLcm(a,b,l,m));
    res=lcm(res,ch[1]->getLcm(a,b,m,r));
    return res;
  }
 
  ll getLcm(ll a,ll b){
    return getLcm(a,b,0,segN);
  }
};
 
#define MAX 100005
ll N,Q,g=1;
ll t[MAX],u[MAX],v[MAX];
bool visited[MAX];
data T;
data2 U;

int main(){  
  T.init();
  U.init();
  cin>>N>>Q;
  for(int i=1;i<=N;i++)cin>>t[i];
  for(int i=1;i<=N;i++){
    if(visited[i])continue;
    ll sum=0,pos=i;
    vector<ll> vec;
    while(!visited[pos]){
      visited[pos]=true;
      sum=calc(sum,pos);
      vec.push_back(pos);
      pos=t[pos];
    }
    g=lcm(g,vec.size());
    for(int j=0;j<(int)vec.size();j++){
      u[vec[j]]=sum;
      v[vec[j]]=vec.size();
    }
  }
  
  for(int i=1;i<=N;i++){
    T.add(i,mul(u[i],(g/v[i])%mod));
    U.set(i,v[i]);
  }

  for(int i=0;i<Q;i++){
    ll l,r,A,B;
    cin>>l>>r;
    A=T.sum(l,r+1);
    B=U.getLcm(l,r+1);  
    cout<<divi(A,(g/B)%mod)<<endl;
  }
  return 0;
}

Measured memory_bytes: 28676
#include <iostream>

using namespace std;

int main() {
    int x, y;
    cin >> x >> y;

    for (int i = 0; i <= x; i++) {
        if (2 * i + 4 * (x - i) == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if (x == 1) {
        if (y == 2) {
            cout << "Yes" << endl;
            return 0;
        } else if (y == 4) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 3636
// https://atcoder.jp/contests/abc166/tasks/abc166_e

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,avx512f")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <vector>

using uint = unsigned int;
signed main() {
  uint n;
  std::cin >> n;
  std::vector<uint> a;
  a.reserve(n);
  for (uint i = 0; i < n; ++i) { uint t; std::cin >> t; a.emplace_back(t); }

  std::vector<uint> ansv(16);
  for (uint i = 0; i < n; ++i) {
    for (uint j = i + 1; j < n; ++j) {
      ansv[i%16] += (j - i) == a[j] + a[i];
    }
  }

  long long ans = 0;
  for (const auto& x : ansv) { ans += x; }
  std::cout << ans << std::endl;

  return 0;

}

Measured memory_bytes: 4000
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	VI A(N);
	REP(i, N)cin >> A[i];
	SORT(A);
	int ans = 0;
	bool F[1000010] = { false };
	bool FF[1000010] = { false };
	REP(i, N) {
		int n = A[i];
		bool f = 1;
		if (F[n] && !FF[n]) {
			//cout << n << endl;
			ans--;
			FF[n] = 1;
			continue;
		}


		for (int i = 1; i*i <= n; ++i)
		{
			if (n%i == 0)
			{
				if (F[i]) {
					f = 0;
					FF[n] = 1;
					break;
				}
				if (i*i != n)
				{
					if (F[n / i]) {
						f = 0;
						FF[n] = 1;
						break;
					}
				}
			}
		}
		F[A[i]] = 1;
		if (f)ans++;

	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 6612
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

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

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

int main() {
  in6 x;
  cin >> x;
  in6 price = 100;
  in6 ans = 0;
  while(price < x) {
    price *= 1.01;
    ans++;
  }
  cout << ans;
  hinata;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i = 0;i < n;i++){
    cin >> d[i];
  }
  long long ans = 0;
  
  for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
      if (i == j){
        continue;
      }
      else{
        ans += d[i]*d[j];
      }
    }
  }
  
  cout << ans/2 << endl;
}

Measured memory_bytes: 3584
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

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

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

struct edge { int to, cost; edge(int to, int cost) : to(to), cost(cost) {} edge() {} };
typedef vector<edge> edges;

edges G[3010];
int d[3010];

signed main()
{
    omajinai;

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

    fill_n(d, N + 1, inf);

    rep(i, M) {
        int a, b, l; cin >> a >> b >> l;
        a--, b--;

        G[a].PB(edge(b, l));
        G[b].PB(edge(a, l));
    }

    priority_queue<pii, vpii, greater<pii> > pq;

    rep(i, K) {
        int s; cin >> s;
        s--;
        d[s] = 0;
        pq.push(pii(0, s));
    }
    
    while (pq.size()) {
        pii p = pq.top(); pq.pop();

        int v = p.scd;

        if (d[v] < p.fst) continue;

        rep(i, G[v].size()) {
            edge &e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                pq.push(pii(d[e.to], e.to));
            }
        }
    }

    double ma = -1.0;

    rep(i, N) {
        rep(j, G[i].size()) {
            edge &e = G[i][j];
            ma = max(ma, (d[i] + d[e.to] + e.cost) / 2.0);
        }
    }

    cout << round(ma) << endl;
}

Measured memory_bytes: 6152
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(x) x.begin(),x.end()
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define endl "\n"
const ll maxn = 2e5+10;
 
int main()
{
    fastio;
    ll i, j, k, t, n, m, d, c=0;
    vll a;

    cin>>n>>d;
    
    for ( i = 0; i < n; i++)
    {
        ll x,y;
        cin>>x>>y;

        if (sqrt((x*x)+(y*y))<=d)
        {
            c++;
        }
    }
    
    cout<<c<<endl;


    return 0;
}

Measured memory_bytes: 3672
#include<stdio.h>
#include<ctype.h>

int main(void){
	char str1[100],str2[100],str3[100];
	
	scanf("%s%s%s",str1,str2,str3);
	printf("%c%c%c\n",toupper(str1[0]),toupper(str2[0]),toupper(str3[0]));	
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    vector<int> P(M), S(M);
    set<int> AC;
    map<int, int> penalty;
    for (int i = 0; i < M; i++) {
        string s;
        cin >> P[i] >> s;
        if (s == "AC") S[i] = 1;
    }
    int ans1 = 0, ans2 = 0;
    for (int i = 0; i < M; i++) {
        if (S[i] == 0) {
            penalty[P[i]]++;
        } else {
            if (!AC.count(P[i])) {
                AC.insert(P[i]);
                ans2 += penalty[P[i]];
            }
        }
    }
    ans1 = AC.size();
    cout << ans1 << ' ' << ans2 << endl;
    return 0;
}

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

int main(){
int N;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++){
   cin >>  A[i];
  }
  sort(A,A+N);
  cout << A[N-1]-A[0] << endl;
return 0;}

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

typedef long long ll;

int main() {
	int a = 0;
	std::cin >> a;
	if (a - ((a / 10)*10) == 9 || a == 9 || a >= 90) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

const int MAX_N = 200000;
long long fact[MAX_N];
long long factinv[MAX_N];

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

//階乗のリストを作る
void make_fact_tbl(long long n, long long mod){
	fact[0] = 1;
	for(long long i=1; i<=n; i++){
		fact[i] = fact[i-1] * i;
		fact[i] %= mod;
	}
}

//階乗の逆元のリストを作る
void make_factinv_tbl(long long n, long long mod){
	factinv[0] = -1; //0の逆元は存在しない
	for(long long i=1; i<=n; i++){
		factinv[i] = mod_pow(fact[i], mod-2, mod);
	}
}

//組み合わせの計算に必要な情報の作成
void comb_init(long long n, long long mod){
	make_fact_tbl(n, mod);
	make_factinv_tbl(n, mod);
}

//組み合わせの計算
long long comb(long long n, long long k, long long mod){
	if(n < k) return 0;
	if(k == 0 || n-k == 0) return 1;
	//printf("n:%lld k:%lld n-k:%lld\n", fact[n], factinv[k], factinv[n-k]);
	return ((fact[n] * factinv[k]) % mod) * factinv[n-k] % mod;
}


int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n;
	int l, r;
	cin >> n;

	comb_init(MAX_N-1, MOD);

	map<int, int> a;
	for(int i=0; i<n+1; i++){
		int t;
		cin >> t;
		if(a.find(t) == a.end()){
			a[t] = i+1;
		}else{
			l = a[t];
			r = i+1;
		}
	}

	/*
	for(int i=1; i<=n; i++){
		cout << fact[i] << endl;
		cout << factinv[i] << endl;
		cout << fact[i] * factinv[i] % MOD << endl;
	}
	*/

	for(int k=1; k<=n+1; k++){
		//cout << comb(n+1, k, MOD) << endl;
		//cout << comb(l-1+n+1-r, k-1, MOD) << endl;
		ll ans = comb(n+1, k, MOD);
		ans = (ans + MOD - comb(l-1+n+1-r, k-1, MOD)) % MOD;
		cout << ans << endl;
	}


	
	return 0;
}


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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define ALL(a) (a.begin(), a.end())
#define FOR(x,to) for(x=0;x<(to);x++)

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

void solve() {
	string s,t;
	cin >> s >> t;
	int n = (int)s.length();
	for (int k = 0; k < n; ++k) {
		bool ok = true;
		for (int i = k-1; i >= 0; --i) {
			if (s[n-1-i] != t[k-1-i]) {
				ok = false;
				break;
			}
		}

		for (int i = 0; i < n-k; ++i) {
			if (s[i] != t[i+k]) {
				ok = false;
				break;
			}
		}

		if (ok) {
			cout << "Yes\n";
			return;
		}
	}

	cout << "No\n";
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

	//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int na,nb,nc,x;
    int count=0;

    cin >> na >> nb >> nc >> x;

    for (int i=0;i<=na;i++){
        for (int j=0;j<=nb;j++){
            for (int k=0;k<=nc;k++){
                int y = 500*i + 100*j + 50*k;
                if (y==x) count++;
            }
        }
    }
    cout << count;
}

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

#define ll long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int N = 200001;


void solve() {
    int n;
    cin >> n;
    ll arr[n + 1];
    memset(arr , 0 , sizeof arr);
    for(ll i = 0 ,a ; i < n - 1 ; i ++) cin >> a , arr[a] ++;
    for(ll i = 1 ; i <= n ; i ++) cout << arr[i] << '\n';
}

/*
 */

int main()
{
    fastio
    int testcase = 1;
    //cin >> testcase ;
    
    while(testcase --) {
        solve();
        cout << '\n';
    }
    
    return 0;
}
 



Measured memory_bytes: 5212
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0047
{
    public class Program

    {
        public static void Main(string[] args)
        {
            Dictionary<string, bool> cups = new Dictionary<string, bool>() { { "A", true }, { "B", false }, { "C", false } };
            while (true)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line)) break;

                string[] change = line.Split(',');
                bool tmp = cups[change[0]]; cups[change[0]] = cups[change[1]]; cups[change[1]] = tmp;
            }
            Console.WriteLine(cups.Where(x => x.Value == true).First().Key);
        }
    }

}



Measured memory_bytes: 16032
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	n, w := scInt2()
	wlist, vlist := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		wlist[i], vlist[i] = scInt2()
	}

	// DPテーブルの初期化
	// dp[i][sumV] := i-1 番目までの品物から価値が sumV 以上を達成するように選んだときの、重さの総和の最小値
	// vi <= 10**3, N<=100なので 100001 あれば十分
	// 重さの最小を求めるので、infで初期化する
	dp := make([][]int, n+1)
	inf := math.MaxInt32
	maxV := 100001
	for i := 0; i < n+1; i++ {
		// 重さの範囲内でテーブルを作る
		values := make([]int, maxV)
		for j := 0; j < maxV; j++ {
			values[j] = inf
		}
		dp[i] = values
	}

	// 初期条件
	dp[0][0] = 0

	for i := 0; i < n; i++ {
		// i番目の商品の重さごとの価値を確認する
		for sumV := 0; sumV < maxV; sumV++ {
			// i番目の商品を選択できる場合
			if sumV-vlist[i] >= 0 {
				// i番目の商品を選択する場合
				nw := dp[i][sumV-vlist[i]] + wlist[i]
				dp[i+1][sumV] = min(dp[i+1][sumV], nw)
			}
			dp[i+1][sumV] = min(dp[i+1][sumV], dp[i][sumV])
		}
	}
	ans := 0
	for sumV := 0; sumV < maxV; sumV++ {
		if dp[n][sumV] <= w {
			ans = sumV
		}
	}
	fmt.Println(ans)
}

func scStr() string {
	var s string
	fmt.Scan(&s)
	return s
}

func scInt() int {
	var x int
	fmt.Scan(&x)
	return x
}

func scInt2() (int, int) {
	var x, y int
	fmt.Scan(&x, &y)
	return x, y
}

func scInt3() (int, int, int) {
	var x, y, z int
	fmt.Scan(&x, &y, &z)
	return x, y, z
}

func scInts(n int) (slice []int) {
	slice = make([]int, n)
	for i := range slice {
		fmt.Scan(&slice[i])
	}
	return slice
}

func hw(h int, w int, init int) [][]int {
	hw := make([][]int, h)
	for i := 0; i < h; i++ {
		hw[i] = make([]int, w)
		for j := 0; j < w; j++ {
			hw[i][j] = init
		}
	}
	return hw
}

func sum(slice []int) (sum int) {
	sum = 0
	for i := range slice {
		sum += slice[i]
	}
	return
}

func uniqueInts(ints []int) (unique []int) {
	m := map[int]bool{}
	for _, v := range ints {
		if !m[v] {
			m[v] = true
			unique = append(unique, v)
		}
	}
	return unique
}

func uniqueStrs(strs []string) (unique []string) {
	m := map[string]bool{}
	for _, v := range strs {
		if !m[v] {
			m[v] = true
			unique = append(unique, v)
		}
	}
	return unique
}

func min(x, y int) int {
	if x > y {
		return y
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func minInts(ints []int) int {
	sort.Ints(ints)
	return ints[0]
}

func maxInts(ints []int) int {
	sort.Ints(ints)
	n := len(ints)
	return ints[n-1]
}

func powi(x, pow int) int {
	return int(math.Pow(float64(x), float64(pow)))
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

class UnionFind
{
public:
	explicit UnionFind(int size)
		: mParent(size, -1)
		, mRank(size, 0)
        , mData(size, 0)
		{}
	bool unionSet(int x, int y)
	{
		if ((x = root(x)) == (y = root(y)))
			return false;
		if( mRank[x] < mRank[y] )
		{
			mParent[y] += mParent[x];
			mParent[x] = y;
            unionData( mData[y], mData[x] );
		}
		else
		{
			mParent[x] += mParent[y];
			mParent[y] = x;
			if( mRank[x] == mRank[y] ) ++mRank[x];
            unionData( mData[x], mData[y] );
		}
		return true;
	}
	bool isEqualSet(int x, int y)
	{
		return root(x) == root(y);
	}
	int root(int x)
	{
		return mParent[x] < 0 ? x : mParent[x] = root(mParent[x]);
	}
	int size(int x)
	{
		return -mParent[root(x)];
	}

	void unionData( int& parent, int& child )
	{
			parent += child;
	}
	void setData( int x, int data )
	{
			mData[root(x)] = data;
	}
	int getData( int x )
	{
			return mData[root(x)];
	}

private:
	vector<int> mParent; // = mSize
	vector<int> mRank;
	vector<int> mData;
};

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

	UnionFind uf(n);
	REP(i,m)
	{
		int x,y,z;cin>>x>>y>>z;
		uf.unionSet(x-1,y-1);
	}

	vector<int> v( n, 0 );
	int sum = 0;
	REP(i,n)
	{
		int head = uf.root(i);
		if( v[head] == 1 ) continue;
		v[head] = 1;
		++sum;
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(int argc, char *argv[])
{
    long long a, b, x;
    scanf("%lld %lld %lld", &a, &b, &x);
    printf("%lld\n", b/x - a/x + (a%x == 0?1LL:0LL) );
    return 0;
}

Measured memory_bytes: 128