akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <iterator>

template<typename T>
std::ostream & operator<<(std::ostream & os, std::vector<T> vec)
{
    os<<"{ ";
    std::copy(vec.begin(), vec.end(), std::ostream_iterator<T>(os, " "));
    os<<"}";
    return os;
}

std::vector <int> get_digits(int num){
    std::set <int> digits;
    while(num){
        digits.insert(num % 10);
        num /= 10;
    }
    return std::vector<int>(digits.begin(), digits.end());
}

int construct(int payable_amount, const std::vector <int> &allowable_digits){
    int answer = -1;
    for(int i = payable_amount ; ; ++i){
        std::vector <int> digits = get_digits(i);
        //std::cout << i << " " << digits << '\n';
        if(std::includes(allowable_digits.begin(), allowable_digits.end(), digits.begin(), digits.end())){
            answer = i;
            break;
        }
    }
    return answer;
}

int main(int argc, char const *argv[])
{
    int N,K;
    std::cin >> N >> K;
    
    std::vector <int> allowable_digits;
    allowable_digits.reserve(10 - K);
    
    int start = 0;

    for(int i = 0 ; i < K ; ++i){
        int disliked_digit;
        std::cin >> disliked_digit;
        for(int j = start ; j < disliked_digit ; ++j){
            allowable_digits.emplace_back(j);
        }
        start = disliked_digit + 1;
    }
    
    for(int i = start ; i < 10 ; ++i){
        allowable_digits.emplace_back(i);
    }

    // "allowable_digits" is already sorted as the disallowable digits were given in sorted order
    std::cout << construct(N, allowable_digits) << '\n';

    return 0;
}


Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class B {
    static void Main(string[] args) {
        var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int A = st[0];
        int B = st[1];

        string ans = "";

        if (A < B) {
            for (int i = 0; i < B; i++) {
                ans += A.ToString();
            }
        } else {
            for (int i = 0; i < A; i++) {
                ans += B.ToString();
            }
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13268
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.equals("SUN")){
            System.out.println(7);
        }else if(s.equals("MON")){
            System.out.println(6);
        }else if(s.equals("TUE")){
            System.out.println(5);
        }else if(s.equals("WED")){
            System.out.println(4);
        }else if(s.equals("THU")){
            System.out.println(3);
        }else if(s.equals("FRI")){
            System.out.println(2);
        }else if(s.equals("SAT")){
            System.out.println(1);
        }
        System.out.println();
        sc.close();
    }
}

Measured memory_bytes: 20948
n,k = map(int,input().split())
p = list(map(int,input().split()))
p = list(map(lambda x:x+1, p))
num = sum(p[:k])
ans = num
for i in range(k,n):
    num = num + p[i] - p[i-k]
    ans = max(num,ans)
print(ans/2)


Measured memory_bytes: 25060
import math


def isMM(num):
    if num < 13 and num > 0:
        return True
    else:
        return False


def hantei(number):
    num = math.floor(number/100)
    ber = number % 100
    if isMM(num) is False and isMM(ber) is False:
        return "NA"
    elif isMM(num) is True and isMM(ber) is True:
        return "AMBIGUOUS"
    elif isMM(num) is True and isMM(ber) is False:
        return "MMYY"
    else:
        return "YYMM"


num = int(input())
print(hantei(num))


Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9+5
#define ll long long
int cal1(vector<int> wt,vector<int> v,int W,int n)
{
    if(n==0 || W<=0 )
        return 0;
    int inc = 0;
    int exc = 0;

    // included
    if(wt[n-1]>W)
        return cal1(wt,v,W,n-1);

    inc = cal1(wt,v,W-wt[n-1],n-1)+v[n-1];

    //excluded
    exc = cal1(wt,v,W,n-1);

    return max(inc,exc);
}
void max_s(ll &a,ll b)
{
    a = max(a,b);
}
void cal(vector<int> wt,vector<int> v,ll W,int n)
{
    vector<ll> dp(W+1,0);
    for(int i=0 ; i<n ; i++)
    {
        for(ll wt_a=W-wt[i] ; wt_a>=0 ; wt_a--)
        {
            max_s(dp[wt_a + wt[i]],dp[wt_a] + v[i]);
     //       for(auto i:dp)  cout<<i<<" "; cout<<endl;
        }

//        for(auto i:dp)  cout<<i<<" "; cout<<endl;
    }
cout<<dp[W];
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n,W;    cin>>n>>W;
    vector<int> wt(n),v(n),dp(W+1,0);       //dp[i] what is the max val i can get by using wt = i;

    for(int i=0 ; i<n ; i++)        cin>>wt[i]>>v[i];

    cal(wt,v,W,n);
}


Measured memory_bytes: 1408
n = int(input())
h = list(map(int,input().split()))
cnt = 0
ans = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        cnt += 1
    else:
        ans = max(cnt,ans)
        cnt = 0
    ans = max(cnt,ans)
print(ans)

Measured memory_bytes: 14224
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

#define ll long long int
#define ull unsigned long long int

#define INF 100000000000L

using namespace std;

