akhauriyash/Code-Regression huggingface dataset:
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
import Data.Maybe
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
	n <- readLn
	xs <- map strToInt . words <$> getLine
	let ys = zipWith (-) xs [0..]
	let y = (sort ys)!!(n `div` 2)
	let zs = map (\x -> abs (x - y)) ys

	putStrLn . show $ sum zs


Measured memory_bytes: 110588
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <utility>
#include <algorithm>
#include <set>
#include <queue>
#include <climits>
#include <limits>
#define inf 1000000000000000000

#define ll long long
#define max(A, B) ((A) > (B) ? (A) : (B))
#define min(A, B) ((A) < (B) ? (A) : (B))
#define pair(A, B) make_pair(A, B)

using namespace std;

typedef pair<int, int> pi;
typedef pair<pair<int, int>, int> pii;

void performA() {
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
    return;
  }
  cout << "No" << endl;
  return;
}

void performB() {
  int n; cin >> n;
  int pts = (n/500) * 1000;
  n %= 500;
  pts += (n/5) * 5;
  cout << pts << endl;
}

void performC() {
  int k, n; cin >> k >> n;
  int first; cin >> first;
  int last;
  for (int i = 1; i < n; i++) {
    cin >> last;
  }
  int diff = fabs(first - last);
  int arc = k - diff;
  cout << min(arc, diff) << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll t = 1; //cin >> t;
  while (t--) {performA();}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
#define MOD 998244353
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST ll T;cin>>T;while(T--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
map<int,int> mp;
bool fact(int i){
    if(mp[1] && i!=1) return(false);
    for(int j=2;j*j<=i;j++){
        if(i%j!=0) continue;
        if(mp[j] || mp[i/j]) return(false);

    }
    return(true);
}
void solve(){
    int n,a,cnt=0;
    cin>>n;

    for(int i=0;i<n;i++){
        cin>>a;
        mp[a]++;
    }
    for(auto pp:mp){
        if(pp.second>1) continue;
        if(fact(pp.first)) cnt+=pp.second;
        //cout<<pp.first<<endl;
    }

    cout<<cnt;
    return;
}
int main(){
    IO
    //TEST
    solve();
    return(0);
}


Measured memory_bytes: 32404
// 2014/06/09 Tazoe

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
	while(true){
		double v;
		cin >> v;

		if(cin.eof())
			break;

		int N = ceil((v*v+98.0)/98.0);

		cout << N << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
#include <stdio.h>

int main()
{
	int N, H, W;
	scanf("%d%d%d", &N, &H, &W);
	int A[N], B[N];
	int i, j, k;
	for (i = 0; i < N; i++) {
		scanf("%d%d", &A[i], &B[i]);
	}
	int count=0;
	for (i = 0; i < N; i++) {
		if (A[i] >= H && B[i] >= W) {
			count++;
		}
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int le[2000][2000], ri[2000][2000], up[2000][2000], down[2000][2000];

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

    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; i++)
    {
        cin >> s[i];
    }
    for (int i = 0; i < h; i++)
    {
        if (s[i][0] != '#')
            le[i][0] = 1;
        for (int j = 1; j < w; j++)
        {
            if (s[i][j] != '#')
                le[i][j] = le[i][j - 1] + 1;
        }
    }
    for (int i = 0; i < h; i++)
    {
        if (s[i][w - 1] != '#')
            ri[i][w - 1] = 1;
        for (int j = w - 2; j >= 0; j--)
        {
            if (s[i][j] != '#')
                ri[i][j] = ri[i][j + 1] + 1;
        }
    }
    for (int j = 0; j < w; j++)
    {
        if (s[0][j] != '#')
            up[0][j] = 1;
    }
    for (int i = 1; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (s[i][j] != '#')
                up[i][j] = up[i - 1][j] + 1;
        }
    }
    for (int j = 0; j < w; j++)
    {
        if (s[0][j] != '#')
            down[h - 1][j] = 1;
    }
    for (int i = h - 2; i >= 0; i--)
    {
        for (int j = 0; j < w; j++)
        {
            if (s[i][j] != '#')
                down[i][j] = down[i + 1][j] + 1;
        }
    }
    int ret = 0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (s[i][j] == '#')
                continue;
            ret = max(ret, le[i][j] + ri[i][j] + up[i][j] + down[i][j] - 3);
        }
    }
    cout << ret << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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 (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    string s;
    string t;
    cin>>s>>t;
    ll n = s.length();
    s += s ;
    bool yes = false;
    rep(i,n){
        bool ok = true;
        rep(j,n){
            if(s[j+i]!=t[j])ok=false;
        }
        if(ok){
            yes = true;
            break;
        }
    }
    Yes(yes);
    return  0;
}


Measured memory_bytes: 256
use std::collections::VecDeque;

fn main() {
    let (n, d, a) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut it = buf.trim_end().split_whitespace();
        let n: usize = it.next().unwrap().parse().unwrap();
        let d: i64 = it.next().unwrap().parse().unwrap();
        let a: i64 = it.next().unwrap().parse().unwrap();
        (n, d, a)
    };
    let mut monsters: Vec<Vec<i64>> = Vec::new();
    for _ in 0..n {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut it = buf.trim_end().split_whitespace();
        let x: i64 = it.next().unwrap().parse().unwrap();
        let h: i64 = it.next().unwrap().parse().unwrap();
        monsters.push(vec![x, h]);
    }
    monsters.sort_by(|a, b| a[0].cmp(&b[0]));
    let mut ans: i64 = 0;
    let mut total: i64 = 0;
    let mut q: VecDeque<Vec<i64>> = VecDeque::new();
    for i in 0..n {
        let x = monsters[i][0];
        let mut h = monsters[i][1];
        while (q.len() > 0) && (q.front().unwrap()[0] < x) {
            let damage = q.pop_front().unwrap();
            total -= damage[1];
        }
        h -= total;
        if h > 0 {
            let mut cnt = h / a;
            if cnt * a < h {
                cnt += 1;
            }
            ans += cnt;
            let damage = cnt * a;
            total += damage;

            q.push_back(vec![x + 2 * d, damage])
        }
    }
    println!("{}", ans);
}


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

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

    int m;
    cin>>m;
    m=m*m*m;
    cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */
