akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

template<class T> inline bool cmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool cmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll MAXN=1e5+5;
const ll MAXLG=__lg(MAXN)+2;

ll n,m,dp[MAXN];
vector<ll> edge[MAXN];

ll DFS(ll nd) {
    if (dp[nd] != -1) {
        return dp[nd];
    }

    dp[nd] = 0;
    for (auto v:edge[nd]) {
        dp[nd] = max(dp[nd],DFS(v)+1);
    }

    return dp[nd];
}
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n >> m;
    REP (i,m) {
        ll f,t;
        cin >> f >> t;
        edge[f].eb(t);
    }

    MEM(dp,-1);
    REP1 (i,n) {
        DFS(i);
    }

    ll ans = -1;
    REP1 (i,n) {
        ans = max(ans,dp[i]);
    }

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


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

int main(){
  ll a,b,n;
  cin>>a>>b;
  n=b-a;
  cout<<(n*(n+1))/2-b<<endl;
}

Measured memory_bytes: 256
import math

n = int(input())
m = int(math.sqrt(n))

if n % m == 0:
    print(int(math.log10(m) + 1))

else:
    for i in range(1, m)[::-1]:
        if n % (i) == 0:
            print(int(math.log10(n / i) + 1))
            break


Measured memory_bytes: 2940
#define USE_MATH_DEFINES 1
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 998244353ll
#define INF 1000000000000000000ll
#define EPS 1e-9
#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock

typedef long long         ll;
typedef long double       ld;
typedef pair <ll,ll>      pl;
typedef tuple <ll,ll,ll>  tl;

ll N, M, K, S, pm[200005], pmdec[200005], fac[200005], facmmi[200005];

inline ll expo (ll b, ll e) {
	ll v = 1;
	while (e) {
		if (e & 1) v = (v * b) % MOD;
		b = (b * b) % MOD;
		e >>= 1;
	}
	return v;
}

inline ll binomial (ll x, ll y) {
	if (x < y) return 0;
	else return (fac[x] * ((facmmi[x-y] * facmmi[y]) % MOD)) % MOD;
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> N >> M >> K;
	
	pm[0] = 1;
	pmdec[0] = 1;
	fac[0] = 1;
	facmmi[0] = 1;
	
	for (ll i = 1; i <= 200000; i++) {
		pm[i] = (pm[i-1] * M) % MOD;
		pmdec[i] = (pmdec[i-1] * (M-1)) % MOD;
		fac[i] = (fac[i-1] * i) % MOD;
		facmmi[i] = expo(fac[i], MOD-2);
	}
	
	S = 0;
	
	for (ll i = 0; i <= K; i++) {
		ll term = binomial(N-1, i);
		term = (term * M) % MOD;
		term = (term * pmdec[N-1-i]) % MOD;
		S = (S + term) % MOD;
	}
	
	cout << S;
	
    return 0;
}

Measured memory_bytes: 9900
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
 