int main(){
    ll N,K;
    string S;
    cin >> N >> K;
    cin >> S;
    vector<int> z,o;
    int pos = 0;
    while(1){
        int count = 0;
        while(S[pos] == '0'){
            count++;
            pos++;
            if(pos == N) break;
        }
        if(count != 0){
            z.push_back(count);
        }
        if(pos == N) break;
        count = 0;
        while(S[pos] == '1'){
            count++;
            pos++;
            if(pos == N) break;
        }
        if(count != 0){
            o.push_back(count);
        }
        if(pos == N) break;
    }
    if(z.size() <= K){
        cout << N << endl;
        return 0;
    }
    // for(int i = 0; i< o.size();i++){
    //     cout << o[i] << " ";
    // }
    // cout << endl;
    // for(int i = 0; i< z.size();i++){
    //     cout << z[i] << " ";
    // }
    //cout << endl;
    ll max_sum = 0;
    if(S[0] == '0'){
        for(int i=0;i<K;i++){
            max_sum += z[i] + o[i];
        }
        int limit = min(o.size(),z.size()-1);
        for(int i=0;i<limit-K+1;i++){
            ll sum = 0;
            for(int j= 0;j < K;j++){
                sum += z[i+j+1] + o[i+j];
            }
            if(i+K <=o.size()-1){
                sum += o[i+K];
            }
            max_sum = max(sum,max_sum);
        }
        cout << max_sum << endl;
        return 0;
    }
    if(S[0] == '1'){
        for(int i=0;i<K;i++){
            max_sum += z[i] + o[i];
        }
        max_sum += o[K];
        int limit = min(o.size(),z.size());
        for(int i=0;i<limit-K+1;i++){
            ll sum = 0;
            for(int j= 0;j < K;j++){
                sum += z[i+j] + o[i+j];
            }
            if(i+K <=o.size()-1){
                sum += o[i+K];
            }
            max_sum = max(sum,max_sum);
        }
        cout << max_sum << endl;
        return 0;
    }


}

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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
    stin(s);
    ll t=0;
    ll k=0;
    ll c=-1;
    FOR(i,0,s.sz-1){
        if(s[i]=='>'){
            c++;
            k+=c;
            if(c>=t) k++;
        }
        if(s[i]=='<'){
            if(c>=0) t=0;
            t++;
            c=-1;
            k+=t;
        }
    }
    sal(k);
}


Measured memory_bytes: 900
from collections import Counter

n = int(input())
al = list(map(int, input().split()))

c_al = Counter(al)

