akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

int main(void){
    int n;
    unsigned long long l[100];
    int i;
    scanf("%d", &n);
    l[0] = 2;
    l[1] = 1;
    for (i = 2; i < 100; i++){
        l[i] = l[i-1] + l[i-2];
    }


    printf("%lld\n", l[n]);


    return 0;
}


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

int main(){
    int N;
    cin >> N;
    int x[N], y[N];
    rep(i, N){
        cin >> x[i] >> y[i];
    }

    int MIN = N;
    rep(i, N){
        rep(j, N){
            if(i==j) continue;
            int ans = N;
            int dx = x[j] - x[i];
            int dy = y[j] - y[i];
            rep(k, N){
                rep(l, N){
                    if(k==l) continue;
                    if(x[l]-x[k]==dx && y[l]-y[k]==dy){
                        ans--;        
                    }
                }
            }
            MIN = min(ans, MIN);
        }
    }
    printf("%d\n", MIN);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int sum=0;
		int xcopy=x;
		for(int i=100000000;i>=1;i=i/10) {
			sum+=x/i;
			x=x%i;
		}
		if(xcopy%sum==0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}

Measured memory_bytes: 20948
def main():
  a = int(input())
  b = int(input())
  c = int(input())
  d = int(input())
  e = int(input())
  
  ans = -50
  if a <= b:
    if a <= c:
      ans += a
    else:
      ans += c
  else:
    if b <= c:
      ans += b
    else:
      ans += c
  
  if d <= e:
    ans += d
  else:
    ans += e
  
  print(ans)
main()


Measured memory_bytes: 5596
#pragma GCC optimize("O3")
#pragma GCC otimize("unroll-loops");
#pragma GCC target("avx")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n, k;
llong cnt[11];

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

    n -= 2;
    for (llong i = 1; i <= 11; i++) {
        for (llong j = 1; j <= 5; j++) {
            cnt[(63 * i + 9 * j + 9) % 11]++;
        }
    }

    llong ans = (n / 11) * cnt[k];
    for (llong i = n - (n % 11) + 1; i <= n; i++) {
        for (llong j = 1; j <= 5; j++) {
            if ((63 * i + 9 * j + 9) % 11 == k) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  k <- getl toInt
  unless (k == 0) $ do
    solve k <$> getl (wrds toInt) >>= print
    main

solve :: Int -> [Int] -> Int
solve k xs = sum xs `div` (k-1)

toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 5516
import math


def is_prime(a):
    sqrt_a = int(math.sqrt(a))
    for i in range(2, sqrt_a + 1):
        if a % i == 0:
            return False
    return True


def main():
    n = int(input())
    count = 0

    for i in range(n):
        a = int(input())
        if is_prime(a):
            count += 1

    print(count)


if __name__ == "__main__":
    main()



Measured memory_bytes: 5676
#include<bits/stdc++.h>
using namespace std;
#define lol long long
int main(){
  lol a,b,c,d;
  cin>>a>>b;
  for(int i=1;i<=3;i++){
    if(i!=a && i!=b){
      c=i;
      break;
    }
  }
  cout<<c<<"\n";
  return(0);
}


Measured memory_bytes: 256
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc164_a.cpp
 * time   : Sat May  2 21:34:37 2020
 * quest  : A - Sheep and Wolves
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int s, w;
  cin >> s >> w;
  cout << (s > w ? "safe\n" : "unsafe\n");
  return 0;
}


Measured memory_bytes: 3612
object Main extends App {
  val n = readLine.toInt

  for (i <- 0 until n) {
    val Seq(x1, y1, x2, y2, x3, y3, x4, y4) = readLine.split(' ').map(_.toDouble).toList
    val vabx = x2 - x1
    val vaby = y2 - y1
    val vcdx = x4 - x3
    val vcdy = y4 - y3

    val det = vabx * vcdy - vcdx * vaby

    println(if (det.abs > 1e-10) "NO" else "YES")
  }
}


Measured memory_bytes: 44112
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;

public class RightTriangle
{
	public static void Main(string[] args)
	{
		int count = int.Parse(Console.ReadLine());
		BindingList<string> resultList = new BindingList<string>();
		for (int i = 0; i < count; i++)
		{
			string[] read = Console.ReadLine().Split(' ');
			int a = int.Parse(read[0]);
			int b = int.Parse(read[1]);
			int c = int.Parse(read[2]);
			
			int hypotenuse = a;
			int side1 = b;
			int side2 = c;
			if (a < b)
			{
				hypotenuse = b;
				side1 = a;
				if (b < c)
				{
					hypotenuse = c;
					side2 = b;
				}
			}
			else if (a < c)
			{
				hypotenuse = c;
				side2 = a;
			}
			if (side1*side1+side2*side2 == hypotenuse*hypotenuse)
			{
				resultList.Add("YES");
			}
			else
			{
				resultList.Add("NO");
			}
		}
		foreach (string result in resultList)
		{
			Console.WriteLine(result);
		}
	}
}

Measured memory_bytes: 6412
#include <bits/stdc++.h>
using namespace std;
//static const int INF = (1 << 21);
int memo[100010 * 2];
int main(void){
    // Your code here!
    int N,C;
    cin >> N >> C;
    for(int i = 0; i < N; i++){
        int s,t,c;
        cin >> s >> t >> c;
        s *= 2;
        t *= 2;
        memo[s-1]++;
        memo[t]--;
    }
    
    for(int i = 1; i < 100010 * 2; i++){
        memo[i] += memo[i-1];
    }
    
    int ans = 0;
    for(int i = 0; i < 100010 * 2; i++) ans = max(ans, memo[i]);
    ans = min(ans, C);
    cout << ans << endl;
}


Measured memory_bytes: 1024
N = int(input())

# (0,0)からと(0,10**9)からの距離でMinとMaxを持っておいてみる
from_0 = [(10**9, 10**9), (0,0)]
from_f = [(10**9, 10**9), (0,0)]

for i in range(N):
    x,y = map(int, input().split())
    if x + y < from_0[0][0] + from_0[0][1]:
        from_0[0] = (x,y)
    if x + y > from_0[1][0] + from_0[1][1]:
        from_0[1] = (x,y)
    
    new_y = 10**9 - y
    if x + new_y < from_f[0][0] + from_f[0][1]:
        from_f[0] = (x,new_y)
    if x + new_y > from_f[1][0] + from_f[1][1]:
        from_f[1] = (x,new_y)
    
dist_0 = abs(from_0[1][0] - from_0[0][0]) + abs(from_0[1][1] - from_0[0][1])
dist_f = abs(from_f[1][0] - from_f[0][0]) + abs(from_f[1][1] - from_f[0][1])
print(max(dist_0, dist_f))

Measured memory_bytes: 9288
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;


void solve() {
	int N, T; cin >> N >> T;
	vector<int>v(N);
	REP(i, N)cin >> v[i];
	v.push_back(1e18);
	ll ans = 0;
	REPR(i, N) {
		ans += min(v[i + 1] - v[i], T);
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 4864
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int gmc(int x, int y) {
	
	if (x<=y) {
		swap(x, y);
	}
	if (y==0) return x;
	
	return gmc(y, x%y);
}

int main() {
	
	int x, y;
	cin >> x >> y;
	
	cout << gmc(x, y) << "\n";
	
	return 0;
}

Measured memory_bytes: 1164
import numpy as np

min_price = -1
C = []
A = []
N = 0
X = 0

def check_flag(data, now, price):
    global C, A, N, X, min_price
    if now == N or sum(data >= X) == len(data):
        # print(data, now, price)
        if sum(data >= X) == len(data) and (min_price == -1 or min_price > price):
            min_price = price
        return

    for n in range(now, N):
        check_flag(data+A[n], n+1, price+C[n])
    
def main():
    global C, A, N, X, min_price
    N, M, X = [int(x) for x in input().split()]
    for _ in range(N):
        temp = [int(x) for x in input().split()]
        C.append(temp[0])
        A.append(temp[1:])
    A = np.array(A)
    check_flag(np.array([0] * M), 0, 0)
    print(min_price)

if __name__ == "__main__":
    main()


Measured memory_bytes: 27136
factorization :: Int -> [(Int, Int)]
factorization n =
  if c > 0 then iter 3 m [(2, c)] else iter 3 n []
  where
    (c, m) = factor n 2 0
    factor n m c =
      if n `mod` m /= 0 then (c, n)
      else factor (n `div` m) m (c + 1)
    iter i n a
      | n == 1    = reverse a
      | n < i * i = reverse ((n, 1) : a)
      | otherwise =
          let (c, m) = factor n i 0
          in if c == 0 then iter (i + 2) n a
             else iter (i + 2) m ((i, c):a)

divisor_num :: Int -> Int
divisor_num n = foldl (\a (_, x) -> a * (x + 1)) 1 (factorization n)

solve :: Int -> Int
solve a
 | a == 1    = 1
 | otherwise = divisor_num a

main = do
 n <- read <$> getLine :: IO Int
 print $ sum $ map (solve) [1..(n-1)]


Measured memory_bytes: 4940
from collections import *
n=int(input())
numbers=input().rstrip().split(" ")
S=Counter(numbers)
#print(S)
sigma=0
#print(S["1"])
for i in S.values():
    sigma+=i*(i-1)/2
alls=int(sigma)
answers=[]
for number in numbers:
    minus=S[number]-1
    answers.append(alls-minus)
for answer in answers:
    print(answer)

Measured memory_bytes: 31644
import sys 
MOD = 10 ** 9 + 7
INF = 10**5
from collections import deque

def main():
    n = int(input())
    dist = []
    edge = []
    ans = 0
    for i in range(n):
        a = list(map(int,input().split()))
        dist.append(a)
        for j in range(n):
            if i < j:
                edge.append((a[j],i,j))
                ans += a[j]
    
    for k in range(n - 1):
        for i in range(n):
            for j in range(n):
                dist[i][j] = min(dist[i][j] ,dist[i][k] + dist[k][j])
    
    edge.sort(reverse = True,key = lambda x:x[0])
    for c,a,b in edge:
        if dist[a][b] < c:
            ans = -1
            break
        for i in range(n):
            if i != a and i != b:
                if c == dist[a][i] + dist[i][b]:
                    ans -= c
                    break
    print(ans)   

if __name__=='__main__':
    main()

Measured memory_bytes: 52920
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1e9;
#define put(n) cout<<(n)<<endl
#define rep(i,N) for(int(i)=0;(i)<(N);++(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define pb(n) push_back(n)

int main(){
    int N;
    cin >> N;
    vector<int> H(N+1);
    for(int i=1;i<=N;++i) cin >> H[i];
    int dp[100100];
    fill(dp,dp+100100,INF);
    dp[1] = 0;
    dp[2] = abs(H[2]-H[1]);
    for(int i=3;i<=N;++i){
        dp[i] = min(dp[i-2]+abs(H[i]-H[i-2]),dp[i-1]+abs(H[i]-H[i-1]));
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)


constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
	string s; cin >> s;
	--a, --b, --c, --d;

	bool ok = true;
	rep(i, a, c) if (s[i] == '#' && s[i + 1] == '#') ok = false;
	rep(i, b, d) if (s[i] == '#' && s[i + 1] == '#') ok = false;

	if (c < d) {
		if (ok) cout << "Yes";
		else cout << "No";
	}
	else {
		bool three = false;
		rep(i, b, d + 1) {
			if (0 < i && i + 1 < n && s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') three = true;
		}
		if (three && ok) cout << "Yes";
		else cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
#define data_type long long
#define boro 100007
vector< vector<data_type> > adjlist;
bitset <boro>is_visited;
data_type weight[boro];
data_type dfs(data_type a)
{
    if(is_visited[a])
        return weight[a];
    is_visited[a]=1;
    data_type m=0;
    for(auto i:adjlist[a])
        {
            if(is_visited[i]==0)
                {
                    weight[i]=dfs(i);
                }
            m=max(weight[i]+1,m);
        }

    return weight[a]=m;

}
int main()
{
    data_type n,m,x,y;
    cin>>n>>m;
    adjlist.resize(n);
    while(m--)
        {
            cin>>x>>y;
            x--,y--;
            adjlist[x].push_back(y);
        }

    for(int i=0; i<n; i++)
        {
            if(is_visited[i])
                continue;
            weight[i]=dfs(i);
        }

    cout<<*max_element(weight,weight+n)<<endl;


    return 0;
}


Measured memory_bytes: 12760
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<climits>
#include<map>
#define ll long long
using namespace std;
int main() {
	ll n,m;
	cin >> n;
	map<string,int>mp;
	for (ll i = 0; i < n; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	cin >> m;
	for (ll i = 0; i < m; i++) {
		string s;
		cin >> s;
		mp[s]--;
	}
	ll ans = 0;
	vector<ll>::iterator it;
	string s;
	for (auto it = mp.begin(); it != mp.end(); it++) {
		ans = max((int)(ans), it->second);
	}
	cout << ans << endl;


}


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

using namespace std;
int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	int cnt = 0;
	int ans;
	for (int i = min(a, b); i > 0; i--)
	{
		if (a % i == 0 && b % i == 0)
			cnt++;
		if (cnt == k) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int p, q, r;

int main() {
    cin >> p >> q >> r;
    int ans = min(p+q, p+r);
    ans = min(ans, q+r);
    cout << ans << endl;
}


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

int main(){
  int cnt=0;
  vector<int> x(10000);
  for(int i=0; i<10000; i++){
    cin >> x[i];
    if(x[i]==0){
      break;
    }
    cnt++;
  }

  for(int i=0; i<cnt; i++){
    cout << "Case " << i+1 << ": " << x[i] << endl;
  }

  return 0;
}


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

#define ALPH   26

int main(void) {
	string w, ans;
	int len, idx;
	int cnt[ALPH];

	cin >> w;
	
	len = w.length();
	if (len % 2 != 0) {
		cout << "No\n";
		return 0;
	}

	for (int i = 0; i < ALPH; ++i)
		cnt[i] = 0;
	for (int i = 0; i < len; ++i) {
		idx = (int)(w[i] - 'a');
		++cnt[idx];
	}
	
	ans = "Yes";
	for (int i = 0; i < ALPH; ++i) {
		if (cnt[i] % 2 != 0) {
			ans = "No";
			break;
		}
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e8+1;
int main()
{
    FASTINOUT;
    string s;
    cin>>s;
    int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
    if (a+b+c+d==7)
        cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<7;
    else if (a+b-c+d==7)
        cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"="<<7;
    else if (a+b+c-d==7)
        cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"="<<7;
    else if (a+b-c-d==7)
        cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"="<<7;
    else if (a-b+c+d==7)
        cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"="<<7;
    else if (a-b-c+d==7)
        cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"="<<7;
    else if (a-b+c-d==7)
        cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"="<<7;
    else if (a-b-c-d==7)
        cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"="<<7;
    return 0;
}


Measured memory_bytes: 256
N,K = [int(x) for x in input().split()]
x = (N-1)*(N-2)//2
edge = 2
cnt = 0
li = []
if(x<K):
    print(-1)
else:
    for i in range(2,N+1):
        li.append([1,i])
    
    for i in range(N-2,0,-1):
        for j in range(i):
            if(cnt>=x-K):
                break
            li.append([N-i,N-i+j+1])
            cnt+=1
            if(cnt>=x-K):
                break
        else:
            continue
        break
    if(N==3 and K==1):
        li.pop()
    if(N==4 and K==3):
        li.pop()
    print(len(li))
    for i in li:
        print(i[0],i[1])


Measured memory_bytes: 4120
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long unsigned int ull;
typedef long long int ll;
typedef pair<ll, ll> P;

vector<vector<ll>> vec_sort(vector<vector<ll>> v,int itr)
{
    if (v.size() <= 1){
        return v;
    }
    ll l = v[0][itr];
    vector<vector<ll>> a, b;
    for(ll i; i < v.size(); i++)
    {
        if (i == 0){
            continue;
        }
        if (v[i][itr] <= l)
        {
            a.pb(v[i]);
        }
        else
        {
            b.pb(v[i]);
        }
    }
    a = vec_sort(a,itr);
    b = vec_sort(b,itr);
    a.pb(v[0]);
    a.insert(a.end(), all(b));
    return a;
}

int main()
{
    int N;
    cin >> N;
    vector<ll> a,b;
    REP(i,N){
        ll ai,bi;
        cin >> ai >> bi;
        a.pb(ai);
        b.pb(bi);
    }
    sort(all(a));
    sort(all(b));
    vector<ll> x_min;
    vector<ll> x_max;
    REP(i,N){
        x_min.pb(a[i]);
    }
    REP(i,N){
        x_max.pb(b[i]);
    }

    double med_min,med_max;
    ll ans;
    if(N%2==1){
        med_min = x_min[(N+1)/2-1];
        med_max = x_max[(N+1)/2-1];
        ans = med_max - med_min + 1;
    }else{
        med_min = (x_min[N/2-1]+x_min[N/2])/2.0;
        med_max = (x_max[N/2-1]+x_max[N/2])/2.0;
        ans = 2 * (med_max - med_min) + 1;
    }
    //cout << "[" << med_min << "," << med_max << "]" << endl;

    cout << ans << endl;
    // x[N]_MIN=MAX(A)
    // x[N]_MAX=MAX(B)

    //X[0]_MIN=MIN(A)
    //X[0]_MAX=MIN(B)



    //1    4   10 10         15       20
    //  2    5       11  12  15          21
}

Measured memory_bytes: 11060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define pb push_back
#define fi first`
#define se second
void solve()
{
    ll n, a, b;
    cin >> n >> a >> b;
    if(abs(a-b)&1)
    {
    	if(a>b)
    		swap(a,b);
    	cout<<min(a-1,n-b)+1+abs(b-a-1)/2;

    }
    else
    {
    	cout<<abs(a-b)/2;
    }


}

int main()
{



    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while(t--)
    {
        solve();
        // cout << endl;
    }

}




Measured memory_bytes: 256
class Ball
  def initialize
    result = []
    n = $stdin.gets.chomp.to_i
    n.times do 
      balls = $stdin.gets.chomp.split(' ').map(&:to_i)
      flag = true
      @cup1 = [0]
      @cup2 = [0]
      balls.each do |num|
         unless insert_ball(num)
           flag = false
           break
         end
      end
      result.push((flag)?"YES":"NO")
    end

    result.each do |str|
      puts str
    end
  end

  def insert_ball(num)
    if @cup1[-1] > num && @cup2[-1] > num
      return false
    elsif @cup1[-1] > num && @cup2[-1] < num
      @cup2 << num
    elsif @cup1[-1] < num && @cup2[-1] > num
      @cup1 << num
    else 
      if @cup1[-1] > @cup2[-1]
        @cup1 << num
      else
        @cup2 << num
      end
    end
  end
end

b = Ball.new

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

int main()
{
  string S;
  cin >> S;
  for (int i = 0; i < S.size(); i += 2)
  {
    cout << S[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define int long long
using namespace std;
const int N_MAX=100000;
int N,M;
int dp[N_MAX];
vector<vector<int>> graph;
//dp[i]:頂点iへ行く最長移動距離
signed main(){
	cin>>N>>M;
	graph.resize(N);
	vector<int> h(N,0);
	REP(i,M){
		int a,b; cin>>a>>b;
		a--;b--;
		graph[a].push_back(b);
		h[b]++;
	}
	queue<int> L,S;
	REP(i,N){ 
		if(h[i]==0) S.push(i);
	}
	while(!S.empty()){
		int n=S.front();S.pop();
		L.push(n);
		REP(j,graph[n].size()){
			int v=graph[n][j];
			h[v]--;
			if(h[v]==0) S.push(v);
		}
	}
	int ans=0;
	while(!L.empty()){
		int i=L.front();L.pop();
		REP(j,graph[i].size()){
			int v=graph[i][j];
			dp[v]=max(dp[v],dp[i]+1);
			ans=max(ans,dp[v]);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 8064
def main():
    H,W,K = list(map(int, input().split()))
    S = ['' for i in range(H)]
    for i in range(H):
        S[i] = input()

    ans = H*W

    for i in range(0,1<<(H-1)):
        g = 0
        id = [0 for j in range(H)]
        for j in range(0,H):
            id[j] = g
            if i>>j&1 == 1:
                g += 1
        
        g_cnt = [0 for j in range(g+1)]
        c_ans = g
        j = 0
        div_w = 0
        while j < W:
            for k in range(0, H):
                if S[k][j] == '1':
                    g_cnt[id[k]] += 1
            for k in range(0,g+1):
                if g_cnt[k] > K:
                    c_ans += 1
                    g_cnt = [0 for j in range(g+1)]
                    if div_w == j:
                        c_ans += H*W
                        break
                    j -= 1
                    div_w = j
                    break
            j += 1
            if c_ans > ans:
                break
        
        ans = min(ans, c_ans)

    
    print(ans)


main()

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

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


Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

vector<ll>g[55];
map<P,ll>path;

int main(void){
    ll n,m;
    cin>>n;
    map<P,ll>edge;
    for(ll i=0;i<n-1;i++){
        ll a,b;
        cin>>a>>b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
        edge[P(a,b)]=i;
        edge[P(b,a)]=i;
    }
    cin>>m;
    vector<ll>u(m),v(m);
    for(ll i=0;i<m;i++){
        cin>>u[i]>>v[i];
        u[i]--;
        v[i]--;
    }
    for(ll i=0;i<n;i++){
        vector<bool>used(n,0);
        queue<P>que;
        que.push(P(i,0));
        used[i]=true;
        while(!que.empty()){
            P p = que.front();
            que.pop();
            ll now = p.first;
            ll Set = p.second;
            for(ll k = 0;k<g[now].size();k++){
                ll next = g[now][k];
                if(used[next])continue;
                ll num = 0;
                num = Set|(1LL<<edge[P(now,next)]);
                path[P(i,next)]=num;
                used[next]=1;
                que.push(P(next,num));
            }
        }
    }
    /*for(ll i=1;i<n;i++){
        for(ll j=i+1;j<=n;j++){
            cout<<path[P(i,j)]<<endl;
        }
    }*/
    ll complement = 0;
    for(ll i = 1;i<(1LL<<m);i++){
        ll num = 0;
        ll digit = 0;
        ll s = 0;
        for(ll j=0;j<m;j++){
            if((i>>j)&1){
                num++;
                s = s|path[P(u[j],v[j])];
            }
        }
        for(ll j=0;j<n-1;j++){
            if((s>>j)&1)digit++;
        }
        if(num%2==0)complement-=pow(2,n-1-digit);
        else complement+=pow(2,n-1-digit);
    }
    ll ans = pow(2,n-1);
    //cout<<ans<<endl;
    ans-=complement;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
  int n,m;
  while(cin >>n>>m,n||m){
    bool f[1000]={false};
    for(int i=0,j=0; i<n; i++){
      for(int k=m;;j++){
	if(j>=n) j = 0;
	if(!f[j]) k--;
	if(i == n-1 && !f[j]){cout <<j+1<<endl;break;}
	if(k == 0){f[j] = true; break;}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define ull unsigned long long
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
int INF = 1001001001;
const int MOD=1e9+7;

int main() {
  string t;
  in t;
  rep(i,t.size())if(t[i] == '?') t[i] = 'D';
  cout<<t<<endl;
  return 0;
}


Measured memory_bytes: 3724
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;

int money,c[1010],n,x;
int main(){
  while(true){
    x=0;
    scanf("%d",&money);
    if(money==0){break;}
    n=1000-money;
    for(int i=0;500<=n;i++){x++;n=n-500;}
    for(int i=0;100<=n;i++){x++;n=n-100;}
    for(int i=0;50<=n;i++){x++;n=n-50;}
    for(int i=0;10<=n;i++){x++;n=n-10;}
    for(int i=0;5<=n;i++){x++;n=n-5;}
    for(int i=0;1<=n;i++){x++;n=n-1;}
    printf("%d\n",x);
  }
}

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

int main() {
    ll mod = 1e9 + 7;
    string s;
    cin >> s;

    vector<ll> dp(13, 0);
    if (s[0] == '?') {
        for(int i = 0; i < 10; i++)
            dp[i] = 1;
    } else {
        dp[s[0]-'0'] = 1;
    }
    for(int i = 1; i < s.size(); i++) {
        vector<ll> new_dp(13, 0);
        for(int j = 0; j < 13; j++) {
            if (s[i] != '?') {
                int tar = (j * 10 + (s[i]-'0')) % 13;
                new_dp[tar] += dp[j];
                new_dp[tar] %= mod;
            } else {
                for(int k = 0; k < 10; k++) {
                    int tar = (j * 10 + (k)) % 13;
                    new_dp[tar] += dp[j];
                    new_dp[tar] %= mod;
                }
            }
        }
        dp.swap(new_dp);
    }
    cout << dp[5] << endl;
    return 0;
}
// 10 % 13 -> 3
// 20 % 13 -> ?
// 10 % 13


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

string s;
int ans;
int main() {
	int i;
	cin >> s;
	for(i=1; i<s.size(); i++) {
		if(s[i] != s[i-1]) ans++;
	}
	cout << ans;
	return 0;
}


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

Measured memory_bytes: 596
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

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

    vector<int> T(N);
    vector<int> X(N);
    vector<int> Y(N);

    for (int i = 0; i < N; ++i) {
        cin >> T[i] >> X[i] >> Y[i];
    }

    const char* ans = "Yes";

    int px = 0;
    int py = 0;
    int pt = 0;

    for (int i = 0; i < N; ++i) {
        int x = X[i];
        int y = Y[i];
        int t = T[i];

        int dist = abs(x - px) + abs(y - py);
        int dt = t - pt;

        if (dt < dist || (dt - dist) % 2 == 1) {
            ans = "No";
            break;
        }

        px = x;
        py = y;
        pt = t;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n), b(n);
    ll ans = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i] >> b[i];
        if((k | a[i]) == k) ans += b[i];
    }
    if(k == 0){
        cout << ans << endl;
        return 0;
    }

    int MostSignificantBit = 0;
    for(int i = 30; i >= 0; --i){
        if((k >> i) & 1){
            MostSignificantBit = i;
            break;
        }
    }

    for(int i = MostSignificantBit; i >= 0; --i){
        int val = k;
        if((k >> i) & 1){
            val ^= (1 << i);
            for(int j = i - 1; j >= 0; --j) val |= (1 << j);
        }

        ll foo = 0;
        for(int j = 0; j < n; ++j){
            if((val | a[j]) == val) foo += b[j];
        }

        chmax(ans, foo);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);

void solve(){
    ll n;
    cin>>n;
    map<ll,ll>mp;
    for(ll i=2;i*i<=n;i++){
        while(n%i==0)
            mp[i]++,n/=i;
    }
    if(n>1)mp[n]++;
    ll res=0;
    for(auto x:mp){
        ll cur=0;
        loop(70,i,1){
            cur=i*(i+1)/2;
            if(cur==x.s){
                res+=i;
                break;
            }
            else if(cur>x.s){
                res+=(i-1);
                break;
            }
        }
    }
    cout<<res<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
using namespace std;
//-------------------------------

int main(){
    int n, m; 
    cin >> n >> m ;
    vector<int> foods(m, 0);

    //-------------------
    for(int i=0; i<n; i++){
        int K;
        cin >> K;

        for(int j=0; j<K; j++){
            int A; 
            cin >> A; --A;
            foods[A]++;
        }
    }

    //-------------------
    int ans = 0; 
    for(int i=0; i<=m; i++){
        if(foods[i]==n){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main()
{
	int N;
	scanf("%d", &N);
	int i, a[1000], b[1000], c[1000];
	for (i = 0; i < N; i++)
	{
		scanf("%d %d %d", &a[i], &b[i], &c[i]);
	}
	for (i = 0; i < N; i++)
	{
		float A = a[i], B = b[i], C = c[i];
		float d = fmax(A, B), sm1 = fmin(A, B);
		float biggest = fmax(d, C), sm2 = fmin(d, C);
		if (pow(biggest, 2) == (pow(sm1, 2) + pow(sm2, 2)))printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 1020
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
	int main(){
		int n;
		double xa,xb,ya,yb,ra,rb,l,r1,r2;
		scanf("%d",&n);
		while(n-->0){
			scanf("%lf %lf %lf %lf %lf %lf",&xa,&ya,&ra,&xb,&yb,&rb);
			l=(xa-xb)*(xa-xb)+(ya-yb)*(ya-yb);
			r1=ra+rb;
			r2=ra-rb;
			if(l>r1*r1)
					printf("0\n");
			else if(r1*r1>l&&r2*r2<l)
					printf("1\n");
			else if(r2*r2>l){
				if(r2>0)
					printf("2\n");
				else printf("-2\n");
			}
			else printf("1\n");
	 
		}
		return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void) {
    char s[11];
    scanf("%s", &s);
    if(s[5] == '0') {
        if(s[6] == '1' || s[6] == '2' || s[6] == '3' || s[6] == '4') {
            printf("Heisei");
        } else printf("TBD"); 
    } else printf("TBD");

    return 0;
    
}



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

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

	for ( int i = 0; i <= n; i++ ) {
		for ( int j = 0; j <= n - i; j++ ) {
			int k = n - i - j;
			if ( 10000 * i + 5000 * j + 1000 * k == y ) {
				cout << i << ' ' << j << ' ' << k << endl;
				return 0;
			}
		}
	}

	cout << "-1 -1 -1" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
const char endk = '\n';
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll mod = 1e9 + 7;
	//const ll mod = 998244353;

	ll n;
	string s;
	cin >> n >> s;

	ll cnt = 0;
	for (ll i = 0; i < n; i++) {
		if (s[i] == '1') cnt++;
	}

	ll mod1 = cnt + 1, mod2 = cnt - 1;
	vector<ll> modpow1(n), modpow2(n);
	ll x = 1, y = 1, modsum1 = 0, modsum2 = 0;
	bool flag = false;
	if (mod2 == 0) {
		flag = true;
		for (ll i = 0; i < n; i++) {
			modpow1[i] = x % mod1;
			//modpow2[i] = y % mod2;
			if (s[n - 1 - i] == '1') {
				modsum1 += x; //modsum2 += y;
				modsum1 %= mod1; //modsum2 %= mod2;
			}
			x *= 2; //y *= 2;
			x %= mod1; //y %= mod2;
		}
	}
	else {
		for (ll i = 0; i < n; i++) {
			modpow1[i] = x % mod1;
			modpow2[i] = y % mod2;
			if (s[n - 1 - i] == '1') {
				modsum1 += x; modsum2 += y;
				modsum1 %= mod1; modsum2 %= mod2;
			}
			x *= 2; y *= 2;
			x %= mod1; y %= mod2;
		}
	}

	vector<ll> v(2e5 + 1, 0);
	for (ll i = 1; i <= 2e5; i++) {
		ll x = __builtin_popcount(i);
		v[i] = v[i % x] + 1;
	}

	for (ll i = 0; i < n; i++) {
		if (s[i] == '1') {
			if (flag) cout << 0 << endl;
			else {
				ll x = modsum2 - modpow2[n - 1 - i];
				if (x < 0) x += mod2;
				cout << v[x % mod2] + 1 << endl;
			}
		}
		else {
			ll x = modsum1 + modpow1[n - 1 - i];
			x %= mod1;
			cout << v[x % mod1] + 1 << endl;
		}
	}
}

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

const char c[] = {'K', 'U', 'P', 'C'};

int main(void){
  string str;
  int ans = 0;

  cin >> str;

  while(1){
    bool flg;
    for(int i=0; i < 4; i++){
      flg = false;
      for(int p=0; p < str.length(); p++){
        if(str[p] == c[i]){
          flg = true;
          str[p] = 'a';
          break;
        }
      }
      if(!flg){
        break;
      }
    }
    if(flg){
      ans++;
    }else{
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())

int main() {
    int N;
    cin >> N;
    vector<int> R(N);
    Rep(i, N) {
        cin >> R[i];
    }
    int minv = R[0], maxv = R[1] - R[0];
    for (int i = 1; i < N; ++i) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 3572
def bb
    k,x = gets.chomp.split(/\s/).map{|x| x.to_i}

    if k == 1
        puts x
        exit
    end

    pos = [x]
    for i in 1..(k-1)
        pos.push(-i+x)
        pos.push(i+x)
    end

    puts pos.sort.join(' ')
end

bb


Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int w, q;
int there[101];
int main() {
    while (scanf("%d%d",&w,&q)) {
        if (!w&&!q) break;
        memset(there, -1, sizeof(there));
        for (int i=0; i<q; i++) {
            char c; cin>>c;
            if (c=='s') {
                int id, cw; scanf("%d%d",&id,&cw);
                int b=-1;
                for (int j=0; j<w; j++) {
                    if (there[j]!=-1) continue;
                    int cnt=0, temp=j;
                    while (j<w&&there[j]==-1) {
                        j++; cnt++;
                    }
                    if (cnt>=cw) {
                        b=temp;
                        for (int k=b; k<b+cw; k++) there[k]=id;
                        break;
                    }
                }
                if (b==-1) puts("impossible");
                else printf("%d\n",b);
            } else {
                int id; scanf("%d",&id);
                for (int j=0; j<w; j++) if (there[j]==id) there[j]=-1;
            }
        }
        puts("END");
    }
}

Measured memory_bytes: 0
N=int(input())
H=list(map(int,input().split()))
a=b=c=0

for i in range(N):
	if H[i]<=a:
		a=H[i]
		b+=1
		if b>=c:
			c=b
	else:
		a=H[i]
		b=0
print(c)

Measured memory_bytes: 14252
main(a,b,c,n,r){
  for(;scanf("%d%d%d%d",&a,&b,&c,&n),a;){
    if(a>c)r=a,a=c,c=r;
    if(b>c)r=b,b=c,c=r;
    for(;n;puts(r*2>hypot(a,b)?"OK":"NA"),n--)
      scanf("%d",&r);
  }
  return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
import sys
import itertools


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N, K = [int(x) for x in input().split()]
    d = []
    A = []
    for i in range(K):
        d.append(input())
        A.append(input().split())
    a = list(set(itertools.chain.from_iterable([list(set(x)) for x in A])))
    print(N - len(a))
    return

if __name__ == '__main__':
    main()


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

int main() {
  // ここにプログラムを追記
  int cell;
  int cW;
  int cB;
  
  cin >> cell;
  cin >> cW;
  
  
  cB = cell*cell - cW;
  
  cout << cB << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int n, d;
	cin >> n >> d;
	int x = 2 * d + 1;
	cout << (n % x ? n / x + 1 : n / x);
}

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

int main() {
    int N, M; cin >> N >> M;
    vector<int> a(M);
    for (int i = 0; i < M; i++) {
        cin >> a[i];
    }
    int ans = N;
    for (int i = 0; i < M; i++) {
        ans -= a[i];
    }   
    if (ans >= 0) cout << ans << endl; 
    else cout << -1 << endl;
}

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

int main()
{
  int a[5];
  std::cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  std::sort(a, a+5);
  
  int smin = 999;
  do {
    int s = 0;
    int i;
    for (i=0 ; i<4 ; i++) {
      s += (a[i] % 10) ? (a[i]/10 + 1) * 10 : a[i];
    }
    s += a[i];
    if (s < smin) {
      smin = s;
    }
  } while (std::next_permutation(a, a + 5));
  
  std::cout << smin << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

string s;
cin >> s;
int n = SZ(s);
reverse(all(s));

vector<string> div = {"dream", "erase", "eraser","dreamer"};
rep(i,4) reverse(all(div[i]));

bool ok = true;
int i = 0;
while(i < n) {
    if(i <= n-7 && s.substr(i,7) == div[3] ) {
        i += 7;
        continue;
    }
    if(i <= n-6 && s.substr(i,6) == div[2] ) {
        i += 6;
        continue;
    }
    if(i <= n-5 && s.substr(i,5) == div[0] || s.substr(i,5) == div[1]) {
        i += 5;
        continue;
    }
    ok = false;
    break;
}

if(ok) puts("YES");
else puts("NO");
return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
 
public class Main {
 
	public static final MyScanner in = new MyScanner();
 
	public static void main(String[] args) {
 
		char[] s = in.nextLine().toCharArray();
		System.out.println(s[0] == s[1] && s[0] == s[2] ? "No" : "Yes");
	}

	public static class MyScanner{
		Scanner sc = new Scanner(System.in);
		String nextLine() {return sc.nextLine();}
		String next() {return sc.next();}
		int nextInt() {return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next());}
	}

}

Measured memory_bytes: 23124