public class Program
{
    public void Proc() {
        Reader.IsDebug = false;
        long[] inpt = Reader.ReadLine().Split(' ').Select(a=>long.Parse(a)).ToArray();
 
        long target = inpt[1];
 
        long[] boxList = Reader.ReadLine().Split(' ').Select(a=>long.Parse(a)).ToArray();
 
        long ans = 0;
        for(int i=0; i<boxList.Length; i++) {
            long count = boxList[i];
            if(i<boxList.Length-1) {
                count+=boxList[i+1];
            }
            if(count <= target) {
                continue;
            }
            if(i<boxList.Length-1) {
                ans+=Math.Min(boxList[i+1], count-target);
                boxList[i+1] -= Math.Min(boxList[i+1], count-target);
                count = boxList[i];
                if(i<boxList.Length-1) {
                    count+=boxList[i+1];
                }
            }
            if(count > target) {
                ans+=Math.Min(boxList[i], count-target);
                boxList[i]-=Math.Min(boxList[i], count-target);
            }
        }
        Console.WriteLine(ans);
 
    }
 
 
    public class Reader {
        public static bool IsDebug = true;
        private static System.IO.StringReader SReader;
        private static string InitText = @"


6 1
1 6 1 2 0 4


";
        public static string ReadLine() {
            if(IsDebug) {
                if(SReader == null) {
                    SReader = new System.IO.StringReader(InitText.Trim());
                }
                return SReader.ReadLine();
            } else {
                return Console.ReadLine();
            }
        }
    }
    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 19160
N = int(input())
A = list(map(int, input().split()))

b = []
for i, a in enumerate(A):
	b += [a - i]
b.sort()

#print(b)

def solve(b):
	result = 0
	for i, a in enumerate(A):
		result += abs(a - (b + i))
	return result

if 0 == N % 2:
	b1, b2 = b[N // 2 - 1], b[N // 2]
	print(min(solve(b1), solve(b2)))
else:
	b1 = b[N // 2]
	print(solve(b1))


Measured memory_bytes: 26836
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int N;
	cin >> N;
	int* x = new int[N];
	for (size_t i = 0; i < N; i++)
		cin >> x[i];

	int* ways = new int[N];
	
	for (size_t j = 0; j < N; j++)
		ways[j] = 0;
		
	ways[0] = 2;

	long long start = 0;
	for (int i = 2; i < N; i++)
	{
		if (i - (x[i - 1] + 1) / 2 > start)
			start++;
		ways[start]++;
	}

	for (size_t i = 1; i < N; i++)
		ways[i] += ways[i-1];

	long long result = ways[0];
	for (int j = 1; j < N; j++)
		result = (result * (ways[j] - j)) % 1000000007;

	cout << result;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 99999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    int n;
    cin >>n;
    vector<double> v(n);
    rep(i,n) cin >> v[i];
    rep(i,n-1){
        sort(v.begin(),v.end());
        v[0] = (v[0]+v[1])/2;
        double tmp = v[1];
        v[1] = v[(int)v.size()-1];
        v[(int)v.size()-1] = tmp;
        v.pop_back();
    }
    cout << v[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

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

	cout << a + b + c << endl;
	return 0;
}




Measured memory_bytes: 3164
#include <stdio.h>

int main(void){

 long long int A, B, K;
  scanf("%lld %lld %lld",&A,&B,&K);
  if(K<A){
    printf("%lld %lld",A-K,B);
  }else if(K>A+B){
    printf("0 0");
  }
  else{
    printf("0 %lld",B-K+A);
  }

  return 0;
}


Measured memory_bytes: 128
//abc102_a.cpp
//Sat Jul  7 20:04:44 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
using ll=long long;

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

	if (n%2 == 0){
		cout << n << endl;
	}else {
		cout << n*2 << endl;
	}
}

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

const string YES = "Yes";

class Edge{
public:
    int from, to;
    long long value;
    Edge(int a, int b, long long c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
vector<ll> hukugen;

std::vector<long long> dijkstra(int s, int N, std::vector<Edge> E){
    std::vector<long long> ans(N, 1e18);
    std::vector<std::vector<Edge>> Edges(N);
    for(auto e : E){
        Edges.at(e.from).push_back(e);
    }
    std::priority_queue<std::pair<long long, int>, std::vector<std::pair<long long, int>>, std::greater<std::pair<long long, int>>> que;
    ans.at(s)= 0;
    que.push(std::make_pair(0, s));
    while(!que.empty()){
        std::pair<long long, int> p = que.top();
        que.pop();
        if(ans.at(p.second) < p.first)continue;
        for(int i = 0;i < Edges.at(p.second).size();i++){
                if(ans.at(p.second) + Edges.at(p.second).at(i).value < ans.at(Edges.at(p.second).at(i).to)){
                    hukugen[Edges.at(p.second).at(i).to] = p.second;
                    ans.at(Edges.at(p.second).at(i).to) = ans.at(p.second) + Edges.at(p.second).at(i).value;
                    que.push(std::make_pair(ans.at(Edges.at(p.second).at(i).to),Edges.at(p.second).at(i).to));
                }
        }
    }
    return ans;
}

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B){
    hukugen = vector<ll>(N);
    vector<Edge> vec;
    for(int i = 0;i < M;i++){
        vec.push_back(Edge(A[i] - 1, B[i] - 1, 1));
        vec.push_back(Edge(B[i] - 1, A[i] - 1, 1));
    }
    vector<ll> d = dijkstra(0, N, vec);
    cout<<"Yes"<<endl;
    for(int i = 1;i < N;i++){
        cout<<hukugen[i] + 1<<endl;
    }
}

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


Measured memory_bytes: 35840
#include<cstdio>
using namespace std;
int main(){
    int r,c;
    scanf("%d %d",&r,&c);
    int COL[r+1][c+1];
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            int tmp=0;
            scanf(" %d",&tmp);
            COL[i][j]=tmp;
        }
    }
    
    for(int i=0;i<r;i++){
        int sum=0;
        for(int j=0;j<c;j++){
            sum+=COL[i][j];
        }
        COL[i][c]=sum;
    }
    for(int i=0;i<c;i++){
        int sum=0;
        for(int j=0;j<r;j++){
            sum+=COL[j][i];
        }
        COL[r][i]=sum;
    }
    int sum=0;
    for(int i=0;i<r;i++){
        sum+=COL[i][c];
    }
    COL[r][c]=sum;
  
    for(int i=0;i<=r;i++){
        for(int j=0;j<=c;j++){
            printf("%d",COL[i][j]);
            if(j!=c){
                printf(" ");
            }
            
        }
        printf("\n");
    }

}



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


int main(void) {
int a,b,c,k;
cin >> a >> b >> c >> k;
int cnt = 0;
while (b <= a) {
    b *= 2;
    cnt++;
}
while (c <= b) {
    c *= 2;
    cnt++;
}

if (cnt <= k) cout << "Yes" << endl;
else cout << "No" << endl;

return 0;
}





Measured memory_bytes: 3628
import numpy as np
import fractions

N = int(input())
A = np.array([int(i) for i in (input()).split(" ")])

maxA = np.max(A)


if(maxA == np.min(A)):
    print(maxA)
elif(N==2):
    print(maxA)
else:
    R=np.zeros((N))
    L=np.zeros((N))
    M=np.zeros((N))

