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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N, K; cin >> N >> K;
    vec a(N);
    rep(i, N) cin >> a[i];
    sort(all(a));
    int res = 0;
    rep(i, K){
        res += a[i];
    }
    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
vi g[252521];
double val[252521];

double ans[252521];

double dfs1(int p,int bef){
  double sum = 0.0;
  double cnt = 0.0;
  for(int to : g[p])if(to!=bef){
    sum += dfs1(to,p)+1.0;
    cnt += 1.0;
  }
  if(cnt != 0.0)sum /= cnt;
  return val[p] = sum;
}

void dfs2(int p,int bef){
  // root is p
  ans[p] = val[p];
  // summation
  double childsum = 0.0;
  double cnt = (double)g[p].size();
  for(int to : g[p]){
    childsum += val[to];
  }
  for(int to : g[p])if(to!=bef){
    // rotate root to
    double bef = val[to];
    val[p] = cnt==1.0 ? 0.0 : (childsum - val[to] + cnt - 1) / (cnt - 1);
    val[to] = (val[to] * (g[to].size()-1) + val[p] + 1) / g[to].size();
    dfs2(to,p);
    val[to] = bef;
  }
  val[p] = ans[p];
}

int main(){
  scanf("%d",&n);
  REP(i,n-1){
    int u,v;
    scanf("%d%d",&u,&v);
    --u;--v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs1(0,-1);
  dfs2(0,-1);
  REP(i,n)printf("%.9f\n",ans[i]);
  return 0;
}


Measured memory_bytes: 22784
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BOneClue solver = new BOneClue();
        solver.solve(1, in, out);
        out.close();
    }

    static class BOneClue {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int k = in.nextInt(), x = in.nextInt();

            StringBuilder sb = new StringBuilder();
            for (int i = x - (k - 1); i <= x + (k - 1); i++) {
                sb.append(i).append(" ");
            }
            out.println(sb);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22356
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int T1, T2;
	ll A1, A2, B1, B2;
	ll LA, LB;
	ll ans = 0;

	cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
	LA = A1 * T1 + A2 * T2;
	LB = B1 * T1 + B2 * T2;

	if (LA == LB) {
		cout << "infinity" << endl;
		return 0;
	}
	else if (LA > LB) {
		ll D = LA - LB;
		if (T1 * A1 < T1* B1) {
			ll INI = T1 * B1 - T1 * A1;
			ans = 2 * (INI / D) + (INI % D == 0 ? 0 : 1);
		}
	}
	else {
		ll D = LB - LA;
		if (T1 * B1 < T1 * A1) {
			ll INI = T1 * A1 - T1 * B1;
			ans = 2 * (INI / D) + (INI % D == 0 ? 0 : 1);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        x: usize,
        l: [usize; n],
    }
    let mut d = 0;
    let mut count = 1;
    for li in l {
        d += li;
        if d > x {
            break;
        }
        count += 1;
    }
    println!("{}", count);
}


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

const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int a[300000];
int main(){
	int n;cin>>n;
	map<int,int>mp;
	rep(i,n){
		scanf("%d",&a[i]);
		mp[a[i]]++;
	}
	ll ans=0;
	for(auto p:mp){
		ans+=p.second*(ll)(p.second-1)/2;
	}
	rep(i,n){
		cout<<ans-(mp[a[i]]*(ll)(mp[a[i]]-1))/2+(mp[a[i]]-1)*(ll)(mp[a[i]]-2)/2<<endl;
	}
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	string s; cin>>s;
	int n=s.length();

	map<int,int> f;
	int sum=0,ten=1;
	for(int i=n-1;i>=0;i--){
		sum=((s[i]-'0')*ten+sum)%2019;
		ten=ten*10%2019;
		++f[sum];
	}

	lint ans=0;
	sum=0; ten=1;
	for(int i=n-1;i>=0;i--){
		ans+=f[sum];
		sum=((s[i]-'0')*ten+sum)%2019;
		ten=ten*10%2019;
		--f[sum];
	}
	printf("%lld\n",ans);

	return 0;
}


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

int getSum(int);

int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	int ans = 0;
	for (int i = 1; i <= N; i++)
	{
		int sum=getSum(i);
		if (A <= sum && sum <= B)
			ans += i;
	}
	cout << ans << endl;
	return 0;
}

int getSum(int n)
{
	vector<int> a;
	while (n!=0)
	{
		a.push_back(n % 10);
		n /= 10;
	}
	int sum = 0;
	for (size_t i = 0; i < a.size(); i++)
	{
		sum += a[i];
	}
	return sum;
}