void yes(){
  cout << "Yes" << endl;
  exit(0);
}

void no(){
  cout << "No" << endl;
  exit(0);
}

int main() {
  ll a,b,c; cin >> a >> b >> c;
  if(c>=a && c<=b) yes();
  else no();
}


Measured memory_bytes: 256
#!python
# -*- coding: utf-8 -*-


def main():
    N, K = input().split(' ')
    D = set(map(int, input().split(' ')))
    can_use_num = set(map(str, set(range(10)) - D))

    n = int(N)
    while True:
        if set(str(n)) <= can_use_num:
            break
        n += 1
    print(n)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
//参考元：tomerun 氏のコード(2019-10-27 21:03:32)
//https://atcoder.jp/contests/abc144/submissions/8150492

import java.util.*;

public class Main{
   public static void main(String[] args){
     Scanner scan = new Scanner(System.in);
     long num1 = scan.nextLong();
     long ans = Long.MAX_VALUE;
     
     // 本来はnum1個の約数について調べなければならないが、
     // 約数の対称性により a < bのとき Nの平方根個分調べるだけで済む
	 for (long i = 1; i * i <= num1; i++) {
          if (num1 % i == 0) {
              ans = Math.min(ans, i + num1 / i - 2);
          }
      }
     
     System.out.println(ans);
     

   }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  long long i;
  for(i=0;i<12;i++){
      if(i==4)
      cout<<" "<<s[i];
      else
      cout<<s[i];
  }cout<<endl;
  return 0;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
 
using namespace std;
 
int main() {
    string S;
 
    cin >> S;
 
    for (int i = 0; i < 3; ++i) {
        if (S[i] == '7') {
            cout << "Yes";
            return 0;
        }
    }
 
    cout << "No";
    return 0;
}

Measured memory_bytes: 3624
import math

def main():

    a, b = [int(i) for i in input().split()]

    lo = max(1000 * a, 800 * b)
    hi = min(1000 * (a + 1), 800 * (b + 1))

    if lo < hi:
        print(math.ceil(lo / 80))
    else:
        print(-1)


main()


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

int main(){
    ll n; cin >> n;
    vector<ll> a(n),b(n);

    priority_queue<pair<ll,ll> , vector<pair<ll,ll> >, greater<pair<ll,ll> > > pq;

    for(int i=0;i<n;++i){
        cin >> a[i] >> b[i];
        if(b[i] - a[i] < 0){
            cout << "No" << endl;
            return 0;
        }
        pq.push(make_pair(b[i], a[i]));
    }

    ll now = 0;
    while(pq.size()){
        pair<ll,ll> cur = pq.top();
        pq.pop();
        //cout  << now << " " << cur.first << endl;
        now += cur.second;
        if(now > cur.first){
            cout << "No" << endl;
            return 0;
        }
        
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 9456
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a)
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;

inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=200005;
//i_am_noob
int n,a[maxn],b[maxn];

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n;
	rep(n) cin >> a[i] >> b[i];
	sort(a,a+n),sort(b,b+n);
	if(n%2==1) print1(b[n>>1]-a[n>>1]+1);
	else print1(b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1]+1);
	return 0;
}


Measured memory_bytes: 6764
N = int(input())
A = list(map(int,input().split()))
ans = 1
Flag = True
zero_flag = False
for i in range(N):
    if A[i]==0:
        zero_flag = True
        break
for i in range(N):
    ans = ans*A[i]
    if ans > 10**18:
        Flag = False
        break
        
# print(len(str(ans))-1)
if zero_flag:
    print(0)
