akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/*
<url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0509>
?????????============================================================
?????¢???????????¢??????????????????????????????????????????.???????????????????????§????????????????????¨????????¢????????¨???????±???????????????°?????????????????????.
?????????, ?????¢?????§?¨??????¢??¨??????????????¨???, ??????????????????????¬?????????¶ (1), (2) ????????????????????¨??????.
(1) ???????????????????????¢??? 4 ????????? x, y ??§?¨??????¨??? 0 ??\??? 10000 ??\????????´??°??§??????,
    ????????¢???????????? x ???, ????????? y ??????????????§??????.
(2) ?????????????????°????????? 10000 ?????\?????§??????.
??\???????????? ??? 1 ?????????????????¢????????° n ??¨??????????¨?????????¨?????´??° r ???????????§????????£?????????????????????.
2 ????????\??????????????????, ?????????????????????????????§?¨? (x1, y1) ??¨??????????????§?¨? (x2, y2) ?????§?¨???????
x1, y1, x2, y2 ????????§????????§????????£??????????????????.

???????????? r = 1 ?????¨??? 1 ???????????¢??????, r = 2 ?????¨??? 1 ???????????¢???, 2 ???????????¨???????????????????????????.
??????????????´??????????????????????????\???????????¨.

=================================================================

?§£??¬=============================================================

================================================================
*/

int m[2][10010];
vector<pll> ps[10010];
int maxh, maxw;
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N, r;
	while (cin >> N >> r, N | r) {
		maxh = -1, maxw = -1;
		memset(m, 0, sizeof(m));
		for (int i = 0; i < 10010;i++) ps[i].clear();
		for (int i = 0;i < N;i++) {
			int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
			x1++; y1++; x2++; y2++;
			ps[y1].push_back({ x1,1 });
			ps[y1].push_back({ x2,-1 });
			ps[y2].push_back({ x1,-1 });
			ps[y2].push_back({ x2,1 });
			maxh = max(maxh, y2);
			maxw = max(maxw, x2);
		}

		int Area = 0, Length = 0;
		int cur = 0, next = 1;
		for (int i = 0; i <= maxh + 1;i++) {
			memset(m[next], 0, sizeof(m[next]));
			for (auto p : ps[i]) {
				m[next][p.first] += p.second; // ?´??????????????????¶???
			}
			for (int j = 0; j <= maxw;j++) {
				m[next][j + 1] += m[next][j]; // ?´??????? ?¨?????????????
				m[next][j] += m[cur][j]; // ?´??????? ???????????????
			}
			for (int j = 0; j <= maxw;j++) {
				if (m[next][j] > 0) Area++;
				if ((m[cur][j] > 0) != (m[next][j] > 0)) Length++;
				if ((m[next][j] > 0) != (m[next][j + 1] > 0)) Length++;
			}
			cur = !cur;
			next = !next;
		}
		cout << Area << endl;
		if (r == 2) cout << Length << endl;
	}
	return 0;
}

Measured memory_bytes: 4396
import java.util.Scanner;