if n % 2 == 0:
    for k,v in c_al.items():
        if v != 2:
            print(0)
            exit()
    print(pow(2, n // 2, 10 ** 9 + 7))

elif n % 2 != 0:
    for k, v in c_al.items():
        if k == 0:
            if v != 1:
                print(0)
                exit()
        elif v != 2:
            print(0)
            exit()
    print(pow(2, n // 2, 10 ** 9 + 7))

Measured memory_bytes: 20624
#include <iostream>
#include <string>
#include <math.h>
#include <cmath>
#include <string.h>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#define INF 1000000000
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
#define sove(v) sort((v).begin(),(v).end());
typedef long long int ll;
using namespace std;
int main(){

	int n, k; cin >> n >> k;
	int i,ans = 0;
	for (i = 1; ; i *= k) {
		if (n < i) { break; }
		ans++;
	}
	cout << ans << endl;

	return 0;
}

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

ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }else{
        return gcd(b,a%b);
    }
}

ll lcm(ll a,ll b){
    ll d=gcd(a,b);
    return a/d*b;
}

int main(){
    ll A,B; cin>>A>>B;

    cout<<lcm(A,B)<<endl;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;
int main(){
	int a,b;
	cin>>a>>b;
	cout<<(a-1)*(b-1)<<endl;
}

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

int main(){
  int n, xa ,j;

  int ans = 1000000000;
  cin >> n;
  rep(i, n){
    cin >> xa;
    j = 0;
    while(xa%2==0){
      xa /= 2;
      j++;
    }
    ans = min(ans, j);
  }

  cout << ans << endl;




}


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

int main()
{
    int i,cnt=0;
    string s,t;
    cin>>s>>t;
    for(i=0;i<s.length();i++)
    {
        if(s[i]!=t[i])
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;


    return 0;
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

int a[N], ans[N];
vector<int> g[N];

int d[N], last = 1;

void dfs(int v, int p) {
  int old_last = last;
  int pos = lower_bound(d, d + last, a[v]) - d;
  int old_v = d[pos];
  int old_pos = pos;
  d[pos] = min(d[pos], a[v]);
  last += pos + 1 == last;
  ans[v] = last - 1;
  for (int u : g[v]) {
    if (u != p) {
      dfs(u, v);
    }
  }
  d[old_pos] = old_v;
  last = old_last;
}

void solve(int) {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    d[i] = inf;
  }
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(0, 0);
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << '\n';
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}




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

int main(){
	int h,w;
	cin >> h >> w;
	char g[105][105];
	rep(i,h) rep(j,w) cin >> g[i][j];
	
	rep(i,h){
		rep(j,w){
			if(g[i][j] == '.'){
				bool exist = false;
				rep(k,h){
					if(g[k][j] == '#') exist = true;
				}
				if(!exist){
					rep(k,h){
						g[k][j] = '0';
					}
				}
				exist = false;
				rep(k,w){
					if(g[i][k] == '#') exist = true;
				}
				if(!exist){
					rep(k,w){
						g[i][k] = '0';
					}
				}
			}
		}
	}
	rep(i,h){
		bool flag = false;
		rep(j,w){
			if(g[i][j] == '0') continue;
			flag = true;
			cout << g[i][j];
		}
		if(flag){
			cout << endl;
		}
	}
    return 0;
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {
//			int a = Integer.parseInt(sc.next());
//			List<Integer> list = new ArrayList<>();
//			for (int i = 0; i < a; i++) {
//				list.add(Integer.parseInt(sc.next()));
//			}
//			Collections.sort(list, Collections.reverseOrder());
//
//			long lcm = lcm(list.get(0), list.get(1));
//			for (int i = 1; i < a - 1; i++) {
//				lcm = lcm(lcm, list.get(i + 1));
//			}
//
//			lcm -= 1;
//			long all = 0;
//
//			for (int i = 0; i < a; i++) {
//				all += lcm % list.get(i);
//			}
//			System.out.println(all);
			
			int a = Integer.parseInt(sc.next());
			int all = 0;
			for (int i = 0; i < a; i++) {
				all += Integer.parseInt(sc.next());
			}
			System.out.println(all -a);
		}

	}

	static long gcd(long m, long n) {
		if (m < n)
			return gcd(n, m);
		if (n == 0)
			return m;
		return gcd(n, m % n);
	}

	static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

pii pp[MAXN];

set<pair<pii, int> > st[2];

pair<pii, int> get_pair(int ind, int type){
	if (type == 1){
		return mp(mp(-pp[ind]._1, pp[ind]._2), ind);
	} else {
		return mp(mp(pp[ind]._2, pp[ind]._1), ind);
	}
}

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, n){
		scanf("%d%d", &pp[i]._1, &pp[i]._2);
	}
	ll ans = 0ll;
	REP(k, 0, 2){
		REP(j, 0, 2){
			st[j].clear();
		}
		REP(i, 0, n){
			REP(j, 0, 2){
				st[j].insert(get_pair(i, j));
			}
		}
		ll cur = 0;
		int x = 0;
		for(int cnt = k; cnt < n + k; cnt++){
			int ind = st[cnt & 1].begin()->_2;
			if (x < pp[ind]._1){
				cur += pp[ind]._1 - x;
				x = pp[ind]._1;
			} else if (x > pp[ind]._2){
				cur += x - pp[ind]._2;
				x = pp[ind]._2;
			}
			REP(j, 0, 2){
				st[j].erase(get_pair(ind, j));
			}
		}
		cur += abs(x);
		ans = max(ans, cur);
	}
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 13568
<?php
  const DIRS = "RDLU";
  $h[] = "000000";
  $v[] = "0000000";
  for($i=0;$i<4;$i++) {
      $h[] = "0".trim(fgets(STDIN))."0";
      $v[] = "0".trim(fgets(STDIN))."0";
  }
  $h[] = "0".trim(fgets(STDIN))."0";
  $v[] = $v[0];
  $h[] = $h[0];

  $x = 2; $y = 1; $dir = 0;
  $stepx =  array(1,0,-1,0);
  $stepy = array(0,1,0,-1);

 echo 'R';
  while(!($x==1 && $y==1)) {
    for($i=0;$i<4;$i++) {
      $d = ($dir+$i)%4;
      $d2 = ($d+3)%4;
      if(($d==0 && $v[$y-1][$x]) || ($d==1 && $h[$y][$x])
        || ($d==2 && $v[$y][$x]) || ($d==3 && $h[$y][$x-1])) {
        $x += $stepx[$d2];
        $y += $stepy[$d2];
        $dir = $d2;
        break;
      }
    }
    echo DIRS[$dir];
  }
  echo PHP_EOL;

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<ll>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el printf("\n")
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);

int main()
{
	IOS;
    cout.precision(30);
    string s,t; cin >> s >> t;
    cout << (s[0]==t[0])+(s[1]==t[1])+(s[2]==t[2]);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define White 0
#define Gray 1
#define Black 2
#define N 100

int n,a[N][N];
int color[N],d[N],f[N];//d,fはdiscoverとfinish
int count;//深さをカウント
void dfs();
void dfs_visit(int);

int main(){
  int i,j;
  int x,y,z;


  scanf("%d",&n);

  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      a[i][j]=0;
    }
  }
  
  
  for(i=0; i<n; i++){
    scanf("%d %d",&x,&z);
    x--;
    for(j=0; j<z; j++){//zはx個ある隣接する頂点の個数
      scanf("%d",&y);
      y--;
      a[x][y]=1;
    }
  }

    dfs();
    return 0;
}

void dfs(){//初期化
  int x;
  for(x=0; x<n; x++){
    color[x]=White;
  }
  count=0;

  for(x=0; x<n; x++){
    if(color[x]==White) dfs_visit(x);//未探索のとき探索を行う
  }

  for(x=0; x<n; x++){
    printf("%d %d %d\n",x+1,d[x],f[x]);//x+1なのはforが0からはじまってるから
  }
}

void dfs_visit(int x){
  int y;
  color[x]=Gray;
  d[x]=++count;//先にd[x]にcountの値を入れてからインクリメント
  for(y=0; y<n; y++){
    if(a[x][y]==0) continue;//Whiteならループを中断して始めから
    if(color[y]==White){//最初にすべてのcolorがWhiteで初期化されてる。もしWhiteの場合、再帰する
      dfs_visit(y);//未探索なら再帰する
    }
  }
  color[x]=Black;
  f[x]=++count;
}



Measured memory_bytes: 2048
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int change=0;
  int amount=1000;
  if(n<=amount){
    change = amount-n;
  }
  else{
    while(amount < n){
      amount = amount+1000;
    }
    change = amount - n;
  }
  cout << change << endl;
  return 0;
}

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