    L[0] = 0
    R[N-1] = 0
    for i in range(1,N):
        #0~i-1番目までの最大公約数
        L[i] = fractions.gcd(A[i-1],L[i-1])
        #i~N番
        R[N-1-i] = fractions.gcd(A[N-1-i+1],R[N-1-i+1])

    M[0] = R[0]
    M[-1] = L[-1]
    for i in range(1,N-1):
        M[i] = fractions.gcd(L[i],R[i])

    print("{}".format(int(np.max(M))))


Measured memory_bytes: 24244
import numpy as np

x = list(map(int, input().split()))

if x[2] >= x[0] and x[0] >= 1:
    x[2] -= x[0]
    x[0] = 0

    if x[2] >= x[1] and x[1] >= 1:
        x[1] = 0
    else:
        x[1] -= x[2]

elif x[2] < x[0] and x[0] >= 1:
    x[0] -= x[2]

elif x[0] == 0 and x[1] == 0:
    pass
elif x[0] == 0 and x[1] >= 1:
    if x[2] >= x[1] and x[1] >= 1:
        x[1] = 0
    else:
        x[1] -= x[2]



print(str(x[0]) + " " + str(x[1]))

Measured memory_bytes: 21632
let max_m = 2000

let to_int_list str =
  Str.split (Str.regexp_string " ") str |> List.map int_of_string

let make_dp a n =
  let dp = Array.make_matrix (n + 1) (max_m + 1) false in
  let rec duduwa i j =
    if j > max_m then doit (i + 1)
    else begin
      if dp.(i - 1).(j) then dp.(i).(j) <- true
      else if j > a.(i - 1) && dp.(i - 1).(j - a.(i - 1)) then dp.(i).(j) <- true;
      duduwa i (j + 1)
    end
  and doit i =
    if i > n then dp
    else (dp.(i).(a.(i - 1)) <- true; duduwa i 1)
  in
  doit 1

let _ =
  let n = read_int () in
  let a = Array.of_list (to_int_list (read_line ())) in
  let _ = read_int () in
  let m = to_int_list (read_line ()) in
  let dp = make_dp a n in
  List.iter (fun e -> Printf.printf "%s\n" (if dp.(n).(e) then "yes" else "no")) m

Measured memory_bytes: 2584
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

n,a,b=map(int,input().split())

ans=pow(2,n)-1
ans%=mod
atmp=1
waru=1
for i in range(a):
    atmp*=n-i
    waru*=i+1
    atmp%=mod
    waru%=mod
waru=pow(waru,mod-2,mod)
atmp*=waru

btmp=1
waru=1
for i in range(b):
    btmp*=n-i
    waru*=i+1
    btmp%=mod
    waru%=mod
waru=pow(waru,mod-2,mod)
btmp*=waru
# print(atmp,btmp)
ans=ans-(atmp+btmp)+mod*2
ans%=mod
print(ans)

Measured memory_bytes: 291724
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

const int N = 50;

vector<pair<int,pii>> g[N];
bool vis[N][N*N+1];
ll d[N][N*N+1];
int cnt[N], cst[N];

void dij(int s){
	priority_queue<pair<ll,pii>, vector<pair<ll,pii>>, greater<pair<ll,pii>>> pq;	
	pq.push({0,{0,s}});
	while(pq.size()){
		ll dist = pq.top().first;
		int u = pq.top().second.first;
		int c = pq.top().second.second;
		pq.pop();
		if(!vis[u][c]){
			vis[u][c] = 1;
			d[u][c] = dist;
			if(c != N*N && !vis[u][c+1]){
				pq.push({dist + cst[u],{u,min(c+cnt[u],N*N)}});
			}
			for(auto e: g[u]){
				int to = e.first;	
				int coin_cst = e.second.first;
				int w = e.second.second;
				if(c >= coin_cst && !vis[to][c-coin_cst]){
					pq.push({dist + w,{to,c-coin_cst}});	
				}
			}
		}
	}
}

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,m,s;
	cin >> n >> m >> s;
	rep(i,0,m){
		int x,y,coins,w;
		cin >> x >> y >> coins >> w;
		--x,--y;
		g[x].push_back({y,{coins,w}});
		g[y].push_back({x,{coins,w}});
	}
	rep(i,0,n)cin >> cnt[i] >> cst[i];
	dij(min(s,N*N));
	rep(i,1,n)rep(j,0,N*N+1)if(vis[i][j])gmin(d[i][0],d[i][j]);
	rep(i,1,n)cout << d[i][0] << '\n';
}


Measured memory_bytes: 8204
def goes_to_zero(n):
    cnt = 0
    while(n > 0):
        n %= bin(n).count('1')
        cnt += 1
    return cnt

N = int(input())
X = input()

XC = X.count('1')
XI = int(X, 2)
XCP = XC + 1
XCM = XC - 1
XTP = XI % XCP
XTM = XI % XCM if XCM != 0 else 0

