akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(v, n) { rep(_, n) cout << v[_].F << " " << v[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, a) (int)(lower_bound(all(v), a) - v.begin())
#define UB(v, a) (int)(upper_bound(all(v), a) - v.begin())

int main() {
    int n, k;
    cin >> n >> k;
    
    vector<int> a(n);
    int sum = 0; // <= 500 * 10^6
    rep(i, n) { cin >> a[i]; sum += a[i]; }
    
    sort(all(a));
    
    // 約数全列挙
    // 数列の数をa, b, cとする
    // a', b', c'になるとする
    // sum = a + b + c = a' + b' + c'
    // g = gcd(a', b', c')
    // sum % g = 0
    // gはsumの約数
    set<int> s;
    for (int i = 1; i * i <= sum; ++i) {
        if (sum % i == 0) {
            s.insert(i);
            s.insert(sum / i);
        }
    }
    
    // その候補にk回以下でできるか
    ll ans = 1; // 最悪、例えばk = 0のときg = 1. すべて、1で割った余りは0
    for (auto x : s) {
        // out("x " << x);
        
        // x = 7
        // 数列 1 1 2 2 3 5
        
        // 上側にする残り 6 6 5 5 4 2
        // 下側(今回たまたますべて0にする)にする残り 1 1 2 2 3 5
        // 各列、6 + 1 = 7, 5 + 2 = 7, ...
        // 余りか倍数にする残り足してるからそりゃxになる
        // すべて上側にするとすると28
        // 2つ下側にしたら28 - 14 = 14と、sumになる
        // どの2つを下側にするか
        
        // 例えば2を下側に、3を上側にするとする    1.
        // (上側数列)5 4, (下側)2 3
        // 上側 -> A、下側 -> B
        // B -= 2, A += 3
        // 逆に2を上側に、3を下側にするとする    2.
        // A += 5(7との差), B -= 3
        // AにしてもBにしても1.の方が少なくいける
        // Aが大きいならBが小さい(合計が一定)
        
        // 6 6 5 5 4 2に関して、右側(小さい)ほどAにした方がいい
        // 回数をAの総和でcountしてる
        
        // すべてAにして総和は28
        // 左4つをBにしたら28 - 7 * 4 = 0
        // countは右2つの4 + 2 = 6
        
        ll A = 0; // すべてAにする
        int b[n];
        rep(i, n) { b[i] = x - a[i] % x; A += b[i]; } // += にしてて初期化してないから事故った
        // outa(b, n);
        
        A /= x; // 何個左にするか(28 / 7 = 4)
        // out("A " << A);
        
        sort(b, b + n);
        ll need = 0;
        rep(i, n - A) {
            need += b[i];
        }
        // out("need " << need);
        if (need <= k) chmax(ans, x);
    }
    out(ans);
}


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

#define ll long long 

ll s, h1, w, w1, h2;
const ll MAXN = 1e9;

int main(){
	scanf("%lld", &s);
	// Find smallest factor that can divide s, let X and S/X+1 be h1 and W
	ll l = 1, r = min(s, MAXN);
	while(l < r){
		ll mid = (l+r)/2;
		if(s/mid < MAXN){
			r = mid;
		}else{
			l = mid+1;
		}
	}
	h1 = l; w = s/l;
	if(s%l != 0){
		w++;
	}
	ll curA = h1*w;
	ll toCut = curA-s;
	w1 = 1; h2 = toCut;
	for(ll i = 2; h2 > MAXN; i++){
		while(h2%i == 0){
			w1 *= i;
			h2 /= i;
		}
	}
	assert(w1*h1 + (w-w1)*(h1+h2) - w*h2 == s);
	printf("0 0 %lld %lld %lld %lld\n", w1, h1, w, h2);
}

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

import sys
def input(): return sys.stdin.readline().strip()
    
from heapq import heappop, heappush

# 今回はダイクストラするので、データの持ち方は隣接リスト
N = int(input())
nodes = [[] for _ in range(N+1)]
for i in range(N-1):
    a, b, c = map(int, input().split())
    # nodes[出発ノード](到着ノード, コスト))
    nodes[a].append((b, c))
    # 無向グラフなのでこっちも入れる
    nodes[b].append((a, c))

def dijkstra(nodes, start):
    # 最短距離メモ
    memo = [float('inf')] * (len(nodes))
    # スタート位置
    que = [(0, start)]
    memo[start] = 0
    # キューが空になるまで
    while len(que) != 0:
        # startからの距離, 現在のノード
        dist, cur = heappop(que)
        # 出発ノードcurの到着ノードでループ
        for nxt, cost in nodes[cur]:
            # 今回の経路のが短い時
            if memo[cur] + cost < memo[nxt]:
                memo[nxt] = memo[cur] + cost
                # 現在の移動距離をキューの優先度として、早い方から先に処理するようにする
                heappush(que, (memo[nxt], nxt))
    # ノードstartからの最短距離リストを返却
    return memo

Q, K = map(int, input().split())
# 引数：(ノードの隣接リスト, 出発ノード)
memo = dijkstra(nodes, K)

for i in range(Q):
    x, y = map(int, input().split())
    # 今回は全てKを経由するので、Kからの距離さえ分かれば全部出る
    print(memo[x] + memo[y])


Measured memory_bytes: 46268
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll a[105][105],b[105];
int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            
            ans += a[i][j] * b[j];
            
        }
        cout << ans << endl;
        ans = 0;
    }
    return 0;
}



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