elif ans<=10**18 or Flag:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 21652
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<long long int> p(a), q(b), r(c);
	for(int i=0;i<a;i++){
		cin >> p.at(i);
	}
	sort(p.begin(),p.end());
	for(int i=0;i<a-x;i++){
		p.at(i) = 0;
	}
	for(int i=0;i<b;i++){
		cin >> q.at(i);
	}
	sort(q.begin(),q.end());
	for(int i=0;i<b-y;i++){
		q.at(i) = 0;
	}
	for(int i=0;i<c;i++){
		cin >> r.at(i);
	}
	sort(r.begin(),r.end());
	vector<long long int> s(a+b+c);
	for(int i=0;i<a;i++){
		s.at(i) = p.at(i);
	}
	for(int i=0;i<b;i++){
		s.at(a+i) = q.at(i);
	}
	for(int i=0;i<c;i++){
		s.at(a+b+i) = r.at(i);
	}
	sort(s.begin(),s.end());
	long long int ans = 0;
	for(int i=0;i<x+y;i++){
		ans += s.at(a+b+c-1-i);
	}
	cout << ans << endl;
	return 0;
}

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

int main(void){
  int n;
  cin >> n;
  int vec_1[n],vec_2[n];
  vector<int> ans(n,0);
  for(int i=0;i<n;i++){
    cin >> vec_1[i];
  }
  for(int i=0;i<n;i++){
    cin >> vec_2[i];
  }
  int sum_1[n+1]={},sum_2[n+1]={};
  for(int i=0;i<n;i++){
    sum_1[i+1]=sum_1[i]+vec_1[i];
    sum_2[i+1]=sum_2[i]+vec_2[i];
  }
  for(int i=0;i<n;i++){
    ans[i]+=sum_1[i+1]-sum_1[0]+sum_2[n]-sum_2[i];
  }
  sort(ans.begin(), ans.end());
  cout << ans[n-1] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		String s = sc.next();
		String t = sc.next();
		int cnt = 0;
		for (int i = 0; i < 3; i++) {
			if (s.charAt(i) == t.charAt(i)) {
				cnt++;
			}
		}
		System.out.println(cnt);

		sc.close();
	}
}

Measured memory_bytes: 22740
import itertools
def main():
    N = int(input())
    A = list(map(int , input().split()))
    B = list(map(int , input().split()))
    #B = input()
    #print (A)
    #print (S)
    #list_N = []
    list_N = list(range(1,N+1))
    #print (list_N)
    #AA = A.index(N) + 1
    #BB = B.index(N) + 1
    #print (AA)
    n1 = 0
    n2 = 0
    count_n = 0
    for i in itertools.permutations(list_N) :
        if A == B :
            print ("0")
            break
        list_i = list(i)
        #print(list_i)
        #print(A)
        count_n = count_n + 1
        if A == list_i :
            n1 = count_n
        elif B == list_i :
            n2 = count_n
        #print (count_n)
    #print (n1)
    #print (n2)
    if A != B :
        print (str(abs(n1 - n2)))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){

    int N, i;
    scanf("%d", &N);
    //printf("N:%d", N);

    const int MAX = N+1;
    int ti[MAX], xi[MAX], yi[MAX]; // i=0にt=0の条件:(x,y)=(0,0)を格納しないとN=1の処理が出来ない
    char dammy;

    // 配列初期化, t=0の条件を追加
    for (i = 0; i < N;i++){
        ti[i] = xi[i] = yi[i] = 0;
    }

    for (i = 1; i < MAX; i++)
    {
        scanf("%c", &dammy);
        scanf("%d %d %d", &ti[i], &xi[i], &yi[i]);
        
    }

    int distance = 0;
    int judge = 1;
 
    for (i = 0; i < MAX-1; i++){
        distance = abs(xi[i + 1] - xi[i]) + abs(yi[i + 1] - yi[i]);
        if((distance <= abs((ti[i+1]-ti[i]))&&(distance%2 == abs((ti[i+1]-ti[i]))%2))){
            judge *= 1;
        }else{
            judge *= 0;
        }
    }

    if(judge == 1){
        printf("Yes");
    }else{
        printf("No");
    }

        return 0;
}


Measured memory_bytes: 1408
n = int(input())
l = list(map(int,input().split()))

while l.count(0) != n-1:
    m = max(l)
    for i in l:
       if (i < m) and i != 0:
           m = i
         
    index = l.index(m)
    
    for i in range(n):
        if i == index:
            pass
        
        else:
            l[i] = l[i] % m