void printheap(int);

int arr[300];
int n,cnt=1;

int main(int argc,char* argv[]){
  int x;
  
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>arr[i];

  printheap(0);
  return 0;
}

void printheap(int p){
  if(p!=n){
    double x= (static_cast<double>(p)-1)/2;
  
    printf("node %d: key = %d, ",cnt++,arr[p]);

    if(x >= 0)
      printf("parent key = %d, ",arr[static_cast<int>(x)]);

    if(p*2+1 < n)
      printf("left key = %d, ",arr[p*2+1]);

    if(p*2+2 < n)
      printf("right key = %d, ",arr[p*2+2]);

    printf("\n");

    printheap(p+1);
  }
}

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

int main() {
  long long N;
  cin >> N;
  long long cnt = 0;
  for(int i = 1; i < N; i++) {
    long long ans = 1;
    long long a = i;
    for (int i = 2; i <= sqrt(a); i++) {
    int cnt = 0;
    while (a % i == 0) {
      cnt++;
      a /= i;
    }
    ans *= (cnt + 1);
    if (a == 1) break;
  }
  if (a != 1) ans *= 2;

  cnt += ans;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3672
import java.util.Scanner;
 
 
public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

	while(true){

        int n = sc.nextInt();
	int i = 0;
	int[] test = new int[n];
	double[] hen = new double[n];
	double sum = 0;
	double sum2 = 0;
	double ave = 0;
	double ave2 = 0;

	if(n==0){
		break;
	}

	for(i=0; i<n; i++){
		test[i] = sc.nextInt();
	}

	for(i=0; i<n; i++){
		sum += test[i];
	}

		ave = sum / test.length;

	for(i=0; i<n; i++){
		hen[i] = (test[i] - ave)*(test[i] - ave);
		sum2 += hen[i];
	}	
		ave2 = sum2 / test.length;

		System.out.print(String.format("%.8f", Math.sqrt(ave2)));
		System.out.print("\n");
	}
    }
}


Measured memory_bytes: 31584
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    int sm = 0;
    rep(i, n) {
        int l, r;
        cin >> l >> r;
        sm += r - l + 1;
    }
    cout << sm << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

using namespace std;
#include <stdio.h>

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/


void solve(){
  int test;
  //cin>>test;
  test=1;
  while(test--){
        int n;
        cin>>n;
        
        bool flag=false;
        unordered_map<int,int> st;
        
        forn(i,0,n){
            int x;
            cin>>x;
            st[x]++;
            if(st[x]>1)
            flag=true;
        }
        if(flag)
        cout<<"NO";
        else
        cout<<"YES";
  }         
}    

    




///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}





Measured memory_bytes: 8520
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void minAssign(T)(ref T dst, T src)
{
    dst = min(dst, src);
}

alias sread = () => readln.chomp();

void main()
{
    long N = lread();

    auto dp = new long[](N + 1);
    dp[] = long.max;
    dp[0] = 0;

    foreach (i; 0 .. N)
        if (dp[i] != long.max)
        {
            dp[i + 1].minAssign(dp[i] + 1);

            size_t j = 6;
            while (i + j < dp.length)
            {
                dp[i + j].minAssign(dp[i] + 1);
                j *= 6;
            }

            j = 9;
            while (i + j < dp.length)
            {
                dp[i + j].minAssign(dp[i] + 1);
                j *= 9;
            }
        }

    dp[N].writeln();
}


Measured memory_bytes: 2556
import java.util.*;
	import java.io.*;

	public class Main {
		static int n,m,mod=(int)1e9+7;
		static ArrayList<ArrayList<Integer>> g;
		static int l1,l2,color[];
		static char mat[][];
		static boolean cj;
		static long dp[][];
		public static void main(String[] args) throws IOException{
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			int t=1;
	//		Integer.parseInt(br.readLine().trim());
			StringBuilder printans=new StringBuilder();
			while(t-->0)
			{
				StringTokenizer tok=new StringTokenizer(br.readLine()," ");
				n=Integer.parseInt(tok.nextToken());
				m=Integer.parseInt(tok.nextToken());
				mat=new char[n][m];
				for(int i=0;i<n;i++) {
					String ccc=br.readLine().trim();
					
					for(int j=0;j<m;j++) {
						mat[i][j]=ccc.charAt(j);
						
					}
				
					
				}
				dp=new long[n+1][m+1];
				memset();
				System.out.println(dfs(0,0));
				
				
			}
			
			
		}
		static long  dfs(int i,int j) {
			if(i==n-1 && j==m-1) {
				
				return 1;
			}
			if(i>=n || j>=m) {
				return 0;
				
			}
			long ans=0;
			if(dp[i][j]!=-1)return dp[i][j];
			if(i<n-1 && mat[i+1][j]!='#') {
				ans+=dfs(i+1,j)%mod;
			}
			if(j<m-1 && mat[i][j+1]!='#') {
				ans+=dfs(i,j+1)%mod;
			}
			dp[i][j]=ans%mod;
			return ans%mod;
		}
		
		static void memset() {
			for(long a[]:dp) {
				Arrays.fill(a,-1);
			}
		}
		
			
	}


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