#define lightfly 48.00
#define fly 51.00
#define bantam 54.00
#define feather 57.00
#define light 60.00
#define lightwelter 64.00
#define welter 69.00
#define lightmiddle 75.00
#define middle 81.00
#define lightheavy 91.00
int main()
{
    double weight;
    while(cin >> weight)
    {
        if(weight <= lightfly) cout << "light fly" << endl;
        else if(weight <= fly) cout << "fly" << endl;
        else if(weight <= bantam) cout << "bantam" << endl;
        else if(weight <= feather) cout << "feather" << endl;
        else if(weight <= light) cout << "light" << endl;
        else if(weight <= lightwelter) cout << "light welter" << endl;
        else if(weight <= welter) cout << "welter" << endl;
        else if(weight <= lightmiddle) cout << "light middle" << endl;
        else if(weight <= middle) cout << "middle" << endl;
        else if(weight <= lightheavy) cout << "light heavy" << endl;
        else cout << "heavy" << endl;
    }
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long 
  #define float double
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define pb push_back
  int32_t main()
  { 
      IOS
      int n;
      cin>>n;
      
      int b[n-1];
      for(int i=0;i<n-1;i++)
      {
        cin>>b[i];
      }
      
      int sum=b[0]+b[n-2];
      for(int i=1;i<n-1;i++)
      {
        sum+=min(b[i],b[i-1]);
      }        
      cout<<sum;
        return 0;
  }

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int x,y,s,reg,max,l,reg2;
        for(;;){
        	reg=0;
        	max=0;
        	x=sc.nextInt();
        	if(x==0){
        		return;
        	}
        	y=sc.nextInt();
        	s=sc.nextInt();
        	for(int i=1;i<s;i++){
        		for(int j=1;j<s;j++){
        			reg2=i*(100+x)/100+j*(100+x)/100;
        			if(reg2==s){
        				reg=i*(100+y)/100+j*(100+y)/100;
        				if(reg>max){
        					max=reg;
        				}
        			}
        		}
        	}
        	System.out.println(max);
        }
    	
    }
}


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

void bubbleSort(vector<string> &c, int n) {
    for (int i = 0; i < n; i++) {
        for (int j = n-1; j > i; j--) {
            if (c.at(j)[1] < c.at(j-1)[1]) swap(c.at(j), c.at(j-1));
        }
    }
}

void selectionSort(vector<string> &c, int n) {
    for (int i = 0; i < n; i++) {
        int minj = i;
        for (int j = i; j < n; j++) {
            if (c.at(j)[1] < c.at(minj)[1]) minj = j;
        }
        swap(c.at(i), c.at(minj));
    }
}

void printOut(vector<string> c, int n) {
    for (int x = 0; x < n; x++) {
        if (x) cout << " ";
        cout << c.at(x);
    }
    cout << endl;
}