public class Main {
	int[] boll;
	int index;
	
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		boll = new int[10];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 10; j++)
				boll[j] = scan.nextInt();
			index = 0;
			System.out.println(solve(0, 0) ? "YES" : "NO");
		}
	}
	
	boolean solve(int left, int right) {
		if (index == 10) return true;
		else {
			if (boll[index] > left) {
				left = boll[index];
				index++;
				return solve(left, right);
			} else if (boll[index] > right) {
				right = boll[index];
				index++;
				return solve(left, right);
			} else return false;
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

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

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

int main(){
  ll N,K,R,S,P;
  string T;
  cin >> N>>K>>R>>S>>P>>T;
  ll ans=0;
  for(ll i=0;i<K;i++){
    if(T.at(i)=='r'){
      ans+=P;
    }
    if(T.at(i)=='s'){
      ans+=R;
    }
    if(T.at(i)=='p'){
      ans+=S;
    }
  }
  for(ll i=K;i<N;i++){
    if(T.at(i)!=T.at(i-K)){
    if(T.at(i)=='r'){
      ans+=P;
    }
    if(T.at(i)=='s'){
      ans+=R;
    }
    if(T.at(i)=='p'){
      ans+=S;
    }
    }
    else{
      T.at(i)='x';
    }
  }
  cout << ans << endl;
    
}
      
  
  
  

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<double> da(n);
  for(int i=0;i<n;i++){
   cin >> da[i];
  }
  vector<vector<double>> dp(n+1,vector<double>(n+1,0));
  dp[0][0]=1;
  for(int i=1;i<n+1;i++){
    dp[i][0]=dp[i-1][0]*(1-da[i-1]);
    for(int j=1;j<n+1;j++){
      dp[i][j]=dp[i-1][j-1]*da[i-1]+dp[i-1][j]*(1-da[i-1]);
    }
  }
  double ans=0;
  for(int i=0;i<n/2+1;i++)
    ans+=dp[n][n-i];
  cout << fixed << setprecision(10);
  cout << ans << endl;
/*  for(int i=0;i<n+1;i++){
    for(int j=0;j<n+1;j++){
      cout << dp[i][j] << ' ';
    }
    cout << endl;
  }*/
}

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

int main(){
	int N;
	cin >> N;
	int a[N];
	rep(i,N) cin >> a[i];
	int ans = 0;
	rep(i,N) ans += a[i]-1;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
  long long int a, b, c, c_eatable, answer;
  cin >> a >> b >> c;
  if(c <= a+b + 1)
    c_eatable = c;
  else
    c_eatable = a+b+1;
  
  answer = b+c_eatable;
  cout << answer;
  
  return 0;
}

Measured memory_bytes: 256
x=y=0
gets
while gets
    a,b=$_.split.map &:to_i
    t=1<<63
    r=t*2-1
    while t>0
        r-=t if a*(r-t)>=x && b*(r-t)>=y;
        t>>=1
    end
    x=a*r=r>0?r:1
    y=b*r
end
p x+y

Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>

using namespace std;

double dp[3100][1600];

void coin(double* arr,int N ){

	int max_tails = (N-1)/2;
	dp[0][0] = arr[0];
	dp[0][1] = (1-arr[0]);

	for(int tails = 2; tails <= max_tails;tails++)
		dp[0][tails] = 0;

	for(int coins = 1; coins <= N;coins++)
		dp[coins][0] =  arr[coins]*dp[coins-1][0];

	for(int tails=1;tails <= max_tails;tails++)
		for(int coins = 1; coins <= N;coins++)
			dp[coins][tails] = arr[coins]*dp[coins-1][tails] + (1-arr[coins])*dp[coins-1][tails-1];
	
}

int main(){

	int N;
	cin >> N;
	double arr[N];
	for(int i=0;i<N;i++)
		cin >> arr[i];

	coin(arr,N);

	double prob = 0;
	for(int tails=0;tails < (N+1)/2;tails++)
		prob += dp[N-1][tails];

	cout << setprecision(10) << prob << '\n';

	
	return 0;
}

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

int main(){
    ll a,b;
    cin >> a >> b;
    cout << (a-1)/b+1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int main(){
  int n;
  cin >> n;

  vector<vector<int> > f;
  vector<vector<int> > p;

  REP(i, n){
    vector<int> a(10); for(auto &A:a) cin >> A;
    f.push_back(a);
  }
  REP(i, n){
    vector<int> a(11); for(auto &A:a) cin >> A;
    p.push_back(a);
  }

  int ans = - INF;
  FOR(i, 1, 1024){
    int a[10];
    int temp = i;
    REP(j, 10){
      a[j] = temp % 2;
      temp /= 2;
    }
    temp = 0;
    REP(j, n){
      int count = 0;
      REP(k, 10){
        count += f[j][k] * a[k];
      }
      temp += p[j][count];
    }
    ans = max(ans, temp);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s = iterator.next().unwrap();

    return s.replace(",", " ");
}


Measured memory_bytes: 2068
#include <cstdio>
#include <vector>
#include <algorithm>

std::vector<long long> divisor(long long n)
{
  std::vector<long long> r;
  for (long long i = 1; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      r.emplace_back(i);
      if(i * i != n) r.emplace_back(n / i);
    }
  }
  std::sort(r.begin(), r.end());
  return r;
}

int main()
{
  long long n;
  scanf("%lld", &n);
  auto v = divisor(n);
  long long ans = 0;
  for (auto d : v)
  {
    if (d == 1 || n % d != 0) continue;
    if (n / d == n / (d - 1)) ans += d - 1;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define def(x) cerr << #x << " is " << x << endl;
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
int main(){
    ios
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        int x,n; cin>>x>>n;;
        map<int,bool> ma;
        FOR(i,0,n){
            int x; cin>>x;
            ma[x]=1;
        }
        int mn = INT_MAX;
        int ans;
        FOR(i,-1000,1000){
            if(ma[i]) continue;
            int diff= abs(x-i);
            if(diff<mn){
                mn = diff;
                ans = i;
            }
        }
        cout<<ans;
    }   
}



Measured memory_bytes: 3732
import java.util.*;
 
public class Main{
    static int H, W, suc;
    static String[][] c;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[][] C = new int[3][N-1];
        for(int i = 0; i < N-1; i++){
            C[0][i] = sc.nextInt();
            C[1][i] = sc.nextInt();
            C[2][i] = sc.nextInt();
        }
        sc.close();

        int[] t = new int[N];
        t[N-1] = 0;
        for(int i = 0; i < N-1; i++){
            t[i] += (C[0][i] + C[1][i]);
            if(i != N-2){
                for(int j = i+1; j < N-1; j++){
                    if(t[i] <= C[1][j])
                        t[i] = C[1][j] + C[0][j];
                    else{
                        while(t[i] % C[2][j] != 0)
                            t[i]++;
                        t[i] += C[0][j];
                    }
                }
            }
        }
        for(int i = 0; i < N; i++){
            System.out.println(t[i]);
        }
    }
}

Measured memory_bytes: 25736
n,m,x,y=map(int,input().split())
X=list(map(int,input().split()))
Y=list(map(int,input().split()))
s=max(X)
t=min(Y)
ans='War'
for i in range(x+1,y+1):
    if i>s:
        if i<=t:
            ans='No War'
            break

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

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

    count=0;
    for(i=0;i<s.length() / 2; i++){
        if(s[i] != s[s.length() - i -1] ){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/


  int N;

  cin>>N;

  long long a[100001];

  long long left[100001];

  long long right[100001];

  left[0]=0;

  right[N+1]=0;
  
  for(int i=1;i<=N;i++){

    cin>>a[i];

    left[i]=__gcd(a[i],left[i-1]);

  }

  for(int i=N;i>=1;i--){

    right[i]=__gcd(a[i],right[i+1]);

  }

  long long maxx=0;

  for(int i=1;i<=N;i++){
    maxx=max(__gcd(left[i-1],right[i+1]),maxx);
    
  }

  cout<<maxx<<endl;
		
  return 0;

}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void answer1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void answer2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void answer3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void answer(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i, j;
  //ll n;
  //cin >> n;
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  //string s; cin >> s;
  ll result = 0;
  bool judge = true;
  //answer(b>=a,a,a-1);

  /*
  vector<ll> a(n);
  for(i=0;i<n;i++)
    cin >> a[i];
  //for(i=0;<n;i++)
  */
  result=max({a,b,c});
  for(i=0;i<k;i++){
    result*=2;
  }
  result+=a+b+c-max({a,b,c});
  cout<<result<<endl;





  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


const int max_comb=3000;
vector<ll> fac(max_comb+1); //n! (mod M)
vector<ll> ifac(max_comb+1); //k!^(-1) (mod M)

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

ll comb(int a, int b){     // C(a,b) = a! * b!^(-1) * (a-b)^(-1)
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

ll perm(int a, int b){     // P(a,b) = a! * (a-b)!^(-1)
    if(b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b] % MOD;
    return tmp * fac[a] % MOD;
}

void pre_comb()
{
    fac[0] = 1;
    ifac[0] = 1;
    for(int i = 0; i<max_comb; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*minv(i+1) % MOD; // k!^(-1) (mod M)
    }
    return;
}


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    int i;
    for(i=0; i<n; i++) {
        int tmp;
        scanf("%d", &tmp);
        a[i]=2*i-tmp;
        if(i>0 && a[i-1]>a[i]) a[i]=a[i-1];
    }

    ll ans=1;
    for(i=0; i<n; i++) {
        int k = lower_bound(a.begin(), a.end(), 2*i)-a.begin();
        if(k<n && a[k]==2*i) {
            ans=ans*(k+1-i)%MOD;
        }
        else {
            ans=ans*(k-i)%MOD;
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter

from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
#dequeを使うときはpython3を使う、pypyはダメ
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

#mod = 10**9+7
#w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

#N = int(input())
#N, K = map(int, input().split())
#L = [int(input()) for i in range(N)]
#A = list(map(int, input().split()))
#S = [list(map(int, input().split())) for i in range(N)]

S=input()
N=len(S)
flag=False

for i in range(N//2):
    if S[i]!=S[N-1-i]:
        print('No')
        exit()

half=N//2
for i in range(half//2):
    if S[i]!=S[half-1-i] or S[i+half+1]!=S[half-1-i+half+1]:
        print('No')
        exit()

print('Yes')

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> mii;
typedef map<ll,int> mli;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;  ///1e9+7

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    ll n,i;
    cin>>n;
    if(n%2==0 or n==5) cout<<-1 el;
    else{
        ll d=7;
        for(i=1;i<=n;i++){
            if(d%n==0){cout<<i el; return;}
            d*=10;
            d+=7;
            d%=n;
        }
        cout<<-1 el;
    }
}

main()
{
    fastio();
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3572
#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()
{
    int m, n;
    cin >> m;
  	if (m > 99) {
      m %= 100;
      n = m % 10;
    }
  	else n = m % 10; 
    if (n == 3)
        cout << "bon" << endl;
    else if (n == 0 || n == 1 || n == 6 || n == 8)
        cout << "pon" << endl;
    else
        cout << "hon" << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdlib>
#include<utility>
#include<tuple>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<deque>
#include<bitset>
#include<cmath>
#include<map>
#include<iomanip>
using namespace std;
using ll = long long int;
const ll mod = 1e9 + 7;
#define rep(i, a, b) for(int i = a; i < b; i++)

int main() {

	int n;
	cin >> n;

	if (n <= 81) {
		rep(i, 1, 10) {
			rep(j, 1, 10) {
				if (i * j == n) {
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
  	cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  cout << A.at(N-1) - A.at(0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
const int N = 100010;
 
using namespace std;
 
int main()
{
	ll prod=1;
	int n,z=0;
	cin >> n;
	ll a[N];
	for(int i=0;i<n;i++) {
		cin >>a[i];
		if(a[i] == 0) z=1;
	}
	if(z == 1) {cout<<0<<endl; return 0;}
	for(int i=0;i< n;i++) {
		if(a[i] <=1000000000000000000/ prod )
			prod*=a[i];
		else{ cout<<-1<<endl;return 0;}
	}
	if(prod<=1000000000000000000)
	cout<<prod<<endl;
	else cout<<-1<<endl;
}


Measured memory_bytes: 4404
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define pb push_back
#define pi pair<int, int>
#define l first
#define r second
#define all(x) x.begin(), x.end()
#define fori(a, b, step) for (int i = a; i < b; i += step)
#define forj(a, b, step) for (int j = a; j < b; j += step)

const int maxn = 2e5 + 1, mod1 = 1e9 + 7, mod2 = 1e9 + 9, mod3 = 1148822869;
const int k1 = 29, k2 = 31, k3 = 37;

using namespace std;

struct trie {
    int next[26];
    int psb[26];
    int p = -1;

    trie() {
        for (int i = 0; i < 26; i++) {
            next[i] = -1;
            psb[i] = 0;
        }
    }
};

trie t[5 * maxn];
int mx = 0;
string v[maxn];

void add_string(string s) {
    int x = 0;
    for (int i = 0; i < s.size(); i++) {
        if (t[x].next[s[i] - 'a'] == -1) {
            t[x].next[s[i] - 'a'] = ++mx;
            t[mx].p = x;
        }
        x = t[x].next[s[i] - 'a'];
    }
    bool cc[26];
    for (int j = 0; j < 26; j++)
        cc[j] = 0;
    int i = s.size() - 1;
    for (; x != -1; x = t[x].p) {
        for (int j = 0; j < 26; j++)
            t[x].psb[j] += cc[j];
        cc[s[i] - 'a'] = 1; --i;
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        string nv = "";
        for (int j = v[i].size() - 1; j >= 0; j--)
            nv += v[i][j];
        v[i] = nv;
        add_string(v[i]);
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        int x = 0;
        for (int j = 0; j < v[i].size() - 1; j++)
            x = t[x].next[v[i][j] - 'a'];
        ans += t[x].psb[v[i].back() - 'a'];
    }
    cout << ans - n;
    return 0;
}


Measured memory_bytes: 219360
N = int(input())
A = list(map(int,input().split()))
sum = 0
cnt_two = 0
for i in range(N):
  if A[i] % 4 == 0:
    sum += 1
  elif A[i] % 2 == 0:
    cnt_two += 1
print("Yes" if sum + cnt_two // 2 >= N // 2 else "No")

Measured memory_bytes: 14252
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), greater<type>())
#define SORTF(a, comp) sort(ALL(a), comp)
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) (lower_bound(ALL(a), (x)) - a.begin())
#define bisect_right(a, x) (upper_bound(ALL(a), (x)) - a.begin())
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUT2(a) REPx(&x, a) INPUT(x);
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define ENDL cout << endl;

// const int INF = 2e9;
const LL INF = 9e18;
const LL MOD = 1e9+7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  VB check(n, false);
  VI box(n, 1);
  check[0] = true;
  REP(int, i, m)
  {
    int x, y;
    cin >> x >> y;
    --x; --y;
    --box[x];
    ++box[y];
    if (check[x]) check[y] = true;
    if (box[x] == 0) check[x] = false;
  }
  int ans = 0;
  REPx(x, check) if (x) ++ans;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
long long n,m,ans,l;
int main()
{
	cin>>n>>m;ans=1;l=1e9+7;if(abs(m-n)>1) {cout<<"0\n";return 0;}
	for(int i=1;i<=n;i++) ans=ans*i%l;
	for(int i=1;i<=m;i++) ans=ans*i%l;
	cout<<(n!=m?ans:ans*2%l)<<"\n";
	return 0;
}

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

using namespace std;


int main()
{
	int n;
	cin >> n;

	for (int i = 0; i < n; ++i)
	{
		int a;
		cin >> a;
		if (a % 2 != 0)
		{
			continue;
		}

		if (a % 3 != 0 && a % 5 != 0)
		{
			cout << "DENIED" << endl;
			return 0;
		}
	}
	cout << "APPROVED" << endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N;
	cin >> N;
	vector<pair<long long, long long>>A(N);
	for (long long i = 0; i < N; i++) {
		cin >> A.at(i).first;
		A.at(i).second = i;
	}
	sort(A.begin(), A.end(), greater<pair<long long, long long>>());
	vector<long long>ans(N);
	for (long long i = 0; i < N; i++) {
		if (i < N / 2) ans.at(A.at(i).second) = A.at(N / 2).first;
		else ans.at(A.at(i).second) = A.at(N / 2 - 1).first;
	}
	for (long long i = 0; i < N; i++) {
		cout << ans.at(i) << endl;
	}
}

Measured memory_bytes: 6912
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

#define MAX_N 1010
#define MAX_M 200000100

int main(){
    ll k,s,ans=0;
    cin >> k >> s;
    for (ll i=0;i<=k;++i)for (ll j=i;j<=k;++j)for (ll l=j;l<=k;++l){
        if (i+j+l==s){
            if (i==j && j==l){
                ans++;
            }else if (i==j || j==l || i==l){
                ans+=3;
            }else{
                ans+=6;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
import bisect
n=int(input())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
c=[int(x) for x in input().split()]
a.sort()
b.sort()
c.sort()


ans=0
ind=[0]
for i in range(n):
  ind.append(n-bisect.bisect_right(c,b[i])+ind[i])

for i in a:
  b_ind=bisect.bisect_right(b,i)

  ans+=ind[n]-ind[b_ind]

print(ans)

Measured memory_bytes: 29412
#include<iostream>
#define MAX_N 101
using namespace std;
typedef long long ll;

ll soinsu_count[MAX_N];

int main() {
    int N;
    cin >> N;
    for (int i = 2; i <= N; i++) {
        int tmp = i, div_num = 2;
        while (tmp > 1) {
            if (tmp % div_num == 0) {
                tmp /= div_num;
                soinsu_count[div_num]++;
            }
            else div_num++;
        }
    }
    ll two = 0, four = 0, ft = 0, tf = 0, sf = 0;
    for (int i = 2; i <= N; i++) {
        if (soinsu_count[i] >= 74) sf++;
        if (soinsu_count[i] >= 24) tf++;
        if (soinsu_count[i] >= 14) ft++;
        if (soinsu_count[i] >= 4) four++;
        if (soinsu_count[i] >= 2) two++;
    }
    ll ans = 0;
    ans += sf;
    if (two > 1) ans += tf * (two - 1);
    if (four > 1) ans += ft * (four - 1);
    if (four > 1 && two > 2) ans += four * (four - 1) * (two - 2) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define mx 100005
#define For(i,n) for(int i;i<n;i++)
typedef long long ll;
using namespace std;
int n,m,p[mx],b[mx][2];
ll a[mx];
int f(int s){
  int t=p[s];
  if(t<0)return s;
  p[s]=f(t);
  return p[s];
}
ll g(int j){
  int x=f(b[j][0]),y=f(b[j][1]);
  if(x!=y){
    int s=p[x],t=p[y];
    if(s>t){
      p[x]=y;
      p[y]+=s;
    }
    else{
      p[y]=x;
      p[x]+=t;
    }
    return 1ll*s*t;
  }
  return 0ll;
}
int main(){
  scanf("%d%d",&n,&m);
  a[m-1]=1ll*n*(n-1)/2;
  For(i,m){
    scanf("%d%d",&b[i][0],&b[i][1]);
    b[i][0]-=1;b[i][1]-=1;
  }
  For(i,n)p[i]=-1;
  for(int i=m-2;i>=0;i--)a[i]=a[i+1]-g(i+1);
  For(i,m)printf("%lld\n",a[i]);
}

Measured memory_bytes: 3200
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float('inf')
MOD = 10**9+7
dy = [0,1,0,-1]
dx = [1,0,-1,0]
ddy = [0,1,1,1,0,-1,-1,-1]
ddx = [1,1,0,-1,-1,-1,0,1]

n = int(input())
H = list(map(int,input().split()))+[0]
cnt = 0
for i in range(n):
    if H[i] == max(H[:i+1]):
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
#ifndef _TEMPLATE_ROOT
#define _TEMPLATE_ROOT
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define repl(i, a, b) for(ll i = a; i < (b); ++i)
#define repd(i, a, b) for(int i = a; i >= (b); --i)
#define repdl(i, a, b) for(ll i = a; i >= (b); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
#endif
#ifndef _TEMPLATE_IO
#define _TEMPLATE_IO

template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void writef(T ...tail) { write(tail...); cout << flush; }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  if (v.size()) {
    rep(i, 0, sz(v) - 1)
      out << v[i] << " ";
    out << v.back();
  }
  return out;
}
#endif
using namespace std;

struct Dsu {
  int dsu[200005];
  Dsu() { rep(i, 0, 200005) dsu[i] = -1; }
  int size(int u) { return -dsu[find(u)]; }
  int find(int u) { if (dsu[u] < 0) return u; return dsu[u] = find(dsu[u]); }
  void merge(int u, int v) {
    u = find(u), v = find(v);
    if (u == v) return;
    if (-dsu[u] < -dsu[v]) swap(u, v);
    dsu[u] += dsu[v];
    dsu[v] = u;
  }
} dsu;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  int n, m; read(n, m);
  int ans = 0;
  rep(i, 0, m) {
    int a, b; read(a, b);
    dsu.merge(a, b);
  }
  rep(i, 1, n + 1) chmax(ans, dsu.size(i));
  write(ans);
}





Measured memory_bytes: 4424
#include <iostream>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl

using namespace std;
using ll = long long;

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


int main() {
    int n;
    ll X;
    cin >> n >> X;
    vector<ll> x(n);
    rep(i, n) cin >> x[i];

    ll ans = 0;
    rep(i, n) {
        ans = gcd(ans, abs(X - x[i]));
    }
    cout << ans << endl;
}

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

int main()
{
    int N, M;
    cin >> N >> M;
    int L, R;
    // first input
    cin >> L >> R;
    int min = L, max = R;

    for (int i = 1; i < M; i++) {
        cin >> L >> R;
        if (min < L) {
            min = L;
        }
        if (R < max) {
            max = R;
        }
    }

    if (max < min) {
        cout << 0 << endl;
    }
    else {
        cout << max - min + 1 << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] tmpList = line.split(" ", 0);
		int m = Integer.parseInt(tmpList[0]);
		int n = Integer.parseInt(tmpList[1]);

		if(m == n) {
			System.out.print("Yes");
		} else {
			System.out.print("No");
		}
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n;
	scanf("%d", &n);
	vector <long long int> A;
	for (int i = 0; i < n; ++i)
	{
		int x;
		scanf("%d", &x);
		A.push_back(x);
	}
	sort(A.rbegin(), A.rend());
	vector <long long int> B;
	for (int i = 1; i < A.size(); ++i)
	{
		if(A[i] == A[i-1] && B.size() < 2)
		{
			B.push_back(A[i]);
			i++;
		}
	}
	if(B.size() < 2)
		cout<<0<<"\n";
	else
		cout<<B[0]*B[1]<<"\n";
	return 0;
}

Measured memory_bytes: 1400
n = int(input())
ans = []

s = 0
while 1:
    if s == 1 and n < 1:
        break
    s = 1
    if n%26 == 0:
        ans.append(0)
    else:
        ans.append(n%26)
    n -= n%26
    n = n//26
for i in range(len(ans)):
    if i != len(ans)-1:
        if ans[i] <= 0:
            ans[i+1] -= 1
            ans[i] += 26
    else:
        if ans[i] <= 0:
            del ans[i]
ans = ans[::-1]
for i in range(len(ans)):
    print(chr(96+ans[i]),end="")
print("")

Measured memory_bytes: 9232
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int a,b;
int main(void){
    cin>>a>>b;
    if(a<=0&&b>=0)cout<<"Zero\n";
    else if(b<0&&(b-a)%2==0)cout<<"Negative\n";
    else cout<<"Positive\n";
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;

int main()
{
    int H, N;
    cin >> H >> N;
    
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        H -= A;
    }
    if (H <= 0) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

def gcd(n, m):
    if m == 0:
        return n
    while m != 0:
        n, m = m, n % m
    return n

def lcm(n, m):
    return n * m // gcd(n, m)

L = A[0]
for a in A:
    L = lcm(L, a)

ans = 0
for a in A:
    ans += L // a

print(ans % MOD)


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

int main(){
  	int N, price,max=0,ans=0;
  	cin >> N;
 	//vector<int> price(N);
  	for(int i=0; i < N; ++i){
     	//cin >> price.at(i);
      	cin >> price;
      	ans+=price;
      	if(max<price)
          	max = price;
    }
  	ans-=max;
  	ans+=(max/2);
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int n1,ary[50];

int solve(int i,int value){
  int res;
  if(value==0){
    return 1;
  }
  if(i>=n1){
    return 0;
  }
  res=solve(i+1,value) || solve(i+1,value-ary[i]);
  return res;
}

int main(){
  int n2,V,i;
  scanf("%d",&n1);
  for(i=0;i<n1;i++){
    scanf("%d",&ary[i]);
  }
  scanf("%d",&n2);
  for(i=0;i<n2;i++){
    scanf("%d",&V);
    if(solve(0,V))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    ll dp[N+1][3] = {};
    rep(i,0,N){
        int A,B,C;
        cin >> A >> B >> C;
        dp[i+1][0] = max(dp[i][1] + B, dp[i][2] + C);
        dp[i+1][1] = max(dp[i][0] + A, dp[i][2] + C);
        dp[i+1][2] = max(dp[i][0] + A, dp[i][1] + B);
    }
    cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;
}

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

int main() {
  int a,b,N,J;
  cin >> a >> b ;
  N = a * b ;
  J = N - (N / 2) * 2 ; //cout << J ;
  if ( J == 1 ) {
    cout << "Odd" << endl;
  }
  else
    cout << "Even" << endl;
}

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

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

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

use std::cmp::{min, max};
use std::collections::{HashMap, HashSet, VecDeque, BinaryHeap};

fn main() {
    input!{
        n: usize,
        k: usize,
        v: [i64; n]
    }
    let mut w = v.clone();
    for _ in 0..k {
        let mut wt = vec![0; n + 1];
        for i in 0..n {
            let l = max(0, i as i64 - w[i]) as usize;
            let r = min(i + w[i] as usize, n - 1);
            wt[l] += 1;
            wt[r + 1] -= 1;
        }
        for i in 0..n {
            wt[i + 1] += wt[i];
        }
        wt.pop();
        w = wt;
        if w.iter().all(|&x| x == n as i64) {
            break;
        }
    }
    print!("{}", w[0]);
    for i in 1..n {
        print!(" {}", w[i]);
    }
    println!("");
}


Measured memory_bytes: 6736
#include<stdio.h>
#include<stdlib.h>

struct node {
	struct node *right;
	struct node *left;
	struct node *parent;
	int key;
};

typedef struct node * Node;

Node root;

Node treeMinimum(Node x) {
	while (x->left != NULL) x = x->left;
	return x;
}

Node treeMaximum(Node x) {
	while (x->right != NULL) x = x->right;
	return x;
}

Node treeSearch(Node u, int k) {
	while (u != NULL && k != u->key) {
		if (k < u->key) u = u->left;
		else u = u->right;
	}
	return u;
}

Node treeSuccessor(Node x) {
	if (x->right != NULL) return treeMinimum(x->right);
	Node y = x->parent;
	while (y != NULL && x == y->right) {
		x = y;
		y = y->parent;
	}
	return y;
}

void treeDelete(Node z) {
	Node y; // node to be deleted
	Node x; // child of y

	if (z->left == NULL || z->right == NULL) y = z;
	else y = treeSuccessor(z);

	if (y->left != NULL) x = y->left;
	else x = y->right;

	if (x != NULL) x->parent = y->parent;

	if (y->parent == NULL) root = x;
	else {
		if (y == y->parent->left) y->parent->left = x;
		else y->parent->right = x;
	}

	if (y != z) z->key = y->key;

	free(y);
}

void insert(int k) {
	Node y = NULL;
	Node x = root;
	Node z;

	z = malloc(sizeof(struct node));
	z->key = k;
	z->left = NULL;
	z->right = NULL;

	while (x != NULL) {
		y = x;
		if (z->key < x->key) x = x->left;
		else x = x->right;
	}

	z->parent = y;
	if (y == NULL) root = z;
	else {
		if (z->key < y->key) y->left = z;
		else y->right = z;
	}
}

void inorder(Node u) {
	if (u == NULL) return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}

void preorder(Node u) {
	if (u == NULL) return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}


int main() {
	int n, i, x;
	char com[20];
	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%s", com);
		if (com[0] == 'f') {
			scanf("%d", &x);
			Node t = treeSearch(root, x);
			if (t != NULL) printf("yes\n");
			else printf("no\n");
		}
		else if (com[0] == 'i') {
			scanf("%d", &x);
			insert(x);
		}
		else if (com[0] == 'p') {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if (com[0] == 'd') {
			scanf("%d", &x);
			treeDelete(treeSearch(root, x));
		}
	}

	return 0;
}


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

int main() {
  int N, l, r, sum = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    sum += r - l + 1;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        DecimalFormat df = new DecimalFormat("0.00000000");
        
        final int N = Integer.parseInt(sc.next());
        long[] a = new long[N];
        boolean distinct = true;
        for (int i=0; i<N; i++)
            a[i] = Long.parseLong(sc.next());
        Arrays.sort(a);
        for (int i=0; i<N-1; i++)
            if (a[i] == a[i+1]) distinct = false;
        out.println(distinct ? "YES" : "NO");
        
        out.flush();
    }
}

Measured memory_bytes: 49332
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
#include <utility>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, string> P;




int main() {
    int n;
    cin >> n;
    int h[111111];
    rep(i, n)cin >> h[i];
    int c = 0;
    int cmax = 0;
    rep(i, n-1) {
        if (h[i + 1] <= h[i]) {
            c++;
            cmax = max(c, cmax);
        }
        else {
          
            c = 0;
        }
    }
    cout << cmax << endl;
}


Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import floor, ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
a = LIST()

tmp = 1
for i in range(N):
	if a[i] == tmp:
		tmp += 1

if tmp == 1:
	print(-1)
else:
	print(N-(tmp-1))


Measured memory_bytes: 27188
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
    cin >> a;
    cin >> b;
    int x = a.size();
	int y = b.size();
    for(int i = 0;i < y;i++)
		{
	        cout << a[i] << b[i];
	    }
	if(x > y)
		{
	        cout << a[x-1];
	    }
    return 0;
}

Measured memory_bytes: 256
/*
By Tianyi Chen. All rights reserved.
Date: 2017-01-24
*/
#include<bits/stdc++.h>
using namespace std;
int n;
int64_t add,a[100000],b[100000];
int main() {
 cin>>n;for(int i=0;i<n;++i)scanf("%lld%lld",a+i,b+i);
 for(int i=n-1;i>=0;--i) {
  a[i]+=add;
  add+=(a[i]/b[i]+!!(a[i]%b[i]))*b[i]-a[i];
 }
 cout<<add;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

int extgcd(int a, int b, int &x, int &y){
    int d = a;
    if(b != 0){
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else{
        x = 1;
        y = 0;
    }
    return d;
}

int gcd_multi(vec a){
    int x, y, g;
    g = a[0];
    FOR(i, 1, a.size()) g = extgcd(g, a[i], x, y);
    return g;
}

signed main(){

    int N, X; cin >> N >> X;
    vec x(N); readvec(x);

    vec d(0);
    REP(i, N) if(x[i] != X) d.push_back(llabs(X - x[i]));

    if(d.size() == 0){
        cout << 0;
    }else if(d.size() == 1){
        cout << d[0];
    }else{
        cout << gcd_multi(d);
    }
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

using namespace std;

typedef long long ll;

int main() {
	int q;
	cin >> q;
	ll sb = 0;
	ll sla = 0, sra = 0;
	vector<int> la, ra;
	while (q--) {
		int ty;
		cin >> ty;
		if (ty == 1) {
			int a, b;
			cin >> a >> b;
			sb += b;
			if (la.size() > 0 && a > la[0]) {
				sra += a;
				ra.push_back(a);
				push_heap(ra.begin(), ra.end(), greater<int>());
				if (ra.size() > la.size()) {
					sla += ra[0];
					la.push_back(ra[0]);
					push_heap(la.begin(), la.end());
					sra -= ra[0];
					pop_heap(ra.begin(), ra.end(), greater<int>());
					ra.pop_back();
				}
			} else {
				sla += a;
				la.push_back(a);
				push_heap(la.begin(), la.end());
				if (la.size() > ra.size() + 1) {
					sra += la[0];
					ra.push_back(la[0]);
					push_heap(ra.begin(), ra.end(), greater<int>());
					sla -= la[0];
					pop_heap(la.begin(), la.end());
					la.pop_back();
				}
			}
		} else {
			ll ans = sra - sla + sb;
			int x = la[0];
			if (la.size() > ra.size()) {
				ans += la[0];
			}
			cout << x << " " << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3452