for i in range(N):
    if X[i] == "0":
        print(goes_to_zero((XTP + pow(2, N - 1 - i, XCP)) % XCP) + 1)
    else:
        if XCM == 0:
            print(0)
        else:
            print(goes_to_zero((XTM - pow(2,N - 1 - i, XCM)) % XCM) + 1)

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

int get_digit_sum(int n) {
	int digit_sum = 0;
	while(n > 0) {
		digit_sum += n % 10;
		n /= 10;
	}

	return digit_sum;
}

int main() {
	int n, a, b;
	cin >> n >> a >> b;

	int sum = 0;
	for(int i = 1; i <= n; i++) {
		int digit_sum = get_digit_sum(i);
		if(digit_sum >= a && digit_sum <= b) sum += i;
	}

	cout << sum << endl;

 	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <queue>
using namespace std;

int main() {
    int N;
    int X;
    int Y;

    cin >> N;
    cin >> X >> Y;
    --X;
    --Y;

    const int INF = 1000000;
    vector< vector<int> > dist(N);
    vector < vector<int> > adja(N);
    vector<int> distCount(N);

    adja[X].push_back(Y);
    adja[Y].push_back(X);

    for (int i = 1; i < N; ++i) {
        adja[i].push_back(i-1);
        adja[i-1].push_back(i);
    }

    for (int i = 0; i < N; ++i) {
        deque <int> que;
        que.push_back(i);
        dist[i] = move(vector<int>(N, INF));
        dist[i][i] = 0;

        while (!que.empty()) {
            int now = que.front();
            que.pop_front();

            for (int j = 0; j < adja[now].size(); ++j) {
                int nextv = adja[now][j];

                if (dist[i][nextv] == INF) {
                    dist[i][nextv] = dist[i][now] + 1;
                    que.push_back(nextv);
                }
            }
        }
    }

    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            ++distCount[dist[i][j]];
        }
    }


    for (int i = 1; i < N; ++i) {
        cout << distCount[i] << endl;
    }


    return 0;
}

Measured memory_bytes: 16128
#include<stdio.h>
int main()
{
	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);
	if (a < b)
		printf("%d ", a);
	else
		printf("%d ", b);
	if (a + b - n > 0)
		printf("%d\n", a + b - n);
	else
		printf("0\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	string s;
	cin >> s;
	int n = s.size();
	for (int i = 0; i < n - 1; i++) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
	}
	for (int i = 0; i < n - 2; i++) {
		if (s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
	return 0;
}



Measured memory_bytes: 3760
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
    buf := make([]byte, 0, 1000000)
    for {
        l, p, e := rdr.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}

func toInt(str string) int  {
    n, _ := strconv.Atoi(str)
    return n
}

func abs(a int) int {
    return int(math.Abs(float64(a)))
}

func getPar(x int, parent[1000]int) int {
    if parent[x] == x {
        return x
    } else {
        parent[x] = getPar(parent[x], parent)
        return parent[x]
    }
}

func main() {
    nm := strings.Split(readLine(), " ")
    n := toInt(nm[0])
    m := toInt(nm[1])
    var parent [1000]int
    for i := 0;i < n; i++ {
        parent[i] = i
    }


    for i := 0; i < m; i++ {
        ab := strings.Split(readLine(), " ")
        pa := getPar(toInt(ab[0]) - 1, parent)
        pb := getPar(toInt(ab[1]) - 1, parent)
        parent[pb] = pa
    }

    cities := make(map[int]int)
    villageCnt := 0
    for i := 0;i < n; i ++ {
        pi := getPar(i, parent)
        if i != pi {
            cities[pi] = 1
        } else {
            villageCnt ++
        }
    }
    cityCnt := len(cities)
    fmt.Println(abs(cityCnt * 2 - villageCnt))
}


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

int main(void)
{
  string S[3];
  cin >> S[0] >> S[1] >> S[2];
  int turn = 0;
  int pos[3] = {0};

  char temp;
  while (true)
  {
    if (pos[turn] >= S[turn].length())
    {
      break;
    }
    temp = S[turn][pos[turn]];
    pos[turn]++;
    turn = temp - 'a';
  }

  char result[3] = {'A', 'B', 'C'};
  cout << result[turn] << endl;

  return 0;
}

Measured memory_bytes: 256
n = input()
n = int(n)
ss = input().split()
sslist = sorted(ss)
# print(sslist)
dic_ss = {}
for x in sslist:
  dic_ss.setdefault(x,0)
  dic_ss[x] += 1
# print(dic_ss)
# 1) 3回以上の重複があれば、その数字だけを使って、排除 N -> N-2
for key, value in dic_ss.items():
  while value >= 3:
    value -= 2
  dic_ss[key] = value
# print(dic_ss)
# 2) 2回重複の最小値と最大値を使って重複排除 Min N -> N-1, Max M -> M-1
key1 = None
key2 = None
for key, value in dic_ss.items():
  if key1 == None and value == 2:
    key1 = key
  elif key2 == None and value == 2:
    key2 = key
  if key1 != None and key2 != None:
    dic_ss[key1] = 1
    dic_ss[key2] = 1
    key1 = None
    key2 = None
# print(dic_ss)
# 3) 2回重複が1つ残ったら、重複なしから1つ削除
count = len(dic_ss)
for key, value in dic_ss.items():
  if value > 1:
    count -= 1
print(count)

Measured memory_bytes: 20144
#include<bits/stdc++.h>
using namespace std;
//define
#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define Rep(x,y) for(int k=x;k<y;k++)
#define str string
#define pb() push_back()
#define all(x) x.begin(),x.end()
#define elif else if
#define mod 100000007
//vectordefine
#define vint vector<int>
#define vvint vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vool vector<bool>
#define vtr vector<str>
#define vvtr vector<vector<str>>
//queuedefine
#define qint queue<int>
#define qtr queue<string>
#define qc queue<char>
//pairdefine
#define pint pair<int,int>
#define pic pair<int,char>
#define pci pair<char,int>
#define pis pair<int,str>
#define psi pair<str,int>
#define pcc pair<char,char>
#define pss pair<str,str>
#define mp make_pair
//mapdefine
#define mint map<int,int>
#define mic map<int,char>
#define mci map<char,int>
#define mis map<int,str>
#define msi map<str,int>
//function
str shizuku(char,char);
//UnionFind
struct UnionFind{
  vint par;
  UnionFind(int N):par(N){
    rep(0,N)par[i]=i;
  }
  int root(int x){
    if(par[x]==x)return x;
    return par[x]=root(par[x]);
  }
  void unite(int x,int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry)return;
    par[rx]=ry;
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }
};
//binary_search