print(max(l))

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(int i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 1e18
#define five 100005;
#define six 1000005;
#define prllclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
const int N = 100005;
ll fct[N];
ll invf[N];
ll power(ll a,ll b,ll m)
{
   ll ans=1;
   while(b>0)
   {
       if(b%2)
       {
           ans=(ans*a)%m;
       }
       a=(a*a)%m;
       b=b/2;
   }
   return ans;
}
ll inverse(ll a,ll m)
{
       return (power(a,m-2,m));
}
ll C(ll n,ll r)
{
       if(r>n){return 0;}
       ll xx = (invf[r]*invf[n-r])%mod;
       xx *= fct[n];
       return xx%mod;
}
void initialize()
{
       fct[0] = 1;
       invf[0] = 1;
       fri(i,1,N){
              fct[i] = (i*fct[i-1])%mod;
              invf[i] = inverse(fct[i],mod);
       }
}

int main()
{
       initialize();
       ll n,k;
       cin>>n>>k;
       fri(i,1,k+1){
              ll xx = (C(k-1,i-1)*C(n-k+1,i))%mod;
              cout<<xx<<endl;
       }
}


Measured memory_bytes: 1792
n=input()
k=int(input())
lenn=len(n)
dp=[[[0]*2 for i in range(k+1)] for j in range(lenn)]
for i in range(int(n[0])+1):
  keta=int(n[0])
  if i<keta:
    if i==0:
      dp[0][0][1]+=1
    else:
      dp[0][1][1]+=1
  elif i==keta:
    dp[0][1][0]+=1
for i in range(1,lenn):
  keta=int(n[i])
  for l in range(10):
    for j in range(k):
      if l>0:
        dp[i][j+1][1]+=dp[i-1][j][1]
      else:
        dp[i][j][1]+=dp[i-1][j][1]
      if l<keta:
        if l>0:
          dp[i][j+1][1]+=dp[i-1][j][0]
        else:
          dp[i][j][1]+=dp[i-1][j][0]
      elif l==keta:
        if keta==0:
          dp[i][j][0]+=dp[i-1][j][0]
        else:
          dp[i][j+1][0]+=dp[i-1][j][0]
  if keta==0:
    dp[i][k][0]+=dp[i-1][k][0]
  else:
    dp[i][k][1]+=dp[i-1][k][0]
  dp[i][k][1]+=dp[i-1][k][1]
print(dp[lenn-1][k][0]+dp[lenn-1][k][1])

Measured memory_bytes: 40304
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
#include<stdio.h>
#include<string>
using namespace std;
int main(){
  int N,ans=1;
  string s;
  cin>>N;
  cin>>s;
  for(int h=0;h<N-1;h++){
    if(s[h]!=s[h+1]){
    ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>

using namespace std;

long foo(long N, long current, vector<long> args) {
  long ans = 0;
  for (long x : args) {
    long tmp = current * 10 + x;
    if (tmp <= N) {
      ans++;
      ans += foo(N, tmp, args);
    }
  }
  return ans;
}

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

  vector<long> vec7; vec7.push_back(7);
  vector<long> vec5; vec5.push_back(5);
  vector<long> vec3; vec3.push_back(3);

  vector<long> vec75; vec75.push_back(7); vec75.push_back(5);
  vector<long> vec73; vec73.push_back(7); vec73.push_back(3);
  vector<long> vec53; vec53.push_back(5); vec53.push_back(3);

  vector<long> vec753; vec753.push_back(7); vec753.push_back(5); vec753.push_back(3);

  long num7 = foo(N, 0, vec7);
  long num5 = foo(N, 0, vec5);
  long num3 = foo(N, 0, vec3);

  long num75 = foo(N, 0, vec75);
  long num73 = foo(N, 0, vec73);
  long num53 = foo(N, 0, vec53);

  long num753 = foo(N, 0, vec753);

  cout << num753
    - (num75 - num7 - num5)
    - (num73 - num7 - num3)
    - (num53 - num5 - num3)
    - num7 - num5 - num3
    << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tiii;
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;

int s[101000];
int e[101000];

int main() {
    int N, M;
    cin >> N >> M;
    fill(s, s + N, 0);
    fill(e, e + N, 0);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        int n = min(a, b);
        int m = max(a, b);
        s[n - 1]++;
        e[m - 1]++;
    }
    bool ok = true;
    int num = 0;
    for (int i = 0; i < N - 1; i++) {
        num = num + s[i] - e[i];
        if (num % 2 == 1) {
            ok = false;
        }
    }
    if (ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 1024
N = int(input())
A = input()
B = input()
C = input()

ret=0

for i in range(N):
  a=A[i]
  b=B[i]
  c=C[i]
  
  if a==b==c:
    continue
  elif a!=b and a!=c and b!=c:
    ret+=2
  else:
    ret+=1
print(ret)

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long A)
{
    cout << (N % 500 <= A ? YES : NO) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long A;
    scanf("%lld", &A);
    solve(N, A);
    return 0;
}


Measured memory_bytes: 256
import math

N = int(input())

C = [0 for i in range(N-1)]
S = [0 for i in range(N-1)]
F = [0 for i in range(N-1)]
A = [0 for i in range(N)]
for i in range(N-1):
  C[i], S[i], F[i] = map(int, input().split())

for i in range(N-1)[::-1]:
  ans = S[i] + C[i]
  for j in range(i, N-2):
    if ans <= S[j+1]:
      ans = A[j+1]
      break
    else:
      ans = math.ceil(ans / F[j+1]) * F[j+1] + C[j+1]
  A[i] = ans
  
for i in range(N):
  print(A[i])

Measured memory_bytes: 41180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
const int n_max = 1e5+10;
set<int> g[n_max];
set<int> used;
bool tot_ok = true;

void dfs(int cv, int pv){
  // cout << cv << " " << pv << endl;
  bool ok = false;
  for(auto &nv : g[cv]){
    if(nv == pv) continue;
    dfs(nv,cv);
    if(used.count(cv)==1){
      ok = true;
    }
  }
  if(!ok){
    if(used.count(pv)==0){
      ok = true;
      used.insert(cv);
      used.insert(pv);
    }
  }

  if(!ok){
    tot_ok = false;
  }

}


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

  int n;
  cin >> n;

  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    --a;--b;
    g[a].insert(b);
    g[b].insert(a);
  }
  used.insert(-1);
  dfs(0,-1);

  rep(i,n){
    if(used.count(i)==0 || !tot_ok){
      cout << "First" << endl;
      return 0;
    }
  }

cout << "Second" << endl;

  return 0;
    

}


Measured memory_bytes: 19072
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    int sum = 0;
    rep(i, n){
        cin >> l[i];
        sum += l[i];
    }

    sort(l.begin(), l.end());
    if(l[n-1] < sum-l[n-1]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    
    String x = sc.next();
    String y = sc.next();
    char[] c= x.toCharArray();
    char[] d= y.toCharArray();
    for(int i = 0; i < c.length;i++){
      if (c[i] != d[i]){
        System.out.println("No");
        return;
      }
    }
    if (c.length+1 != d.length){
     System.out.println("No");
      return;
    }
        
    System.out.println("Yes");
  }
}


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

using namespace std;

//#define MD 100010

int main(){
    string a,b,c;
    cin>>a>>b>>c;
    int la=a.length(),lb=b.length(),lc=c.length();
    int ia=0,ib=0,ic=0;
    char g='a';
    
    while(1){
        if(g=='a'){
            ia++;
            if(ia<=la){
                g=a[ia-1];
            }else{
                cout<<"A"<<endl;
                break;
            }
        }else if(g=='b'){
            ib++;
            if(ib<=lb){
                g=b[ib-1];
            }else{
                cout<<"B"<<endl;
                break;
            }
        }else{
            ic++;
            if(ic<=lc){
                g=c[ic-1];
            }else{
                cout<<"C"<<endl;
                break;
            }
        }
    }
   return 0;
}

Measured memory_bytes: 256
def main():
    s = input()
    t = input()
    dp = [[0]*(len(s)+1) for i in range(len(t)+1)]
    for i in range(1,len(t)+1):
        for j in range(1,len(s)+1):
            if t[i-1] == s[j-1]:
                dp[i][j] = dp[i-1][j-1] + 1
            else:
                dp[i][j] = max(dp[i-1][j], dp[i][j-1])
    ans = ""
    i = len(t)
    j = len(s)
    while i != 0 and j != 0:
        if t[i-1] == s[j-1]:
            ans = t[i-1] + ans
            i -= 1
            j -= 1
        elif dp[i-1][j] < dp[i][j-1]:
            j -= 1
        else:
            i -= 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 111580
import java.util.*;
public class Main 
{
	static int[] ball = new int[10];
	static int a = 0, b = 0;
	static boolean flag = false;
	static void dfs(int pos)
	{
		if(pos >= 10)
		{
			flag = true;
			return;
		}
		if(ball[pos] > a)
		{
			a = ball[pos];
			dfs(pos + 1);
		}
		if(ball[pos] > b)
		{
			b = ball[pos];
			dfs(pos + 1);
		}
	}
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int N = stdIn.nextInt();
			while(N-- != 0)
			{
				flag = false;
				a = 0;
				b = 0;
				for(int i = 0; i < 10; ++i)
				{
					ball[i] = stdIn.nextInt();
				}
				dfs(0);
				if(flag)
				{
					System.out.println("YES");
				}
				else
				{
					System.out.println("NO");
				}
			}
		}
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
int main(void)
{
    int a,b,n,m=0;
    scanf("%d %d %d",&a,&b,&n);
    if(a>b){
        if(n%a==0)
            m=n/a;
        else
            m=n/a+1;
    }
    else{
        if(n%b==0)
            m=n/b;
        else
            m=n/b+1;
    }
    printf("%d",m);
    return 0;
}

Measured memory_bytes: 128
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  int a,b,c;cin>>a>>b>>c;
  cout << min({a+b,b+c,c+a}) << endl;
}


