akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

void fastio() {
	cin.tie(nullptr);
	cin.sync_with_stdio(false);
}

using LL = long long;
using LD = long double;

const LL MOD = 1e9+7;
const LL INF = LLONG_MAX;
const LL N = 1e6+1;

int main() {
	fastio();
	
	LL n, k;

	cin >> n >> k;

	vector<LL> p(n), c(n);

	for (auto &e : p) {cin >> e; e--;}
	for (auto &e : c) cin >> e;

	LL ans = -INF;
	
	for (LL i = 0; i < n; ++i) {
		// place on i first
		LL st = i, next = p[i];
		LL cnt = c[next], cntmx = c[next];
		LL size = 1, ind = 1;
		if (next == i) {
			ans = max({ans, cnt, k*cnt});
		}
		else {
			next=p[next];
			LL k2 = k-1;
			vector<LL> pres(n, 0);
			pres[0] = cnt;

			while (k2) {
				cnt += c[next];
				cntmx = max(cntmx, cnt);
				k2--;
				size++;
				//cout << next << " " << st << "...\n";
				if (ind < n) {
					pres[ind] = max({cntmx, cnt});
					ind++;
				}
				if (next == st) {
					break;
				}
				next = p[next];
			}

			if (k2 == 0) {
				ans = max({ans, cntmx});
			}
			else {
				ans = max({ans, cntmx});
				if (k % size == 0) {
					ans = max({ans, (k/size)*cnt-cnt + cntmx});
				}
				else {
					ans = max({ans, (k/size)*cnt + pres[k%size-1]});
				}
			}
		}
		//cout << i << " " << cnt << " " << size << "..\n";
	}

	cout << ans << "\n";

}

Measured memory_bytes: 3744
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
	vector<string> text;
	while(true){
		string line;
		getline(cin, line);
		if(line == "END_OF_TEXT"){ break; }
		text.push_back(line);
	}
	int x = 0, y = 0;
	string buffer;
	while(true){
		string cmd;
		cin >> cmd;
		if(cmd == "-"){ break; }
		if(cmd == "a"){
			x = 0;
		}else if(cmd == "e"){
			x = text[y].size();
		}else if(cmd == "p"){
			x = 0;
			if(y > 0){ --y; }
		}else if(cmd == "n"){
			x = 0;
			if(y < text.size() - 1){ ++y; }
		}else if(cmd == "f"){
			if(x < text[y].size()){
				++x;
			}else if(y < text.size() - 1){
				x = 0;
				++y;
			}
		}else if(cmd == "b"){
			if(x > 0){
				--x;
			}else if(y > 0){
				--y;
				x = text[y].size();
			}
		}else if(cmd == "d"){
			if(x < text[y].size()){
				text[y].erase(text[y].begin() + x);
			}else if(y < text.size() - 1){
				text[y] += text[y + 1];
				text.erase(text.begin() + y + 1);
			}
		}else if(cmd == "k"){
			if(x == text[y].size() && y < text.size() - 1){
				buffer = "\n";
				text[y] += text[y + 1];
				text.erase(text.begin() + y + 1);
			}else if(x != text[y].size()){
				buffer = string(text[y].begin() + x, text[y].end());
				text[y].erase(text[y].begin() + x, text[y].end());
			}
		}else if(cmd == "y"){
			if(buffer == ""){
			}else if(buffer == "\n"){
				text.insert(text.begin() + y + 1, string(text[y].begin() + x, text[y].end()));
				text[y].erase(text[y].begin() + x, text[y].end());
				++y; x = 0;
			}else{
				text[y].insert(x, buffer);
				x += buffer.size();
			}
		}
	}
	for(int i = 0; i < text.size(); ++i){ cout << text[i] << endl; }
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main()
{
    int a, b; 
    while(1){
        scanf("%d %d", &a, &b);
        if(a==0 && b == 0) break;
        if(a>b) printf("%d %d\n", b,a);
        else printf("%d %d\n", a,b);
    };
    
}



Measured memory_bytes: 2576
#include "bits/stdc++.h"
using namespace std;
    map < string , int > mp;