//main
signed main(){
    int M,X,count=0,count2=0;
    double d,D;
    int alph='A'-'a';
    char op,Ch;
    str S,T;
    vint N(3);
    rep(0,3)cin>>N[i];
    sort(all(N));
    cout<<N[0]+N[1]<<endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<iostream>
const int maxn=1e5+10;
char s[maxn];
int main()
{
    scanf("%s",s+1);
    int len=strlen(s+1);
    for(int i=1;i<=len;i++)
    {
        if(i>=2 && s[i]==s[i-1])
        {
            printf("%d %d\n",i-1,i);
            return 0;
        }
        if(i>=2 && i<len && s[i-1]==s[i+1])
        {
            printf("%d %d\n",i-1,i+1);
            return 0;
        }
    }
    printf("-1 -1\n");
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N, K;
  cin >> N >> K;
  long long ans = 0;
  if(K % 2 == 0){
    ans+=(N / K) * (N / K) * (N / K);
    ans+=(N/K+(N%K)/(K/2))*(N/K+(N%K)/(K/2))*(N/K+(N%K)/(K/2));
  }else{
    ans = (N / K) * (N / K) * (N / K);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split(" "))
a=[0 for i in range(n)]
g=0
for i in range(k):
  d=int(input())
  A=input().split(" ")
  for j in range(d):
    if a[int(A[j])-1]==0:
      a[int(A[j])-1]=1
      g=g+1
print(n-g)

Measured memory_bytes: 9200
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int sumProfit;
		int sumNumber;
		String str[];
		int count;

		double b = 2.4;
		double c = 2.5;
		double d = 2.6;

		sumProfit = 0;
		sumNumber = 0;
		count = 0;
		while (sc.hasNext()) {
			str = sc.next().split(",");
			sumProfit += Integer.valueOf(str[0]) * Integer.valueOf(str[1]);
			sumNumber += Integer.valueOf(str[1]);
			count++;
		}
		System.out.println(sumProfit);
		System.out.printf("%.0f\n", sumNumber * 1.0 / count);
	}
}

Measured memory_bytes: 12000
import std.stdio, std.string, std.array, std.conv;

void main() {
    int n = readln.chomp.to!int;
    int[] h = readln.split.to!(int[]);
    bool ok = true;
    int cnt = 1;
    foreach (i; 1 .. n) {
        if (h[i] > h[i-1]) {
            ++cnt;
        } else if (h[i] < h[i-1]) {
            if (h[i-1] - h[i] > cnt) ok = false;
            cnt = 0;
        }
    }
    writeln(ok ? "Yes" : "No");
}