int main()
{
    map<string, int>freq;
    int n;
    string val;
    cin >> n;

    for (int i = 0;i < n;i++) {
        cin >> val;
        freq[val] += 1;
    }

    cout << "AC x " << freq["AC"]<<endl;
    cout << "WA x " << freq["WA"]<<endl;
    cout << "TLE x " << freq["TLE"]<<endl;
    cout << "RE x " << freq["RE"]<<endl;
    return 0;
}


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

int main()
{
    int k,a,b;
    cin>>k>>a>>b;
    int p=a/k;
    int q=b/k;
    if(a%k==0||b%k==0||q>p) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3596
import sys
def input(): return sys.stdin.readline().rstrip()

N = int(input())
A = list(map(int, input().split()))

A_max = max(A)
prime = [[] for _ in range(A_max + 1)]
for i in range(2,A_max + 1):
    if prime[i] == []:
        n = i
        while n <= A_max:
            prime[n].append(i)
            n += i

li = [0] * (A_max + 1)
for a in A:
    for p in prime[a]:
        li[p] += 1


if max(li) <= 1:
    print('pairwise coprime')
elif max(li) == N:
    print('not coprime')
else:
    print('setwise coprime')

Measured memory_bytes: 276324
#include <iostream>
using namespace std;
int main(){
    long long a[10005];
    int N,ans=0;
    cin >>N;
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    for(int j=0;j<N;j++){
        for(int k=0;k<50;k++){
            if(a[j]%2==0){
                ans++;
                a[j]=a[j]/2;
            }
        }
    }
        cout<< ans << endl;
}


Measured memory_bytes: 384
import * as fs from 'fs'
function main(input: string) {
  const lines = input.trim().split('\n')

  const [n] = (lines.shift() || '0').split(' ').map(Number)
  const m: { [k: string]: number } = {}
  lines.forEach(line => {
    const k = line
      .split('')
      .sort()
      .join('')
    m[k] = (m[k] || 0) + 1
  })
  const res = values(m)
    .map(comb2)
    .reduce((p, c) => p + c, 0)
  // console.log(m)
  console.log(res)

  // console.log({ a, b, c })
}
const comb2 = v => {
  if (v === 1) {
    return 0
  }
  return (v * (v - 1)) / 2
}

const values = (obj: Object) => Object.keys(obj).map(e => obj[e])

const path = process.argv[2]
if (!path) {
  main(fs.readFileSync('/dev/stdin', 'utf8'))
} else {
  const testPath = `${path}/tests`
  const files = fs.readdirSync(testPath)
  const qn = files.length / 2
  for (let i = 1; i <= qn; i++) {
    console.log(`${testPath}/sample-${i}.in`)
    console.log('-- res')
    main(fs.readFileSync(`${testPath}/sample-${i}.in`, 'utf8'))
    console.log('-- expected')
    console.log(fs.readFileSync(`${testPath}/sample-${i}.out`, 'utf8'))
  }
}


Measured memory_bytes: 44864
N = int(input())

TARGET = 1000000000000001
MAGIC_NUMBER = 1000

tab_pow = [0]
tmp = 0
for i in range(1, MAGIC_NUMBER + 1):
    if tab_pow[-1] >= TARGET: break
    tmp += 26 ** i
    tab_pow.append(tmp)


for n_dog in range(1, MAGIC_NUMBER + 1):
    if tab_pow[n_dog] > N - 1: break

# print("#", tab_pow, n_dog)

ans = []
N = N - 1 - tab_pow[n_dog - 1]
step = 26 ** (n_dog - 1)
for i in range(n_dog):
    # print("#", ans, N)
    for j in range(26):
        if N < step:
            break
        else:
            N -= step
    #
    ans.append(chr(ord('a') + j))
    step /= 26
        
ans = ''.join(ans)
print(ans)

Measured memory_bytes: 9216
S=input()
c=[0]*(len(S) + 1)
for i in range(len(S)):
    if S[i]=="<":
        c[i+1]=c[i]+1

for j in range(len(S)-1,-1,-1):
    if S[j]==">":
        c[j] = max(c[j], c[j+1]+1) 
print(sum(c))


Measured memory_bytes: 23336
N=int(input())
A=list(map(int, input().split()))

def gcd_list(L):
    b=min(L)
    for i in L:
        while True:
            if i%b==0:
                break
            c=b
            b=i%b
            i=c
    return(b)

print(gcd_list(A))

Measured memory_bytes: 14252
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long q = sc.nextInt();
		long h = sc.nextInt();
		long s = sc.nextInt();
		long d = sc.nextInt();
		long n = sc.nextInt();
		long ans = 0;
		if (q * 2 < h) {
			if (q * 4 < s) {
				if (q * 8 < d) {
					ans = n * 4 * q;
				} else {
					if (n % 2 == 0) {
						ans = n / 2 * d;
					} else {
						ans = n / 2 * d + 4 * q;
					}
				}
			} else {
				if (s * 2 < d) {
					ans = n * s;
				} else {
					if (n % 2 == 0) {
						ans = n / 2 * d;
					} else {
						ans = n / 2 * d + s;
					}
				}
			}
		} else {
			if (h * 2 < s) {
				if (h * 4 < d) {
					ans = n * 2 * h;
				} else {
					if (n % 2 == 0) {
						ans = n / 2 * d;
					} else {
						ans = n / 2 * d + 2 * h;
					}
				}
			} else {
				if (s * 2 < d) {
					ans = n * s;
				} else {
					if (n % 2 == 0) {
						ans = n / 2 * d;
					} else {
						ans = n / 2 * d + s;
					}
				}
			}
		}
		System.out.print(ans);
	}
			
}


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

