akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")



void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    // char ;
    ll n,ans=0;
    scanf("%lld",&n);
    ll a[n];
    rep(i,0,n){
        scanf("%lld",&a[i]);
        a[i]-=i+1;
    }
    sortup(a,n);
    ll b=a[n/2];
    rep(i,0,n){
        ans+=ABS(b-a[i]);
    }
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;

typedef long long ll;

int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  vector<ll> vb(n + 1);
  for (int i = n - 1; i >= 0; i--) {
    vb[i] = vb[i + 1] + c.end() - upper_bound(c.begin(), c.end(), b[i]);
  }
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += vb[upper_bound(b.begin(), b.end(), a[i]) - b.begin()];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define MX 1000005
typedef long long ll;
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define mem(a) memset(a,0,sizeof(a))
int a[1005],b[1005];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ////////////////////////////////////
    int n,m,x,y,z,i,j,k;
    cin>>n>>m>>x>>y;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    a[n++]=x;
    for(int i=0;i<m;i++)
    {
        cin>>b[i];
    }
    b[m++]=y;
    sort(a,a+n);
    sort(b,b+m);
    if(a[n-1]<b[0])
    {
        cout<<"No War"<<endl;
    }
    else
    {
        cout<<"War"<<endl;
    }
    return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/01/06  Problem: EDU_DP N / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */


LL ans = 0LL;
LL dp[402][402];
LL a[402];
LL sums[402];
// min
// [L,R)
LL f(int L, int R) {
	if (L + 1 == R)return 0;
	if (dp[L][R] != LINF) {
		return dp[L][R];
	}

	LL ret = LINF;
	// [l,r)
	auto query = [](int l , int r) {
		return sums[r] - sums[l];
	};
	FOR(i, L + 1, R) {
		LL sub = f(L, i) + f(i, R)+ query(L,i)+query(i,R);
		ret = min(ret, sub);
	}

	return dp[L][R] = ret;
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	fill(*dp, *dp + 402 * 402, LINF);
	LL N;

	cin >> N;
	FOR(i, 0, N) {
		cin >> a[i];
	}
	FOR(i, 0, N) {
		sums[i + 1] = sums[i] + a[i];
	}
	ans = f(0, N);
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;
int main()
{
    string s;
    cin >> s;
    string ans = s[0] != s[1] && s[1] != s[2] && s[2] != s[0] ? "Yes" : "No";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h> 
using namespace std;

typedef long long ll;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) 
#define rep(pp,nn) for (int ii = pp; ii < nn; ++ii)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

string int_to_string(int x) {
    stringstream ss;
	ss << x;
	string ni = ss.str();
	return ni;
}
int string_to_int(string x) {
	int n;
	stringstream s(x);
	s >> n;
	return n;
}

int64_t power_mod(ll a, ll b, ll mo) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = (ans % mo * a % mo) % mo;
		}
		a = (a % mo * a % mo) % mo;
		b /= 2;
	}
	return ans;
}
int64_t POW(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = ans * a;
		}
		a = a * a;
		b /= 2;
	}
	return ans;
}

vector<int64_t> INVERSE(int64_t nn, int64_t mo) {
	vector<int64_t> inv(nn + 1);
	vector<int64_t> mul(nn + 1);
	inv[0] = 1;
    inv[1] = 1;
	for (ll i = 2; i <= nn; ++i) {
		inv[i] = (mo - (mo / i) * inv[mo % i] % mo) % mo; 
	}
	mul[0] = 1;
	for (int i = 1; i <= nn; ++i) {
		mul[i] = (mul[i - 1] * inv[i]) % mo;
	}
	return mul;
}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int main() {
	int r, g, b, k;
	cin >> r >> g >> b >> k;
	while (k--) {
		if (g <= r) {
			g *= 2;
		}else if (b <= g) {
			b *= 2;
		}
	}
	if (g > r && b > g) {
		cout << "Yes\n";
	}else {
		cout << "No\n";
	}
}














Measured memory_bytes: 3620
import sys
input = sys.stdin.readline