bool isStable(vector<string> c1, vector<string> c2, int n) {
    for (int i = 0; i < n; i++) {
        if (c1.at(i) != c2.at(i)) return false;
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    vector<string> c1(n);
    vector<string> c2(n);
    for (int i = 0; i < n; i++) {
        cin >> c1.at(i);
    }
    for (int i = 0; i < n; i++) c2[i] = c1[i];
    bubbleSort(c1, n);
    selectionSort(c2, n);

    printOut(c1, n);
    cout << "Stable" << endl;
    printOut(c2, n);
    if (isStable(c1, c2, n)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    return 0;
}



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

int main()
{
	int N;
	std::string S;
	std::cin >> N >> S;
	for (auto& e: S)
		e = ((e - 'A') + N) % 26 + 'A';
	std::cout << S << std::endl;

	return 0;
}

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

import sys

DEBUG = False

def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep = " "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    n, k = read_list(int)
    print(min(n, n - (n // k) * k, abs(n - (n // k + 1) * k)))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
#define tl 1'000'000'007
ll powmod(ll x){
    if(x==0) return 1;
    return 2*powmod(x-1)%tl;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll>A(n);
    map<ll,ll>p;
    REP(i,n){
        cin >> A[i];
        p[A[i]]++;
        if(p[A[i]]>1) A[i]*= -1;
    }
    sort(A.begin(), A.end());
    // REP(i,n) cout << A[i] << endl;
    ll cc= -(n-1);
    int flag= 1;
    REP(i,n){
        if(A[i]!=cc) flag=0;
        cc+= 2;
    }
    ll ans= powmod(n/2)*flag;
    cout << ans << endl;
    
}

Measured memory_bytes: 5760
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;


template<class Abel> class WeightedUnionFind{
    vector<ll> par; 
    vector<ll> r_size; 
    vector<ll> rank; 
    vector<Abel> diff_weight;
    public:
        WeightedUnionFind(ll N, Abel SUM_UNITY = 0){
            init(N, SUM_UNITY);
        }

        //Nの大きさで初期化
        void init(ll N, Abel SUM_UNITY = 0){
            par.resize(N); r_size.resize(N); rank.resize(N); diff_weight.resize(N);
            for(int i=0; i<N; ++i){ par[i] = i; r_size[i] = 1; rank[i] = 0; diff_weight[i] = SUM_UNITY; }
        }

        ll root(ll x){
            if(par[x] == x)return x;
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }

        Abel get_weight(int x){
            root(x);
            return diff_weight[x];
        }

        ll diff(int x, int y){
            return get_weight(y) - get_weight(x);
        }

        //xとyとが所属する集合を併呑する
        //なお，weight(y) - weight(x) = wとなるようにmerge
        void merge(ll x, ll y, Abel w){
            w += get_weight(x); w -= get_weight(y);
            ll rx = root(x); ll ry = root(y);
            if(rx == ry) return;
            if(rank[rx] < rank[ry]) swap(rx,ry), w = -w;
            if(rank[rx] == rank[ry]) ++rank[rx];
            r_size[rx] += r_size[ry];
            par[ry] = rx;
            diff_weight[ry] = w;
        }

        bool same(ll x, ll y){
            return root(x) == root(y);
        }

        //素集合の大きさを返す
        ll size(ll x){
            return r_size[root(x)];
        }
};

int main(){
    int N, M, l, r, d;
    cin >> N >> M;
    WeightedUnionFind<int> uf(N,0);
    bool ans = true;
    rep(_,M){
        cin >> l >> r >> d;
        --l; --r;
        if(uf.same(l,r) && abs(uf.diff(l,r)) != d)ans = false;
        uf.merge(l,r,d);
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 5876
import java.util.*;

public class Main{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int a[]=new int[n];
    for(int i=0;i<n;i++)
    a[i]=sc.nextInt();
    int[] dp=new int[k+1];
    for(int i=0;i<=k;i++)
    {
      for(int j=0;j<n;j++)
      {
        if(i>=a[j] && dp[i-a[j]]==0)
        dp[i]=1;
      }
    }
    String ans=dp[k]==1?"First":"Second";
    System.out.println(ans);
  }
}

Measured memory_bytes: 36612
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

n = onem()

a = [onem() for i in range(n)]

ans = a[0] - 1

i = 1
co = 2
while i != n:
    if a[i] == co:
        co += 1
        i += 1
    else:
        if a[i] > co:
            if a[i] % co == 0:
                ans += a[i]//co - 1
            else:
                ans += a[i]//co
        i += 1



print(ans)







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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    ll N,M; cin >> N >> M;
    vector<ll> A(N); REP(i,N) cin >> A[i];
    SORT(A); REVERSE(A);
    vector<ll> S(N+1); S[0] = 0;
    REP(i,N) S[i+1] = S[i] + A[i];

    ll xl = 2, xr = 200001, X = (xl+xr)/2;
    while(xr-xl>1){
        ll tmp = 0;
        REP(i,N){
            ll l=-1, r=N, n=(l+r)/2;
            while(r-l>1){
                if(A[i]+A[n]>=X) l = n;
                else r = n;
                n = (l+r)/2;
            }
            tmp += r;
        }
        if(tmp > M) xl = X;
        else xr = X;
        X = (xl+xr)/2;
    }
    ll ans = 0, tmp = 0;
    REP(i,N){
        ll l=-1, r=N, n=(l+r)/2;
        while(r-l>1){
            if(A[i]+A[n]>=xr) l = n;
                else r = n;
                n = (l+r)/2;
        }
        ans += S[r] + r*A[i];
        tmp += r;
    }
    ans += xl*(M-tmp);
    cout << ans << endl;
}

Measured memory_bytes: 1792
import qualified Data.Vector.Unboxed as V
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List
import Data.Maybe

main = do
  n <- readLn  :: IO Integer
  putStrLn $ solve n

solve n = map (chr .(+ ord 'a') . fromIntegral) $ go n []
  where
    go n ns
      | n == 0 = ns
      | otherwise =
          let (p, q) = divMod (n-1) 26
          in go p (q:ns)
  
getInt :: IO Int
getInt = readLn

second :: (b -> c) -> (a, b) -> (a, c)
second f (a, b) = (a, f b)

readInt :: BS.ByteString -> Maybe (Int, BS.ByteString)
readInt = fmap (second BS.tail) . BS.readInt

readIntVec :: Int -> IO (V.Vector Int)
readIntVec n = V.unfoldrN n readInt <$> BS.getLine

readIntList :: IO [Int]
readIntList = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readIntPair :: IO (Int, Int)
readIntPair = do
  v <- readIntVec 2
  return (v V.! 0, v V.! 1)


Measured memory_bytes: 3896
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

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



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

void replace_upper_lower(string &S, int i)
{
  if(S.at(i)>=65&&S.at(i)<=90)
      S.at(i) += 32;
  else if(S.at(i)>=97&&S.at(i)<=122)
      S.at(i) -= 32;
}

int main()
{
  string S;
  
  getline(cin, S);
  
  if(S.size()==0)
    return 0;
  
  
  if(S.size()==1)
  	replace_upper_lower(S, 0);
  else
  {
    for(int i=0;i<S.size()-1;i++)
    {
      replace_upper_lower(S, i);
    }
  }
    
  cout << S << endl;
  
  return 0;
}



Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin >> a;
    int n = 0, s = 0, e = 0, w = 0;
    for(int i = 0; i < a.size(); i++){
        if(a[i] == 'N')
        n++;
        if(a[i] == 'S')
        s++;
        if(a[i] == 'E')
        e++;
        if(a[i] == 'W')
        w++;
    }
    if((n == 0 && s >= 1) || (n >= 1 && s == 0) || (e == 0 && w != 0) || (e != 0 && w == 0))
    cout << "No" << endl;
    else
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
using System;

namespace ABC125
{
    class Program
    {
        static int Main(string[] args)
        {
            Program.ProblemB();
            return 0;
        }

        static int ProblemB()
        {
            int n = int.Parse(System.Console.ReadLine());
            string[] Val = System.Console.ReadLine().Split(' ');
            string[] Cos = System.Console.ReadLine().Split(' ');

            int max;
            max = 0;

            for(int i = 0; i < n; i++)
            {
                int[] m = new int[n];
                m[i] = int.Parse(Val[i]) - int.Parse(Cos[i]);
                if (m[i] > 0) max += m[i];
            }

            System.Console.WriteLine(max);

            return 0;
        }
    }
}

Measured memory_bytes: 13140
using System;
using System.Collections.Generic;
using System.Linq;

public static class Program
{
    public static void Main(string[] args)
    {
        var nm = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var min = 1;
        var max = nm[0];
        for (int i = 0; i < nm[1]; i++)
        {
            var door = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            min = min < door[0] ? door[0] : min;
            max = max > door[1] ? door[1] : max;
        }
        Console.WriteLine(max >= min ? max - min + 1 : 0);
    }
}

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

int main(){
  
  int n, q, b, e;
  
  cin >> n;
  vector<int> A(n);
  vector<int>::iterator a = A.begin();
  for(int i = 0;i < n;i++) cin >> A[i];
  
  cin >> q;
  for(int i = 0;i < q;i++){
    cin >> b >> e;
    reverse(a + b, a + e);
  }
  
  for(int i = 0;i < n;i++){
    cout << (i?" ":"");
    cout << A[i];
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = Integer.parseInt(scan.next());
		int b = Integer.parseInt(scan.next());
		int[][] c= new int[a][b];
		int[] asum = new int[b];
		int[] bsum = new int[a];
		int sumall = 0;
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				c[i][j]=Integer.parseInt(scan.next());
				asum[j]+=c[i][j];
				bsum[i]+=c[i][j];
				sumall+=c[i][j];
			}
		}
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				System.out.print(c[i][j]+" ");
			}
			System.out.println(bsum[i]);
		}
		for(int i=0;i<b;i++) 
			System.out.print(asum[i]+" ");
		System.out.print(sumall+"\r\n");
	}	
}

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


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

  int m[2],d[2];
  rep(i,2) cin >> m[i] >> d[i];
  if(d[0]<d[1]){
    cout << 0 << endl;
  }
  else {
    cout << 1 << endl;
  }
    
  
  return 0;
    

}