typedef long long int ll;
const int N = 1e5 + 5;
ll arr[N];
int main(){
   ll i, j , n , m , x;
    cin >> n >> x;
    for(i = 0 ; i < n; i ++)cin >> arr[i], arr[i] = abs(arr[i] - x);
    ll ans = arr[0];
    //for(i = )
    for(i = 1 ; i < n; i++)ans = __gcd(ans, arr[i]);
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
#
# File    : A.rb
# Author  : Kazune Takahashi
# Created : 1/13/2019, 8:32:26 PM
# Powered by Visual Studio Code
#

q = gets.chomp.split(" ").map{|i| i.to_i}.sort
if q == [1, 4, 7, 9]
  puts "YES"
else
  puts "NO"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    int ans=0;
    rep(i,s.size()){
        if(s[i]=='1')ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <bitset>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dcm(a) setprecision(a)<<fixed
#define MOD 1000000007
#define clr(memo, a) memset(memo,a,sizeof(memo))
#define PI acos(-1)
int const N=1e3+5;
int dp[N][N];
void sum(int &a,int b){
a=(a%MOD+b%MOD)%MOD;
}
void solve()
{
    int n,m;
    cin>>n>>m;
    dp[0][0]=1;
for(int i=0;i<n;i++)
for(int j=0;j<m;j++){
    char c;
    cin>>c;
    if(c=='.'){
        sum(dp[i+1][j],dp[i][j]);
        sum(dp[i][j+1],dp[i][j]);
    }
}
cout<<dp[n-1][m-1]<<endl;
}
int main()
{
    fast;
    solve();

    return 0;
}


Measured memory_bytes: 4224
import copy

n = int(input())
S = list([list(input()) for _ in range(n)])

strlist=[]

B=copy.deepcopy(S)

for s1 in S:
    for moji in s1:
        c=False
        for s2 in B:
            if moji not in s2:
                c=False
                break
            else: c=True
        if c:
            strlist.append(moji)
            [B[i].remove(moji) for i in range(n)]
strlist.sort()
print(''.join(strlist))
            

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;

inline ll getXor(const vector<ll> & v , int l , int r){
	ll res = v[r];
	if(l > 0) res ^= v[l - 1];
	return res;
}


inline ll getSum(const vector<ll> & v , int l , int r){
	ll res = v[r];
	if(l > 0) res -= v[l - 1];
	return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n;
	cin >> n;
	
	vi v(n);
	vector<ll> xr(n), sum(n);
	rep(i , n){
		cin >> v[i];
	}
	
	rep(i , n){
		xr[i] = sum[i] = v[i];
		if(i > 0){
			xr[i] ^= xr[i - 1];
			sum[i] += sum[i - 1];
		}
	}
	
	ll ans = 0;
	
	rep(i , n){
		int l = i , r = n;
		while(r - l > 1){
			int mid = (r + l) / 2;
			if(getSum(sum , i , mid) == getXor(xr , i , mid)){
				l = mid;
			}else{
				r = mid;
			}
		}
		
		ans += l - i + 1;
	}
	
	cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  vector<int>p(N);
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  vector<int>sum1(N,0);
  for (int i = 0; i < N; i++) {
    if (i == 0){
      sum1.at(i) = p.at(i);
    }
    else {
      sum1.at(i) = sum1.at(i-1) + p.at(i);
    }
  }
  
  vector<int>sum2(N-K+1);
  for (int i = 0; i < N-K+1; i++) {
    sum2.at(i) = sum1.at(K-1+i) - sum1.at(i) + p.at(i);
  }
  sort(sum2.begin(), sum2.end());
  
  double A = (0.5*K + 1.0*sum2.at(N-K)/2);
  printf("%.8lf\n", A);
}
  
  
  
    
    

Measured memory_bytes: 5516
N=input()
n = int(N)
nketa =len(N)
ans = 0
if nketa%2==1:
    ans += n - 10**(nketa-1) +1

if nketa > 1:
    for i in range(1,nketa):
        if i%2 == 1:
            ans += 10**i - 10**(i-1)
print(ans)
        

Measured memory_bytes: 2940
from heapq import heappush, heappop
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = 0
d = [-a[0]]
for ai in a[1:]:
    nxt = -heappop(d)
    ans += nxt
    heappush(d, -ai)
    heappush(d, -ai)
print(ans)


Measured memory_bytes: 105096
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

vector<ll> pn(51,0);
ll ans=0;

void dfs(ll k,ll a,ll b,ll l,ll r){
    if(k==0){
        ans++; return;
    }
    ll ce=(l+r)/2;
    if(a<=ce && ce<=b) ans++;
    if(a<=l+1 && ce-1<=b) ans+=pn[k-1];
    else if(a<ce && b>l) dfs(k-1,max(a,l+1),min(b,ce-1),l+1,ce-1);
    if(a<=ce+1 && r-1<=b) ans+=pn[k-1];
    else if(b>ce && a<r) dfs(k-1,max(a,ce+1),min(b,r-1),ce+1,r-1);
}

int main(){
    pn[0]=1;
    rep(i,50) pn[i+1]=pn[i]*2+1;
    ll n,x,cnt=1; cin>>n>>x;
    rep(i,n) cnt=cnt*2+3;
    dfs(n,0,x-1,0,cnt-1);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-3-17 20:08:39
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

typedef tuple<int, int, int> P;
vector<P> V;
vector<int> W;
int N;

int main()
{
  cin >> N;
  for (auto i = 0; i < N; i++)
  {
    int a, b;
    cin >> a >> b;
    V.push_back(P(a, b, 0));
  }
  for (auto i = 0; i < N; i++)
  {
    int a, b;
    cin >> a >> b;
    V.push_back(P(a, b, 1));
  }
  sort(V.begin(), V.end());
  int ans = 0;
  for (auto e : V)
  {
    int x = get<0>(e);
    int y = get<1>(e);
    int c = get<2>(e);
    if (c == 0)
    {
      W.push_back(y);
    }
    else
    {
      sort(W.begin(), W.end());
      reverse(W.begin(), W.end());
      for (auto it = W.begin(); it != W.end(); it++)
      {
        if (*it < y)
        {
          ans++;
          W.erase(it);
          break;
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#N, K = list(map(int, input().strip().split()))
#H = list(map(int, input().strip().split()))
H = int(input().strip())
attachs = {}

def needed_attach(value):
  #print(value)
  if value == 1:
    return 1
  else:
    if value in attachs:
      x = attachs[value]
    else:
      x = needed_attach(value // 2) * 2 + 1
      attachs[value] = x
    return x

print(needed_attach(H))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N;
    vec memo(1e+5);
    rep(i,N) {
        cin>>A;
        ++memo[A];
    }
    ll ans = 0;
    reps(i,1,(1e+5) - 1){
        ans = max(ans, memo[i-1] + memo[i] + memo[i+1]);
    }
    cout<<ans<<endl;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()

typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;

const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
const Double EPS = 1e-9;

int N;
int win[110];
int rank[110];

void solve() {
	int rep = N * (N - 1) / 2;

	for_(i,0,rep) {
		int A, B, C, D; cin >> A >> B >> C >> D;
		--A; --B;
		if (C < D) win[B] += 3;
		else if (C > D) win[A] += 3;
		else {
			++win[A];
			++win[B];
		}
	}
	
	vector< pii > vp;
	for_(i,0,N) {
		vp.push_back(pii(win[i], i));
	}
	
	sort(allof(vp), greater<pii>());
	
	int nw = iINF;
	int r = 0;
	int add = 1;
	
	for_(i,0,N) {
		pii p = vp[i];
		
		if (nw > p.first) {
			r += add;
			add = 1;
			nw = p.first;
		} else {
			++add;
		}
		
		rank[p.second] = r;
	}
	
	for_(i,0,N) cout << rank[i] << endl;
}

int main() {
	cin >> N;
	solve();
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; n > i; i++)
#define all(c) (c).begin(),(c).end()
int main(void){
  int N;
  cin >> N;
  vector<int> v;
  rep(i,N){
    int tmp;cin>>tmp;v.push_back(tmp);
  }
  sort(all(v));
  int offset = 0;
  for(int i = 1; N-offset>i;i++){
    if(v[i] == v[i-1]){
      v.erase(v.begin()+i);
      v.erase(v.begin()+(i-1));
      i--;offset+=2;
    }
  }
  cout << v.size() << endl;
}

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

int main(){
  int cnt = 1;
  int N;
  cin >> N;
  vector <int> rads(N);
  for (int i = 0; i < N; i++){
    cin >> rads.at(i);
  }
  
  sort(rads.begin(), rads.end());
  int prev = rads.at(0);
  for (int j = 1; j < N; j++){
    if (prev != rads.at(j))
      cnt++;
    prev = rads.at(j);
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	string ks = "ABC";
	int k;
	cin >> k;
	string ps = to_string(k);
	print(ks + ps);






	return 0;
}

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

int main()
{
    int s, w;
    cin >> s >> w;
    string ans;
    if (s <= w)
        ans = "unsafe";
    else
        ans = "safe";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
# import sys

# n = int(input())

# result = []
# k = 26
# i = 1

# while k < n:
# 	n -= k
# 	k *= 26
# 	i += 1

# length = i
# n -= 1

# pow26 = 1
# for i in range(length):


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

count = {}
for x in a:
	if x in count:
		count[x] += 1
	else:
		count[x] = 1

s = sum(a)

Q = int(input())
for q in range(Q):
	a, b = map(int, input().split())
	acount = count[a] if a in count else 0
	s -= a * acount 
	s += b * acount
	count[a] = 0
	if b not in count:
		count[b] = acount
	else:
		count[b] += acount
	print(s)


Measured memory_bytes: 23004
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e4 + 10;

bool prime[N];

bool mod_divides(vector<ll> poly, int p);

int main() {
	fast_cin();
	int n; cin >> n;
	vector<ll> poly(n + 1);
	for (int i = n; i >= 0; --i) {
		cin >> poly[i];
	}
	set<int> cand;
	for (int i = 2; i < N; ++i) {
		prime[i] = true;
	}
	for (int i = 2; i < N; ++i) {
		if (prime[i]) {
			cand.insert(i);
			for (int j = 2 * i; j < N; j += i) {
				prime[j] = false;
			}
		}
	}
	ll g = 0;
	for (auto &a : poly) {
		g = __gcd(g, abs(a));
	}
	int sq = sqrt(g);
	for (int i = 2; i <= sq; ++i) {
		if (g % i == 0) {
			cand.insert(i);
			while (g % i == 0) {
				g /= i;
			}
		}
	}
	if (g > 1) {
		cand.insert(g);
	}
	for (auto &p : cand) {
		if (mod_divides(poly, p)) {
			cout << p << '\n';
		}
	}
}

bool mod_divides(vector<ll> poly, int p) {
	for (auto &a : poly) {
		a %= p;
		a += p;
		a %= p;
	}
	int deg = poly.size() - 1;
	for (int n = deg; n >= 0; --n) {
		if (!poly[n]) {
			continue;
		} else if (n < p) {
			return false;
		} else {
			poly[n - p + 1] += poly[n];
			poly[n - p + 1] %= p;
		}
	}
	return true;
}

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

int main() {
  string s;
  cin >> s;
  int count=0;
  if(s.at(0)==s.at(1)) count++;
  if(s.at(0)==s.at(2)) count++;
  if(s.at(0)==s.at(3)) count++;
  if(s.at(1)==s.at(2)) count++;
  if(s.at(1)==s.at(3)) count++;
  if(s.at(2)==s.at(3)) count++;
  if(count==2)cout <<"Yes"<<endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
<?php

class In {

	private $buf = [];
	private $count = 0;
	private $pointer = 0;

	public function nextLine() {
		$ret = '';
		if($this->hasNext()){
			while($this->hasNext()){
				$ret .= $this->next();
			}
		}else{
			$ret = trim(fgets(STDIN));
		}

		return $ret;
	}

	public function next() {
		if(!$this->hasNext()) {
			$str = trim(fgets(STDIN));
			$this->buf = explode(' ',$str);
			$this->count = count($this->buf);
			$this->pointer = 0;
		}

		return $this->buf[$this->pointer++];
	}

	public function hasNext() {
		return $this->pointer < $this->count;
	}

	public function nextInt() {
		return (int)$this->next();
	}

	public function nextDouble() {
		return (double)$this->next();
	}
}

class Out {
	public function println($str = '') {
		echo $str . PHP_EOL;
	}
}

$in = new In();
$out = new Out();

$X = $in->nextInt();
$t = $in->nextInt();

$out->println(max(0,$X-$t));

?>


Measured memory_bytes: 4604
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n = int(input())
#a = [int(i) for i in readline().split()]
m = n
while m%2 ==0:
    m//=2
if m == 1:
    print("No")
    exit()
elif n%2:
    print("Yes")
    for i in range(2,n):
        print(i, i+1)
    print(n,1)
    print(1,n+n-1)
    for i in range(2,n,2):
        print(i+n,i+n+1)
    for i in range(2,n-2,2):
        print(i+n,i+n+3)
    print(n+1,n-1)
else:
    m=n-1
    print("Yes")
    for i in range(2,m):
        print(i, i+1)
    print(m,1)
    print(1,m+n-1)
    for i in range(2,m,2):
        print(i+n,i+n+1)
    for i in range(2,m-2,2):
        print(i+n,i+n+3)
    print(n+1,m-1)
    
    c = n^(n-2)^1
    print(c,n)
    if ((n-2)-c-1)%4==2:
        print(n-2,n+n)    
    else:
        print(n+1,n+n)    
        
    










Measured memory_bytes: 5932
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<vector>
using namespace std;
int  i,j,k,h,w,a,b,c,d,x,y,z,n,ret=0;
int main(void){
  cin>>n;
  int h[n+1]={0},s[n]={0};
  for(i=1;i<=n;i++)cin>>h[i];
  for(i=1;i<=n;i++)s[i]=h[i]-h[i-1];
  //for(i=0;i<n+1;i++)cout<<"h["<<i<<"]="<<h[i]<<"s["<<i<<"]="<<s[i]<<endl;
  for(i=0;i<=n;i++)if(s[i]>0)ret+=s[i];
  cout<<ret;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<endl
#define AA(i) cout<<i<<endl;
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
    ll A,V,B,W,T; cin >> A>>V>>B>>W>>T;
    A = max(A-B,B-A);
    B = - W + V;
    if(T * B >= A && B > 0) {AA("YES");}
    else AA("NO");
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>

using namespace std;
typedef long long ll;

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    for (int i = 0; i < H; i++)
    {
        cin >> s[i];
    }
    vector<vector<int>> acc_h(H, vector<int>(W));
    vector<vector<int>> acc_v(H, vector<int>(W));

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (s[i][j] != '.')
            {
                continue;
            }
            if (0 == j)
            {
                acc_h[i][j] = 1;
                continue;
            }
            acc_h[i][j] = acc_h[i][j - 1] + 1;
        }
    }

    for (int i = 0; i < H; i++)
    {
        for (int j = W - 1; j >= 0; j--)
        {
            if (acc_h[i][j] == 0)
            {
                continue;
            }
            int tempmax;
            if (j == W - 1)
            {
                tempmax = acc_h[i][j];
                continue;
            }
            if (acc_h[i][j + 1] == 0)
            {
                tempmax = acc_h[i][j];
                continue;
            }
            acc_h[i][j] = tempmax;
        }
    }

    for (int i = 0; i < W; i++)
    {
        for (int j = 0; j < H; j++)
        {
            if (s[j][i] != '.')
            {
                continue;
            }
            if (0 == j)
            {
                acc_v[j][i] = 1;
                continue;
            }
            acc_v[j][i] = acc_v[j - 1][i] + 1;
        }
    }

    for (int i = 0; i < W; i++)
    {
        for (int j = H - 1; j >= 0; j--)
        {
            if (acc_v[j][i] == 0)
            {
                continue;
            }
            int tempmax;
            if (j == H - 1)
            {
                tempmax = acc_v[j][i];
                continue;
            }
            if (acc_v[j + 1][i] == 0)
            {
                tempmax = acc_v[j][i];
                continue;
            }
            acc_v[j][i] = tempmax;
        }
    }
    int ans = -1;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            ans = max(ans, acc_v[i][j] + acc_h[i][j] - 1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 42336
// https://atcoder.jp/contests/abc155/tasks/abc155_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    unordered_set<int> st;
    REP(i, 3) {
        int t;
        cin >> t;
        st.insert(t);
    }
    if (st.size() == 2) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}


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

using namespace std;

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

	if (s == "SUN") { cout << 7 << endl; }
	if (s == "MON") { cout << 6 << endl; }
	if (s == "TUE") { cout << 5 << endl; }
	if (s == "WED") { cout << 4 << endl; }
	if (s == "THU") { cout << 3 << endl; }
	if (s == "FRI") { cout << 2 << endl; }
	if (s == "SAT") { cout << 1 << endl; }

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
int main()
{
	int n, m;
	char ans[] = "nnn";
	scanf("%d%d", &n, &m);
	for(int i = 0, s, c; i < m; ++i)
	{
		scanf("%d%d", &s, &c);
		if(ans[s - 1] == 'n')
		{
			ans[s - 1] = c + '0';
		}
		else
		{
			if(ans[s - 1] != c + '0')
			{
				printf("-1\n");
				return 0;
			}
		}
	}
	if(n == 1 && ans[0] == '0')
	{
		printf("0\n");
		return 0;
	}
	if(ans[0] == '0')
	{
		printf("-1\n");
		return 0;
	}
	if(ans[0] == 'n')
	{
		if(n == 1)
		{
			ans[0] = '0';
		}
		else
		{
			ans[0] = '1';
		}
	}
	if(ans[1] == 'n')
	{
		ans[1] = '0';
	}
	if(ans[2] == 'n')
	{
		ans[2] = '0';
	}
	for(int i = 0; i < n; ++i)
	{
		printf("%c", ans[i]);
	}
	printf("\n");
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

  cout << ((a + b + c > 21) ? "bust" : "win") << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	private static String YES = "YES";
	private static String NO_ = "NO";

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int[] sides = new int[3];
		int side1 = 0, side2 = 0, side3 = 0;

		while ((line = br.readLine()) != null) {
			if (line.contains(" ")) {
				sides[0] = Integer.parseInt(line.split(" ")[0]);
				sides[1] = Integer.parseInt(line.split(" ")[1]);
				sides[2] = Integer.parseInt(line.split(" ")[2]);
				Arrays.sort(sides);
				side1 = sides[0];
				side2 = sides[1];
				side3 = sides[2];
				if (side3 * side3 == side1 * side1 + side2 * side2) {
					System.out.println(YES);
				} else {
					System.out.println(NO_);
				}
			}
		}
	}
}

Measured memory_bytes: 23700
def main():
    import sys
    input=sys.stdin.readline
    x,y,a,b,c=map(int,input().split())
    P=list(map(int,input().split()))
    Q=list(map(int,input().split()))
    R=list(map(int,input().split()))
    P.sort()
    Q.sort()
    R.sort()
    P_=P[a-x:][::-1]
    Q_=Q[b-y:][::-1]
    ans=sum(P_)+sum(Q_)
    for i in range(c):
        r=R.pop()
        if not P_:
          	P_.append(float("INF"))
        if not Q_:
          	Q_.append(float("INF"))
        if r<=P_[-1] and r<=Q_[-1]:
            break
        elif r>P_[-1] and P_[-1]<=Q_[-1]:
            p=P_.pop()
            ans+=r-p
        else:
            q=Q_.pop()
            ans+=r-q
    print(ans)
if __name__ == '__main__':
    main()

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	int N; cin >> N;
	string S; cin >> S;
	for(int i = 0; i < S.size(); ++i){
		int c = S[i]-'A';
		(c += N) %= 26;
		S[i] = char(c+'A');
	}
	cout <<S << endl;

}


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

int main() {

	int n; cin >> n;
	int ac = 0;
	int wa = 0;
	int tle = 0;
	int re = 0;
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		if (s == "AC") ac++;
		if (s == "WA") wa++;
		if (s == "TLE") tle++;
		if (s == "RE") re++;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
typedef long long ll;

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

    ll n;
    cin >> n;

    for(int a = 1; a <= 3500; ++a){
        for(int b = 1; b <= 3500; ++b){
            ll c1 = 4*a*b;
            ll c2 = n*b;
            ll c3 = n*a;
            ll c4 = n*a*b;

            if(c1-c2-c3==0){
                if(c4 == 0){
                    cout << a << " " << b << " " << 1 << endl;
                    return 0;
                }
                else continue;
            }
            else if(c1-c2-c3 < 0 || c1-c2-c3 > c4) continue;
            else{
                if(c4 % (c1-c2-c3) == 0){
                    ll c = c4 / (c1-c2-c3);
                    cout << a << " " << b << " " << c << endl;
                    return 0;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	if(a > b && a > c){
		cout << (a << k) + b + c << endl;
	}else if(b > a && b > c){
		cout << (b << k) + a + c << endl;
	}else{
		cout << (c << k) + b + a << endl;
	}
	return 0;
}

Measured memory_bytes: 256
s = input()
p = input()
for i, c in enumerate(s):
    is_valid = False
    if c == p[0]:
        if len(p) == 1:
            print('Yes')
            break
        else:
            for j in range(1, len(p)):
                i += 1
                if i >= len(s):
                    i -= len(s)
                if s[i] != p[j]:
                    break
                else:
                    if j == len(p) - 1:
                        is_valid = True
    if is_valid == True:
        print('Yes')
        break
else:
    print('No')



Measured memory_bytes: 5560
function Main(input){
  abcde = input.split(' ');
  a = parseInt(abcde[0].trim());
  b = parseInt(abcde[1].trim());

  if(a - 1 >= b){
    console.log(a + a - 1)
  }
  else if(b - 1 >= a) {
    console.log(b + b - 1)
  }
  else{
    console.log(a+b)
  }
   
  }
  Main(require("fs").readFileSync("/dev/stdin","utf-8"));

Measured memory_bytes: 7372
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	int n,sumax,temp;
	int num[5001];
	
	while(scanf("%d",&n)){
		if(n==0)
		break;
		for(int i=0;i<n;i++){
			scanf("%d",&num[i]);
		}
		sumax = -100000;
		for(int i=0;i<n;i++){
			temp = 0;
			for(int j=i;j<n;j++){
				temp+=num[j];
				if(temp>sumax)
				sumax=temp;
			}
		}
		printf("%d\n",sumax);
	}
}

Measured memory_bytes: 3148
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n>>a>>b;
	b=b/n*n;
	if(a<=b)cout<<"OK"<<endl;
	else cout<<"NG"<<endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<string> S(N);

  for(int k = 0;k<N;k++){
      cin >> S.at(k);
  }
  sort(S.begin(),S.end());
  int count = 0;
  for(int i = 0;i<N-1;i++){
      	if(S.at(i)!=S.at(i+1)){
			count++;
      	}

    }
   cout << count+1 <<endl;

}



Measured memory_bytes: 9532
MOD = 10**9+7
n, k = map(int, input().split())
cnt = [0]*(k+1)
for i in range(1, k+1):
    cnt[i] = pow(k//i, n, MOD)


dp = [0]*(k+1)
for i in reversed(range(1, k+1)):
    if not cnt[i]:
        continue
    tmp = cnt[i]
    for j in range(2, k+1):
        if k < i*j:
            break
        tmp -= dp[i*j]
        tmp %= MOD
    dp[i] = tmp

ans = 0
for i in range(1, k+1):
    ans += i*dp[i]
    ans %= MOD

print(ans)

Measured memory_bytes: 13540
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

int n, m;
int A[200020];
int C[200020];
int T[200020];

void solve(){
	scanf("%d%d", &n, &m);
	for(int i=1;i<=n;i++) scanf("%d", A+i), C[A[i]]++;
	for(int i=1;i<=n;i++) rep(j, C[i]) if(i - j > 0) T[i - j] ++;
	int ans = 0;
	for(int i=1;i<=n;i++) if(T[i]) ++ans;
	for(int i=1;i<=m;i++) {
		int x, y; scanf("%d%d", &x, &y);
		int a = A[x];
		if(a - C[a] + 1 > 0) {
			if(T[a - C[a] + 1] == 1) --ans;
			T[a - C[a] + 1]--;
		}
		C[a]--;
		A[x] = y;
		C[y]++;
		if(y - C[y] + 1 > 0) {
			if(T[y - C[y] + 1] == 0) ++ans;
			T[y - C[y] + 1]++;
		}
		printf("%d\n", n - ans);
	}
}

int main(){
	int T = 1; // scanf("%d", &T);
	while(T--) {
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i, ns, ne) for (int i = ns; i < ne; ++i)
using namespace std;

int main() {
  long long n, x, a, b, tmp, ans = 0;
  cin >> n >> x >> a;

  rep(i, 0, n) {
    if (i < n - 1) {
      cin >> b;
    } else {
      b = 0;
    }
    if (a + b >= x) {
      tmp = a + b - x;
      b = b - tmp;
      ans += tmp;
    }
    a = b;
  }

  cout << ans << endl;
  getchar();
}

Measured memory_bytes: 3620
//
//  main.cpp
//  ITP1_5-A
//
//  Created by Saicj on 2015/07/14.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>
using namespace std;

int main(int argc, const char * argv[])
{

    int H;
    int W;
    
    while (true) {
        
        cin >> H >> W;
        
        if (H == 0 && W == 0) {
            break;
        }
        
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cout << "#";
            }
            
            cout << endl;
        }
        
        cout << "\n";
        
    }
    
    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int chmin(long *x, long y) { if (*x > y) { *x = y; return 1; } return 0; }

int main() {
    const long INF = LONG_MAX >> 5;
    long N;
    long h[100010];
    long dp[100010];

    scanf("%ld", &N);
    for (long i = 0; i < N; i++) {
        scanf("%ld", &h[i]);
    }
    for (long i = 0; i < 100010; i++) {
        dp[i] = INF;
    }

    dp[0] = 0;
    for (long i = 1; i < N; i++) {
        chmin(&dp[i], dp[i - 1] + labs(h[i] - h[i - 1]));
        if (i > 1) chmin(&dp[i], dp[i - 2] + labs(h[i] - h[i - 2]));
    }
    printf("%ld\n", dp[N - 1]);
    return 0;
}


Measured memory_bytes: 1792
n, y = map(int, input().split())

for i in range(0, n+1):
    for j in range(0, n+1-i):
        k = n-i-j
        if 10000*i+5000*j+1000*k == y:
            print(i, j, k)
            exit()

print(-1, -1, -1)


Measured memory_bytes: 40684
"""
                            pppppppppppppppppppp
                         ppppp  ppppppppppppppppppp
                      ppppppp    ppppppppppppppppppppp
                      pppppppp  pppppppppppppppppppppp
                      pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
       ppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppp
      pppppppppppppppppppppppppppppppppppppppppppppppp  ppppppppppppppppppppp
     ppppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppppp
    ppppppppppppppppppppppppppppppppppppppppppppppp    pppppppppppppppppppppppp
   pppppppppppppppppppppppppppppppppppppppppppppp     pppppppppppppppppppppppppp
  ppppppppppppppppppppppppppppppppppppppppppppp      pppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppppppp               pppppppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppp     pppppppppppppppppppppppppppppppppppppppppppppp
  ppppppppppppppppppppppppppp    pppppppppppppppppppppppppppppppppppppppppppppppp
    pppppppppppppppppppppppp  pppppppppppppppppppppppppppppppppppppppppppppppppp
     ppppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppppp
      pppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppp
       ppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
                              pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppp  pppppppp
                              ppppppppppppppppppppp    ppppppp
                                 ppppppppppppppppppp  ppppp
                                    pppppppppppppppppppp
"""


import sys
from functools import lru_cache, cmp_to_key
from collections import defaultdict as dd, deque, Counter as C
from bisect import bisect_left as bl, bisect_right as br, bisect
from math import sqrt
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(var, end="\n"): sys.stdout.write(str(var)+end)
def outa(*var, end="\n"): sys.stdout.write(' '.join(map(str, var)) + end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


n, d = sp()
answer = 0
for i in range(n):
    x, y = sp()
    if sqrt(x ** 2 + y ** 2) <= d:
        answer += 1
print(answer)


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

long long k, now = 0;
vector<int> v;

int main() {
  cin >> k;
  v.assign(k, 0);
  for (int i = 1;; ++i) {
    now *= 10;
    now += 7;
    now %= k;
    if (!now) {
      cout << i << endl;
      return 0;
    }
    if (v[now]) break;
    v[now] = 1;
  }
  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 7156
#include <stdio.h>

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

Measured memory_bytes: 596
def find(x):
	while x!=p[x]:
		x=p[x]
	return x

def union(a,b):
	x=find(a)
	global con
	y=find(b)
	if x!=y:
		p[y]=p[x]=min(x,y);con-=1
		r[min(x,y)]+=r[max(x,y)];con=max(con,r[min(x,y)])
n,m=map(int,input().split())
p=[i for i in range(n+1)]
con=1
r=[1]*(n+1)
for i in range(m):
  u,v=map(int,input().split())
  union(u,v)
print(max(r))

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

using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
struct Edge{
  ll to,id;
};
typedef vector<vector<ll>> Graph;
typedef vector<pii> vpii;

int main() {
  ll R,C,N; cin>>R>>C>>N;
  vector<pair<ll,ll>> x0,xr,y0,yc;
  REP(i,N) {
    ll x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2;
    if((x1==0||x1==R||y1==0||y1==C)&&(x2==0||x2==R||y2==0||y2==C)) {
      {
        ll x=x1,y=y1;
        if(x==0) x0.PB({y,i});
        if(x==R) xr.PB({y,i});
        if(y==0) y0.PB({x,i});
        if(y==C) yc.PB({x,i});
      }
      {
        ll x=x2,y=y2;
        if(x==0) x0.PB({y,i});
        if(x==R) xr.PB({y,i});
        if(y==0) y0.PB({x,i});
        if(y==C) yc.PB({x,i});
      }
    }
  }



  sort(ALL(x0));
  sort(ALL(xr));
  sort(ALL(y0));
  sort(ALL(yc));

  stack<ll> stk;

  // x=0, y=0~C-1
  for(auto p:x0) {
    ll y=p.first;
    if(y<C) {
      if(stk.size()&&stk.top()==p.second) stk.pop();
      else stk.push(p.second);
    }
  }

  // y=C, x=0~R-1
  for(auto p:yc) {
    ll x=p.first;
    if(x<R) {
      if(stk.size()&&stk.top()==p.second) stk.pop();
      else stk.push(p.second);
    }
  }

  // x=R, y=C~1
  for(ll i=0;i<xr.size();i++) {
    auto p=xr[xr.size()-i-1];
    ll y=p.first;
    if(y>0) {
      if(stk.size()&&stk.top()==p.second) stk.pop();
      else stk.push(p.second);
    }
  }

  // y=0, x=R~1
  for(ll i=0;i<y0.size();i++) {
    auto p=y0[y0.size()-i-1];
    ll x=p.first;
    if(x>0) {
      if(stk.size()&&stk.top()==p.second) stk.pop();
      else stk.push(p.second);
    }
  }
  if(stk.size()) puts("NO");
  else puts("YES");
}


Measured memory_bytes: 4840
import collections
# s = [[]]
n, m = map(int,input().split())
s = [list(map(int,input().split())) for i in range(m)]

# n, m = 4, 2
# s = [[1,3], [2,4]]

if m == 1:
    print(s[0][-1] - s[0][0] + 1)
else:
    l = s[0][0]
    r = s[0][1]
    for i in range(1,m):
        l = max(l,s[i][0])
        r = min(r,s[i][1])
    print(max(r-l+1,0))

Measured memory_bytes: 27636
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int n; cin >> n;
  while(n--){
    int e[3];
    cin >> e[0] >> e[1] >> e[2];
    sort(e,e+3);
    if(e[2]*e[2] == e[0]*e[0] + e[1]*e[1])
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1168
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N, M;
	
	cin >> N >> M;

	int a[N+1];
	
	memset(a, 0, sizeof(a));
	
	rep(i, M)
	{
		int m, n;
		cin >> m >> n;
		a[m]++;
		a[n]++;
	}

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

	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef pair<int,int> pii;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=(int)(n);v>=0;v--)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//------------------------------------------------------------------------------

signed main() {
    vector<int> s(5,0);
    FORE(x,s) cin>>x, x=max(x,40);
    cout<<accumulate(ALL(s),0)/5<<endl;
    return 0;
}

Measured memory_bytes: 3084
N = int(input())
*A, = map(int, input().split())
INF = 10**9
p = q = 0
for i, a in enumerate(A):
    if a > 0:
        p += 1
    elif a < 0:
        q += 1

def solve(s, t):
    R = []
    i = A.index(s)
    if s == t:
        j = A.index(t, i+1)
    else:
        j = A.index(t)
    for k, a in enumerate(A):
        if i == k or j == k:
            continue
        if a >= 0:
            R.append("%d %d\n" % (s, a))
            s -= a
    for k, a in enumerate(A):
        if i == k or j == k:
            continue
        if a < 0:
            R.append("%d %d\n" % (t, a))
            t -= a
    R.append("%d %d\n" % (t, s))
    t -= s
    return t, R
ans = 0
if p > 0 and q > 0:
    s = t = 0
    for a in A:
        if a > 0:
            t = a
        elif a < 0:
            s = a
    ans, R = solve(s, t)
elif p > 0:
    A.sort()
    ans, R = solve(A[0], A[1])
elif q > 0:
    A.sort()
    ans, R = solve(A[-2], A[-1])
else:
    R = ["0 0\n"]*(N-1)
print(ans)
print("".join(R))

Measured memory_bytes: 19940