#l = list(map(int, input().split()))
#import numpy as np
#arr = np.array([int(i) for i in input().split()])
'''
a,b=[],[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''

n,m=map(int,input().split())
if abs(n-m)>1:
    print(0)
    sys.exit()

f=[1]
for i in range(1,max(n,m)+1):
    x=f[i-1]*i
    if x>10**9+7:
        x%=10**9+7
    f.append(x)
if n!=m:
    print(f[n]*f[m]%(10**9+7))
else:
    print(f[n]*f[m]*2%(10**9+7))

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

using namespace std;

int N, L[210];

int main() {
	scanf("%d", &N);
	for (int i = 0; i < 2 * N; i++) {
		scanf("%d", &L[i]);
	}
	sort(L, L + 2 * N);
	int ans = 0;
	for (int i = 2 * N - 2; i >= 0; i -= 2) {
		ans += L[i];
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        m: usize,
        aa: [usize; m],
    };

    let a = aa.iter().sum::<usize>();
    if a > n {
        println!("-1");
    } else {
        println!("{}", n - a);
    }
}


Measured memory_bytes: 2156
#include <bits/stdc++.h>
#include <set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000

#define writeln(n) cout<<n<<endl

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong gcd(llong a, llong b) {
    return b != 0 ? gcd(b, a % b) : a;
}
//setprecision(10);


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<llong> a(n,0);
    REP(i,n) cin>>a[i];
    llong ans=0;
    sort(a.begin(),a.end(),greater<llong>());
    vector<pair<llong,int>> cnt(n);
    for(int i=0; i<n-1; i++)
    {
        if(a[i]==a[i+1])
        {
            cnt[i]=make_pair(a[i],2);
            i++;
        }
    }
    sort(cnt.begin(),cnt.end());

    ans=(llong)cnt[n-1].first*(llong)cnt[n-2].first;
    cout<<ans<<endl;

}

Measured memory_bytes: 2560
from functools import reduce
from math import ceil

# 入力
N, H = map(int, input().split())
a, b = zip(*(map(int, input().split()) for _ in range(N)))

# 投げるべき刀を強力なものから投げる。その後、振るべき刀を降り続ける。
m = max(a)
c = sorted(filter(lambda x: x > m, b), reverse=True)
ans = (
    reduce(
        lambda acc, e: (acc[0] + 1, acc[1] + e) if acc[1] < H else acc,
        c,
        (0, 0)
    )[0] if sum(c) >= H else
    len(c) + ceil((H - sum(c)) / max(a))
)

# 出力
print(ans)


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

#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pl;

ld const PI = 4*atan((ld)1);

int main()
{
	fastio;

	ll x, d, k;
	cin >> x >> k >> d;

	ll mn = abs(x) / d;

	if (k <= mn)
	{
		if (x < 0) cout << abs(x + (k * d)) << '\n';
		else cout << abs(x - (k * d)) << '\n';
	}
	else
	{
		k -= mn;
		if (x < 0) cout << abs(x + (mn + k%2) * d) << '\n';
		else cout << abs(x - (mn + k%2) * d) << '\n';
	}

	return 0;
}


Measured memory_bytes: 3648
def rotation(s,t):
    if sorted(s) != sorted(t):
        return False
    canRotate = False
    for int in range(len(s)):
        if s != t:
            s_list = list(s)
            temp = s_list.pop(len(s)-1)
            s = ''.join(s_list)
            s = temp + s
        elif s == t:
            canRotate = True
            break
    return canRotate

s = input()
t = input()
yesno = rotation(s,t)
if yesno == True:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			list.add(Integer.parseInt(sc.next()));
		}

		int ans = Integer.MAX_VALUE;
		Collections.sort(list);
		for(int i = 1; i <= 100; i++) {
			int sum = 0;
			for(int j = 0; j < list.size(); j++) {
				int tmp = Math.abs(list.get(j) - i);
				sum += tmp * tmp;
			}
			ans = Math.min(ans, sum);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  for(int i=s.size()-1;i>=0;i--){
    if(s[i]=='m'&&s[i-1]=='a'&&s[i-2]=='e'&&s[i-3]=='r'&&s[i-4]=='d'){
      i-=4;
    }else if(s[i]=='r'&&s[i-1]=='e'&&s[i-2]=='m'&&s[i-3]=='a'&&s[i-4]=='e'&&s[i-5]=='r'&&s[i-6]=='d'){
      i-=6;
    }else if(s[i]=='e'&&s[i-1]=='s'&&s[i-2]=='a'&&s[i-3]=='r'&&s[i-4]=='e'){
      i-=4;
    }else if(s[i]=='r'&&s[i-1]=='e'&&s[i-2]=='s'&&s[i-3]=='a'&&s[i-4]=='r'&&s[i-5]=='e'){
      i-=5;
    }else{
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 512
#coding:utf-8
#1_4_D
def is_carriable(w_lim, trucks, loads):
    """ Check whether w_lim(maximum carrying capacity) is possible or not """
    i = w = 0
    while i < len(loads):
        if w + loads[i] > w_lim:
            trucks -= 1
            w = 0
        else:
            w += loads[i]
            i += 1

        if trucks == 0:
            return False
    return True

n, trucks = map(int, input().split())
loads = [int(input()) for i in range(n)]

left = max(loads)
right = sum(loads) + 1

while right - left > 1:
    mid = (left + right) // 2
    if is_carriable(mid, trucks, loads):
        ans = mid
        right = mid
    else:
        left = mid

if is_carriable(max(loads), trucks, loads):
    ans = max(loads)

print(ans)

Measured memory_bytes: 11616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ll long long
template <typename T>
bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}

const ll MOD = 1e9+7;
long long Comb(int n, int i){long long ans = 1; if(i>n || i < 0) return 0; if(i == 0 || i == n) return 1; else {for(int j = 1; j <= i; ++j){ans *=(n+1-j); ans /= j; ans %= MOD;} }return ans;}

void solve(){
  int n; cin >> n;
  int a[n];
  ll ans = 0;
  rep(i, n) {
    cin >> a[i];
    if(i){
      if(a[i] < a[i-1]){

        ans += a[i-1] - a[i];
        a[i] += a[i-1] - a[i];

      }
    }
  }
  cout << ans << endl;
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 4300
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    
    println!("{}", (n*(n-1))/2)
}

Measured memory_bytes: 4352
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,b) for(ll i=(b)-1, i>=a; --i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scanv(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#define square(x) x*x
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------
ll n,a,b;
void input(){
    cin>>a>>b>>n;
}
void src(){
    rep(i,n){
        if(a%2==1){a--;}
        a/=2;b+=a;
        swap(a,b);
    }
    if(n%2==1){swap(a,b);}
    cout<<a<<" "<<b;     
}    
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())  # N must be an odd number

    left = 1
    count = 0
    buff = 0
    for d in range(N-1, 0, -2):

        if (N-1) & 1 and d <= -d % N:
            buff = 1

        right = left + d - buff
        print(left, right)

        left += 1
        count += 1
        if count == M:
            return


if __name__ == "__main__":
    main()


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define Graph vector<vector<int>>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void func(long long N, std::vector<long long> A) {}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }

    ll max = 0;
    ll ans = 0;

    for (ll i = 0; i < N; i++) {
        if (A.at(i) >= max) {
            max = A.at(i);
            ans += max - A.at(i);
        }

        else {
            ans += max - A.at(i);
        }
    }

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


Measured memory_bytes: 4864
#include<bits/stdc++.h>
typedef long long int ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define p push
#define p1 pop
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair<ll,ll>
#define e 1000000007
using namespace std;
ll v[105],w[105],n,dp[105][100005];
ll solve(ll i,ll W)
{
    if(i==n)
        return 0;
    if((W-w[i])<0)
        return solve(i+1,W);
    if(dp[i][W]!=-1)
        return dp[i][W];
    return dp[i][W]=max(v[i]+solve(i+1,W-w[i]),solve(i+1,W));
}
int main(){
    ll W;cin>>n>>W;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;++i)
        cin>>w[i]>>v[i];
    cout<<solve(0,W);
    return 0;
}

Measured memory_bytes: 82304
N = int(input())
CSF = [list(map(int,input().split())) for i in range(N-1)]

for j in range(0,N,1):
    t = 0
    for i in range(j,N-1,1):
        C,S,F = CSF[i]

        if t < S:#まだ１ポンも出てないなら待つしかない
            t = S
        
        if t%F != 0:
            t += F-t%F
        
        t += C

    print(t)
    


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


using namespace std;

int main() {
    int ans, N, tmp, odd = 1;
    vector<int> A;

    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> tmp;
        A.push_back(tmp);
        if (tmp % 2 == 0) {
            odd *= 2;
        }
    }

    ans = pow(3, N) - odd;

    cout << ans;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#define rep(i, n)for(int i=0; i<n; i++)
using ll = long long int;
using namespace std;

int main(){
    int n;
    cin >> n;
    
    rep(i, 11){
        if(1000*i>n){
            cout << 1000*i-n << endl;
            break;
        }else if(1000*i==n){
            cout << 0 << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>

using namespace std;

int main(void){
    int N,K,T;
    
    cin>>N>>K;
    if((N-1)%(K-1)!=0){
        T=(N-1)/(K-1)+1;
    }else{
        T=(N-1)/(K-1);
    }
    cout<<T<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n,h,m1,m2,c;
    cin >> n;
    c = n%60;
    m1 = (n-c)/60;
    m2 = m1%60;
    h  = (m1-m2)/60;
    cout << h <<":"<< m2 << ":"<< c<<"\n"; 
}


Measured memory_bytes: 3092
#include <iostream>
#include <string.h>
#include <algorithm>
typedef long long ll;
using namespace std;

int main()
{
  char a[10],b[10];
  int ans=0,i;
  cin >> a >> b;
  for(i=0;i<3;i++){
    if(a[i] == b[i]){
      ans++;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
H=[]
for i in range(N):
  h = int(input())
  H.append(h)
H.sort()
m = 1000000000
for i in range(N-K+1):
  if(m>H[i+K-1]-H[i]):
    m = H[i+K-1]-H[i]
print(m)


Measured memory_bytes: 7384
#include <iostream>
using namespace std;
int main(){
    int a,b,c,n,x;
    cin>>a>>b>>c;
    for(x=a,n=0;x<=b;x++){
        if(x>b)break;
        if(c%x==0){n++;}
    }
    cout<<n<<endl;
    
    return 0;
}


Measured memory_bytes: 3088
#include<stdio.h>

int main (void){
  int k,n,a = 0;
  int house[200005];
  int dis[200005];

  scanf("%d %d",&k,&n);
  for(int i = 0;i < n;i++){
    scanf("%d",&house[i]);
  }

  for(int i = 1; i < n; i++){
    dis[i] = k - house[i] + house[i - 1];
  }
  dis[0] = house[n - 1] - house[0];

  a = k;

  for(int i = 0;i < n ;i++){
    if(dis[i] < a){
      a = dis[i];
    }
  }
printf("%d\n",a);
return 0;

}


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

int main(int argc, const char * argv[]) {
    int N, max = 0;
    string s;
    cin >> N >> s;
    for (int i=0; i<N-1; i++) {
        int a[26] = {0} , max1 = 0;
        for (int j = 0; j<=i; j++) {
            a[int(s[j])-int('a')]=1;
        }
        for (int k =i+1; k<N; k++) {
            if(a[int(s[k])-int('a')]==1){
                a[int(s[k])-int('a')]=0;
                max1++;
            }
        }
        if (max1>max) {
            max = max1;
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <iterator>
#define r(i, n) for (int i = 0; i < n; i++)
#define R(i, c, n) for (int i = c; i < n; i++)
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DUMP(a)            \
  REP(d, a.size())         \
  {                        \
    cout << a[d];          \
    if (d != a.size() - 1) \
      cout << " ";         \
    else                   \
      cout << endl;        \
  }
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) \
  sort(ALL(v));   \
  v.erase(unique(ALL(v)), v.end());
#define pb push_back
using namespace std;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

  string a;
  cin >> a;
  int count = 0;
  int maxCount = 0;
  for(auto &s:a){
    if (s=='A'||s=='C'||s=='G'||s=='T'){
      count ++;
    }else{
      count = 0;
    }
    if (count > maxCount) {
      maxCount = count;
    }
  }
  cout << maxCount << endl;

  return 0;
}

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

int n,w;
int w1[101],v[101];
int dp[101][100001];
signed main() {
	scanf("%lld %lld",&n,&w);
	rep(i,n) {
		scanf("%lld %lld",&w1[i],&v[i]);
	}
	rep(i,n) {
		rep(j,w+1) {
			if(j<w1[i]) {
				dp[i+1][j]=dp[i][j];
			}
			else {
				dp[i+1][j]=max(dp[i][j],dp[i][j-w1[i]]+v[i]);
			}
		}
	}
	printf("%lld\n",dp[n][w]);
}


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

int main() {
	int n;
	cin >> n;
	int cnt = 0;
	bool ans = false;

	rep(i, n) {
		int a, b;
		cin >> a >> b;
		if(a == b) {
			cnt++;
		} else {
			cnt = 0;
		}
		if (cnt >= 3) ans=true;
	}

	if (ans == true) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3632
/*
AUTHOR: Aman Raj
LANG: C++
*/

using namespace std;

typedef   long long  int ll;
#include <bits/stdc++.h>


//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
#define fast  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define all(a) a.begin(),a.end()
//#define mod 998244353


#define mod   1000000007

#define inf 1e18
//#define mod 3
#define flush fflush(stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<ll, ll, hash< ll > > ht;

// find_by_order()  // order_of_key
typedef tree<
    ll,
    null_type,
    less<ll>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;






ll power1(ll a, ll b)//a raised to power b
   {  if(b<=0) return 1; if(b==1) return a;
       ll c=power1(a,b/2);
        c*=c;c%=mod;if(b%2==1) c*=a;c%=mod;
        return c;
   }
   ll mi(ll a,ll m)
   { ll c= power1(a,m-2);

     return c;
   }



 struct less_then_greater {
    template<typename T, typename U>
    bool operator()(T const& lhs, U const& rhs) const {
        if (lhs.first < rhs.first) return true;
        if (rhs.first < lhs.first) return false;
        return lhs.second > rhs.second;
    }
};
 /*std::priority_queue<std::pair<int, int>,
                    std::vector<std::pair<int, int>>,
                    less_then_greater
                   > pq;*/
  /*   #define MAXN 1000001
ll spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)

        // marking smallest prime factor for every
        // number to be itself.
        spf[i] = i;

    // separately marking spf for every even
    // number as 2
    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {
        // checking if i is prime
        if (spf[i] == i)
        {
            // marking SPF for all numbers divisible by i
            for (int j=i*i; j<MAXN; j+=i)

                // marking spf[j] if it is not
                // previously marked
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}
vector<ll> getFactorization(ll x)
{
    vector<ll> ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}
*/
// take multiset of all edges
// meanwhile for all cc keep record of all edges in multiset too which can be used to digest
// one line or two lines
//
vector<ll> v;
bool check(ll l,ll k)
{  //cout<<l<<endl;
    for(auto x:v)
    {
        ll cuts=(x+l-1)/l -1;
        if(k>=cuts)k-=cuts;
        else {return false;}
    }
    return true;
}
int main()
{   ll n,k;cin>>n>>k;
     v.resize(n);for(auto &x:v)cin>>x;
     ll l=1,r=1e9+1;
      
      while(l<r)
      {
          ll mid=l+(r-l)/2;
          if(check(mid,k))r=mid;
          else l=mid+1;
      }
      cout<<l<<endl;
    return 0;
}


Measured memory_bytes: 4776
import sys

def solve():
    while True:
        v,m = map(int,raw_input().split())
        if [v,m] == [0,0]:
	    return
	r1,r5,r10 = 0,0,0
	re = m - v
	r10 = re / 1000
	re %= 1000
	r5 = re	/ 500
	re %= 500
	r1 = re	/ 100
	print str(r1) +	" " + str(r5) +	" " + str(r10)



if __name__ == "__main__":
    solve()

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

typedef long long int LLI;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

struct Edge {
  LLI len;
  int u;
  int v;
};

struct E {
  LLI len;
  int to;
};

bool cmp(const Edge &a, const Edge &b) {
  return a.len > b.len;
}

bool cmp2(const E &a, const E &b) {
  if (a.len != b.len) return a.len < b.len;
  return a.to < b.to;
}

int N;
LLI ans[114514];
LLI num[114514];
Edge es[114514];
vector<E> ds[114514];

LLI dfs(int v, int p, LLI conv) {
  //printf("(v, p, conv)=(%d, %d, %lld)\n", v, p, conv);
  LLI ret = 1;
  ans[v] += conv;
  for (E &e : ds[v]) {
    int u = e.to;
    if (u == p) continue;
    //ans[u] += conv;
    LLI res = dfs(u, v, conv);
    conv += res * e.len;
    ans[v] += res*e.len;
    ret += res;
  }
  return num[v] = ret;
}

void dfs2(int v, int p, LLI conv) {
  //printf("2(v, p, conv)=(%d, %d, %lld)\n", v, p, conv);
  ans[v] += conv;
  LLI t = num[v];
  for (E &e : ds[v]) {
    int u = e.to;
    if (u == p) continue;
    //ans[u] += conv;
    t -= num[u];
    dfs2(u, v, conv+e.len*t);
  }
}

int main() {
  scanf("%d", &N);
  UnionFind uf(N);
  for (int i=0; i<N-1; i++) {
    int a, b;
    LLI c;
    scanf("%d%d%lld", &a, &b, &c);
    --a;
    --b;
    es[i] = Edge{c, a, b};
  }
  sort(es, es+N-1, cmp);
  for (int i=0; i<N-1; i++) {
    auto &e = es[i];
    int a = uf.root(e.u);
    int b = uf.root(e.v);
    ds[a].emplace_back(E{e.len, b});
    ds[b].emplace_back(E{e.len, a});
    uf.unionSet(e.u, e.v);
  }

  for (int i=0; i<N; i++) {
    sort(ds[i].begin(), ds[i].end(), cmp2);
  }

  int root = uf.root(0);
  dfs(root, root, 0);
  dfs2(root, root, 0);
  /*for (auto& e: ds[root]) {
    int u = e.to;
    ans[root] += e.len*num[u];
  }*/

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


Measured memory_bytes: 13436
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define MOD 1000000007;//1e9+7

typedef vector<vector<char>>field_t;
typedef pair<int, int> pos_t;
pos_t operator+(const pos_t &lhs, const pos_t &rhs) { return { lhs.first + rhs.first,lhs.second + rhs.second }; }
bool operator==(const pos_t &lhs, const pos_t &rhs) { return (lhs.first == rhs.first) && (lhs.second == rhs.second); }
const pos_t dir[] = { { -1, 0 },{ 1, 0 },{ 0, -1 },{ 0, 1 } };

int BFS(int H, int W, field_t S, pos_t start, pos_t goal) {
    vector<vector<int>> memo(H + 2, vector<int>(W + 2, 0));
    queue<pos_t>q;
    q.push(start);

    while (!q.empty()) {
        pos_t now = q.front();
        q.pop();

        if (now == goal)return memo[now.first][now.second];
        for (int i = 0; i < 4; i++) {
            pos_t next = now + dir[i];
            if (S[next.first][next.second] == '.'&&memo[next.first][next.second] == 0) {
                q.push(next);
                memo[next.first][next.second] = memo[now.first][now.second] + 1;
            }
        }
    }
    return -1;
}

void solve() {
    int H, W;
    cin >> H >> W;
    field_t S(H + 2, vector<char>(W + 2, '#'));
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++)cin >> S[i][j];
    }

    int ans = 0;
    for (int sx = 1; sx <= H; sx++) {
        for (int sy = 1; sy <= W; sy++) {
            for (int gx = 1; gx <= H; gx++) {
                for (int gy = 1; gy <= W; gy++) {
                    if (S[sx][sy] == '.'&&S[gx][gy] == '.') {
                        ans = max(ans, BFS(H, W, S, { sx,sy }, { gx,gy }));
                    }
                }
            }
        }
    }

    cout << ans;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
  long int N,A,B,count;
  long int a,b;
  scanf("%ld %ld %ld",&N,&A,&B);
  
  a=N/(A+B);
  b=N-a*(A+B);
  count=A*a;
  if(b>A) count=count+A;
  else count=count+b;
  printf("%ld",count);
  return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import sys
N, T = map(int, raw_input().split())
A = map(int, raw_input().split())
mini = A[0]
maxdlt = 0
count = 0
for n in A:
    #tmp = maxdlt
    if mini > n:
        mini = n
    dlt = n - mini
    if dlt == maxdlt:
        count = count + 1
    if dlt != 0:
        if maxdlt < dlt:
            maxdlt = dlt
            count = 1
print(count)


Measured memory_bytes: 11304
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll, ll> pll;


ll n, k;
int main()
{
        cin >> n >> k;
        for(ll i=k-n+1;i<=k+n-1;i++) cout <<  i << " "; cout << endl;
        return 0;
}


Measured memory_bytes: 256
import sys
def main():
    n = int(input())
    a = list(map(int, input().split()))
    s = [0 for i in range(10**5+1)]
    sa = sum(a)
    for i in a:
        s[i] += 1
    q = int(input())
    for x in sys.stdin.readlines():
        b, c = map(int, x.split())
        s[c] += s[b]
        sa += (c-b)*s[b]
        s[b] = 0
        print(sa)

main()

Measured memory_bytes: 21104
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N],b[N],c[N-1];
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  for(int i=0;i<N;i++){
    cin>>b[i];
  }
  for(int i=0;i<N-1;i++){
    cin>>c[i];
  }
  int ans=0;
  ans+=b[a[0]-1];
  for(int i=1;i<N;i++){
    ans+=b[a[i]-1];
    if(a[i]-1==a[i-1]){
      ans+=c[a[i]-2];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define zmrl(x) (int)((x).size())
#define ahen(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
const int N = 300001;

int tree[300300<<1];

void update(int idx, int val) {
    tree[idx+=N] = val;
    for (idx>>=1; idx; idx>>=1) {
        tree[idx] = max(tree[idx<<1], tree[idx<<1|1]);
    }
}

int solve(int le, int ri) {
    int ret = 0;
    for (le+=N, ri+=N; le<=ri; le>>=1, ri>>=1) {
        if (le&1) ret = max(ret, tree[le++]);
        if (~ri&1) ret = max(ret, tree[ri--]);
    }
    return ret;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n,k; cin>>n>>k;
    int A[300300];
    for (int i=1; i<=n; i++) {
        cin>>A[i];
    }
    int res = 1;
    update(A[1], 1);
    for (int i=2; i<=n; i++) {
        int maxlen = solve(max(A[i]-k, 0LL), min(A[i]+k, N-1));
        res = max(res, maxlen+1);
        if (tree[A[i]+N] < maxlen+1) {
            update(A[i], maxlen+1);
        }
    }
    cout << res << '\n';
    return 0;
}

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

int main(){
  long long n;
  cin >> n;
  vector<int> a(n-1),b(n);
  for(long long i=0;i<n-1;i++){
    cin >> a.at(i);
    b.at(a.at(i)-1)++;
  }
  
  for(long long i=0;i<n;i++){
    cout << b.at(i) << endl;
  }
  
  return 0;
}


Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii; 
const int N = 1e5+10, mod = 2e9+10;

void solve() {
    string s, t; cin >> s >> t;

    int ans = 0;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] != t[i]) {
            ++ans;
        }
    }
    cout << ans << endl;
}

int main(void) {
    int t = 1; 
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 3860
from itertools import accumulate
from operator import add

N,K = map(int,input().split())
A = map(int,input().split()) 
for k in range(K):
    B = [0] * N
    for i,x in enumerate(A):
        L = max(0, i-x)
        R = min(N-1, i+x)
        B[L] += 1
        if R+1 != N:
            B[R+1] -= 1
    L = list(accumulate(B,add)) 
    #L = list(accumulate(B))[:]
    if L == A:
        break
    A = L
print(*A)    

Measured memory_bytes: 180148
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long N;
long long K;
set<long long> ng;
	vector<long long> ok;
long long ret;



void dfs(long long now) {
	if(now >= N){
		ret = min(now, ret);
		return;
	}

	for(int i = 0; i < ok.size(); i++){
		int next = now*10 + ok[i];
		if(next != 0){
			dfs(next);
		}
	}

}


int main(){
	ret = INT_MAX;

	cin >> N >> K;
	for(int i = 0; i < K; i++){
		long long tmp;
		cin >> tmp;
		ng.insert(tmp);
	}

	for(int i = 0; i < 10; i++){
		if(ng.count(i) == 0){
			ok.push_back(i);
		}
	}

	dfs(0); 

	cout << ret << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#include<ext/rope>
//using namespace __gnu_cxx
//#include<ext/pb_ds/priority_queue.hpp>
//using namespace __gnu_pbds;
#define lowbit(x) (x&-x)
#define pb push_back
#define empb emplace_back
#define all(x) (x).begin(),(x).end()
#define clr(a,b) memset(a,b,sizeof(a))
#define caze(T) for(cin>>T;T;T--)
#define inf (1<<29)
#define Endl ('\n')
#define fi first
#define se second
#define db double
#define ldb long double
#define ll long long
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define ull unsigned long long
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
inline char nc() {
	#define SZ 1000000
	static char buf[SZ], *p1, *p2;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,SZ,stdin),p1==p2)?EOF:*p1++;
}
template<typename T>
inline int scan(T &x) {
	char c, sign=1; 
	while(!isdigit(c=nc())&&c!=EOF)if(c=='-')sign*=-1;
	if(c==EOF) return EOF;
	for(x = 0; isdigit(c); c = nc())
		x = (x<<1) + (x<<3) + (c&15);
	return x *= sign, 1;
}
template<typename T, typename...Args>
inline int scan(T &x, Args&...args) {
	return scan(x), scan(args...);
}
int main()
{
	int n;cin>>n;
	vector<int>c[2];
	c[0].resize(1<<17);
	c[1].resize(1<<17);
	for(int i=0;i<n;++i)
	{
		int x;cin>>x;
		c[i&1][x]++;
	}
	int ans=n;
	int mx=0,nx=0,mp;
	for(int i=0;i<1<<17;++i)
	{
		if(c[1][i]>mx)
			nx=mx,mx=c[1][i],mp=i;
		else if(c[1][i]==mx)
			nx=mx;
		else if(c[1][i]>nx)
			nx=c[1][i];
	}
	for(int j=0;j<1<<17;++j)
	{
		int t=n/2-c[0][j];
		if(mp==j) t+=n/2-nx;
		else t+=n/2-mx;
		ans=min(t,ans);
	}
	cout<<ans<<Endl;
}

Measured memory_bytes: 1280
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e15)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int a,b; cin>>a>>b;
	cout<<max(0ll,a-b-b)<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int a[m];
  for(int i=0;i<m;i++)cin >> a[i];
  if(n>=m)cout << 0 << endl;
  else{
    int L[m],sum=0;
    sort(a,a+m);
    a[m]=a[m-1];
    for(int i=0;i<m;i++)L[i]=a[i+1]-a[i];
    sort(L,L+m,greater<int>());
    for(int i=0;i<n-1;i++)sum+=L[i];
    cout << a[m-1]-a[0]-sum << endl;
  }
}
  
  


Measured memory_bytes: 4260
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 

using namespace std;

//#Rohitpratap311
//#Keep Calm And Stay Happy

typedef long long ll;
typedef long double ld;

bool ifprime(ll n)
{
    if(n==2||n==3) { return true ; }
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0) { return false; }
    }
    return true;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ld d,t,s;
        cin>>d>>t>>s;
        if(d/s<=t)
        {
            cout<<"Yes";
        }
        else
        {
            
            cout<<"No";
        }
    }
    return 0;
}

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

#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 1e9+7;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int p[3];
    //int cnt[3] = {};
    f(3){
        cin >> p[i];
    }
    string s;
    cin >> s;
    ll ans = 0;
    int u[n+5] = {};
    for(int i = 0 ; i < n ; i++){
        if(i>=k&&s[i]==s[i-k]&&u[i-k])continue;
        if(s[i]=='s'){
            ans += p[0];
        }
        else if(s[i]=='p'){
            ans += p[1];
        }
        else{
            ans += p[2];
        }
        u[i] = 1;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 848
N=int(input())
H=list(map(int,input().split()))
if len(H)==1:
  print("Yes")
  exit()
for i in range(1,N):
  if H[i-1]<=H[i]-1:
    H[i]-=1
  elif H[i-1]>H[i]:
    print("No")
    exit()
else:
  print("Yes")

Measured memory_bytes: 14396
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
using ll = long long;
using namespace std;
int main(){
    ll n;
    cin>>n;
    //n以下のうち、商とあまりが等しくなるもの
    //a*m+m=n (m<a)
    //aで全探索
    ll ans=0;
    for(ll i=1; i<sqrtl(n); i++){
        ll tmp=(n-i)/i;
        if(n/tmp==n%tmp){
            ans+=tmp;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

  int ans = 0;
  rep(i, N) { ans += 2 * min(x[i], K - x[i]); }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String t = sc.nextLine();
        int tmp = 0;
        for(int i=0;i<s.length();i++){
        if (s.charAt(i) != t.charAt(i))tmp++;
    }
        System.out.println(tmp);
    }
}

Measured memory_bytes: 42616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn = 1e5 + 5;
ll n, m, sum;
ll a[maxn];
int main(){
	scanf("%lld%lld", &n, &m);
	for(ll i = 0; i < m; i++){
		scanf("%lld", &a[i]);
		sum += a[i];
	}
	if(sum <= n){
		printf("%lld\n", n - sum);
	}
	else{
		printf("-1\n");
	}
	return 0;
}

Measured memory_bytes: 3836
// code.begin();
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back 
#define what_is(x) cerr<<#x<<" is "<<x<<endl;
#define print(v) for(auto i:v) cout<<i<<" ";cout<<endl;
#define my_time ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long 
#define endl "\n"
#define MOD 1000000007
const long long int INF=1e18;
#define mod 1000000007
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    ordered_set; 
//find_by_order(x)
//order_of_key(x)  


int power(int x,unsigned int y)
{
    int res=1;
    
    while(y>0)
    {
        // if y is odd multiply with result
        if(y&1)
        res=res*x;
        
        y=y>>1; // y=y/2;
        x=x*x;
        
    }
    return res;
}

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

ll  max3(ll  a, ll  b, ll c)
{
    return max(c, max(a, b));
}
int min3(int a, int  b, int  c)
{
    return min(a, min(b, c));
}

int  powermod(int  x, int  y, int p )
{
    int res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
int logg(int  a)
{
    int  x = 0;
    while (a > 1)
    {
        x++;
        a /= 2;
    }
    return x;
}


int modinv(int x)
{
    return powermod(x, mod - 2, mod);
}



int  main(){
	my_time;

int t;
t=1;
//cin>>t;int test=0;
while(t--)
{
   
   string str1,str2;
   cin>>str1>>str2;
   
   int n=str1.size();
   int m= str2.size();
   
   int dp[n+1][m+1];
   
   
   for(int i=0;i<=n;i++)
   {
       for(int j=0;j<=m;j++)
       {
           if(i==0 || j==0)
           {
               dp[i][j]=0;
               continue;
           }
           
           if(str1[i-1]==str2[j-1])
           dp[i][j]=dp[i-1][j-1]+1;
           else
           dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
       }
   }
   
   int i=n;int j=m;
   string ans="";
   while(i>0 && j>0)
   {
       if(str1[i-1]==str2[j-1])
       {
           ans.push_back(str1[i-1]);
           i--;
           j--;
       }
       else if(dp[i-1][j]>dp[i][j-1])
       {
           i--;
       }
       else
       {
           j--;
       }
       
       
   }
   reverse(ans.begin(),ans.end());
   cout<<ans<<endl;
   
   
   
}
    return 0;
}


//code.end();





Measured memory_bytes: 38804