Measured memory_bytes: 256
<?php

while (true) {
	$input = trim(fgets(STDIN));
	$input = explode(" ", $input);
	foreach ($input as $value) {
		$args[] = $value;
		if (count($args) >= 2) {
			break;
		}
	}
	if (count($args) >= 2) {
		break;
	}
}


$islands = (int)$args[0];
$request_cnt = (int)$args[1];
$b_count = $islands-1;
$b_array = [];
$cnt = 0;
$requests=[];

while ($cnt < $request_cnt) {
	$input = trim(fgets(STDIN));
	$input = explode(" ", $input);
	$requests[] =[
		"from" => (int)$input[0],
		"to" => (int)$input[1]
	];
	++$cnt;
}
usort($requests, "my_sort");

$result = 0;
$prev = -1;
foreach ($requests as $request) {
	$from = $request["from"];
	$to = $request["to"];
	if ((int)$from < $prev) {
		continue;
	}
	++$result;
	$prev = $to;
}


out($result);



function out($var){
	echo $var , PHP_EOL;
}

function my_sort($a, $b){
	if ($a["to"] == $b["to"]) {
		return $a["from"] < $b["from"] ? -1 : 1;
	}else{
		return $a["to"] < $b["to"] ? -1 : 1;
	}
}

Measured memory_bytes: 50036
#include <iostream>

int ball[10];
bool ans;

void solve();

void dfs(int i, int right, int left);

int main(){
    int n;
    std::cin >> n;
    
    while(n--){
        for(int i = 0; i < 10; ++i)
            std::cin >> ball[i];
        solve();
        if(ans)
            std::cout << "YES" << std::endl;
        else
            std::cout << "NO" << std::endl;
    }
    
    return 0;
}

void solve(){
    ans = false;
    dfs(0, 0, 0);
    return;
}

void dfs(int i, int right, int left){
    if(i == 10){
        ans = true;
        return;
    }
    
    if(ball[i] < right && ball[i] < left)
        return;
    
    if(ball[i] > right)
        dfs(i + 1, ball[i], left);
    else
        dfs(i + 1, right, ball[i]);
    
    if(ans)
        return;
    
    return;
}

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


int main(){
    int N; cin >> N;
    vector<int> A(2 * N);
    for (int i = 0; i < N; i++) {
        int rain_dam; cin >> rain_dam;
        A[i] = A[i + N] = rain_dam;
    }

    vector<int> ans(N);
    // First mountain rainfall.
    int rain_mount = 0;
    for (int i = 0; i < N; i++) {
        rain_mount += A[i] * pow(-1, i % 2);
    }
    ans[0] = rain_mount;
    // The others.
    for (int i = 1; i < N; i++) {
        ans[i] = (A[i - 1] - ans[i - 1] / 2) * 2;
    }

    for (auto elem: ans) cout << elem << " ";
    return 0;
}


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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

