akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;

const int MOD = pow(10, 9) + 7;

int main() {
	int N;
	cin >> N;
	long long ans = 1;
	for (int i = 1; i <= N; i++)
		ans = ans * i % MOD;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) < (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n) - 1; (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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);
    return a / g * b;
}

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    ll n,m,ans = 0,cnt = 1;
    cin >> n >> m;
    if (n - m > 1 || n - m < -1) {
        cout << 0 << endl;
        return 0;
    }
    rep1(i, n + 1){
        cnt *= i;
        cnt %= mod;
    }
    ans = cnt;
    cnt = 1;
    rep1(i, m + 1){
        cnt *= i;
        cnt %= mod;
    }
    if (n - m == 0) {
        cout << (ans * cnt * 2) % mod << endl;
    }else{
        cout << (ans * cnt) % mod << endl;
    }
    return 0;
}


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

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if( a == b )
    cout << c << endl;
  else if( a == c )
    cout << b << endl;
  else if( b == c )
    cout << a << endl;
  return 0;
}

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

int main(){
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e - a <= k) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  
  return 0;
}

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    char a, b; cin >> a >> b;

    cout << (int(a) < int(b) ? '<' : int(a) == int(b) ? '=' : '>');
}


Measured memory_bytes: 256
import math
import fractions
import copy
import numpy as np

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
x,y = ips()
y= y*2+1
if x%y == 0:
    print(x//y)
else:print(x//y+1)


Measured memory_bytes: 22804
#include <bits/stdc++.h>
#define ll long long
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 1e5+5, M=1e5+5, oo=0x3f3f3f3f, mod = 1e9+7;

int n, k, dp[N], arr[N];
int main()
{
    _69e27
    memset(dp, oo, sizeof dp);
    dp[0] = 0;
    cin >> n >> k;
    for(int i=0; i<n; i++)
        cin >> arr[i];
    for(int i=0; i<n; i++){
        for(int j=i+1; j<=i+k; j++){
            if(j < n)
                dp[j]=min(dp[j], dp[i]+abs(arr[i]-arr[j]));
        }
    }
    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

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

void printArray(int *A, int N) {
  rep(i, N) {
    std::cout << A[i];
    if (i == N - 1) {
      std::cout << '\n';
    } else {
      std::cout << ' ';
    }
  }
}

void insertionSort(int *A, int N) {
  for (int i = 1; i < N; i++) {
    int v = A[i];
    int j = i - 1;

    while (j >= 0 && v < A[j]) {
      A[j + 1] = A[j];
      j--;
    }

    A[j + 1] = v;

    printArray(A, N);
  }
}

int main() {
  int N;
  std::cin >> N;

  int A[N];
  rep(i, N) { std::cin >> A[i]; }

  printArray(A, N);
  insertionSort(A, N);

  return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int main () {
    string s;
    cin >> s;
    bool f = 1;
    for (int i = 0; i < s.length(); i++) {
        if (i&1) {
            if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
               f = 0; 
            }
        }
        else {
            if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
                f = 0;
            }
        }
    }
    if (f) {
        puts("Yes");
    }
    else {
        puts("No");
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int x,y,z;
int n,m,k,t;
long long a[1000005],b[1000005];
pair<long long, long long> c[1000005];
int main() {
	scanf("%d%d%d",&x,&y,&z);
	printf("%d\n",min(z,y/x));
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
using namespace std;
typedef long long ll;
ll a,b,c;
int main(){
	cin>>a>>b>>c;
	if((a&1) && (b&1) && (c&1))printf("%lld",min(a*b,min(a*c,b*c)));
	else puts("0");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N,C;
int a[30][100010];
int main(){
	cin>>N>>C;
	rep(i,N){
		int s,t,c;
		cin>>s>>t>>c;
		c--,s--;
		a[c][s]++;
		a[c][t]--;
	}
	rep(c,C){
		rep(i,100002) a[c][i+1] += a[c][i];
	}
	int ans = 0;
	rep(i,100003){
		int tmp = 0;
		rep(c,C) if(a[c][i]>0) tmp++;
		chmax(ans,tmp);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 11904
x = int(input())
fives = []
for i in range(130):
    fives.append(i**5)

a = 0
b = 0
for i in range(len(fives)):
    for j in range(len(fives)):
        if fives[i] - fives[j] == x:
            a = i
            b = j
        elif fives[j] - fives[i] == x:
            a = j
            b = i
        elif fives[i] + fives[j] == x:
            a = i
            b = -1*j

print(str(a) + " " + str(b))


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  long long N, count;
  string color;
  cin >> N >> color;
  count = N;
  
  rep (i,N-1){
    if (color.at(i) == color.at(i+1)){
      count--;
    }
  }
  
  cout << count << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> f(n), s(n);
    for (int i=0; i<n; ++i) {
        cin >> f[i] >> s[i];
    }
    sort(f.begin(), f.end());
    sort(s.begin(), s.end(), greater<>());
    if (n%2) {
        cout << s[(n-1)/2] - f[(n-1)/2] + 1;
    } else {
        cout << s[n/2] - f[n/2] + s[n/2-1] - f[n/2-1] + 1;
    }
    return 0;
}

Measured memory_bytes: 4764
import sys
from itertools import combinations
input = sys.stdin.readline
n = int(input())

xl = []
xr = []
xc = []
yt = []
yb = []
yc = []
for i in range(n):
    x,y,d = input().split()
    x,y = int(x), int(y)
    if d == "R":
        xr.append(x)
        yc.append(y)
    elif d == "L":
        xl.append(x)
        yc.append(y)
    elif d == "U":
        xc.append(x)
        yt.append(y)
    else:
        xc.append(x)
        yb.append(y)
xr.sort()
xl.sort()
xc.sort()
yt.sort()
yb.sort()
yc.sort()

# xの最小値
xr_min = xr[0] if xr else None
xl_min = xl[0] if xl else None
xc_min = xc[0] if xc else None
xmin = [xr_min, xl_min, xc_min]

# xの最大値 最小化
xr_max = xr[-1] if xr else None
xl_max = xl[-1] if xl else None
xc_max = xc[-1] if xc else None
xmax = [xr_max, xl_max, xc_max]

# 上に行く　最小化
yt_max = yt[-1] if yt else None
yb_max = yb[-1] if yb else None
yc_max = yc[-1] if yc else None
ymax = [yt_max, yb_max, yc_max]

# 下に行く
yt_min = yt[0] if yt else None
yb_min = yb[0] if yb else None
yc_min = yc[0] if yc else None
ymin = [yt_min, yb_min, yc_min]

def cross(p1, p2):
    ret = []
    if p1 is None or p2 is None:
        return ret
    sub = abs(p1-p2)
    ret.append(sub)
    ret.append(sub/2)
    ret.append(sub/2+1)
    return ret

def check(t, xmax, xmin, ymax, ymin):
    op = [+1, -1, 0]
    xmax_ = -float("inf")
    xmin_ = float("inf")
    ymax_ = -float("inf")
    ymin_ = float("inf")
    # xmax
    for i, x in enumerate(xmax):
        if x is not None:
            xmax_ = max(xmax_, x+t*op[i])
    # xmin
    for i, x in enumerate(xmin):
        if x is not None:
            xmin_ = min(xmin_, x+t*op[i])
    # ymax
    for i, y in enumerate(ymax):
        if y is not None:
            ymax_ = max(ymax_, y+t*op[i])
    # ymin
    for i, y in enumerate(ymin):
        if y is not None:
            ymin_ = min(ymin_, y+t*op[i])
    return (xmax_-xmin_)*(ymax_-ymin_)

time_candidate = [0]

for lis in [xmin, xmax, ymin, ymax]:
    for p1, p2 in combinations(lis, 2):
        time_candidate.extend(cross(p1,p2))

ans = float("inf")
for i in set(time_candidate):
    ans_tmp = check(i, xmax, xmin, ymax, ymin)
    ans = min(ans, check(i, xmax, xmin, ymax, ymin))
print(ans)

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

// ====================================================================
const int MOD = 1e9 + 7;
int add(int a, int b) {int ret = (a % MOD) + (b % MOD); if (ret >= MOD)ret -= MOD; return ret;}
int sub(int a, int b) {int ret = ((a % MOD) - (b % MOD)); if (ret < 0)ret += MOD; return ret;}
int mul(int a, int b) {return (1LL * (a % MOD) * (b % MOD)) % MOD;}
// ====================================================================

signed main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    int n;
    std::cin >> n;

    std::vector<int> a(n + 1);
    std::vector<int> sum(n + 1);

    for (int i = 1; i <= n; i++) {
        std::cin >> a[i];
        sum[i] = add(sum[i - 1], a[i]);
    }

    int ans = 0;

    for (int i = 1; i < n; i++) {
        ans = add(ans, mul(sub(sum[n], sum[i]), a[i]));
    }

    std::cout << ans;

    return 0;
}



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

int	main() {
	int N;
	cin >>N;
	for (int i=0; i<N; i++) {
		int a;
		cin >>a;
		if (1==a%2) {
			cout <<"first" <<endl;
			return 0;
		}
	}
	cout <<"second" <<endl;
	return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left, bisect_right

n = int(input())
l = list(map(int, input().split()))
l.sort()
pattern = 0
for i in range(n - 2):
    a = l[i]
    for j in range(i + 1, n - 1):
        b = l[j]
        c_idx = bisect_left(l, a + b)
        pattern += (c_idx - j - 1)
print(pattern)


Measured memory_bytes: 9220
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int cnt = 0;
		Map<Integer, Integer> numCount =new HashMap<>();

		for (int i = 0; i < n; i++) {
			int x = Integer.parseInt(sc.next());
			int count = numCount.containsKey(x) ? numCount.get(x) : 0;
			numCount.put(x, count + 1);
		}

//		numCount.entrySet().stream().map(s -> s.getKey() + ": " + s.getValue()).forEach(System.out::println);
		long ans = numCount.entrySet().stream().filter(s -> s.getValue() % 2 != 0).count();
		System.out.println(ans);
	}
}


Measured memory_bytes: 48724
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    int sum=0;
    rep(i,m){
       int x;
       cin>>x;
       sum+=x;
    }
    (n>=sum)? cout<<n-sum:cout<<"-1";
return 0;
}


Measured memory_bytes: 3620
n,m=map(int,input().split())
a=[1]*(n+1)
b=[0]*(n+1)
b[1]=1
for _ in range(m):
  x,y=map(int,input().split())
  a[x]-=1
  a[y]+=1
  if b[x]:b[y]=1
  if a[x]==0:b[x]=0
print(sum(b))

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

using namespace std;
typedef unsigned long long ll;
const int mod=1e9+7;
int a[20010];
int main()
{
	ll n,k;
	scanf("%lld %lld",&n,&k);
	ll cot=0; 
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(a[i]>a[j]) cot++;
		}
	}
	ll cnt=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<i;j++)
		{
			if(a[j]<a[i]) cnt++;
		}
	} 
	ll sum=0;
	ll kk=k*(k+1)/2;
	if(kk==1) cout <<cot;
	else
	{
		ll kkk=(k-1)*(k)/2;
		sum=cot%mod*(kk%mod)%mod+cnt%mod*(kkk%mod)%mod;
		cout <<sum%mod<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def main():
    N, X, *xn = map(int, open(0).read().split())
    ans = abs(X - xn[0])
    for x in xn:
        df = abs(X - x)
        if df % ans:
            ans = gcd(ans, df)
    print(ans)
    return


main()


Measured memory_bytes: 14052
#include <cstdio>
#include <cstring>
using namespace std;

typedef long long STATES;

int main( void )
{
	STATES free_days[31], dp[51];
	STATES goal_state, next;
	register int i;
	int j, n, answer, free_day, k;

	while ( scanf( "%d", &n ) == 1 && n )
	{
		memset( free_days, 0, sizeof(STATES)*31 );
		memset( dp, 0, sizeof(STATES)*n );

		goal_state = 0;
		for ( i = 0; i < n; i++ ) goal_state |= 1LL << i;

		for ( i = 0; i < n; i++ )
		{
			scanf( "%d", &k );
			for ( j = 0; j < k; j++ )
			{
				scanf( "%d", &free_day );
				free_days[free_day] |= 1LL << i;
			}
		}

		answer = -1;
		for ( i = 0; i < n; i++ ) dp[i] = 1LL << i;
		for ( i = 1; answer == -1 && i <= 30; i++ )
		{
			next = 0;
			for ( j = 0; j < n; j++ ) if ( free_days[i] & ( 1LL << j ) ) next |= dp[j];
			for ( j = 0; j < n; j++ ) if ( free_days[i] & ( 1LL << j ) ) dp[j] |= next;
			if ( next == goal_state ) answer = i;
		}

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

	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int MOD = 1e9+7;

vector<int> getDivs(int N) {
	vector<int> ret;
	for (int i = 1; i*i <= N; i++) {
		if (N%i == 0) {
			ret.push_back(i);
			if (i*i < N) ret.push_back(N/i);
		}
	}
	sort(ret.begin(), ret.end());
	return ret;
}

ll memo[2000];
ll powMod(ll x, ll p) {
	if (x == 0) return 0;
	if (p == 0) return 1;
	if (p == 1) return x;
	if (p%2 == 1) return x*powMod(x, p-1) % MOD;
	ll tmp = powMod(x, p/2);
	return tmp * tmp % MOD;
}

int main() {
	int N, K;
	cin >> N >> K;
	auto divs = getDivs(N);
	int M = divs.size();
	ll ans = 0;
	for (int i = 0; i < M; i++) {
		ll& res = memo[i];
		res = powMod(K, (divs[i]+1)/2);
		for (int j = 0; j < i; j++)
			if (divs[i]%divs[j] == 0) res -= memo[j];
		res = ((res%MOD)+MOD) % MOD;
		if (divs[i]%2 == 0) (ans += res*divs[i]/2%MOD) %= MOD;
		else (ans += res*divs[i]%MOD) %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<ll, ll> 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 Per(i,sta,n) for(int i=n-1;i>=sta;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++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n,m;ll d[100010]={INF};
set<P> S;
vector<P> seg_start[100010];
vector<int> seg_end[100010];
bool visited[100010];
int c[100010],l[100010],r[100010];

void solve(){
    cin >> n >> m;
    rep(i,m) {
        cin >> l[i] >> r[i] >> c[i];
        seg_start[l[i]-1].push_back(P(i,c[i]));
        seg_end[r[i]-1].push_back(i);
    }
    d[0]=0;
    for(P p:seg_start[0]){
        S.insert(P(d[0]+p.second,p.first));
    }
    Rep(i,1,n){
        //cout << i << endl;
        if (S.empty()) {
            cout << -1 << endl;
            return;
        }
        while(visited[(*S.begin()).second]) {
            S.erase(S.begin());
            if (S.empty()) {
            cout << -1 << endl;
            return;
            }
        }
        
        d[i]=(*S.begin()).first;
        if (d[i]==INF) {
            cout << -1 << endl;
            return;
        }
        for(P p:seg_start[i]){
            S.insert(P(d[i]+p.second,p.first));
        }
        for(int a:seg_end[i]){
            visited[a]=true;
        }
        //cout << i << " " << d[i] << endl;
    }
    cout << d[n-1] << endl;
}

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

Measured memory_bytes: 16640
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll [[maybe_unused]] = long long;
using ull [[maybe_unused]] = unsigned long long;
using ld [[maybe_unused]] = long double;

[[maybe_unused]] static constexpr int mod = (int)1e9 + 7;
[[maybe_unused]] static constexpr int inf = 100100100;
[[maybe_unused]] static constexpr ll linf = 1e18;
[[maybe_unused]] static constexpr double eps = 1e-9;
[[maybe_unused]] static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, a) for (ll i = a; i >= 0; --i)
#define all(obj) begin(obj), end(obj)
#define rall(obj) rbegin(obj), rend(obj)
#define pb push_back
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N;
    cin >> N;

    vector<tuple<ll, ll, ll>> r;
    rep (i, N) {
        ll a, b;
        cin >> a >> b;
        r.pb({b, a, i});
    }
    sort(rall(r));
    vector<tuple<ll, ll, ll>> b;
    rep (i, N) {
        ll c, d;
        cin >> c >> d;
        b.pb({c, d, i});
    }
    sort(all(b));
    ll ans = 0;
    rep (i, N) {
        rep(j, N) {
            if (get<1>(r[i]) <= get<0>(b[j]) &&
                get<0>(r[i]) <= get<1>(b[j])) {
                get<0>(b[j]) = -999999;
                get<1>(b[j]) = -999999;
                ++ans;
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
from heapq import heappush, heappop

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())

Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1

grid = []
for _ in range(H):
	grid.append(list(c == "." for c in input().strip()))

m = H * W + 1
smallests = [[m] * W for _ in range(H)]

queue_move = [(0, Cw, Ch)]
queue_warp = [(0, Cw, Ch)]
smallests[Ch][Cw] = 0

def calc():
	while queue_move or queue_warp:
		if queue_move:
			d, x, y = heappop(queue_move)
			if d == smallests[y][x]:
				for dx, dy in ((-1, 0), (1, 0), (0, -1), (0, 1)):
					tx = x + dx
					ty = y + dy
					if tx >= 0 and tx < W and ty >= 0 and ty < H:
						if grid[ty][tx] and d < smallests[ty][tx]:
							smallests[ty][tx] = d
							heappush(queue_move, (d, tx, ty))
							heappush(queue_warp, (d, tx, ty))
		else:
			d, x, y = heappop(queue_warp)
			if d == smallests[y][x]:
				d += 1
				for tx in range(max(0, x - 2), min(W, x + 3)):
					for ty in range(max(0, y - 2), min(H, y + 3)):
						if grid[ty][tx] and d < smallests[ty][tx]:
							smallests[ty][tx] = d
							heappush(queue_move, (d, tx, ty))
							heappush(queue_warp, (d, tx, ty))
	return smallests[Dh][Dw]

result = calc()
if result == m:
	print(-1)
else:
	print(result)


Measured memory_bytes: 131072
#include<bits/stdc++.h>
using namespace std;
int main(void){
  string s,t;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  int l = s.length();
  if( l > t.length())l = t.length();
  for(int i=0;i<l;i++){
  	if(s[i] < t[t.length()-i-1]){
  		cout<<"Yes"<<endl;
  		return 0;
  	}else if(s[i]>t[t.length()-i-1]){
  		cout<<"No"<<endl;
  		return 0;
  	}
  }
  if(t.length() > s.length()){
  	cout<<"Yes"<<endl;
  	return 0;
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
const int INF = 1100000000;
const int H_MAX = 10000;
const int N_MAX = 1000;

int main() {
	int h, n;
	cin >> h >> n;
	int dp[N_MAX+1][H_MAX+1];
	for (int i = 0; i <= n; i++) dp[i][0] = 0;
	for (int j = 1; j <= h; j++) dp[0][j] = INF;
	for (int i = 1; i <= n; i++) {
		int a, b;
		cin >> a >> b;
		for (int j = 1; j <= h; j++) {
			int v1 = dp[i-1][j];
			int v2 = b + dp[i-1][max(0, j-a)];
			int v3 = b + dp[i][max(0, j-a)];
			dp[i][j] = min({v1, v2, v3});
		}
	}
	int ans = dp[n][h];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 39296
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	const int MAX = 1'100'000;
	int N;
	int ans = 0;
	vector<int> con(MAX);
	vector<int> flag(MAX);
	
	cin>>N;
	
	for(int i = 0; i < N; i++){
		int A;
		
		cin>>A;
		
		con[A]++;
	}
	
	for(int i = 1; i < MAX; i++){
		if(con[i] == 0) continue;
		
		if(con[i] >= 2) flag[i] = true;
		
		for(int j = i * 2; j < MAX; j += i){
			flag[j] = true;
		}
		
		if(flag[i] == false) ans++;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 20296
fn main(){
    let v:Vec<_> = getline().trim().split(' ').map(|e| e.parse::<i64>().unwrap()).collect();
    
    let n = v[0];
    let m = v[1];
    let c = v[2];
    let b:Vec<_> = getline().trim().split(' ').map(|e| e.parse::<i64>().unwrap()).collect();
    
    let mut ans = 0;
    
    for i in 0..n{
        let v:Vec<_> = getline().trim().split(' ').map(|e| e.parse::<i64>().unwrap()).collect();
        let mut total = c;
        for j in 0..m{
            total += v[j as usize]*b[j as usize];
        }
        if total > 0{
            ans += 1;
        }
    }
    
    println!("{}", ans);
}

fn getline() -> String{
    let mut __ret=String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s; cin >> s;
    int n=s.size();

    int j=0; //R...RL...Lに分解
    vector<string> t(1,"R");
    for(int i=1; i<n; ++i){
        if(s[i]=='R' && s[i-1]=='L'){
            t.push_back("");
            ++j;
        }
        t[j] += s[i];
    }
    for(int i=0; i<j+1; ++i){
        int r, nt=t[i].size();
        vector<int> v(nt,0);
        for(int k=0; k<nt; ++k){
            if(t[i][k]=='R' && t[i][k+1]=='L'){
                v[k]=(nt+1)/2; //kが偶数と仮定
                v[k+1]=nt/2;
                if(k%2==1) swap(v[k],v[k+1]);
                break;
            }
        }
        for(int k : v) cout << k << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3320
function main(input) {
    var n, m, tmp, a, b, c, g, dist, i, j, k, inf, t, negativeLoop;
    inf = -100000000000000;

    tmp = input[0].split(" ");
    n = parseInt(tmp[0]);
    m = parseInt(tmp[1]);

    g = [];
    dist = [];
    for (i = 0; i < n; i++) {
        g.push([]);
        dist.push(inf)
    }
    dist[0] = 0;

    for (i = 0; i < m; i++) {
        tmp = input[1 + i].split(" ");
        a = parseInt(tmp[0]) - 1;
        b = parseInt(tmp[1]) - 1;
        c = parseInt(tmp[2]);
        g[a].push([b, c]);
    }

    for (k = 0; k < n; k++) {
        for (i = 0; i < n - 1; i++) {
            if (dist[i] === inf) {
                continue;
            }
            for (j = 0; j < g[i].length; j++) {
                t = g[i][j][0];
                c = g[i][j][1];
                if (dist[t] < dist[i] + c) {
                    dist[t] = dist[i] + c;
                }
            }
        }
    }

    negativeLoop = false;
    for (k = 0; k < n; k++) {
        for (i = 0; i < n; i++) {
            if (dist[i] === inf) {
                continue;
            }
            for (j = 0; j < g[i].length; j++) {
                t = g[i][j][0];
                c = g[i][j][1];
                if (dist[t] < dist[i] + c) {
                    dist[t] = dist[i] + c;
                    if (t === n - 1) {
                        negativeLoop = true;
                        break;
                    }
                }
            }
            if (negativeLoop) {
                break;
            }
        }
    }

    if (negativeLoop) {
        console.log("inf");
    } else {
        console.log(dist[n - 1]);
    }
}

main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));

Measured memory_bytes: 10556
#include<iostream>
using namespace std;
int main(){
  bool flag;
  int M, N, L, ans, mon;
  while(1){
    ans = flag = 0;
    cin >> L;
    if(L == 0) break;
    for(int i = 1; i <= 12; i++){
      cin >> M >> N;
      ans += (M - N);
      if(L <= ans && flag == 0){
	flag = 1;
	mon = i;
      }
    }
    if(flag == 0) cout << "NA" << endl;
    else cout << mon << endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

int n, k;
int c[200004];
int v;

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		int a; cin >> a;
		if (c[a] == 0) ++v;
		++c[a];
	}
	sort(c, c + 200004);
	if (v <= k) {
		cout << 0 << endl;
		return 0;
	}
	int ans = 0;
	int t = 0;
	for (t = 0; t < 200004; ++t) {
		if (c[t] != 0) break;
	}
	for (int i = t; i < t + v - k; ++i) {
		ans += c[i];
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  int ans = 1001;
  int k = 0;
  
  for(int i = 0; i < S.size() - T.size() + 1; i++){
    for(int j = 0; j < T.size(); j++){
      if(S.at(i + j) != T.at(j)) k++;
    }
    if(k < ans) ans = k;
    k = 0;
  }
  
  cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n) {
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for(auto v : mp) {
        if(v.second % 2 != 0) {
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}


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

using ll=long long;

int main() {
  char s; cin >>s;
  char ans='a';
  if (isupper(s)) ans='A';
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    i64 n;
    cin >> n;
    vector<i64> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    vector<int> c(n);
    iota(begin(c), end(c), 0);
    sort(begin(c), end(c), [&](int i, int j) {
        return a[i] + b[i] > a[j] + b[j];
    });

    i64 x = 0, y = 0;
    for (int i = 0; i < n; ++i) {
        int j = c[i];
        if ((i & 1) == 0) {
            x += a[j];
        } else {
            y += b[j];
        }
    }

    cout << x - y << endl;
    return 0;
}


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

int main(){
  int a,b;
  int c[7];
  for(int i=0;i<7;i++){
    cin>> a>> b;
    c[i]=a-b;
  }

  for(int i=0;i<7;i++){
    cout<< c[i]<< endl;;
  }
}

Measured memory_bytes: 1160
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <queue>
#include <stack>
#include <string>
#include <cmath>
#include <bitset>

#define rep(i,a) for(int i = 0;i < (a); i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)
#define repd(i,a,b) for(int i = (a); i >= (b); i--)
#define repit(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())
#define pb push_back
#define mp make_pair
#define INF 1e10
#define EPS 1e-10
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
int n, m, a;
struct node{
  int h;
  int p;
  int q;
  bool operator<(const node &o) const{
    return h < o.h;
  }
};
int main(){
  while(cin >> n >> m >> a, n||m||a){
    int h, p, q;
    priority_queue<node> pq;
    rep(i, m){
      cin >> h >> p >> q;
      pq.push((node){h, p, q});
    }
    while(!pq.empty()){
      int p = pq.top().p;
      int q = pq.top().q;
      pq.pop();
      if(p == a){
	a = q;
      }else if(q == a){
	a = p;
      }
    }
    cout << a << endl;
  }
}

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

int main(){
    long long inf = pow(10,9)+7;
    int n;
    cin>>n;
    vector<long long> a(n);
    long long sum = 0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum += a[i];
    }
    long long ans = 0;
    long long his = 0;
    for(int i=0;i<n;i++){
        his += a[i];
        long long tmp = a[i] * ((sum-his)%inf);
        tmp = tmp%inf;
        ans = (ans+tmp)%inf;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4828
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int n = Integer.parseInt(bf.readLine());
 		
	 		ArrayList<Integer> array = new ArrayList<Integer>();
	 		StringTokenizer st2 = new StringTokenizer(bf.readLine());
	 		for(int j=0;j<n;j++){
	 			array.add(Integer.parseInt(st2.nextToken()));
	 		}
	 		int count = 0;
	 	for(int i = 0;i<array.size();i++){
	 		if (array.get(i)%2 == 1 && (i+1)%2 == 1)
	 			count++;
	 	}
 		
 		
 		out.println(count);
	 		
 		out.close();
 		
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 25368
def calc(i):
    if i<0.2:return 3
    elif 0.2<=i<0.6:return 2
    elif 0.6<=i<1.1:return 1
    else:return 0

r_ans=[0]*4
l_ans=[0]*4
while 1:
    try:
        l,r=map(float,raw_input().split())
        l_ans[calc(l)]+=1
        r_ans[calc(r)]+=1
    except:
        break
for i in xrange(4):
    print l_ans[i],r_ans[i]

Measured memory_bytes: 6340
N = int(input())
A = [int(input()) for v in range(N)]

L = A[:]
m1 = max(A)
m1i = A.index(m1)
A.pop(m1i)
m2 = max(A)
m2i = A.index(m2)
A.pop(m2i)

for i in range(N):
    if (L[i] == m1):
        print(m2)
    else:
        print(m1)


Measured memory_bytes: 14060
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String b = sc.next();
        
        switch(b){
            case "A":
                System.out.println("T");
                break;
            case "T":
                System.out.println("A");
                break;
            case "G":
                System.out.println("C");
                break;
            case "C":
                System.out.println("G");
                break;
            default:
                System.out.println("You Wrong");
                break;
        
    }
        
        
    }
  
}

Measured memory_bytes: 20948
import numpy as np
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
N=int(input())
a=list(map(int,input().split()))
ave=int(Decimal(np.average(a)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
sum=0
for i in range(N):
    sum+=pow(a[i]-ave, 2)
print(sum)

Measured memory_bytes: 13792
#include <iostream>

int main()
{
    int X;
    std::cin >> X;
    constexpr int RANGE_MAX = 120;
    int pow5[RANGE_MAX];
    for (int i = 0; i < RANGE_MAX; i++)
    {
        pow5[i] = i * i * i * i * i;
    }

    for (int A = 0; A < RANGE_MAX; A++)
    {
        for (int B = 0; B < A; B++)
        {
            if (pow5[A] - pow5[B] == X)
            {
                std::cout << A << " " << B << std::endl;
                return 0;
            }
            else if (pow5[A] + pow5[B] == X)
            {
                std::cout << A << " " << -B << std::endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define ll long long
struct colorr
{
    ll index;
    ll color;
};
colorr s1[100100];
ll number[100100];
int line(const void*a,const void*b)
{
    return (*(colorr *)a).color-(*(colorr *)b).color;
}
int main()
{
    ll a,b;
    ll n,sum;
    while(scanf("%lld",&n)!=EOF)
    {
        sum=0;
        for(a=1; a<=n; a++)
        {
            scanf("%lld",&s1[a].color);
            s1[a].index=a;
        }
        qsort(s1+1,n,sizeof(s1[0]),line);
        for(a=1; a<=n; a++)
        {
            if(a==1)
                number[a]=s1[a].color;
            else
            {
                number[a]=s1[a].color+number[a-1];
            }
        }
        for(a=n; a>=1; a--)
        {
            if(a==n)
                sum++;
            else
            {
                ll all=number[a];
                if(all*2>=s1[a+1].color)
                    sum++;
                else break;
            }
        }
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 3324
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=22e5+10;
int N,M;
int dist[maxn],vis[maxn];
struct Rail{int y,val;};
struct node
{
    int y,c;
    friend bool operator<(node A,node B){return (A.y==B.y)?(A.c<B.c):(A.y<B.y);}
};
struct Node{int y,Next,c;};
vector<node> real_emp;
vector<Node> emp_emp;
vector<Rail> v[maxn];
inline long long read()
{
    long long s=0,f=1; char ch; for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=-1;
    for(;ch>='0'&&ch<='9';ch=getchar()) s=(s<<3)+(s<<1)+ch-'0'; return s*f;
}
void Dj(int st)
{
    priority_queue< pair<int,int> > q;
    memset(dist,0x3f,sizeof(dist));
    memset(vis,0,sizeof(vis));
    dist[st]=0; q.push(make_pair(0,st));
    while(!q.empty())
    {
        int x=q.top().second; q.pop();
        if(vis[x]) continue; vis[x]=1;
        for(register int i=0;i<v[x].size();++i)
        {
            int y=v[x][i].y,val=v[x][i].val;
            if(dist[y]>dist[x]+val)
            {
                dist[y]=dist[x]+val;
                q.push(make_pair(-dist[y],y));
            }
        }
    }
}
void Input()
{
    N=read(),M=read();
    int xx,yy,zz;
    for(register int i=1;i<=M;++i)
    {
        xx=read()-1,yy=read()-1,zz=read()-1;
        real_emp.push_back((node){xx,zz});
        real_emp.push_back((node){yy,zz});
        emp_emp.push_back((Node){xx,yy,zz});
        emp_emp.push_back((Node){yy,xx,zz});
    }
}
void Solution()
{
    Input();
    sort(real_emp.begin(),real_emp.end());
    for(register int i=0;i<real_emp.size();++i)
    {
        v[N+i].push_back((Rail){real_emp[i].y,1});
        v[real_emp[i].y].push_back((Rail){N+i,1});
    }
    for(register int i=0;i<emp_emp.size();++i)
    {
        int pos1=lower_bound(real_emp.begin(),real_emp.end(),(node){emp_emp[i].y,emp_emp[i].c})-real_emp.begin();
        int pos2=lower_bound(real_emp.begin(),real_emp.end(),(node){emp_emp[i].Next,emp_emp[i].c})-real_emp.begin();
        v[N+pos1].push_back((Rail){N+pos2,0});
    }
    Dj(0);
    printf("%d\n",(dist[N-1]==1061109567)?-1:(dist[N-1]>>1)); exit(0);
}
int main()
{
    Solution();
}


Measured memory_bytes: 108668
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, y, z; cin >> x >> y >> z;
    cout << z << ' ' << x << ' ' << y << '\n';
    return 0;
}


Measured memory_bytes: 256
//The new goal: to learn  GRAPHS  & DYNAMIC PROGRAMMNING during the summer, on God`s will
#include <iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stack>
#include<cmath>
#include<set>
using namespace std;
typedef long long ll;

int main() {
    int a; cin>>a;
    cout<<pow(a,2)+pow(a,3)+a<<endl;
    return 0;
}

Measured memory_bytes: 4256
n, k = map(int,input().split())

lis_d = [];
lis_A = [];

for i in range(k):
    d = int(input());
    A = list(map(int, input().split()));
    lis_d.append(d);
    lis_A.append(A);

all_A = []
for a in lis_A:
    all_A += a;

all_A = set(all_A)

all_num = set(range(1, n + 1));

ans = len(list(all_num - all_A));
print(ans)

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

int main()
{
	int A,B;
	cin>>A>>B;
	if(A%3==0||B%3==0||(A+B)%3==0)
	{
		cout<<"Possible";
	}
	else
	{
		cout<<"Impossible";
	}
	return 0;
}

Measured memory_bytes: 3128
import java.util.*;

public class Main {
    static Scanner scanner;

    public static void main(String[] args) {
        scanner = new Scanner(System.in);
        int x = nextInt();
        int y = nextInt();
        double turu = 2 * x - y / 2.0;
        double kame = y / 2.0 - x ;
        if (turu < 0 || kame < 0) {
            System.out.println("No");
            return;
        }
        if (Math.ceil(turu) == Math.floor(turu) && Math.ceil(kame) == Math.floor(kame)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static void println(Object o) {
        System.out.println(o);
    }

    public static void print(Object o) {
        System.out.print(o);
    }

    public static void printf(String format, Object... o) {
        System.out.printf(format, o);
    }

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

    public static long nextLong() {
        return Long.parseLong(scanner.next());
    }

    public static double nextDouble() {
        return Double.parseDouble(scanner.next());
    }

    public static short nextShort() {
        return Short.parseShort(scanner.next());
    }

    public static float nextFloat() {
        return Float.parseFloat(scanner.next());
    }

    public static void printYes() {
        System.out.println("Yes");
    }

    public static void printYES() {
        System.out.println("YES");
    }

    public static void printNo() {
        System.out.println("No");
    }

    public static void printNO() {
        System.out.println("NO");
    }

    public static void nextLine() {
        scanner.nextLine();
    }

    public static double distance(double x, double y, double x2, double y2) {
        return Math.sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y));
    }

    public static int MOD = 1_000_000_007;
    public static int MAX = 100000;
    public static long[] fac = new long[MAX];
    public static long[] finv = new long[MAX];
    public static long[] inv = new long[MAX];

    public static void combinit() {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    public static long combination(int n, int k) {
        if (n < k || n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }

    public static long factorial(long n) {
        return n <= 0 ? 1 : n * factorial(n - 1);
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F            first
#define S            second
#define pb(x)        push_back(x)
#define mp(a,b)      make_pair(a,b)
#define mt(a,b,c)    make_tuple(a,b,c)
#define sz           size()
#define all(A)       A.begin(), A.end()
#define mem(a, b)    memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)      for(ll i=0;i<(b);i++)
#define f1(i,b)      for(ll i=1;i<=(b);i++)
#define f2(i,a,b)    for(ll i=(a);i<=(b);i++)
#define f3(i,b,a)    for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))

#define mod          10000007
#define PI           acos(-1.0)
#define MAX3(a,b,c)  max(a,max(b,c))

#define whilee(i,t)  while(i!=t)
#define  sl(a)       scanf("%lld",&a)
#define  pl(a)       printf("%lld\n",a)

//x = 1e18 means 10^18
//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end()); //sort(A, +n, greater<int>());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//printf("%I64d\n", a);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

// int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1};  // 4 Direction
// int dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1};  // 8 Direction
// int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1};  // Knight Direction
// int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1};  // Hexagonal Direction

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//unordered_map <ll, ll> A;
//pair <ll,ll> A ;
//tuple <ll, ll, ll> A;
//vector <pair <ll,ll>> A;
//bitset<32> bset1;
//bool ok = true;
//char ch;
//string S, T, U;

ll i=0, j=0, k=0, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, flag=0, cnt=0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);//NULL
    cout.tie(nullptr);//NULL

    cin>>a>>b;
    cout<<ceil(a/(double)b)<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func mainFn() {
	n := getInt()
	as := getIntSlice(n)

	b := make([]int, n)
	l, r := 0, n-1
	for i := n - 1; i >= 0; i-- {
		if (i % 2) != (n % 2) {
			b[l] = as[i]
			l++
		} else {
			b[r] = as[i]
			r--
		}
	}

	for i := range b {
		puts(b[i])
	}
}

// -----------------------------------------

var (
	scanner = bufio.NewScanner(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// scanner.Buffer(make([]byte, buf), buf)
	scanner.Split(bufio.ScanWords)
	mainFn()
	writer.Flush()
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}

func puts(a ...interface{}) {
	if _, err := fmt.Fprintln(writer, a...); err != nil {
		panic(err)
	}
}


Measured memory_bytes: 9344
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, A[int(2e5 + 5)], ans[int(2e5 + 5)];
vector <int> Graph[int(2e5 + 5)];

int Now[int(2e5 + 5)];
int DFS(int node){
  int Before, L = 0;
  if (A[node] <= Now[0]){
    Before = Now[0];
    Now[0] = A[node];
  }else{
    int R = N;
    while (R - L > 1){
      int mid = (L + R) / 2;
      if (A[node] >= Now[mid]) L = mid;
      else R = mid;
    }
    if (A[node] > Now[L]) L++;
    Before = Now[L];
    Now[L] = A[node];
  }

  int ansL = 0, ansR = N;
  while (ansR - ansL > 1){
    int mid = (ansL + ansR) / 2;
    if (Now[mid] < 1e9 + 1) ansL = mid;
    else ansR = mid;
  }
  ans[node] = ansL + 1;

  for (int i = 0; i < Graph[node].size(); i++){
    int next = Graph[node][i];
    if (ans[next] != 0) continue;
    DFS(next);
  }
  Now[L] = Before;
  return 0;
}

int main(){
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%d", A + i);
  for (int i = 0; i < N - 1; i++){
    int U, V; scanf("%d%d", &U, &V);
    Graph[U].push_back(V);
    Graph[V].push_back(U);
  }
  fill(Now, Now + N + 2, 2e9);
  DFS(1);

  for (int i = 1; i <= N; i++){
    printf("%d\n", ans[i]);
  }

  return 0;
}


Measured memory_bytes: 28348