Measured memory_bytes: 4548
#include <bits/stdc++.h>
#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 ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main()
{
    int n;
    cin >> n;
    set<int> s;
    REP(i, n){
        int m;
        cin >> m;
        if(s.find(m) == s.end()) s.insert(m);
        else{
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


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

int main(){
    string s;
    cin>>s[0]>>s[1]>>s[2];
    if (stoi(s)%4==0)
    {
        /* code */
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
    
    
    }


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

int main() {
    int64_t N, W, a = 0;
    cin >> N >> W;
    vector<vector<int64_t>> S(N, vector<int64_t>(2));
    vector<vector<int64_t>> ans(N,vector<int64_t>(W));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 2; j++) {
            cin >> S.at(i).at(j);
        }
    }
    for (int i = 0; i < N; i++) {
        if(i == 0) {
            ans.at(i).at(S.at(i).at(0) - 1) = S.at(i).at(1);
        }
        if (i == N - 1){
            break;
        }
        for (int j = 0; j < W; j++) {
            if (j - S.at(i + 1).at(0) >= 0){
                ans.at(i + 1).at(j) = 
                max(ans.at(i).at(j), ans.at(i).at(j - S.at(i + 1).at(0)) + S.at(i + 1).at(1));
            }
            else {
                ans.at(i + 1).at(j) = ans.at(i).at(j);
            }
        }
    }
    for (int i = 0; i < W; i++) {
        a = max(a, ans.at(N - 1).at(i));
    }
    cout << a << endl;
}

Measured memory_bytes: 79488
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

int main() {
  string s;
  cin >> s;
  if (s[0] != 'A' || count(s.begin() + 2, s.end() - 1, 'C') != 1) {
    cout << "WA" << endl;
    return 0;
  }
  int k = 0;
  for (char c : s) {
    if (isupper(c)) ++k;
  }
  cout << (k == 2 ? "AC" : "WA") << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int k;
	cin>>k;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]==s[k-1]) cout<<s[i];
		else cout<<"*";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll N;
    cin>>N;
    ll even=N/2;
    ll odd=even;
    if(N%2==1)++odd;
    
    cout<<odd*even<<endl;
}


Measured memory_bytes: 764
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")
    };
}

#[allow(unused_imports)]
use std::{i32, i64, u32, u64, usize, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};

fn main() {
    input!{
        s: String,
    }
    if s.starts_with("keyence")
        || s.starts_with("k") && s.ends_with("eyence")
        || s.starts_with("ke") && s.ends_with("yence")
        || s.starts_with("key") && s.ends_with("ence")
        || s.starts_with("keye") && s.ends_with("nce")
        || s.starts_with("keyen") && s.ends_with("ce")
        || s.starts_with("keyenc") && s.ends_with("e")
        || s.ends_with("keyence") { println!("YES"); }
    else { println!("NO"); }
}


Measured memory_bytes: 4352
// ref: https://arc068.contest.atcoder.jp/submissions/3000198
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8] = { 0,0,-1,1,1,1,-1,-1 };
int dy[8] = { -1,1,0,0,1,-1,1,-1 };
const int SIZE = 300050;
//ここまでテンプレ
//↓Binary Indexed Tree
struct BIT {
private:
	int n;
	vector<int> node;
public:
	//N要素のBITを作り、すべて0で初期化する
	//1-indexedであることに注意！！
	BIT(int N) {
		node.resize(N + 1, 0);
		n = N;
	}
	//ノードiまでの和を計算する
	int sum(int i) {
		if (!i)
			return 0;
		return node[i] + sum(i - (i&-i));
	}
	//ノードiにxを足す
	void add(int i, int x) {
		if (i > n)
			return;
		node[i] += x;
		add(i + (i&-i), x);
	}
};
//↑Binary Indexed Tree
int main() {
	int N, M;
	cin >> N >> M;
	//x=l,y=r
	//クエリ<x,0:区間,1:質問,y>
	priority_queue<tint, vector<tint>, greater<tint>> Q;
	vector<unordered_set<int> > memo(M+2);
	//クエリに区間を入れる
	for (int i = 0; i < N; i++) {
		int l, r;
		cin >> l >> r;
		Q.emplace(l, 0, r);
	}
	//クエリに質問を入れていく
	for (int i = 1; i <= M; i++) {
		for (int j = i; j <= M; j += i) {
			int a = j - i, b = j;
			//すでに入れてたら入れない
			if(memo[b].find(b) == memo[b].end())
				Q.emplace(b, 1, b);
			if(memo[a].find(b) == memo[a].end())
				Q.emplace(a, 1, b);
		}
	}
	//BIT
	BIT B(M + 2);
	//クエリを処理する
	vector<unordered_map<int, int> > pam(M + 2);
	while(not Q.empty()){
		int a, b, c;
		tie(a, c, b) = Q.top(); Q.pop();
		//区間クエリなら、区間を追加する
		if (c == 0) {
			//S.update(b,S.getsum(b,b+1)+1);
			B.add(b + 1, 1);
		}
		//質問クエリなら、質問に答える
		else {
			//pam[mp(a,b)]=S.getsum(b,M+1);
			pam[a][b] = B.sum(M + 1) - B.sum(b);
		}
	}
	/*
	for(pair<pint,int> P:pam)
		cout<<P.first.first<<" "<<P.first.second<<" "<<P.second<<endl;
	*/
	//答えを求める
	for (int i = 1; i <= M; i++) {
		int ans = 0;
		for (int j = i; j <= M; j += i) {
			int a = j - i, b = j;
			ans += pam[b][b] - pam[a][b];
		}
		cout << ans << endl;
	}
	system("pause");
	return 0;
}


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

int main(){
  char a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  if(a==f && b ==e && c==d){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}
      

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 
 
#define PI 3.14159265
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
const ll limit = 2e9;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};
 
//const int mod = 998244353;
 