int dx4[] = {1, -1, 0, 0};
int dy4[] = {0, 0, 1, -1};
int dx8[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy8[] = {1, -1, 0, 0, 1, -1, -1, 1};

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

struct point {
    int x, y;
    point(): point(0,0){}
    point(int x, int y): x(x), y(y) {}
};

ll bfs(vector<string> ms) {
    queue<point> q;
    q.push(point(0, 0));
    const int H = ms.size(), W = ms[0].length();
    ll d[H][W];
    const point goal(H - 1, W - 1);
    // count
    d[0][0] = 1, d[goal.x][goal.y] = INF;
    while(!q.empty()) {
       auto p = q.front();
       q.pop();
       if (p.x == goal.x && p.y == goal.y) break;
       rep(i, 4) {
           int nx = p.x + dx4[i];
           int ny = p.y + dy4[i];
           if (0 <= nx && nx < H && 0 <= ny && ny < W && ms[nx][ny] == '.') {
               ms[nx][ny] = '#';
               d[nx][ny] = d[p.x][p.y] + 1;
               q.push(point(nx, ny));
           }
       }
    }
    return d[goal.x][goal.y];
}

signed main() {
    int H, W;
    cin >> H >> W;
    vector<string> ms(H);
    rep(i, H) cin >> ms[i];

    auto cost = bfs(ms);

    ll ans = -1;
    if (cost != INF) {
        ll white = 0;
        rep(i, H) rep(j, W) if (ms[i][j] == '.') ++white;
        ans = white - cost;
    }
    cout << ans << nl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int calc(int x, int y) {
	return x * y;
}
int calcNagasa(int x, int y) {
	return 2 * (x + y);
}
int main() {
	int x, y;
	cin >> x >> y;
	cout << calc(x, y);
	cout << " ";
	cout << calcNagasa(x, y) << endl;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;

int main() {
  long long n,k; cin>>n>>k;
  vector<long long>h(n);
  for(long long i=0; i<n;i++){
    cin>>h[i];
  }
  vector<long long>dp(n,INF);
  dp[0]=0;
  dp[1]=dp[0]+abs(h[1]-h[0]);
  for(int i=0;i<n;i++){
    for(int j=1;j<=k;j++){
      if(i+j<n) dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));  
    }
  }
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

bool coverd[5000][5000];

int main() {
	vector<int> xl,yl,xs, xe, ys, ye;
	xl.reserve(5000);
	yl.reserve(5000);
	xs.reserve(3000);
	xe.reserve(3000);
	ys.reserve(3000);
	ye.reserve(3000);

	int N;
	scanf("%d", &N);

	for (int i = 0; i < N; i++)
	{
		int x1, x2, y1, y2;
		scanf("%d %d %d %d", &x1, &y1, &x2, &y2);

		xl.push_back(x1 + 1000000000);
		xl.push_back(x2 + 1000000000);
		yl.push_back(y1 + 1000000000);
		yl.push_back(y2 + 1000000000);
		xs.push_back(x1 + 1000000000);
		xe.push_back(x2 + 1000000000);
		ys.push_back(y1 + 1000000000);
		ye.push_back(y2 + 1000000000);
	}

	sort(xl.begin(), xl.end());
	sort(yl.begin(), yl.end());
	xl.erase(unique(xl.begin(), xl.end()), xl.end());
	yl.erase(unique(yl.begin(), yl.end()), yl.end());

	for (int i = 0; i < N; i++)
	{
		xs[i] = find(xl.begin(), xl.end(), xs[i]) - xl.begin();
		xe[i] = find(xl.begin(), xl.end(), xe[i]) - xl.begin();
		ys[i] = find(yl.begin(), yl.end(), ys[i]) - yl.begin();
		ye[i] = find(yl.begin(), yl.end(), ye[i]) - yl.begin();
	}

	for (int k = 0; k < N; k++)
	{
		for (int i = xs[k]; i < xe[k]; i++)
		{
			for (int j = ys[k]; j < ye[k]; j++)
			{
				coverd[i][j] = true;
			}
		}
	}

	ll area = 0;
	for (int i = 0; i != (xl.size() - 1); i++)
	{
		for (int j = 0; j != (yl.size() - 1); j++)
		{
			if (coverd[i][j])
			{
				ll x1, x2, y1, y2;
				x1 = xl[i + 1]; x2 = xl[i];
				y1 = yl[j + 1]; y2 = yl[j];
				area += (x1 - x2)*(y1 - y2);
			}
		}
	}

	cout << area << endl;

	return 0;
}


Measured memory_bytes: 22832
a, b, c = gets.split.map(&:to_i)
result = [
  [a, (b + c)],
  [a, (b - c).abs],
  [b, (a + c)],
  [b, (a - c).abs],
  [c, (a + b)],
  [c, (a - b).abs]
].any? { |o, t| o == t }
puts(result ? 'Yes' : 'No')

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

//每次排序后打印结果
void trace(int A[], int N)
{
	for (int i = 0; i < N; i++)
	{
		if (i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");

}

//插入排序函数
void insertiomSort(int A[], int N)
{
//将所有变量声明在循环之外可以减少运行时间，加快速度
	int min = A[0];
	for (int i = 1; i < N; i++)
	{
		min = A[i];
		int j = i - 1;
		while (j >= 0 && A[j] > min)
		{
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = min;
		trace(A, N);
	}
}

int main()
{
	int A[100],i,j,N;
	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%d", &A[i]);
	trace(A, N);
	insertiomSort(A, N);

	return 0;
}


Measured memory_bytes: 2684
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=3*1e5+2;
int cnt[61][2];
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      int n;
      cin>>n;
      int a[n];
      for(int i=0;i<n;i++) cin>>a[i];
      int ans=0;
      for(int i=n-1;i>=0;i--)
      {
        int x=a[i];
        for(int j=0;j<=60;j++)
        {
          if(x&(1LL<<j))
          {
            ans+=((1LL<<j)%MOD*cnt[j][0]%MOD);
            ans%=MOD;
            cnt[j][1]++;
          }
          else{
            ans+=((1LL<<j)%MOD*cnt[j][1]%MOD)%MOD;
            ans%=MOD;
            cnt[j][0]++;
          }
        }
      }
      cout<<ans;
}
// I never lose. I either win or I learn

Measured memory_bytes: 2560
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 310
#define M 3
ll n, m;
vector<PP> v;
int t[1<<M];
ll dp[N][N][N];
int d[M];
int main(){
	rep(i, 1<<M) t[i] = __builtin_popcount(i);
	cin>>n>>m;
	rep(i, m){
		int a, b, c;
		cin>>a>>b>>c;
		v.push_back(PP(P(a, b), c));
		if(b==1 && c>1){
			cout<<0<<endl;
			return 0;
		}
	}
	sort(all(v));
	dp[1][0][0] = dp[0][1][0] = dp[0][0][1] = 1;
	ll res = 0;
	int p = 0;
	for(int ii = 1; ii < n; ii++){
		while(p<m && v[p].fst.fst<=ii+1) p++;
		rep(j, m){
			if(ii+1>v[j].fst.snd){
				for(int k = j; k < m-1; k++) v[k] = v[k+1];
				m--;
				p--;
				j--;
			}
		}
		rep(jj, max(1, ii)) rep(kk, max(1, ii)){
			if(jj && jj==kk) continue;
			d[0] = ii; d[1] = jj; d[2] = kk;
			rep(_, M){
				rotate(d, d+1, d+M);
				if(dp[d[0]][d[1]][d[2]]==0) continue;
				int d2[3];
				memcpy(d2, d, sizeof(d));
				int x = ii+1;
				rep(i, M){
					swap(x, d[i]);
					bool ok = true;
					rep(j, p){
						if(d[i]!=v[j].fst.snd){

							continue;
						}
						int cnt = 0;
						rep(k, M) if(v[j].fst.fst<=d[k] && d[k]<=v[j].fst.snd) cnt++;
						//if(cnt>v[j].snd || (d[i]==v[j].fst.snd&&cnt!=v[j].snd)){
						if(cnt!=v[j].snd){
							ok = false;
							break;
						}
					}
					if(ok) {
						if(ii+1==n){
							(res += dp[d2[0]][d2[1]][d2[2]]);
							if(res>mod) res -= mod;
						} else {
							dp[d[0]][d[1]][d[2]]+=dp[d2[0]][d2[1]][d2[2]];
							if(dp[d[0]][d[1]][d[2]]>mod) dp[d[0]][d[1]][d[2]] -= mod;
						}
					}
					swap(x, d[i]);
				}
			}
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 225536
#include <cstdio>
#include <algorithm>
static const int MAXN = 15;
static const int INF = 0x3fffffff;
template <typename T> inline void upd_max(T &var, const T val) { if (var < val) var = val; }

int n, m;
int g[MAXN][MAXN] = {{ 0 }};

int b[1 << MAXN][MAXN];
int f[1 << MAXN][MAXN];

int main()
{
    scanf("%d%d", &n, &m);
    int sum = 0;
    for (int i = 0, u, v, w; i < m; ++i) {
        scanf("%d%d%d", &u, &v, &w); --u, --v;
        g[u][v] = g[v][u] = w;
        sum += w;
    }

    for (int s = 0; s < (1 << n); ++s) {
        for (int u = 0; u < n; ++u) if (!(s & (1 << u))) {
            b[s][u] = 0;
            for (int i = 0; i < n; ++i) if (s & (1 << i))
                for (int j = i + 1; j < n; ++j) if (s & (1 << j))
                    b[s][u] += g[i][j];
            for (int i = 0; i < n; ++i) if (s & (1 << i))
                b[s][u] += g[i][u];
        }
    }

    for (int i = 0; i < (1 << n); ++i)
        for (int u = 0; u < n; ++u) f[i][u] = -INF;
    for (int t = 0; t < (1 << n); ++t)
        if (t & 1) f[t][0] = b[t ^ 1][0];
    for (int s = 0; s < (1 << n); ++s) {
        for (int u = 0; u < n; ++u) if (f[s][u] != -INF) {
            for (int v = 0; v < n; ++v) if (g[u][v] > 0 && !(s & (1 << v))) {
                int c = (~(s ^ (1 << v))) & ((1 << n) - 1);
                for (int t = c; t > 0; t = (t - 1) & c) {
                    upd_max(f[s | t | (1 << v)][v], f[s][u] + b[t][v] + g[u][v]);
                }
                upd_max(f[s | (1 << v)][v], f[s][u] + g[u][v]);
            }
        }
    }
    printf("%d\n", sum - f[(1 << n) - 1][n - 1]);

    return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //__gnu_pbds::gp_hash_table<int, int> table;
//priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;  //min heap

typedef int OwO;
typedef double UwU;

#define int long long
#define double long double
#define INF 1000000000
#define PI 3.14159265358979323846
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vi vector<int>

using namespace std;

OwO main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  S.push_back('$');
  vi psum(N);
  psum[0]=0;
  int s = 0;
  for(int x = 1; x<N; x++){
    if(S[x-1]=='A' && S[x]=='C')
      s++;
    psum[x]=s;
  }
  while(Q--){
    int l,r;
    cin >> l >> r;
    l--;
    r--;
    cout << psum[r] - psum[l] << endl;

  }

  return 0;
}

Measured memory_bytes: 1872
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int change_to_i(string s){
   stringstream ss; int k;
   ss<<s; ss>>k;
   return k;
}

bool f(string s, int n){
    if(s.size() < 3) return false;
    int cnt[10] = {};
    rep(i, 0, s.size()){
        cnt[s[i] - '0']++;
    }
    if(cnt[3] && cnt[5] && cnt[7]){
        int num = change_to_i(s);
        return num <= n;
    }
    return false;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    queue<string> q;
    q.push("");
    int ans = 0;
    while(q.size()){
        string s = q.front(); q.pop();
        if(f(s, n)) ans++;
        if(s.size() < 10){
            q.push(s + "3");
            q.push(s + "5");
            q.push(s + "7");
        }
    }
    cout << ans << endl;
}

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

int main() {
  ll N;
  cin >> N;
  vector<ll> as(N);
  rep(i, N) cin >> as[i];

  map<ll, ll> m;
  rep(i, N) {
    ll a = as[i];
    m[a]++;
  }

  ll ans = 0;
  for (auto i = m.begin(); i != m.end(); ++i) {
    ll a = i->first;
    ll cnt = i->second;
    if (a <= cnt) {
      ans += cnt-a;
    } else {
      ans += cnt;
    }
  }

  cout << ans << endl;
  
}


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

int main() {
	int N;
	cin >> N;
	vector<int> A(N), B(N);
	for (int i = 0;i < N;i++) {
		cin >> A[i];
		B[i] = A[i];
	}
	sort(A.begin(), A.end());
	for (int i = 0;i < N;i++) {
		if (B[i] != A[N - 1])
			cout << A[N - 1] << endl;
		else
			cout << A[N - 2] << endl;
	}
}

Measured memory_bytes: 3200
<?php
fscanf(STDIN, '%s', $s);
fscanf(STDIN, '%d', $q);
$cnt = 0;
for ($i = 0; $i < $q; $i++) {
    $query[] = explode(' ', trim(fgets(STDIN)));
    if ($query[count($query) - 1][0] === '1') {
        $cnt++;
    }
    $rev_cnt[] = $cnt;
}
//var_dump($rev_cnt);
if ($rev_cnt[$q - 1] % 2 === 0) {
    $ans = $s;
} else {
    $ans = strrev($s);
}
$left = $right = '';
for ($i = 0; $i < $q; $i++) {
    if ($query[$i][0] === '1') {
        continue;
    }
    $tmp = $query[$i][2];
    if (($rev_cnt[$q - 1] - $rev_cnt[$i]) % 2 === 0) {
        if ($query[$i][1] === '1') {
            $left .= $tmp;
        }
        if ($query[$i][1] === '2') {
            $right .= $tmp;
        }
    } else {
        if ($query[$i][1] === '1') {
            $right .= $tmp;
        }
        if ($query[$i][1] === '2') {
            $left .= $tmp;
        }
    }
}
$ans = strrev($left) . $ans . $right;
echo $ans . PHP_EOL;

Measured memory_bytes: 115564
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
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!{
        X: usize,
        A: usize,
    }
    println!("{}", if X < A {0} else {10});
}



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

int main() {

    int n, d, x; cin >> n >> d >> x;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    int sum = 0;
    for (int i = 0; i < n; i++) {
        int day = 1;
        int c = 1;
        while (day <= d) {
            sum++;
            day = c * a[i] + 1;
            c++;
        }
    }
 
    cout << sum + x << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 160000;
const int K = 20000;
map < int, int > mp[2];
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
int solve1(int x, int c){
    if (x == 0) return 1;
    if (x == 1) return 1 + c;
    if (x == 2){
        if (c == 1) return 4;
        if (c == 0) return 3;
    }
    if (x == 3){
        if (c == 1) return 5;
        if (c == 0) return 3;
    }
    if (mp[c].find(x) != mp[c].end()) return mp[c][x];
    int b1, b2;
    for (int i = 60; i >= 0; i--){
        if (x & (1LL << i)){
            b1 = i;
            if (x & (1LL << (i - 1))) b2 = 1; else b2 = 0;
            break;
        }
    }
    int res = c * solve1(x - (1LL << b1), 1);
    if (b2 == 0){
        res = (res + solve1(x - (1LL << (b1)), 1) + solve1(x - (1LL << (b1 - 1)), 0) + binpow(3, b1 - 1)) % mod;
        return mp[c][x] = res;
    }
    res = (res + 2 * binpow(3, b1 - 1) % mod + solve1(x - (1LL << (b1)), 0)) % mod;
    return mp[c][x] = res;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    cout << solve1(n, 1);
}


Measured memory_bytes: 256
import sys
from collections import defaultdict
from queue import deque
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n = gete(int)
    print(n * (n - 1) // 2)


if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
#coding:utf-8

n = int(input())

a = input().split()

count = 0

r = [(n - int(m)) for n,m in enumerate(a)]
l = [(n + int(m)) for n,m in enumerate(a)]

r.remove(r[0])
l.remove(l[-1])

mar = max(r)
mir = min(r)
mal = max(l)
mil = min(l)

R = {}
L = {}

for n,m in zip(r,l):
    R[n] = 0
    L[m] = 0

for n,m in zip(r,l):
    R[n] += 1
    L[m] += 1

for i in R.keys():
    if i in L.keys():
        count += R[i] * L[i]

print("{}".format(count))

Measured memory_bytes: 64368
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '[' << #x << " is: " << x << "] " <<"\n";
#define int long long
int v[101] , wt[101] ;
vector<vector<int>>dp(1e2 + 1 , vector<int> (1e5 + 1 , -1));
int n , w;
int calc(int idx , int c ){

    if(idx == 0 || c == 0)
        return dp[idx][c] = 0 ;
    if(dp[idx][c] != -1)
        return dp[idx][c];
    int firstc = -1 , secondc = -1 ;
    if(c < wt[idx])
        return dp[idx][c] =  calc(idx - 1 , c) ;
    else {
        firstc = v[idx] + calc(idx - 1 , c - wt[idx] );
        secondc = calc(idx - 1 , c);

    }
    return  dp[idx][c] = max(firstc , secondc) ;


}
int32_t main(){
     ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> w ;

   for(int x = 1 ; x <= n ; x++)
        cin >> wt[x] >> v[x] ;
    cout << calc(n  , w );

    return 0;
}


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

#define N 100000

int main() {
  int n, dp[N], num6, num9;
  cin >> n;
  dp[0] = 0;
  dp[1] = 1;
  dp[2] = 2;
  dp[3] = 3;
  dp[4] = 4;
  dp[5] = 5;
  for(int i = 6; i <= n ;++i){
    num6 = 6; num9 = 9;
    while(i - num6*6 >= 0){
      num6 *= 6;
    }
    while(i - num9*9 >= 0){
      num9 *= 9;
    }
    if(i < 9) dp[i] = dp[i - num6] + 1;
    else dp[i] = (dp[i - num6] > dp[i - num9]) ? dp[i - num9] + 1 : dp[i - num6] + 1;
  }
  //for(int i = 0; i <= n; ++i) cout << i << " : " << dp[i] << endl;
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define UPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define LOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];

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 mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}
int dfs(int v, ll N, bool visited[nmax])
{
    bool all_visited = true;

    for (int i = 0; i < N; i++)
    {
        if (!visited[i])
        {
            all_visited = false;
        }
    }

    if (all_visited)
    {
        return 1;
    }
    int ret = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (!graph[v][i])
        {
            continue;
        }
        if (visited[i])
        {
            continue;
        }

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}

void solve(std::string AtCoder, std::string s, std::string Contest)
{
    UPPER(s);
    cout << AtCoder[0] << s[0] << Contest[0] << endl;
}

int main()
{
    std::string AtCoder;
    std::cin >> AtCoder;
    std::string s;
    std::cin >> s;
    std::string Contest;
    std::cin >> Contest;
    solve(AtCoder, s, Contest);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
flag = 0

for i in A:
    if i % 2 == 0:
        if i % 3 == 0 or i % 5 == 0:
            pass
        else:
            flag = 1
            break

if flag == 1:
    print('DENIED')
else:
    print('APPROVED')


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

using namespace std;
using ll = long long;

int main() {
    string s; cin >> s;
    map <char, int> mp;
    for (auto c : s) {
        mp[c]++;
    }

    for (auto pp : mp) {
        if (pp.second & 1) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 3588
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();

		int h = a / 60 / 60;
		int m = (a - h * 60 * 60) / 60;
		int s = a - h * 60 * 60 - m * 60;
		System.out.println(h + ":"+ m + ":" + s);
	}
}



Measured memory_bytes: 26228
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int64_t n,sum_a=0,sum_b=0;
  cin>>n;
  vector<int64_t> a(n),b(n);
  for (int i = 0; i < n; ++i)
  {
    cin>>a[i];
    sum_a+=a[i];
  }
  for (int i = 0; i < n; ++i)
  {
    cin>>b[i];
    sum_b+=b[i];
  }
  if(sum_b>sum_a){
    cout<<-1;
    return 0;
  }
  int64_t s=0;
  int64_t cnt=0;
  std::vector<int64_t> vec;
  for (int i = 0; i < n; ++i)
  {
    if(a[i]<b[i]){
      cnt++;
      s+=(b[i]-a[i]);
    }
    else{
      vec.emplace_back(a[i]-b[i]);
    }
  }
  if(cnt==0){
    cout<<0;
    return 0;
  }
  sort(vec.begin(), vec.end(),greater<int64_t>());
  int64_t tmp=0;
  for(auto&& e: vec) {
    tmp+=e;
    cnt++;
    if(tmp>=s) break;
  }
  cout<<cnt;
}

Measured memory_bytes: 2936