Measured memory_bytes: 256
import sys

ar = []
x = sys.stdin.readline()
x = x.split(' ')
(n,m)=[int(str) for str in x]

ret = 0
chk = []
for i in range(m):
  x = sys.stdin.readline()
  x = x.split(' ')
  (s,c)=[int(str) for str in x]
  if not ( s in chk):
    if(n-s>=0):
      ret += c*10**(n-s)
      chk.append(s)
  else:
    if( c != int(ret/10**(n-s))):
      print("-1")
      exit(0)

if( ret == 0 and n == 1):
  print("0")
  exit(0)
if( ret < 10**(n-1)):
  if not ( 1 in chk):
    print(ret+10**(n-1))
  else:
    print("-1")
else:
  print(ret)
sys.stdout.flush()


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

using namespace std;

#define N 100

long long t[N + 1];

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

int main(){
	long long ans;
	int n, i;

	scanf("%d", &n);

	for (i = 1; i <= n; i++){
		scanf("%lld", t + i);
	}

	ans = t[1];

	for (i = 2; i <= n; i++){
		ans = lcm(ans, t[i]);
	}

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 256
w, h, n = list(map(int, input().split()))
x_min, x_max, y_min, y_max = 0, w, 0, h
for _ in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        x_min = max(x_min, x)
    elif a == 2:
        x_max = min(x_max, x)
    elif a == 3:
        y_min = max(y_min, y)
    else:
        y_max = min(y_max, y)
if x_min >= x_max or y_min >= y_max:
    print(0)
else:
    print((x_max - x_min) * (y_max - y_min))

Measured memory_bytes: 3064
const main = lines => {
  console.log(solve(lines));
};

const solve = (lines: string[]): string => {
  const [K, X] = parseLines(lines);
  const out = [];
  for (let i = X - K + 1; i < X + K; i++) out.push(i);
  return out.join(' ');
};

const parseLines = (lines: string[]) => {
  const obj = lines[0].split(' ').map(n => Number(n));
  debug(obj);
  return obj;
};

const debug = (message?: any, ...optionalParams: any[]) => {
  if (!!process.env.LOCAL_DEBUG) console.log(message, ...optionalParams);
};

if (!process.env.LOCAL_DEBUG) {
  const { stdin: input, stdout: output } = process;
  input.resume();
  input.setEncoding('utf8');
  const lines = [];
  require('readline')
    .createInterface({ input, output })
    .on('line', line => lines.push(line))
    .on('close', () => main(lines));
}

export default solve;


Measured memory_bytes: 7500
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
t = s.count('1')
u = s.count('0')
print(min(t,u)*2)

Measured memory_bytes: 39152
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
//ここから
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
void solve(){
  int n;
  cin>>n;
  int cnt=0;
  rep(i,n){
    if(i%2)continue;
    vector<long int >v=divisor(long(i)+1);
    if(v.size()==8)++cnt;
  }
  cout<<cnt;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int age = scanner.nextInt();
		
		if (age == 1) {
			System.out.println("Hello World");
		}else if(age == 2) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			System.out.println(a + b);
		}
		scanner.close();

	}

}


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