using namespace std;

int getScore[100000];

void hawawa()
{
	int h, w;
	cin >> h >> w;
	vector<vector<int> > ans(h, vector<int>(w));
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto&& i : a) {
		cin >> i;
	}
	int nowx = 0, nowy = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < a[i]; j++) {
			ans[nowx][nowy] = i + 1;
			if (nowx % 2) {
				nowy--;
				if (nowy < 0) {
					nowy = 0;
					nowx++;
				}
			}
			else {
				nowy++;
				if (nowy == w) {
					nowy = w - 1;
					nowx++;
				}
			}
		}
	}
	for (auto&& i : ans) {
		cout << i[0];
		for (int j = 1; j < i.size(); j++) {
			cout << " " << i[j];
		}
		cout << "\n";
	}
}

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main(){
    ios::sync_with_stdio(false);
    ll a,b,c,k; cin >> a >> b >> c >> k;
    if(k==a+b+c) cout << a-c << endl;
    else if((a+b<k)&&(k<=a+b+c)) cout << 2*a+b-k << endl;
    else if((a<=k)&&(k<=a+b)) cout << a << endl;
    else if(k<=a) cout << k << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <stdio.h>       // printf,scanf
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>  //sort,binarySearch
#include <functional> 
#include <iomanip> // setprecision
#include <utility>    // c+11 Array
#include <set>
#include <sstream>
#include <bits/stdc++.h>
#define PI 3.141592653589793238462643383279
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define pb(x) push_back(x)
#define debug(x) cout << #x << " = " << x << endl;
#define debret(x) debug(x) ; return 0;

using namespace std;

int main(void){

    int N;
    int L;

    cin >> N >> L;

    string array[N];

    REP(i,N) cin >> array[i];

    sort(array,array+N);
    
    REP(i,N) cout << array[i];
    cout << endl;
    
    return 0;
}


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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)4e6 + 9;
bitset<N> can;

int main(){
  fastIO;
  int n;
  cin >> n;
  int a;
  int s = 0;
  can[0]=1;
  for(int i = 0 ; i < n ; i ++ ){
    cin >> a;
    s += a;
    can = can | (can << a);
  }
  for(int j = (s+1)/2; j < N ; j ++ ){
    if(can[j]){
      cout << j;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 2176
from collections import Counter
S = list(input())
S.reverse()
L = len(S)
dp = [0] * (L+1)
tmp = 0
for i in range(L):
    tmp += int(S[i]) * pow(10, i, 2019)
    tmp %= 2019
    dp[i] = tmp

c = Counter(dp)
ans = 0
for i, v in c.items():
    ans += v * (v-1) // 2

print(ans)


Measured memory_bytes: 18176
import math
h, w = list(map(int, input().split()))
o = ''
f = w + 2
o = o + (f*'#'+'\n')
for i in range(h):
    v = input()
    vl = len(v)
    a = math.floor((f - vl) / 2)
    o = o + ((a*'#')+v+(a*'#')+'\n')
o = o + (f*'#')
print(o)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int INF=pow(2,31)-1;
const int MAXN=1<<17;
int maxn;
int dat[2*MAXN-1];

void init(int n) {
  maxn=1;
  while (maxn<n) {
    maxn*=2;
  }
  fill(dat,dat+2*maxn-1,INF);
}
void update(int i,int x) {
  i+=maxn-1;
  dat[i]=x;
  while (i>0) {
    i=(i-1)/2;
    dat[i]=min(dat[2*i+1],dat[2*i+2]);
  }
}
int find(int x,int y,int k=0,int l=0,int r=maxn) {
  if (r<=x || y<=l) {
    return INF;
  }
  if (x<=l && r<=y) {
    return dat[k];
  } else {
    int vl=find(x,y,2*k+1,l,(l+r)/2);
    int vr=find(x,y,2*k+2,(l+r)/2,r);
    return min(vl,vr);
  }
}
int main() {
  int n, q;
  cin >> n >> q;
  init(n);
  for (int i=0; i<q; i++) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com==0) {
      update(x,y);
    } else {
      printf("%d\n",find(x,y+1));
    }
  }
  return 0;
}

Measured memory_bytes: 4196
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B, C] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    print max(0, C - (A - B))

if __name__ == '__main__':
    main()


Measured memory_bytes: 2932
import itertools

N = int(input())
XY = []
for i in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))

fact = [1] * (N + 1)
for i in range(1, N + 1):
    fact[i] = fact[i-1] * i


def L2norm(i, j):
    X = XY[i][0] - XY[j][0]
    Y = XY[i][1] - XY[j][1]
    return (X**2 + Y**2) ** (1/2)