Measured memory_bytes: 256
#include<stdio.h>
int m[1002][1002][3]={0};
int main(){
  int w,h,n,i,j,k,a,b,c,d;
  char s;
  scanf("%d %d %d\n",&h,&w,&n);
  for(i=1;i<=h;i++){
    for(j=1;j<=w+1;j++){
      scanf("%c",&s);
      if(s=='\n')continue;
      for(k=0;k<3;k++){
	m[i][j][k]+=m[i-1][j  ][k];
	m[i][j][k]+=m[i  ][j-1][k];
	m[i][j][k]-=m[i-1][j-1][k];
      }
      if(s=='J')m[i][j][0]++;
      if(s=='O')m[i][j][1]++;
      if(s=='I')m[i][j][2]++;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d %d",&a,&b,&c,&d);
    for(j=0;j<3;j++){
     if(j)printf(" ");
     printf("%d",m[c][d][j]-m[c][b-1][j]-m[a-1][d][j]+m[a-1][b-1][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 12228
#include <stdio.h>

int main(void){

  long n;
  scanf("%ld", &n);
  long x[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &x[i]);
  }

  long tairyoku;
  long min = -1;

  for (long i = 1; i <= 100; i++) {
    tairyoku = 0;
    for (long j = 0; j < n; j++) {
      tairyoku += (x[j]-i)*(x[j]-i);
    }
    if (min == -1 || tairyoku < min) {
      min = tairyoku;
    }
  }

  printf("%ld\n", min);

  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define H 1001
#define W 1001
#define MOD 1000000007
#define LL long long int

LL dp[H][W];
char s[H][W];


int main(void)
{
	int i;
	int j;
	int h;
	int w;

	dp[0][0]=1;
	scanf("%d %d", &h, &w);
	for(i=0;i<h;i++){
		scanf("%s",s[i]);
	}
	for(i=1;i<h;i++){
		if(s[i][0] != '#'){
			dp[i][0]=dp[i-1][0];
		}
	}
	for(j=1;j<w;j++){
		if(s[0][j] != '#'){
			dp[0][j]=dp[0][j-1];
		}
	}
	for(i=1;i<h;i++){
		for(j=1;j<w;j++){
			if(s[i][j] != '#'){
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
			}
		}
	}
	printf("%I64d",dp[h-1][w-1]);

	return 0;
}

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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define float			double
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vc				vector<char>
#define vb				vector<bool>
#define vf				vector<float>
#define vs				vector<string>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define hashmap         unordered_map
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

template<class T>
void printV(vector<T> a) {for (auto v : a)cout << v << " ";}
template<class T>
void readV(vector<T>& a) {int n = a.size(); for (int i = 0 ; i < n ; i++)cin >> a[i];}
template<class T>
void printA(T* a , int n) {for (int i = 0; i < n  ; i++)cout << a[i] << " ";}
template<class T>
void readA(T* a , int n) {for (int i = 0 ; i < n ; i++)cin >> a[i];}
auto clk = clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
void run_time() {cout << endl<<"Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;}

void aryan_pandeya() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


int32_t main() {
	aryan_pandeya();
	FIO;

	int a,b,c,d;
	cin>>a>>b>>c>>d;

	cout<<max(max(a*c,a*d),max(b*c,b*d));
	


	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>

using namespace std;

static const int N = 1000;

int c[N + 1][N + 1];
int lcs(string s1, string s2){
	int m = s1.size();
	int n = s2.size();
	int maxL = 0;

	s1 = ' ' + s1;
	s2 = ' ' + s2;
	for (int i = 1; i <= m; ++i) c[i][0] = 0;
	for (int i = 1; i <= n; ++i) c[0][i] = 0;

	for (int i = 1; i <= m; ++i) {
		for (int j = 1; j <= n; ++j) {
			if (s1[i] == s2[j]) c[i][j] = c[i - 1][j - 1] + 1;
			else c[i][j] = max(c[i - 1][j], c[i][j - 1]);
			maxL = max(maxL, c[i][j]);
		}
	}
	return maxL;
}

int main(){
	string s1, s2;
	int n; cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> s1 >> s2;
		cout << lcs(s1, s2) << endl;
	}

	return 0;
}

Measured memory_bytes: 7068
#include <bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
using namespace std;
int main(){
    cout.precision(10);
    int ok=0;
    ll a,b,c,ans=0;
    cin>>a>>b>>c;
    ll cp=c-(a+b);
    if(cp>0&&cp*cp>4*a*b)ok=1;
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long A, B, C, D;
  cin>>A>>B>>C>>D;
  long long a,aa,b,bb,c,cc;
  a=(A-1)/C;
  aa=B/C;
  b=(A-1)/D;
  bb=B/D;
//  cout<<"a:"<<a<<" aa:"<<aa<<" b:"<<b<<" bb:"<<bb;
  long long x=C, y=D, z=x%y;
  while(z>0){
    x=y;
    y=z;
    z=x%y;
  }
  D*=C/y;
  c=(A-1)/D;
  cc=B/D;
//  cout <<" c:"<<c<<" cc:"<<cc<<endl;
  cout << (B-(A-1))-(aa+bb-cc-(a+b-c)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int main(){
 VI d[2],an1,an2;
 DRII(N,M);
 REP(i,M){DRI(x);d[x&1].PB(x);}
 if(SZ(d[1])>2)return 0*puts("Impossible");
 else if(SZ(d[1])==0){
  an1=d[0];
  an2.PB(1);REP(i,SZ(d[0])-1)an2.PB(d[0][i]);an2.PB(d[0].back()-1);
 }
 else if(SZ(d[1])==1){
  an1=d[0];
  an1.PB(d[1][0]);
an2.PB(1);REP(i,SZ(d[0]))an2.PB(d[0][i]);
if(d[1][0]!=1)an2.PB(d[1][0]-1);
 }
 else if(SZ(d[1])==2){
  an1.PB(d[1][0]);
  REP(i,SZ(d[0]))an1.PB(d[0][i]);
an1.PB(d[1][1]);
  if(d[1][0]!=1)an2.PB(d[1][0]-1);
REP(i,SZ(d[0]))an2.PB(d[0][i]);an2.PB(d[1][1]+1);
 }
 REP(i,SZ(an1))printf("%d%c",an1[i],i==SZ(an1)-1?'\n':' ');
 printf("%d\n",SZ(an2));
   REP(i,SZ(an2))printf("%d%c",an2[i],i==SZ(an2)-1?'\n':' ');
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <limits>
#include <numeric>
using namespace std;
#define int long long int

signed main(){
    int a;
    int r=0;
    cin >> a;
    for(int i=1;i<=a;i++){
        for(int j=1;j<=a;j++){
            for(int k=1;k<=a;k++){
                r += gcd(i,gcd(j,k));
            }
        }
    }
    cout << r << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
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 (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

using Graph = vector<vector<int>>;
const ll INF = 1ll<<60;
vector<ll> dp(202020, INF);
vector<ll> a(202020);
vector<ll> ba(202020);
vector<ll> val(202020);
vector<ll> res(202020);

ll N;

void dfs(ll now, ll par, Graph &G){
    //dump(now)
    ll pos = lower_bound(dp.begin(), dp.end(), a[now]) - dp.begin();
    val[now] = dp[pos];
    ba[now] = pos;
    dp[pos] = a[now];

    ll re = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
    res[now] = re;

    for(auto next: G[now]){
        if(next == par) continue;
        dfs(next, now, G);
    }
    dp[ba[now]] = val[now];
    return;
}

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

    cin >> N;
    REP(i, N) cin >> a[i];
    
    Graph G(N);

    REP(i, N-1){
        ll u, v;
        cin >> u >> v;
        u--, v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    dfs(0, -1, G);

    REP(i, N){
        cout << res[i] << endl;
    }

    return 0;
}

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

using namespace std;

int main(void) {
	int n, k,ans = 0;
	cin >> n >> k;
	vector<int> h(n);

	for (int i = 0; i < n; i++) {
		cin >> h[i];
		if (h[i] >= k) {
			ans++;
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 640
input_n = input()
input_a = input().split()
cnt = 0
end_flg = True

while end_flg:
    for i in range(int(input_n)):

        if int(input_a[i]) % 2 == 0:
            input_a[i] = int(input_a[i])/2

        else:
            end_flg = False
            break
    if end_flg == False:break
    cnt+=1

print(cnt)

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

int main() {
    string s;
    cin >> s;

    bool can = false;
    if (s[2] == s[3] && s[4] == s[5]) can = true;

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
a,b,c,x = int(input()),int(input()),int(input()),int(input())
ans = 0
for i in range(min(a+1,41)):
    for j in range(min(b+1,201)):
        k = x-500*i-100*j
        if k >= 0 and k%50 == 0 and k//50 <= c:
            ans += 1
print(ans)

Measured memory_bytes: 9096
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define sort(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;

using namespace std;

int main() {
	int n;
	cin >> n;
	int ans = 0;
	int t;
	cin >> t;
	int prev;
	cin >> prev;
	ff(i, 1, n) {
		int cur;
		cin >> cur;
		int sa = cur - prev;
		if (sa > t) {
			ans += t;
		}
		else ans += sa;
		prev = cur;
	}
	ans += t;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
struct edge {int to,costa,costb;};

signed main() {
int h,w;
cin>>h>>w;
string s[h];
for(int i=0;i<h;i++)cin>>s[i];
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        if(s[i][j]=='.')continue;
        if(i!=0&&s[i-1][j]=='#')continue;
         if(i!=h&&s[i+1][j]=='#')continue;
          if(j!=0&&s[i][j-1]=='#')continue;
           if(j!=w&&s[i][j+1]=='#')continue;
           cout<<"No";
           return 0;
    }
}
cout<<"Yes";

return 0;
}


Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. A-KthTerm.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 K   PIC 9(2).
01 TBL.
   03  FILLER PIC X(32) VALUE '01010102010201050202010501020114'.
   03  FILLER PIC X(32) VALUE '01050105020201150202050401040151'.
01 TBL-R      REDEFINES TBL.
   03  T-R    PIC 9(02) OCCURS 32.
01 OUT        PIC Z9.
PROCEDURE DIVISION.
MAIN-001.
  ACCEPT K.
  MOVE T-R(K) TO OUT.
  DISPLAY FUNCTION TRIM(OUT).
*>
  STOP RUN.


Measured memory_bytes: 636
//    >File Name: 057B.cpp
//    > Author: Webwei

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

struct node{
	int a;
	int b;
	int c;
};
node v[100010],w[100010];

int cc[100010];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>v[i].a>>v[i].b;
	}
	for(int i=0;i<m;i++){
		cin>>w[i].a>>w[i].b;
	}
	int z=0,e=0;
	for(int i=0;i<n;i++){
		int mx=1e9;
		for(int j=0;j<m;j++){
			v[i].c=abs(v[i].a-w[j].a)+abs(v[i].b-w[j].b);
			if(v[i].c<mx){
				mx=v[i].c;
				e=j+1;
			}
		}
		cc[z]=e;
		z++;
	}
	for(int i=0;i<z;i++){
		cout<<cc[i]<<"\n";
	}
	
}


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

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

const INF: i64 = 1 << 60;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let K: usize = sc.get();
    let mut h: Vec<i64> = sc.vec(N);
    h.sort();
    let mut ans = INF;
    for i in 0..N-K+1 {
        let hmin = h[i];
        let hmax = h[i+K-1];
        ans = min(ans, hmax - hmin);
    }
    println!("{}", ans);
}


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

ll cost(vector<vector<ll>> m, vector<vector<ll>> d, int i, int j, int k) {
  ll ret =0;
  rep(ii,n) {
    rep(jj,n) {
      if((ii+jj)%3==0) {
	ret += d[m[ii][jj]][i];
      } else if((ii+jj)%3==1) {
	ret+=d[m[ii][jj]][j];
      } else {
	ret+=d[m[ii][jj]][k];
      }
    }
  }
  return ret;
}

int main() {
  cin >>n>>c;
  vector<vector<ll>> d(c);
  vector<vector<ll>> X(3);
  rep(i,c) {
    X[0].push_back(0);
    X[1].push_back(0);
    X[2].push_back(0);
  }
  rep(i,c) {
    rep(j,c) {
      ll a; cin >> a;
      d[i].push_back(a);
    }
  }
  vector<vector<ll>> m(n);
  rep(i,n) {
    rep(j,n) {
      ll a; cin >> a;
      a--;
      m[i].push_back(a);
      if((i+j)%3==0) {
	rep(k,c) {
	  X[0][k] += d[m[i][j]][k];
	}
      } else if((i+j)%3==1) {
	rep(k,c) {
	  X[1][k] += d[m[i][j]][k];
	}
      } else {
	rep(k,c) {
	  X[2][k] += d[m[i][j]][k];
	}
      }
    }
  }
  ll ans = 1000LL*500LL*500LL+1;
  rep(i,c) {
    rep(j,c) {
      rep(k,c) {
	if(i==j||j==k||i==k) continue;
	ans = min(ans,X[0][i]+X[1][j]+X[2][k]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

#define PB(N) push_back(N)

using namespace std;

using Graph = vector<vector<int>>;

int main(){
  int X,Y;
  cin >> X >> Y;
  bool flag=0;
  for(int i=0;i<=X;i++){
    int j = X-i;
    if(Y==i*2+j*4) flag=1;
  }

  if(flag) cout << "Yes";
  else cout << "No";

  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    int n;
    cin >> n;
    vll a(n);
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
    }

    vll b(n + 1);
    b[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        b[i] = a[i - 1] * 2 - b[i - 1];
    }

    ll d = b[n] - b[0];
    b[0] = d / 2;
    printf("%lld", b[0]);
    for (int i = 1; i < n; i++)
    {
        b[i] = a[i - 1] * 2 - b[i - 1];
        printf(" %lld", b[i]);
    }

    return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll t[2], a[2], b[2];
    cin >> t[0] >> t[1];
    cin >> a[0] >> a[1];
    cin >> b[0] >> b[1];

    // t[0] は青木くんが， t[1] は高橋くんが早い設定に揃えておく
    if(a[0] > b[0]) {
        swap(a[0], b[0]);
        swap(a[1], b[1]);
    }

    // t[0], t[1] 分でつく差
    ll diff[2] = {
        (b[0] - a[0]) * t[0], 
        (b[1] - a[1]) * t[1], 
    };

    // 1周期で走る距離が同じなら，infinity
    if(diff[0] + diff[1] == 0) {
        cout << "infinity" << endl;
        return 0;
    }

    // ひたすらどちらかがリードし続けるなら 0
    if(diff[0] + diff[1] > 0) {
        cout << 0 << endl;
        return 0;
    }

    ll m = -diff[0] / (diff[0]+diff[1]);
    ll ans = m * 2;
    if((diff[0]+diff[1]) * m + diff[0] >  0) ++ans;

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
{
   int a,x,y;
   while(~scanf("%d",&a))
   {
       if(a==1)
       {
           printf("Hello World\n");
       }
       else
       {
           scanf("%d",&x);
           scanf("%d",&y);
           printf("%d\n",x+y);
       }
   }
    return 0;
}


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


int main()
{
    stringstream ss;
    // 入力
    int A,B,C,K;
    cin>>A>>B>>C>>K;

    int maxval=max(A,max(B,C));
    int maxvaled=maxval;
    maxvaled=maxvaled*pow(2,K);
    int ans=maxvaled+A+B+C-maxval;
    cout<<ans<<endl;
    return 0;
}

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

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

  int h,w,n;
  cin >> h >> w >> n;

  int T[110][110];
  
  int curh = 0, curw = 0;
  rep(i, n) {
    int a; cin >> a;

    while(a > 0) {
      if(curh % 2 == 0) {
        T[curh][curw] = i + 1;
        curw++;
        a--;
  
        if(curw == w) {
          curh++;
          curw--;
        }
      } else {
        T[curh][curw] = i + 1;
        curw--;
        a--;
  
        if(curw == -1) {
          curh++;
          curw++;
        }
      }
    }
  }

  rep(i, h) {
    rep(j, w) {
      cout << T[i][j];
      if(j != w - 1) cout << " ";
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 384
import java.util.*;

class Main {
	Scanner sc;
	long A, B;
	long G;
	
	Main() {
		sc = new Scanner(System.in);
	}
	
	void calc() {
		A = sc.nextLong();
		B = sc.nextLong();
		G = gcd(A,B);
		int N = (int)Math.sqrt(G);
		
		int l = -1;
		int c = 0;
		int p;
		for (p = 2; p <= N; p++) {
			if ( (G%p)==0 ) {
				G /= p;
				if (l != p) {
					c++;
					l = p;
				}
				p--;
			}
		}
		if (G >= p) c++;
		System.out.println(c+1);
	}
	
	private static final long gcd(long a, long b) {
		long x0 = 1, x1 = 0;
		long y0 = 0, y1 = 1;
	
		while (b != 0) {
			long q = a / b;
			long r = a % b;
			long x2 = x0 - q * x1;
			long y2 = y0 - q * y1;
	
			a = b; b = r;
			x0 = x1; x1 = x2;
			y0 = y1; y1 = y2;
		}
	
	    return a;
	}

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

Measured memory_bytes: 21844
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);int m=s.nextInt(),n=s.nextInt(),r=0,a,i;for(;m-->0;)for(a=0,i=n;i-->0;)r=Math.max(r,a+=s.nextInt()>0?1:0);System.out.println(r);}}

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

int main() {
    string num;
    cin >> num;
    
    int length = num.length();
    int totalOfAllDigits = 0;
    
    for (int i = 0; i < length; i++) {
        totalOfAllDigits += num[i] - '0';
    }
    
    int numInInt = stoi(num);
    
    // ある数がその数の各桁の和で割り切れるならハーシャッド数
    if(numInInt % totalOfAllDigits == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#define NIL -1
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int n;
int root;
int *p = new int[500000];    //    p---|  Unit
int *left2 = new  int[500000]; // left2 --|--------> T
int *right2 = new int[500000];//right2---|
int *key = new int[500000];  // key----|
  
void Init(){
  rep(i,500000){
    p[i]=left2[i]=right2[i]=key[i]=NIL;
  }
}
  
  
int FindRoot(){
  rep(i,n){
    if(p[i] == NIL){
      return i;
    }
  }
}
  
  
  
void TREE_INSERT(int z){
  int y = NIL;
  int x = root;
  
  while(x != NIL){
    y = x;
    if(key[z] < key[x]){
      x = left2[x];
    }
    else x = right2[x];
  }
  p[z]=y;
  if(y == NIL){
    root = z;
  }
  else if(key[z] < key[y]){
    left2[y] = z;
  }else{
    right2[y] = z;
  }
  
}
  
void InorderTreeWalk(int x){
  if(x != NIL){
    InorderTreeWalk(left2[x]);
    printf(" %d",key[x]);
    InorderTreeWalk(right2[x]);
  }
}
  
void PreorderTreeWalk(int x){
  if(x != NIL){
    printf(" %d",key[x]);
    PreorderTreeWalk(left2[x]);
    PreorderTreeWalk(right2[x]);
  }
}
  
  
int main(){
  int val;
  string op;
  int zr;                   
  
  
  scanf("%d",&n);
  Init();
  root = -1;
  zr=0;
  while(n-- > 0){
    cin >> op;
    if(op == "insert"){
      scanf("%d",&val);
      key[zr]=val;       
      TREE_INSERT(zr);
      zr++;
    }else if(op == "print"){
      InorderTreeWalk(root);
      printf("\n");
      PreorderTreeWalk(root);
      printf("\n");
    }
  }
  
  delete [] p;
  delete [] left2;
  delete [] right2;
  delete [] key;
  
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (ll i=(ll)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const ll INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(ll x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { ll d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll modpow(ll x, ll p) { ll result = 1, now = 1, pm = x; while (now<=p) { if (p&now) { result = result * pm % MOD; } now*=2; pm = pm*pm % MOD; } return result; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

struct coord { ll x, y; };

int main() {
  ll H, W; cin >> H >> W;
  string A[H]; rep(i,H) cin >> A[i];
  vector<vector<ll>> turn(H, vector<ll>(W,-1));

  queue<coord> q;
  rep(i,H) rep(j,W) {
    if (A[i][j]=='#') {
      q.push({i,j});
      turn[i][j] = 0;
    }
  }

  coord to[4] = {{-1,0},{0,-1},{0,1},{1,0}};
  while (q.size()) {
    coord now = q.front(); q.pop();
    rep(i,4) {
      ll tox = now.x+to[i].x, toy = now.y+to[i].y;
      if (tox>=0&&tox<H) {
        if (toy>=0&&toy<W) {
          if (turn[tox][toy]==-1) {
            turn[tox][toy] = turn[now.x][now.y] + 1;
            q.push({tox,toy});
          }
        }
      }
    }
  }
  // rep(i,H) debug(all(turn[i]));

  ll result = 0; rep(i,H) rep(j,W) result = max(result,turn[i][j]);
  cout << result << endl;
  return 0;
}

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


int main(){
  int x,a;
  cin >> x >> a;
  if (x < a) cout << 0 << endl;
  else cout << 10 << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
int main(){
  int n,d;cin>>n>>d;
  if(n%(2*d+1)==0)cout<<n/(2*d+1)<<endl;
  else cout<<n/(2*d+1)+1<<endl;
}

Measured memory_bytes: 256
from collections import Counter

MOD = 998244353

N = int(input())
D = [int(_) for _ in input().split()]
if D[0] != 0:
    print(0)
    exit()

counter = Counter(D)
if counter[0] != 1:
    print(0)
    exit()
max(D)
cnt = 0
ans = 1
pre = 1

for i in range(1, max(D) + 1):
    if counter[i] == 0:
        print(0)
        exit()
    ans *= (pre ** counter[i]) % MOD
    ans = ans % MOD
    pre = counter[i]
print(ans)


Measured memory_bytes: 19936
// #include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <bitset>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=998244353;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power(((((a)%mod)*((a)%mod))%mod),b/2)%mod;
    else return (((a)%mod)*(power(((((a)%mod)*((a)%mod))%mod),b/2)%mod))%mod;
}
inline ll inverse(ll a) {
  a %= mod;
  if (a < 0) a += mod;
  ll b = mod, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += mod;
  return u;
}
  
  
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution
const int ce=1e9+7;
ll fast_mod(ll input)
{
    return input < ce ? input : input%ce;
}

int32_t main()
{
    IOS

    int n;
    cin>>n;
    int ch=1e18;
    ch+=100;
    int pr=1;
    for(int i=1;i<=n;++i)
    {
    	int x;
    	cin>>x;
    	if(x==0)
    	{
    		cout<<0<<endl;
    		return 0;
    	}
    	if((ch+x-1)/x<pr)
    	{
    		pr=ch;
    		continue;
    	}
    	pr*=x;
    }
    if(pr>ch-100)
    {
    	cout<<-1<<endl;
    	return 0;
    }
    cout<<pr;
}       

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<string>;
using namespace std;
bool compare(string a, string b) 
{ 
    return (a+b < b+a); 
} 
int main()
{
  
  int n,l;
  cin>>n>>l;
  string arr[n];
  string res;
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  sort(arr,arr+n,compare);
  for(int i=0;i<n;i++)
    res+=arr[i];
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//useful 
#define rep(i,n) for(int i = 0; i < (n); i++)
int long long gcd(int long long a, int long long b){
    return b?gcd(b,a%b):a;
} //最大公約数
int long long lcm(int long long a, int long long b){
    return a/gcd(a,b)*b;
} //最小公倍数
int long long GetDigit(int long long num){
    int long long digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
} //桁数
int long long GetDigitN(int long long num, int long long N){
    int long long digit=0;
    while(num!=0){
        num /= N;
        digit++;
    }
    return digit;
} //十進数でnumの際のN進数における桁数
int long long divisorcount(int long long n){
	int long long ans = 1;
	vector<int> x(n + 1);
	int long long num = n; // 素因数分解する変数num 
	for (int long long i = 2; i <= n; i++) {
		while (num%i == 0) { // 素数で割り切れなくなるまで割っていく
			x.at(i)++; //割った個数を配列に足す
			num /= i;
		}
	}
	for (int i = 2; i <= n; i++){	
		ans *= x.at(i) + 1; //それぞれを+1して掛けていく
	}
    return ans;
} //約数カウント

int main(){
    int N;
    cin >> N;
    int A = 0, B = 0, C = 0, D = 0;
    string S;
    for(int i = 0; i < N; i++){
        cin >> S;
        if(S == "AC"){
            A = A + 1;
        }
        else if(S == "WA"){
            B = B + 1;
        }
        else if(S == "TLE"){
            C = C + 1;
        }
        else{
            D = D + 1;
        }
    }
    cout << "AC" << " " << 'x' << " " << A << endl;
    cout << "WA" << " " << 'x' << " " << B << endl;
    cout << "TLE" << " " << 'x' << " " << C << endl;
    cout << "RE" << " " << 'x' << " " << D << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long int ll;
int main()
{   ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
    ll n;
    cin>>n;
    if(n>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    
    return 0;
}


Measured memory_bytes: 3644
import sys
from itertools import accumulate
stdin = sys.stdin.readlines()
N, M, Q = map(int, stdin[0].split())
LR = [[0 for _ in range(N-i)] for i in range(N)]
for line in stdin[1:M+1]:
  L, R = map(int, line.split())
  LR[L-1][R-L] += 1
for i in range(N-2,-1,-1):
  acc = accumulate(LR[i])
  next(acc)
  for j in range(1, N-i):
    LR[i][j] = next(acc) + LR[i+1][j-1]

sys.stdout.write("\n".join(map(str, 
  (LR[p-1][q-p] for p,q in (map(int, line.split()) for line in stdin[M+1:]))
)))


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

int main(){    
  int S;
  string N;
  cin >> N;
  S = N.size() - 1;
  if(N.at(S) == '3') cout << "bon" << endl;
  else if((N.at(S) == '0')||(N.at(S) == '1')) cout << "pon" << endl;
  else if((N.at(S) == '6')||(N.at(S) == '8')) cout << "pon" << endl;
  else cout << "hon" << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef struct edge{
  int cost, to, time, com;
}edge;
typedef struct pass{
  int com = 0, cost = 0;
}pass;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int n, m, h, k, s, t, p;
int dp[(1<<9)][30][111];
vector<vector<edge> > g;
vector<pass> vp;

void init(){
  g.resize(n);
  for (int i = 0; i < (1<<k); i++) {
    for (int j = 0; j <= h; j++) {
      for (int k = 0; k <= n; k++) {
        dp[i][j][k] = 1e9;
      }
    }
  }
  for (int i = 0; i < m; i++) {
    int from, to;
    edge e;
    std::cin >> from >> to >> e.cost >> e.time >> e.com;
    from--, to--, e.com--;
    e.to = to;
    g[from].emplace_back(e);
    e.to = from;
    g[to].emplace_back(e);
  }
  std::cin >> s >> t >> p;
  s--, t--;
  vp.resize(p);
  for (int i = 0; i < p; i++) {
    int l, c;
    std::cin >> l >> vp[i].cost;
    for (int j = 0; j < l; j++) {
      std::cin >> c;
      c--;
      vp[i].com |= (1<<c);
    }
  }
}

void dijkstra(int com, int cost){
  priority_queue<piii, vector<piii>, greater<piii> > que;
  dp[com][0][s] = cost;
  que.push(piii(cost, pii(s, 0)));
  while(not que.empty()){
    int c = que.top().first;
    int v = que.top().second.first;
    int t = que.top().second.second;
    que.pop();
    for (int i = 0; i < g[v].size(); i++) {
      edge &e = g[v][i];
      int nt = t + e.time;
      int nc = c;
      if((com&(1<<e.com)) == 0)nc += e.cost;
      if(nt <= h and dp[com][nt][e.to] > nc){
        dp[com][nt][e.to] = nc;
        que.push(piii(nc, pii(e.to, nt)));
      }
    }
  }
}

int main(){
  while(std::cin >> n >> m >> h >> k, n){
    g.clear();
    vp.clear();
    init();
    int ans = 1e9;
    int pass_cost[(1<<k)];
    for (int i = 0; i < (1<<k); i++) {
      pass_cost[i] = 1e9;
    }
    queue<pii> que;
    que.push(pii(0, 0));
    pass_cost[0] = 0;
    while(not que.empty()){
      int v = que.front().first;
      int c = que.front().second;
      que.pop();
      for (int i = 0; i < p; i++) {
        int nv = v | vp[i].com;
        if(pass_cost[nv] > c + vp[i].cost){
          pass_cost[nv] = c + vp[i].cost;
          que.push(pii(nv, pass_cost[nv]));
        }
      }
    }
    for (int i = 0; i < (1<<k); i++) {
      if(pass_cost[i] != 1e9)dijkstra(i, pass_cost[i]);
    }
    for (int i = 0; i < (1<<k); i++) {
      for (int j = 0; j <= h; j++) {
        ans = min(ans, dp[i][j][t]);
      }
    }
    if(ans != 1e9)std::cout << ans << std::endl;
    else std::cout << -1 << std::endl;
  }
  return 0;
}

Measured memory_bytes: 6484
#include<iostream>
#include<vector>
#include<string>
using namespace  std;
vector<char>chara_after{'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>chara_before{'D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C'};
int main(){
    string st;
    cin >> st;
    string ans = "";
    for(int i = 0;i < st.size();i++){
        char c = st[i];
        for(int j = 0;j < chara_before.size();j++){
            if(c == chara_before[j]){
                ans.push_back(chara_after[j]);
                break;
            }
        }
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 3200
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,m = map(int,ipt().split())
    s = input()
    t = input()
    g = math.gcd(n,m)
    l = n*m//g
    sg = n//g
    tg = m//g
    for i in range(g):
        if s[sg*i] != t[tg*i]:
            print(-1)
            exit()

    print(l)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 75160
#include <stdio.h>

int main(void) {
	int a,b,c,d,e,f,g;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	if(a<40) a=40;
	if(b<40) b=40;
	if(c<40) c=40;
	if(d<40) d=40;
	if(e<40) e=40;
	f=a+b+c+d+e;
	g=f/5;
	printf("%d\n",g);
	
	return 0;
}

Measured memory_bytes: 600
// AOJ 1051
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	while (cin >> n, n){
		vector <int> page(n);
		for (int i = 0; i < n; i++){
			cin >> page[i];
		}
		sort(page.begin(), page.end());
		bool h = false;
		for (int i = 0; i < n; i++){
			int now = page[i], nxt;
			h = false;
			for (int j = i + 1; j < n; j++, i++){
				if (page[j - 1] + 1 == page[j]){
					h = true;
					nxt = page[j];
				}
				else break;
			}
			if (h){
				cout << now << "-" << nxt;
			}
			else {
				cout << now;
			}
			cout << (i + 1 == n ? '\n' : ' ');
		}
	}

	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
	ll n;
	scanf("%lld", &n);

	ll b = 100;
	int ans = 0;
	while(b < n) {
		ans++;
		b += b / 100;
	}

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


Measured memory_bytes: 3828