int size[55];
int cntP[55];

int rec(int N,int X) // [0,X)
{  
   assert(X>0);
   if(X==size[N]) return cntP[N];

   int res=0;
   if(X>=2){
      res+=rec(N-1,min(size[N-1], X-1));
   }
   if(X>=size[N-1]+2){
      res++;
   }
   if(X>=size[N-1]+3){
      res+=rec(N-1,min(size[N-1],X-(size[N-1]+2)));
   }
   return res;
}

signed main()
{
   int N,X; cin>>N>>X;
   size[0]=1;
   cntP[0]=1;
   REP(i,N){
      size[i+1]=size[i]*2+3;
      cntP[i+1]=cntP[i]*2+1;
   }
   cout<<rec(N,X)<<endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main() {
	string s;
	cin >> s;

	int a = 0;
	int z = 0;

	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'A') {
			a = i;
			break;
		}
	}

	for (int i = s.length() - 1; i > -1; i--) {
		if (s[i] == 'Z') {
			z = i;
			break;
		}

	}
	
	cout << z - a + 1 << endl;


	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using static System.Console;

class Program {
    static void Main() {
        var n = NextInt();
        var a = new int[3 * n];
        for (var i = 0; i < 3 * n; i++) {
            a[i] = NextInt();
        }
        Array.Sort(a);
        Array.Reverse(a);

        var ans = 0L;
        for (var i = 0; i < n; i++) {
            ans += a[2 * i + 1];
        }
        WriteLine(ans);
    }

    static int NextInt() {
        return int.Parse(NextString());
    }

    static string NextString() {
        var result = new List<char>();
        while (true) {
            int next = Read();
            if (next < 0)
                break;
            var nextChar = (char)next;
            if (!char.IsWhiteSpace(nextChar))
                result.Add(nextChar);
            else if (nextChar != '\r')
                break;
        }
        return string.Join("", result);
    }
}

Measured memory_bytes: 18316
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, alice, bob int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			alice += a[i]
			continue
		}
		bob += a[i]
	}
	fmt.Println(alice - bob)
}


Measured memory_bytes: 512
#include <iostream>
#include <string>

using namespace std;