dist = [[0] * N for i in range(N)]
for i in range(N):
    for j in range(i, N):
        r = L2norm(i, j)
        dist[i][j] = r
        dist[j][i] = r

ans = 0
stock = 0
for perm in itertools.permutations(range(N), N):
    cur = 0
    for i in range(N-1):
        cur += dist[perm[i]][perm[i+1]]
    ans += cur
print(ans/fact[N])

Measured memory_bytes: 41324
/* ****devACE**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005
int dp[N];
int h[N];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		int n,k,i,j;
		cin>>n>>k;

		for(i=0;i<n;i++)cin>>h[i];
		for(i=0;i<N;i++)dp[i]=hell;

		dp[0]=0;
		for(i=0;i<n;i++)
		{
			for(j=i+1;j<=min(i+k,n);j++)
			{
				dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
			}
		}

		cout<<dp[n-1];
	}
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main() {
	int S, FH, SH;
	scanf("%d", &S);
	FH = S / 100;
	SH = S % 100;
	if (FH < 13 && SH < 13 && FH > 0 && SH > 0) {
		printf("AMBIGUOUS\n");
	}
	else if (0 < FH && FH< 13) {
		printf("MMYY\n");
	}
	else if (0 < SH && SH<13) {
		printf("YYMM\n");
	}
	else {
		printf("NA\n");
	}
	return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

	static BufferedReader reader;
	final static boolean MODE_DEBUG = false;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		int[] NM = readLineInt();
		int A = NM[0];
		int B = NM[1];
		int C = NM[2];
		int D = NM[3];
		
		int Tatk = (C+B-1)/B;
		int Aatk = (A+D-1)/D;
		
		print(Tatk<=Aatk?"Yes":"No");
	}
	
	//functions here
	//note that all methods should be STATIC


	private static <T> int arraySearch(T needle, T[] heystack) {
		for(int i=0;i<heystack.length;i++) {
			if(needle.equals(heystack[i])) {
				return i;
			}
		}
		return -1;
	}
	private static int[] sort(int[] base) {
		int[] copy = array_copy(base);
		Arrays.sort(copy);
		return copy;
	}
	private static int[] array_copy(int[] base) {
		int[] copy = new int[base.length];
		for(int i=0;i<base.length;i++) {
			copy[i] = base[i];
		}
		return copy;
	}
	private static int[] asArray(ArrayList<Integer> ints) {
		int[] intlist = new int[ints.size()];
		for(int i=0;i<intlist.length;i++) {
			intlist[i] = ints.get(i);
		}
		return intlist;
	}
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static int[] readLineInt(){
		try{
			String[] s = readLine();
			int[] ints = new int[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Integer.parseInt(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static byte[] readLineByte(){
		try{
			String[] s = readLine();
			byte[] bytes = new byte[s.length];
			for(int i=0;i<bytes.length;i++) {
				bytes[i] = Byte.parseByte(s[i]);
			}
			return bytes;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static char[] readLineChar(){
		try{
			String[] s = readLine();
			char[] chars = new char[s.length];
			for(int i=0;i<chars.length;i++) {
				chars[i] = (char)Integer.parseInt(s[i]);
			}
			return chars;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
	private static void printd(Object o){
		if(MODE_DEBUG)System.err.println(o);
	}
	private static void printd(){
		if(MODE_DEBUG)System.err.println();
	}
}


Measured memory_bytes: 32676
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long lolong;

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

const int maxn = 2020, mod = 924844033;

bool real[maxn << 1];
int f[maxn << 1][maxn];
lolong fac[maxn];

int main() {
	int n = input(), k = input();

	int p = 0;
	for(int i = 1; i <= k; i ++)
		for(int t = 0; t < 2; t ++)
			for(int j = i; j <= n; j += k)
				real[++ p] = j > i;

	/* for(int i = 1; i <= n * 2; i ++) */
	/* 	debug(" %d", real[i]); */
	/* debug("\n"); */

	f[0][0] = 1;
	for(int i = 1; i <= p; i ++) {
		for(int j = 0; j <= n; j ++)
			f[i][j] = f[i - 1][j];
		if(real[i])
			for(int j = 1; j <= n; j ++)
				(f[i][j] += f[i - 2][j - 1]) %= mod;
	}

	/* for(int i = 0; i <= n; i ++) */
	/* 	debug(" %d", f[n << 1][i]); */
	/* debug("\n"); */

	fac[0] = 1;
	for(int i = 1; i <= n; i ++)
		fac[i] = fac[i - 1] * i % mod;

	lolong ans = 0;
	for(int i = 0; i <= n; i ++)
		ans += fac[n - i] * f[n << 1][i] % mod * ((i & 1) ? -1 : 1);
	((ans %= mod) += mod) %= mod;

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


Measured memory_bytes: 31744
#include <iostream>

using namespace std;