struct dsu{
	int parent[N];
	int cont;
	void make_set(int n){
		for(int i = 1; i <= n; i++)
			parent[i] = i;
		cont = n;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a);
		b = find_set(b);	
		if(a != b){
			parent[b] = a;
			cont--;
		}
	}	
};


double v[200007];
double ac[200007];
int main(){
	int n, k; cin>> n >> k;
	
	for(int i = 1; i <= n; i++){
		int x; cin>> x;
		v[i] = (1.0*x*(x+1)/2.0) / x;
		ac[i] = v[i] + ac[i-1];
		//~ cout<<v[i]<<" "; 
	} 
	
	double maxi = 0.0;
	for(int i = 1; i+k-1 <= n; i++){
		int l = i, r = i+k-1;
		if(l>= 1 && r <= n){
			double sum = ac[r] - ac[i-1];		
			if(sum > maxi)
				maxi = sum;
		}
	}
	std::cout << std::fixed;
	std::cout << std::setprecision(9);
	cout<<maxi;
	return 0;
}













Measured memory_bytes: 3328
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<utility>
using namespace std;
 
typedef long long ll;
 
int main(){
  string s;
  cin >> s;
  while(true){
    if(s=="") break;
  	if(s.substr(0,2)=="hi"){
    	s = s.substr(2);
    }else{
    	cout << "No";
        return 0;
    }
  }
  cout << "Yes";
  return 0;
}


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

#define MEM(a, b) memset(a, b, sizeof a);
#define REP(i, k) for(int i = (0); i < (k); i++ )

#define ALL(cont) cont.begin(), cont.end()
#define RALL(cont) cont.begin(), cont.end()
#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define debug puts("FANGO")
#define INF (int)INT_MAX
#define EPS (int)1e-9
#define PI acos(-1)
#define MOD 1000000007

typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef long long int32;
typedef unsigned long long uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

template <class T>
T sqr(T val) {
  return val * val;
}



void solve(__attribute__((unused)) int tc = 0) {
  int n;
  cin >> n;

  vi v;
  int sum = 0;
  REP(i, n) {
    int x;
    cin >> x;
    v.pb(x);
    sum += x;
  }

  int64 m[2][200005];
  MEM(m, 0);
  m[0][0] = v[0];
  m[1][0] = -v[0];
  REP(i, n - 2) {
    m[0][i + 1] = max(m[0][i] + v[i + 1], m[1][i] + v[i + 1] * -1);
    m[1][i + 1] = max(m[0][i] + v[i + 1] * -1, m[1][i] + v[i + 1]);
  }
  m[0][n - 1] = m[0][n - 2] + v[n - 1];
  m[1][n - 1] = m[1][n - 2] + v[n - 1] * -1;

  cout << max(m[0][n - 1], m[1][n - 1]) << endl;


  return;
}

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  /*int TC;
  cin >> TC;
  REP(tc, TC) {
    solve(tc);
  }*/
  solve();
}


Measured memory_bytes: 3960
#include<stdio.h>


int main(){
    int n;
    scanf("%d",&n);
    int R[200000];
    int i;
    for(i=0;i<n;i++){
        scanf("%d\n",&R[i]);
    }
    int min=R[0];
    int max=-1000000000;
    for(i=1;i<n;i++){
        if((R[i]-min)>max){
            max=R[i]-min;
        }
        if(R[i]<min){
            min=R[i];
        }
    }
    printf("%d\n",max);
    return 0;
}




Measured memory_bytes: 2624
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(int argc, char const *argv[])
{
	int a,b;
	scanf("%d %d", &a, &b);
  	int t = b;
    int digit = 0;
  	while(t!=0) {
      t/=10;
      digit++;
    }
	int num = a*pow(10,digit)+b;
  	int ans = pow(num, 0.5);
    if (ans*ans==num) {
      printf("Yes");
    }else{
      printf("No");
    }


	return 0;
}

Measured memory_bytes: 2552
from collections import deque
h, w = map(int, input().split())
black = 0
v = [""] * h
for i in range(h):
    v[i] = input()
    for c in v[i]:
        black += c == '#'

d = [[(10 ** 18)]*w for j in range(h)]
d[0][0] = 0

q = deque()
q.append((0, 0))
dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
while len(q):
    y, x = q.popleft()
    for k in range(4):
        ny = y + dy[k]
        nx = x + dx[k]
        if not (0 <= ny and ny < h and 0 <= nx and nx < w):
            continue
        if v[ny][nx] == '#':
            continue
        if d[ny][nx] < (10 ** 18):
            continue
        d[ny][nx] = d[y][x] + 1
        q.append((ny, nx))

if d[h - 1][w - 1] == 10 ** 18:
    print(-1)
    exit()
print(h*w-black-d[h-1][w-1]-1)


Measured memory_bytes: 3316
n = int(input())
d = {}
d['M'] = 0
d['A'] = 0
d['R'] = 0
d['C'] = 0
d['H'] = 0
for i in range(n):
    s = str(input())
    if s[0] in d:
        d[s[0]] += 1