int main() {
	string N,K;
	cin >> N;
	
	bool all9 = true;
	for (int i = 1; i < N.length(); ++i) {
		if (N[i] != '9') {
			all9 = false;
		}
	}
	
	cout << (N[0] - '0') + 9 * (N.length() - 1) - (all9 ? 0 : 1);
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

class Main{

	private void solve(){
		int h=gInt(),w=gInt();
		HashMap<Long,Integer>m=new HashMap<>();
		for(int q:rep(gInt())) {
			int a=gInt(),b=gInt();
			for(int A:rep(Math.max(1,a-2),Math.min(h-2,a)))
				for(int B:rep(Math.max(1,b-2),Math.min(w-2,b)))
					m.merge(A*1000000000L+B,1,Integer::sum);
		}
		long[]c=new long[10];
		m.values().stream().forEach(i->++c[i]);
		c[0]=(h-2L)*(w-2)-Arrays.stream(c).sum();
		Arrays.stream(c).forEach(System.out::println);
	}
	public static void main(String[]$){
		new Main().solve();
	}

	Scanner s=new Scanner(System.in);

	int gInt(){
		return Integer.parseInt(s.next());
	}
	long gLong(){
		return Long.parseLong(s.next());
	}
	double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplierIterator<Integer> ints(int n){
		return new SupplierIterator<>(n,this::gInt);
	}
	SupplierIterator<Long> longs(int n){
		return new SupplierIterator<>(n,this::gLong);
	}
	SupplierIterator<Double> doubles(int n){
		return new SupplierIterator<>(n,this::gDouble);
	}
	SupplierIterator<String> strs(int n){
		return new SupplierIterator<>(n,s::next);
	}

	static class SupplierIterator<T> implements Iterable<T>,Iterator<T>{
		int			t;
		Supplier<T>	supplier;

		SupplierIterator(int t,Supplier<T> supplier){
			this.t=t;
			this.supplier=supplier;
		}

		@Override
		public Iterator<T> iterator(){
			return this;
		}

		@Override
		public boolean hasNext(){
			return t>0;
		}

		@Override
		public T next(){
			--t;
			return supplier.get();
		}
	}


	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(f,t,-1);
	}

	static class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{

		int to,cur,d;

		Range(int from,int to,int d){
			this.cur=from-d;
			this.to=to;
			this.d=d;
		}

		Range(int n){
			this(0,n-1,1);
		}

		@Override
		public Iterator<Integer> iterator(){
			return this;
		}

		@Override
		public boolean hasNext(){
			return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
		}

		@Override
		public int nextInt(){
			return cur+=d;
		}

		static Range rep(int i){
			return new Range(i);
		}
		static Range rep(int f,int t,int d){
			return new Range(f,t,d);
		}
		static Range rep(int f,int t){
			return rep(f,t,1);
		}
		static Range rrep(int f,int t){
			return rep(f,t,-1);
		}
	}


	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return REP(n).map(i->gInt());
	}
	Stream<String> STRS(int n){
		return REP(n).mapToObj(i->s.next());
	}
}


Measured memory_bytes: 167152
#include <cstdio>

const int MaxN = 100000 + 5;
const int Mod = 1000000007;

struct Graph {
  int cnte;
  int Head[MaxN], To[MaxN * 2], Next[MaxN * 2];

  inline void addEdge(int from, int to) {
    cnte++; To[cnte] = to;
    Next[cnte] = Head[from]; Head[from] = cnte;
  }
};

int N;
int Dp[MaxN][2];
Graph G;

inline int add(int x, int y) { return (x += y) >= Mod ? x - Mod : x; }
inline int mul(int x, int y) { return 1LL * x * y % Mod; }

void init() {
  scanf("%d", &N);
  for (int i = 1; i < N; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    G.addEdge(u, v);
    G.addEdge(v, u);
  }
}

void dfs(int u, int f) {
  Dp[u][0] = Dp[u][1] = 1;
  for (int i = G.Head[u]; i; i = G.Next[i]) {
    int v = G.To[i];
    if (v == f) continue;
    dfs(v, u);
    Dp[u][0] = mul(Dp[u][0], add(Dp[v][0], Dp[v][1]));
    Dp[u][1] = mul(Dp[u][1], Dp[v][0]);
  }
}

void solve() {
  dfs(1, 0);
  printf("%d\n", add(Dp[1][0], Dp[1][1]));
}

int main() {
  init();
  solve();
  return 0;
}

Measured memory_bytes: 8448
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double d;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    int a,b;
    cin>>a>>b;
    string A,B;
    rep(i,1,a) B+=to_string(b);
    rep(i,1,b) A+=to_string(a);
    cout<<min(A,B)<<'\n';
    return 0;
}


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

vector<vector<int> > A;
void Min(int &a,int b){a=min(a,b);}

bool DP(){
  sort(A.begin(),A.end());
  A.erase(unique(A.begin(),A.end()),A.end());
    
  int n = A.size();
  for(int i=0;i<n;i++)
    for(int j=0,used[10]={};j<A[i].size();j++)if(used[A[i][j]]++) return 1;


  vector<vector<int> >dp(1<<10,vector<int>(1<<10,INF));
  dp[0][0] = 0;

  for(int i=0;i<n;i++){
    for(int j=(1<<10)-1;j>=0;j--)
      for(int k=(1<<10)-1;k>=0;k--){
	if(dp[j][k] == INF||dp[j][k] == 10) continue;
	if((j&&k)&&__builtin_popcount(j&k) == dp[j][k]) return 1;

	for(int l=0,nj=j;l<(int)A[i].size();l++){
	  int num = A[i][l];
	  if(l)Min(dp[nj][k|(1<<num)],dp[j][k]+1);
	  if(j&(1<<num))break;
	  nj |= (1<<num);
	  Min(dp[nj][k],dp[j][k]+1);
	}
      }
  }
  

  for(int i=1;i<(1<<10);i++)
    for(int j=1;j<(1<<10);j++){
      if(__builtin_popcount(i&j) == dp[i][j]) return 1;
    }

  return 0;
}