int main() {
  int K;
  cin >> K;
  
  if (K % 2 == 0 || K % 5 == 0) {
    cout << -1 << endl;
  } else {
    long remainder = 7 % K;
    long cnt = 1;
    while (remainder != 0) {
      remainder = (10 * remainder + 7) % K;
      cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 3140
H, W = map(int, input().split())

A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]
Diff = [[0] * (W + 1) for _ in range(H + 1)]
M = 0
for i in range(H):
    for j in range(W):
        m = abs(A[i][j] - B[i][j])
        Diff[i][j] = m
        M += m

dp = [[0] * (W + 1) for _ in range(H + 1)]
dp[0][0] |= (1 << Diff[i][j])

for i in range(0, H):
    for j in range(0, W):
        here = dp[i][j]
        s = Diff[i][j]
        ni = 0
        nj = 0
        ni |= (here << s)
        nj |= (here << s)
        ni |= (here >> s)
        nj |= (here >> s)
        ex = 0
        for k in range(1, s + 1):
            if (here >> k) & 1:
                ex |= (1 << (s - k))
        ni |= ex
        nj |= ex
        dp[i + 1][j] |= ni
        dp[i][j + 1] |= nj

a = dp[H - 1][W - 1]
ans = 0
for k in range(M + 1):
    if (a >> k) & 1:
        ans = k
        break

print(k)


Measured memory_bytes: 53596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn       cout<<"Yes\n"; else cout<<"No\n";
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;
const ll LINF = 1e18;


int main()
{
    const ll M=1000000;
    bool a[M+10]={0};
    a[0]=a[1]=1;
    for(int i=2;i*i<M+7;i++) if(a[i]==0) for(int j=i+i;j<M+7;j+=i) a[j]=1;
    
    ll n;
    cin>>n;
    for(ll i=0;n;i++){
        if(a[i]==0 && i%10==1) cout<<i<<" ",n--;
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (auto& x : A) cin >> x;
	sort(A.rbegin(), A.rend());
	map<int,int> a;
	int r = 0;
	for (auto x : A) {
		if (a.count(x) && a[x] > 0) {
			-- a[x];
			++ r;
		} else {
			int k = 0;
			for (int i = 0; i <= 30; ++ i) if ((x>>i)&1) k = i;
			int y = (1<<(k+1)) - x;
			++ a[y];
		}
	}
	cout << r << endl;
}


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


int main(){
    int  N;
    cin >> N;
    vector<int> Ryokan(N+1,0);
    for(int i=1; i<=N; i++) cin >> Ryokan[i];
    
    int ans_count=1;
    int max_high=Ryokan[1];
    for(int i=2; i<=N; i++){
        if(max_high <= Ryokan[i]){
            ans_count++;
            max_high = Ryokan[i];
        }
        
    }
    cout << ans_count << endl;
    
    /*
    for(int x:Ryokan){
        cout << x <<" ";
    }
    */
}


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

int n,k,a,b;

int main() {
  cin >> a >> b;
  rep(i,max(a,b)) cout << min(a,b);
  cout << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
N=int(input())

uddic=defaultdict(list)
lrdic=defaultdict(list)
uldic=defaultdict(list)
urdic=defaultdict(list)
dldic=defaultdict(list)
drdic=defaultdict(list)

for _ in range(N):
  XS,YS,U=input().split()
  x=int(XS)
  y=int(YS)
  if U=="U":
    uddic[x].append((y,U))
    uldic[x-y].append((x,U))
    urdic[x+y].append((x,U))
  elif U=="D":
    uddic[x].append((y,U))
    dldic[x+y].append((x,U))
    drdic[x-y].append((x,U))
  elif U=="L":
    lrdic[y].append((x,U))
    uldic[x-y].append((x,U))
    dldic[x+y].append((x,U))
  else:
    lrdic[y].append((x,U))
    urdic[x+y].append((x,U))
    drdic[x-y].append((x,U))
    
answer=float("inf")
#UD
for x in uddic:
  ylist=sorted(uddic[x])
  for i in range(len(ylist)-1):
    y1,u1=ylist[i]
    y2,u2=ylist[i+1]
    if u1=="U" and u2=="D":
      answer=min(answer,(y2-y1)*5)
#LR
for y in lrdic:
  xlist=sorted(lrdic[y])
  for i in range(len(xlist)-1):
    x1,u1=xlist[i]
    x2,u2=xlist[i+1]
    if u1=="R" and u2=="L":
      answer=min(answer,(x2-x1)*5)

#UL
for xmy in uldic:
  xlist=sorted(uldic[xmy])
  for i in range(len(xlist)-1):
    x1,u1=xlist[i]
    x2,u2=xlist[i+1]
    if u1=="U" and u2=="L":
      answer=min(answer,(x2-x1)*10)
#UR
for xpy in urdic:
  xlist=sorted(urdic[xpy])
  for i in range(len(xlist)-1):
    x1,u1=xlist[i]
    x2,u2=xlist[i+1]
    if u1=="R" and u2=="U":
      answer=min(answer,(x2-x1)*10)
#DL
for xpy in dldic:
  xlist=sorted(dldic[xpy])
  for i in range(len(xlist)-1):
    x1,u1=xlist[i]
    x2,u2=xlist[i+1]
    if u1=="D" and u2=="L":
      answer=min(answer,(x2-x1)*10)
#DR
for xmy in drdic:
  xlist=sorted(drdic[xmy])
  for i in range(len(xlist)-1):
    x1,u1=xlist[i]
    x2,u2=xlist[i+1]
    if u1=="R" and u2=="D":
      answer=min(answer,(x2-x1)*10)
  
if answer==float("inf"):
  print("SAFE")
else:
  print(answer)

Measured memory_bytes: 216896