#print(d)

v = list(d.values())
import itertools
ans = 0
for c in itertools.combinations(range(5),3):
    ans += v[c[0]]*v[c[1]]*v[c[2]]
print(ans)


Measured memory_bytes: 43624
//-------------
//include
//-------------
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <random>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef long long LL;
typedef  vector<int> VI;
typedef  set<int> SI;
typedef  string STR;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MK make_pair
#define PB push_back
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(a) cout<<a<<endl
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumpl(c) REP(i,SZ(c))cerr<<#c<<i<<"="<<(c[i])<<endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int MOD = 1000000007;
int main()
{
	STR A;
	cin >> A;
	cout << A[0] << SZ(A)-2 << A[SZ(A)-1] << endl;
#ifdef _DEBUG
	while (1);
#endif // _DEBUG

	return 0;
}

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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 200 * 1000 + 9;

int n;
int a[maxN];

int pref[maxN], suff[maxN];

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

	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}

	pref[0] = suff[n + 1] = 0;

	for(int i = 1; i <= n; i++){
		pref[i] = max(pref[i - 1], a[i]);
	}

	for(int i = n; i > 0; i--){
		suff[i] = max(suff[i + 1], a[i]);
	}

	for(int i = 1; i <= n; i++){
		cout << max(pref[i - 1], suff[i + 1]) << '\n';
	}

	return 0;
}

Measured memory_bytes: 3968
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	class Pazzle {
		int y, x;
		int[][] board;
		Pazzle(int y, int x, int[][] board) {
			this.y = y;
			this.x = x;
			this.board = new int[N][N];
			for (int i = 0; i < N; i++)
				for (int j = 0; j < N; j++)
					this.board[i][j] = board[i][j];
		}
		Pazzle(Pazzle p) {
			this.y = p.y;
			this.x = p.x;
			board = new int[N][N];
			for (int i = 0; i < N; i++)
				for (int j = 0; j < N; j++)
					board[i][j] = p.board[i][j];
		}
		String boardToString() {
			String str = "";
			for (int i = 0; i < N; i++) {
				for (int j = 0; j < N; j++) {
					str += Integer.toString(board[i][j]);
				}
			}
			return str;
		}
		void swapBoard(int ny, int nx) {
			int tmp = board[y][x];
			board[y][x] = board[ny][nx];
			board[ny][nx] = tmp;
			y = ny;
			x = nx;
		}
		void printDebug() {
			for (int i = 0; i < N; i++) {
				for (int j = 0; j < N; j++)
					System.out.print(board[i][j] + " ");
				System.out.println();
			}
			System.out.println();
		}
	}
	final int N = 3;
	int[][] board;
	void run() {
		Scanner scan = new Scanner(System.in);

		board = new int[N][N];
		int y = 0, x = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				board[i][j] = scan.nextInt();
				if (board[i][j] == 0) {
					y = i;
					x = j;
				}
			}
		}
		Queue<Pazzle> que = new LinkedList<Pazzle>();
		HashSet<String> hash = new HashSet<String>();
		que.add(new Pazzle(y, x, board));
		String ansPazzle = "123456780";
		int ans = 0;
		int[] dy = { 1, 0, -1, 0 };
		int[] dx = { 0, 1, 0, -1 };
		while (!que.isEmpty()) {
			int length = que.size();
			for (int i = 0; i < length; i++) {
				Pazzle p = que.poll();
				String boardStr = p.boardToString();
				if (boardStr.equals(ansPazzle)) {
					System.out.println(ans);
					return;
				}
				hash.add(boardStr);
				for (int j = 0; j < 4; j++) {
					int ny = p.y + dy[j];
					int nx = p.x + dx[j];
					if (ny >= 0 && nx >= 0 && ny < N && nx < N) {
						Pazzle np = new Pazzle(p);
						np.swapBoard(ny, nx);
						if (hash.contains(np.boardToString()))
							continue;
						que.add(np);
					}
				}
			}
			ans++;
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 609444
#include <bits/stdc++.h>
typedef long long ll;
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++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;


int main() {
    ios_base::sync_with_stdio(false);

    int a,b,h;
    cin >> a >> b >> h;
    cout << h*(a+b)/2.0 << endl;

    return 0;   
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in) ;
	public static void main(String[]args) {
		Main m = new Main();
		m.run();
	}
	
	void run() {
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		if( (n + 1)/2 >= k) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a[100000],b,c,cmp,data,m,h,x,y,xcmp=0,ycmp=0,sum=0;

string s,w;

vector<int> z;

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

    bool fl=true;
        cin >> n >> b;
        rep(i,n){
            cin >> a[i];
            if(a[i]%2!=0){
                fl=false;
            }
        }
        if(fl==true){
            ans=2;
            if(b==1){
                Cout(0);
            }
            else{
                rrep(i,1,n){
                    ans*=2;
                }
                Cout(ans);
            }
        }
        else{
            ans=2;
            rrep(i,1,n-1){
               ans*=2;
            }
            Cout(ans);
        }
        
return 0;
}


Measured memory_bytes: 256