typedef pair<int,int> P;
bool bfs(){
  sort(A.begin(),A.end());
  A.erase(unique(A.begin(),A.end()),A.end());
    
  int n = A.size();
  for(int i=0;i<n;i++)
    for(int j=0,used[10]={};j<A[i].size();j++)if(used[A[i][j]]++) return 1;
  
  queue<P> Q;
  vector<vector<int> >D(1<<10,vector<int>(1<<10,INF));
  D[0][0] = 0;
  Q.push(P(0,0));

  while(!Q.empty()){
    P t = Q.front();Q.pop();
    int I = t.first,J = t.second;
    if(I&&J&&__builtin_popcount(I&J) == D[I][J]) return 1;
    if(D[I][J]==10) continue;    

    for(int i=0;i<n;i++){
      for(int l=0,ni=I;l<(int)A[i].size();l++){
	int num = A[i][l];
	if(l&&D[ni][J|(1<<num)]==INF){
	  D[ni][J|(1<<num)] = D[I][J]+1;
	  Q.push(P(ni,J|(1<<num)));
	} 
	if(I&(1<<num))break;
	ni |= (1<<num);
	if(D[ni][J]==INF)D[ni][J] = D[I][J] + 1,Q.push(P(ni,J));
      }
    }
  }
  return 0;
}

int main(){
  int n;
  while(cin>>n,n){
    string str;
    cin>>str;
    A.clear();
    for(int i=0;i<str.size();i++){
      A.push_back(vector<int>());
      while(str[i]!='u') A.back().push_back(str[i++]-'0');
    }
    cout<<(bfs()? "UN":"")<<"SAFE"<<endl;
  }
  return 0;
}

Measured memory_bytes: 7732
#include<vector>
#include"iostream"
#include"algorithm"
#include<random>
#include<string>
#include<map>
using namespace std;
#define int long long
typedef pair<int, int> P;
#define REP(i,n) for(int i=0;i<n;i++)
int a[114514], ans[114514];
map<int, int>M;
signed main() {
	int n; cin >> n;
	REP(i, n) cin >> a[i];

	vector<P>v;
	REP(i, n) {
		v.push_back(P(a[i], -1*i));
	}
	v.push_back(P(0, 0));
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	int cnt = 0;
	REP(i, v.size() - 1) {
		cnt++;
		if (v[i].first != v[i + 1].first)M[v[i].first] = cnt;
	}

	int mf = -v[0].second;
	REP(i, v.size() - 1) {
		int F = v[i].first, S = -v[i].second;
		mf = min(mf, S);
		ans[mf] += (F - v[i + 1].first)*M[F];
		//cout << F << ' ' << S << endl;
	}
	REP(i, n)cout << ans[i] << endl;
}

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

int main() {
  int a, n, m;
  scanf("%d", &a);
  vector< Pi > datas;
  for(int i = 0; i < a; i++) {
    int H1, H2, M1, M2;
    scanf("%d:%d-%d:%d", &H1, &M1, &H2, &M2);
    datas.push_back(make_pair(H1 * 60 + M1, H2 * 60 + M2));
  }
  scanf("%d", &n);
  vector< vector< Pi > > teacher(n);
  for(int i = 0; i < n; i++) {
    int k;
    scanf("%d", &k);
    while(k--){
      int H1, H2, M1, M2;
      scanf("%d:%d-%d:%d", &H1, &M1, &H2, &M2);
      teacher[i].push_back(make_pair(H1 * 60 + M1, H2 * 60 + M2));
    }
  }
  scanf("%d", &m);
  vector< vector< Pi > > student(m);
  for(int i = 0; i < m; i++) {
    int k;
    scanf("%d", &k);
    while(k--){
      int H1, H2, M1, M2;
      scanf("%d:%d-%d:%d", &H1, &M1, &H2, &M2);
      student[i].push_back(make_pair(H1 * 60 + M1, H2 * 60 + M2));
    }
  }

  int ret = 0;
  for(int i = 0; i < a; i++) {
    int t = 0, s = 0;
    for(int j = 0; j < n; j++) {
      for(int k = 0; k < teacher[j].size(); k++){
        if(teacher[j][k].first <= datas[i].first && datas[i].second <= teacher[j][k].second) {
          ++t;
          break;
        }
      }
    }
    for(int j = 0; j < m; j++) {
      for(int k = 0; k < student[j].size(); k++){
        if(student[j][k].first <= datas[i].first && datas[i].second <= student[j][k].second) {
          ++s;
          break;
        }
      }
    }
    ret += min(t, s);
  }
  printf("%d\n", ret);
}

Measured memory_bytes: 1372